Bring the application, own tests, Dockerfile, toolchain, compose stack, HAProxy, k6 and RustFS configuration, migrations, hooks, evidence and scenario scripts and the CI job from the lab 4 solution commit d2744bc, merge the lab 4 Makefile targets into the lab 5 skeleton Makefile without touching its targets, and append the lab 4 solution variables to the skeleton .env.example. The package and the application follow the contract version 1.5.0, and the image and the throwaway test containers are tagged lab5 so they do not collide with a lab 4 stand on the same host. This is the starting point of the lab 5 cycle: lint, own tests and the offline skeleton check pass before any lab 5 change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
29 lines
1.2 KiB
Bash
Executable File
29 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
replicas() {
|
|
docker inspect -f '{{.Config.Hostname}} {{.State.Status}} started={{.State.StartedAt}} finished={{.State.FinishedAt}}' $(docker compose ps -aq "${API_SERVICE:-api}")
|
|
}
|
|
tmp=evidence/failover.tmp
|
|
since=$(date -u +%FT%TZ)
|
|
{
|
|
echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse --short HEAD)"
|
|
echo "== before: api replicas (hostname = X-Instance-Id), state, StartedAt, FinishedAt"
|
|
replicas
|
|
echo "\$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh"
|
|
make --no-print-directory test-failover ACTION_SCRIPT=scripts/stop-one.sh BASE_URL="${1:-http://localhost:8080}"
|
|
echo "== after: api replicas"
|
|
replicas
|
|
} > "$tmp" 2>&1
|
|
stopped=$(replicas | awk '$2 == "exited" {print $1}')
|
|
{
|
|
echo "== stopped replica: $stopped; shutdown: signal, drain window with readiness 503, close, exit"
|
|
docker logs --since "$since" "$stopped" 2>&1 | grep -E 'Handling signal|Draining|"status":503|Shutting down|Waiting for conn|Finished server|service.stopped|SIGTERM' | tail -16
|
|
echo "\$ scripts/restore.sh"
|
|
scripts/restore.sh
|
|
echo "== after restore"
|
|
replicas
|
|
} >> "$tmp" 2>&1
|
|
mv "$tmp" "evidence/failover-$stopped.txt"
|
|
cat "evidence/failover-$stopped.txt"
|