forked from mtusi2026/mtusi2026lab4
Add two API replicas, safe object reconciliation, upload validation, regression tests and documented load experiments.
25 lines
625 B
Bash
25 lines
625 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
project_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
cd "$project_dir"
|
|
|
|
target=${TARGET_INSTANCE_ID:?test provides target API instance ID}
|
|
|
|
containers=$(docker compose ps --all --quiet api)
|
|
if [ -z "$containers" ]; then
|
|
printf 'No API containers found\n' >&2
|
|
exit 2
|
|
fi
|
|
for entry in $(docker inspect --format '{{.Config.Hostname}}:{{.Id}}' $containers); do
|
|
instance=${entry%%:*}
|
|
container=${entry#*:}
|
|
if [ "$instance" = "$target" ]; then
|
|
docker stop --time 8 "$container" >/dev/null
|
|
exit 0
|
|
fi
|
|
done
|
|
|
|
printf 'No API container matches X-Instance-Id\n' >&2
|
|
exit 2
|