Files
mtusi2026lab2/student-tests/dependency.sh
T
alenchha 6bec450e20
Application / app (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
ЛР 2: PostgreSQL, сессии в Valkey, трек 2
2026-10-19 19:11:28 +03:00

40 lines
1006 B
Bash
Executable File

#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
COMPOSE="docker compose --env-file .env"
wait_ready() {
i=0
while [ "$i" -lt 60 ]; do
if curl -fsS http://localhost:8080/health/ready >/dev/null 2>&1; then return 0; fi
i=$((i + 1))
sleep 1
done
echo "API не стал ready" >&2
return 1
}
restore() {
$COMPOSE start valkey postgres >/dev/null 2>&1 || true
}
trap restore EXIT
echo "=== 1. Останавливаю кэш сессий (valkey) ==="
$COMPOSE stop valkey
$COMPOSE ps --format '{{.Service}} {{.Status}}'
python3 student-tests/test_without_cache.py --base-url http://localhost:8080
$COMPOSE start valkey
wait_ready
echo
echo "=== 2. Останавливаю PostgreSQL ==="
$COMPOSE stop postgres
$COMPOSE ps --format '{{.Service}} {{.Status}}'
python3 student-tests/test_without_db.py --base-url http://localhost:8080
$COMPOSE start postgres
wait_ready
echo
echo "=== 3. Состояние восстановлено ==="
$COMPOSE ps --format '{{.Service}} {{.Status}}'