rename restart-hook test artifacts to just restart

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) <noreply@anthropic.com>
pull/750/head
pranav 2026-04-28 10:52:15 +00:00
parent d141546cdd
commit 93b0d79998
12 changed files with 78 additions and 78 deletions

View File

@ -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

View File

@ -1,5 +1,5 @@
services:
test-restart-hook:
test-restart:
image: busybox:1.36
command: ["sh", "-c", "echo started && sleep infinity"]
restart: always

View File

@ -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
`<deployment>/hooks/commands_0.py` and `<deployment>/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`.

View File

@ -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: .

View File

@ -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 `<deployment>/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
`<deployment>/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.

View File

@ -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

View File

@ -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
`<deployment>/hooks/commands_0.py` and `<deployment>/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`.

View File

@ -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: .

View File

@ -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 `<deployment>/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
`<deployment>/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.

View File

@ -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")

View File

@ -0,0 +1,5 @@
version: "1.0"
name: test-restart
description: "E2E test stack for the deployment restart command"
pods:
- test-restart

View File

@ -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: <repo>/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/<pod_path>/stack/...
# $CERC_REPO_BASE_DIR/test-restart-pod-X/<pod_path>/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 <pod_repo>/<pod_path>/stack/deploy/commands.py.
cat > $POD_CLONE/docker-compose.yml <<EOF
services:
test-restart-hook-multi-$label:
test-restart-multi-$label:
image: busybox:1.36
command: ["sh", "-c", "sleep infinity"]
restart: always
@ -199,7 +199,7 @@ from stack_orchestrator.deploy.deployment_context import DeploymentContext
def start(deployment_context: DeploymentContext):
marker = deployment_context.deployment_dir / "start-hook-marker-$label"
marker = deployment_context.deployment_dir / "marker-$label"
marker.write_text("v1")
EOF
git -C $POD_CLONE add .
@ -217,13 +217,13 @@ configure_git_identity $CLONE2
# For multi-repo (dict-form pods), the stack repo only owns stack.yml — pod
# compose files and hooks live in the per-pod repos under CERC_REPO_BASE_DIR.
mkdir -p $CLONE2/stack-orchestrator/stacks
cp -r $DATA_DIR/stacks/test-restart-hook-multi $CLONE2/stack-orchestrator/stacks/
cp -r $DATA_DIR/stacks/test-restart-multi $CLONE2/stack-orchestrator/stacks/
git -C $CLONE2 add .
git -C $CLONE2 commit -m "test-restart-hook-multi v1"
git -C $CLONE2 commit -m "test-restart-multi v1"
git -C $CLONE2 push -u origin main
STACK_PATH_MULTI=$CLONE2/stack-orchestrator/stacks/test-restart-hook-multi
STACK_PATH_MULTI=$CLONE2/stack-orchestrator/stacks/test-restart-multi
SPEC2=$WORK_DIR/spec-multi.yml
DEP2=$WORK_DIR/dep-multi
@ -241,20 +241,20 @@ fi
echo "multi-repo deploy create test: passed"
$TEST_TARGET_SO deployment --dir $DEP2 start --skip-cluster-management
wait_for_k8s_pods_ready laconic-test-restart-hook-multi
wait_for_k8s_pods_ready laconic-test-restart-multi
for label in a b; do
if [ ! -f "$DEP2/start-hook-marker-$label" ]; then
echo "multi-repo start hook test: FAILED (start-hook-marker-$label missing)"
if [ ! -f "$DEP2/marker-$label" ]; then
echo "multi-repo start test: FAILED (marker-$label missing)"
cleanup_and_exit
fi
val=$(cat $DEP2/start-hook-marker-$label)
val=$(cat $DEP2/marker-$label)
if [ "$val" != "v1" ]; then
echo "multi-repo start hook test: FAILED (start-hook-marker-$label content: $val)"
echo "multi-repo start test: FAILED (marker-$label content: $val)"
cleanup_and_exit
fi
done
echo "multi-repo start hook test: passed"
echo "multi-repo start test: passed"
# Final teardown — destroy the cluster for the next CI run.
$TEST_TARGET_SO deployment --dir $DEP2 \