From 93b0d7999885b4563ff29771860933681309aaba Mon Sep 17 00:00:00 2001 From: pranav Date: Tue, 28 Apr 2026 10:52:15 +0000 Subject: [PATCH] rename restart-hook test artifacts to just restart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename the stack and script accordingly: - test-restart-hook stack → test-restart - test-restart-hook-multi stack → test-restart-multi - run-restart-hook-test.sh → run-restart-test.sh - start-hook-marker file → marker - pod-repo dirs test-restart-hook-pod-{a,b} → test-restart-pod-{a,b} Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/test-k8s-deploy.yml | 6 +- ...ok.yml => docker-compose-test-restart.yml} | 2 +- .../stacks/test-restart-hook-multi/README.md | 14 ----- .../stacks/test-restart-hook-multi/stack.yml | 10 ---- .../data/stacks/test-restart-hook/README.md | 15 ----- .../data/stacks/test-restart-hook/stack.yml | 5 -- .../data/stacks/test-restart-multi/README.md | 14 +++++ .../data/stacks/test-restart-multi/stack.yml | 10 ++++ .../data/stacks/test-restart/README.md | 15 +++++ .../deploy/commands.py | 2 +- .../data/stacks/test-restart/stack.yml | 5 ++ ...start-hook-test.sh => run-restart-test.sh} | 58 +++++++++---------- 12 files changed, 78 insertions(+), 78 deletions(-) rename stack_orchestrator/data/compose/{docker-compose-test-restart-hook.yml => docker-compose-test-restart.yml} (84%) delete mode 100644 stack_orchestrator/data/stacks/test-restart-hook-multi/README.md delete mode 100644 stack_orchestrator/data/stacks/test-restart-hook-multi/stack.yml delete mode 100644 stack_orchestrator/data/stacks/test-restart-hook/README.md delete mode 100644 stack_orchestrator/data/stacks/test-restart-hook/stack.yml create mode 100644 stack_orchestrator/data/stacks/test-restart-multi/README.md create mode 100644 stack_orchestrator/data/stacks/test-restart-multi/stack.yml create mode 100644 stack_orchestrator/data/stacks/test-restart/README.md rename stack_orchestrator/data/stacks/{test-restart-hook => test-restart}/deploy/commands.py (94%) create mode 100644 stack_orchestrator/data/stacks/test-restart/stack.yml rename tests/k8s-deploy/{run-restart-hook-test.sh => run-restart-test.sh} (84%) diff --git a/.github/workflows/test-k8s-deploy.yml b/.github/workflows/test-k8s-deploy.yml index 4ee266c9..62ce4a42 100644 --- a/.github/workflows/test-k8s-deploy.yml +++ b/.github/workflows/test-k8s-deploy.yml @@ -16,7 +16,7 @@ on: - '.github/workflows/triggers/test-k8s-deploy' - '.github/workflows/test-k8s-deploy.yml' - 'tests/k8s-deploy/run-deploy-test.sh' - - 'tests/k8s-deploy/run-restart-hook-test.sh' + - 'tests/k8s-deploy/run-restart-test.sh' schedule: - cron: '3 15 * * *' @@ -47,5 +47,5 @@ jobs: run: ./tests/scripts/install-kubectl.sh - name: "Run k8s deployment test" run: ./tests/k8s-deploy/run-deploy-test.sh - - name: "Run restart-hook k8s deployment test" - run: ./tests/k8s-deploy/run-restart-hook-test.sh + - name: "Run restart k8s deployment test" + run: ./tests/k8s-deploy/run-restart-test.sh diff --git a/stack_orchestrator/data/compose/docker-compose-test-restart-hook.yml b/stack_orchestrator/data/compose/docker-compose-test-restart.yml similarity index 84% rename from stack_orchestrator/data/compose/docker-compose-test-restart-hook.yml rename to stack_orchestrator/data/compose/docker-compose-test-restart.yml index 62438e31..e5f69565 100644 --- a/stack_orchestrator/data/compose/docker-compose-test-restart-hook.yml +++ b/stack_orchestrator/data/compose/docker-compose-test-restart.yml @@ -1,5 +1,5 @@ services: - test-restart-hook: + test-restart: image: busybox:1.36 command: ["sh", "-c", "echo started && sleep infinity"] restart: always diff --git a/stack_orchestrator/data/stacks/test-restart-hook-multi/README.md b/stack_orchestrator/data/stacks/test-restart-hook-multi/README.md deleted file mode 100644 index eea1cd76..00000000 --- a/stack_orchestrator/data/stacks/test-restart-hook-multi/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# test-restart-hook-multi - -E2E test stack used by `tests/k8s-deploy/run-restart-hook-test.sh` to cover the -multi-repo case: `pods:` references two pod repos, each shipping its own -`deploy/commands.py`. `deploy create` should produce -`/hooks/commands_0.py` and `/hooks/commands_1.py`, and -`deployment start` should invoke both `start()` hooks (each writes its own -marker file so neither overwrites the other). - -The pod repos themselves are created by the test script as bare-repo + -working-clone pairs under `$CERC_REPO_BASE_DIR/test-restart-hook-pod-{a,b}`; -they are not committed to this repository. Each pod repo ships its own -`docker-compose.yml` (resolved by `get_pod_file_path` for dict-form pods) and -`stack/deploy/commands.py` — the stack repo only owns `stack.yml`. diff --git a/stack_orchestrator/data/stacks/test-restart-hook-multi/stack.yml b/stack_orchestrator/data/stacks/test-restart-hook-multi/stack.yml deleted file mode 100644 index 21bc16ea..00000000 --- a/stack_orchestrator/data/stacks/test-restart-hook-multi/stack.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: "1.0" -name: test-restart-hook-multi -description: "E2E test stack: verifies hooks/commands_*.py multi-repo file naming and multi-hook invocation" -pods: - - name: test-restart-hook-multi-a - repository: test-restart-hook-pod-a - path: . - - name: test-restart-hook-multi-b - repository: test-restart-hook-pod-b - path: . diff --git a/stack_orchestrator/data/stacks/test-restart-hook/README.md b/stack_orchestrator/data/stacks/test-restart-hook/README.md deleted file mode 100644 index 67711d63..00000000 --- a/stack_orchestrator/data/stacks/test-restart-hook/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# test-restart-hook - -E2E test stack used by `tests/k8s-deploy/run-restart-hook-test.sh`. - -The stack ships a single `start()` hook that writes a versioned marker file -into the deployment directory. The test: - -1. `deploy create` → asserts `commands.py` was copied into `/hooks/`. -2. `deployment start` → asserts the marker file contains the v1 string. -3. Modifies `commands.py` in the stack-source working tree (v1 → v2). -4. `deployment restart` → asserts the new commands.py was re-copied into - `/hooks/` and the marker file now contains the v2 string. - -The pod uses a public `busybox` image that just sleeps; the start hook is the -only thing under test. diff --git a/stack_orchestrator/data/stacks/test-restart-hook/stack.yml b/stack_orchestrator/data/stacks/test-restart-hook/stack.yml deleted file mode 100644 index 07248262..00000000 --- a/stack_orchestrator/data/stacks/test-restart-hook/stack.yml +++ /dev/null @@ -1,5 +0,0 @@ -version: "1.0" -name: test-restart-hook -description: "E2E test stack: verifies hooks/commands.py is re-copied and re-loaded on deployment restart" -pods: - - test-restart-hook diff --git a/stack_orchestrator/data/stacks/test-restart-multi/README.md b/stack_orchestrator/data/stacks/test-restart-multi/README.md new file mode 100644 index 00000000..6a638182 --- /dev/null +++ b/stack_orchestrator/data/stacks/test-restart-multi/README.md @@ -0,0 +1,14 @@ +# test-restart-multi + +E2E test stack used by `tests/k8s-deploy/run-restart-test.sh` to cover the +multi-repo case: `pods:` references two pod repos, each shipping its own +`deploy/commands.py`. `deploy create` should produce +`/hooks/commands_0.py` and `/hooks/commands_1.py`, +and `deployment start` should invoke both `start()` hooks (each writes its +own marker file so neither overwrites the other). + +The pod repos themselves are created by the test script as bare-repo + +working-clone pairs under `$CERC_REPO_BASE_DIR/test-restart-pod-{a,b}`; +they are not committed to this repository. Each pod repo ships its own +`docker-compose.yml` (resolved by `get_pod_file_path` for dict-form pods) +and `stack/deploy/commands.py` — the stack repo only owns `stack.yml`. diff --git a/stack_orchestrator/data/stacks/test-restart-multi/stack.yml b/stack_orchestrator/data/stacks/test-restart-multi/stack.yml new file mode 100644 index 00000000..431ebf14 --- /dev/null +++ b/stack_orchestrator/data/stacks/test-restart-multi/stack.yml @@ -0,0 +1,10 @@ +version: "1.0" +name: test-restart-multi +description: "E2E test stack for the deployment restart command (multi-repo case)" +pods: + - name: test-restart-multi-a + repository: test-restart-pod-a + path: . + - name: test-restart-multi-b + repository: test-restart-pod-b + path: . diff --git a/stack_orchestrator/data/stacks/test-restart/README.md b/stack_orchestrator/data/stacks/test-restart/README.md new file mode 100644 index 00000000..73cdb1fb --- /dev/null +++ b/stack_orchestrator/data/stacks/test-restart/README.md @@ -0,0 +1,15 @@ +# test-restart + +E2E test stack used by `tests/k8s-deploy/run-restart-test.sh`. + +The stack ships a small `start()` hook that writes a versioned marker file +into the deployment directory. The test exercises `deployment restart`: + +1. `deploy create` → asserts `commands.py` was copied into `/hooks/`. +2. `deployment start` → asserts the marker file contains the v1 string. +3. Modifies `commands.py` in the stack-source working tree (v1 → v2). +4. `deployment restart` → asserts the new `commands.py` was re-copied into + `/hooks/` and the marker file now contains the v2 string. + +The pod uses a public `busybox` image that just sleeps; the marker file is +the only thing under test. diff --git a/stack_orchestrator/data/stacks/test-restart-hook/deploy/commands.py b/stack_orchestrator/data/stacks/test-restart/deploy/commands.py similarity index 94% rename from stack_orchestrator/data/stacks/test-restart-hook/deploy/commands.py rename to stack_orchestrator/data/stacks/test-restart/deploy/commands.py index 64e68f3a..eaa15860 100644 --- a/stack_orchestrator/data/stacks/test-restart-hook/deploy/commands.py +++ b/stack_orchestrator/data/stacks/test-restart/deploy/commands.py @@ -28,5 +28,5 @@ def start(deployment_context: DeploymentContext): # literal below from "v1" to "v2" in the stack-source working tree # before running 'deployment restart' to verify the updated hook is # copied into deployment_dir/hooks/ and re-executed. - marker = deployment_context.deployment_dir / "start-hook-marker" + marker = deployment_context.deployment_dir / "marker" marker.write_text("v1") diff --git a/stack_orchestrator/data/stacks/test-restart/stack.yml b/stack_orchestrator/data/stacks/test-restart/stack.yml new file mode 100644 index 00000000..ccb394f6 --- /dev/null +++ b/stack_orchestrator/data/stacks/test-restart/stack.yml @@ -0,0 +1,5 @@ +version: "1.0" +name: test-restart +description: "E2E test stack for the deployment restart command" +pods: + - test-restart diff --git a/tests/k8s-deploy/run-restart-hook-test.sh b/tests/k8s-deploy/run-restart-test.sh similarity index 84% rename from tests/k8s-deploy/run-restart-hook-test.sh rename to tests/k8s-deploy/run-restart-test.sh index a3a2e3d5..c3298d01 100755 --- a/tests/k8s-deploy/run-restart-hook-test.sh +++ b/tests/k8s-deploy/run-restart-test.sh @@ -72,7 +72,7 @@ configure_git_identity () { TEST_TARGET_SO=$( ls -t1 ./package/laconic-so* | head -1 ) echo "Testing this package: $TEST_TARGET_SO" -WORK_DIR=~/stack-orchestrator-test/restart-hook +WORK_DIR=~/stack-orchestrator-test/restart # Multi-repo pod working clones land here; resolved by get_plugin_code_paths. export CERC_REPO_BASE_DIR=$WORK_DIR/repo-base rm -rf $WORK_DIR @@ -100,14 +100,14 @@ configure_git_identity $CLONE1 # External-stack layout: /stack-orchestrator/{stacks,compose}/... mkdir -p $CLONE1/stack-orchestrator/stacks $CLONE1/stack-orchestrator/compose -cp -r $DATA_DIR/stacks/test-restart-hook $CLONE1/stack-orchestrator/stacks/ -cp $DATA_DIR/compose/docker-compose-test-restart-hook.yml $CLONE1/stack-orchestrator/compose/ +cp -r $DATA_DIR/stacks/test-restart $CLONE1/stack-orchestrator/stacks/ +cp $DATA_DIR/compose/docker-compose-test-restart.yml $CLONE1/stack-orchestrator/compose/ git -C $CLONE1 add . -git -C $CLONE1 commit -m "test-restart-hook v1" +git -C $CLONE1 commit -m "test-restart v1" git -C $CLONE1 push -u origin main -STACK_PATH_SINGLE=$CLONE1/stack-orchestrator/stacks/test-restart-hook +STACK_PATH_SINGLE=$CLONE1/stack-orchestrator/stacks/test-restart SPEC1=$WORK_DIR/spec-single.yml DEP1=$WORK_DIR/dep-single @@ -129,16 +129,16 @@ wait_for_pods_started $DEP1 # call_stack_deploy_start runs synchronously inside the start command # (deploy_k8s.py:1026), so the marker is on disk before 'start' returns. -if [ ! -f "$DEP1/start-hook-marker" ]; then - echo "single-repo start hook v1 test: FAILED (marker file missing)" +if [ ! -f "$DEP1/marker" ]; then + echo "single-repo start v1 test: FAILED (marker file missing)" cleanup_and_exit fi -marker_v1=$(cat $DEP1/start-hook-marker) +marker_v1=$(cat $DEP1/marker) if [ "$marker_v1" != "v1" ]; then - echo "single-repo start hook v1 test: FAILED (got: $marker_v1)" + echo "single-repo start v1 test: FAILED (got: $marker_v1)" cleanup_and_exit fi -echo "single-repo start hook v1 test: passed" +echo "single-repo start v1 test: passed" # Mutate the stack-source working tree v1 -> v2. No commit needed: 'deployment # restart' runs 'git pull' against the bare which is a no-op, and _copy_hooks @@ -148,17 +148,17 @@ sed -i 's/"v1"/"v2"/' $STACK_PATH_SINGLE/deploy/commands.py $TEST_TARGET_SO deployment --dir $DEP1 restart --stack-path $STACK_PATH_SINGLE if ! grep -q '"v2"' "$DEP1/hooks/commands.py"; then - echo "single-repo restart hook re-copy test: FAILED (hooks/commands.py still v1)" + echo "single-repo restart re-copy test: FAILED (hooks/commands.py still v1)" cleanup_and_exit fi -echo "single-repo restart hook re-copy test: passed" +echo "single-repo restart re-copy test: passed" -marker_v2=$(cat $DEP1/start-hook-marker) +marker_v2=$(cat $DEP1/marker) if [ "$marker_v2" != "v2" ]; then - echo "single-repo restart hook re-execute test: FAILED (got: $marker_v2)" + echo "single-repo restart re-execute test: FAILED (got: $marker_v2)" cleanup_and_exit fi -echo "single-repo restart hook re-execute test: passed" +echo "single-repo restart re-execute test: passed" # Stop phase 1 deployment but keep the cluster for phase 2. $TEST_TARGET_SO deployment --dir $DEP1 \ @@ -171,12 +171,12 @@ $TEST_TARGET_SO deployment --dir $DEP1 \ # ============================================================================ echo "=== Phase 2: multi-repo create + start ===" -# Pod repos: stack.yml's pods[].repository = 'cerc-io/test-restart-hook-pod-X' +# Pod repos: stack.yml's pods[].repository = 'cerc-io/test-restart-pod-X' # resolves (via get_plugin_code_paths) to -# $CERC_REPO_BASE_DIR/test-restart-hook-pod-X//stack/... +# $CERC_REPO_BASE_DIR/test-restart-pod-X//stack/... for label in a b; do POD_BARE=$WORK_DIR/pod-$label.git - POD_CLONE=$CERC_REPO_BASE_DIR/test-restart-hook-pod-$label + POD_CLONE=$CERC_REPO_BASE_DIR/test-restart-pod-$label git init -b main --bare $POD_BARE git clone $POD_BARE $POD_CLONE configure_git_identity $POD_CLONE @@ -187,7 +187,7 @@ for label in a b; do # commands.py lives at //stack/deploy/commands.py. cat > $POD_CLONE/docker-compose.yml <