на оценку 3

This commit is contained in:
2026-10-21 13:51:35 +03:00
parent 3f69970b05
commit bd28f1ae26
24 changed files with 1130 additions and 91 deletions
+13 -4
View File
@@ -5,11 +5,20 @@ project_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$project_root"
env_file=${ENV_FILE:-.env}
compose() {
docker compose --env-file "$env_file" "$@"
}
# PostgreSQL хранит все обязательные данные и сессии в named volume.
# Redis содержит только восстанавливаемый кеш и намеренно не имеет volume.
docker compose --env-file "$env_file" restart postgres redis
docker compose --env-file "$env_file" up -d --wait postgres redis
compose restart postgres redis
compose up -d --wait postgres redis
# API перезапускается после восстановления обязательной БД и кеша.
docker compose --env-file "$env_file" restart api
# up восстанавливает желаемое число реплик, включая ранее вручную остановленную.
compose up -d --no-deps api
compose restart api
compose up -d --wait --no-deps api
# Публичная точка входа перезапускается последней, когда API уже готовы.
compose restart load-balancer
compose up -d --wait --no-deps load-balancer
+32
View File
@@ -0,0 +1,32 @@
#!/bin/sh
set -eu
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
project_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$project_root"
env_file=${ENV_FILE:-.env}
matched_container=
for container_id in $(docker compose --env-file "$env_file" ps -a -q api); do
instance_id=$(docker inspect --format '{{.Config.Hostname}}' "$container_id")
if [ "$instance_id" = "$TARGET_INSTANCE_ID" ]; then
if [ -n "$matched_container" ]; then
printf '%s\n' "multiple API containers match instance $TARGET_INSTANCE_ID" >&2
exit 1
fi
matched_container=$container_id
fi
done
if [ -z "$matched_container" ]; then
printf '%s\n' "API instance not found: $TARGET_INSTANCE_ID" >&2
exit 1
fi
# A manual docker stop suppresses the container restart policy until the next
# explicit start, so the selected replica remains down for the whole test.
docker stop --time 5 "$matched_container" >/dev/null
printf '%s\n' "stopped API instance $TARGET_INSTANCE_ID"