Перенесите реализацию lab3 и сохраните серии нагрузочных экспериментов

This commit is contained in:
2026-11-16 12:17:15 +03:00
parent ec540a1a72
commit b323f2dab9
109 changed files with 10747 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
#!/bin/sh
# Failover hook of `make test-failover`: gracefully stops the one running API
# replica whose X-Instance-Id is $TARGET_INSTANCE_ID, and nothing else.
# Restore it with: docker compose start api
set -eu
cd "$(dirname "$0")/.."
target=${TARGET_INSTANCE_ID:-}
case "$target" in
'' | *[!0-9a-f]*)
echo "TARGET_INSTANCE_ID must be the 16 lowercase hex characters of an X-Instance-Id" >&2
exit 2
;;
esac
if [ ${#target} -ne 16 ]; then
echo "TARGET_INSTANCE_ID must be the 16 lowercase hex characters of an X-Instance-Id" >&2
exit 2
fi
matches=$(sh scripts/api-instances.sh | awk -v t="$target" '$3 == "running" && $4 == t { print $1 }')
count=$(printf '%s\n' "$matches" | grep -c . || true)
if [ "$count" -ne 1 ]; then
echo "expected one running API replica with X-Instance-Id $target, found $count" >&2
exit 2
fi
docker stop "$matches" >/dev/null
echo "stopped API container $matches (X-Instance-Id $target)"