#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")/.." project=$PWD export COMPOSE_FILE="$project/compose.yaml" python=${PYTHON:-python3} if [[ -z ${PYTHON:-} && -x "$project/.venv/bin/python" ]]; then python="$project/.venv/bin/python" elif [[ $python == */* && $python != /* ]]; then python="$project/$python" fi cd /tmp if ! command -v "$python" >/dev/null; then echo "Интерпретатор не найден: $python. Укажите PYTHON для WSL." >&2 exit 1 fi "$python" -c 'from argon2.low_level import hash_secret' || { echo "Установите argon2-cffi в выбранный Python: $python" >&2 exit 1 } # Короткий TTL только для новых сессий на время отдельного теста. restore() { docker compose up -d --no-deps --no-build --wait --wait-timeout 120 api; } trap restore EXIT SESSION_TTL_SECONDS=20 docker compose up -d --no-deps --no-build --wait --wait-timeout 120 api # Даём балансировщику обновить адреса после пересоздания реплик. stable=0 for ((i=0;i<60;i++)); do if curl -fsS --max-time 3 --cacert "$project/certs/private/ingress/ca.crt" https://localhost:8443/health/ready >/dev/null; then stable=$((stable+1)) if ((stable >= 12)); then break; fi else stable=0 fi sleep 1 done ((stable >= 12)) "$python" "$project/student-tests/auth-test.py"