HAProxy + 2 API-реплики, общие PostgreSQL/Valkey, обязательный Idempotency-Key, graceful drain по SIGTERM, stop-one/restart/rolling-update, серии отказов и REPORT.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.6 KiB
Bash
Executable File
48 lines
2.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Повторяемый сбор доказательств уровней 3–4 в evidence/ (запуск на хосте из корня, стенд уже поднят).
|
|
# Токены/пароли в вывод не попадают: публичные тесты их не печатают, hook-вывод подавлен тестом.
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
export MSYS_NO_PATHCONV=1 PYTHONUTF8=1
|
|
compose() { docker compose --env-file .env "$@"; }
|
|
tester() { compose --profile tools run --rm tester sh -c "$1" 2>&1 | grep -v '^ Container'; }
|
|
stamp() { echo "# $(date -u +%Y-%m-%dT%H:%M:%SZ), commit $(git rev-parse --short HEAD 2>/dev/null || echo uncommitted)"; }
|
|
mkdir -p evidence
|
|
: > evidence/stop-one.log
|
|
|
|
echo '== public checks'
|
|
{ stamp
|
|
tester 'pip install -q --disable-pip-version-check --root-user-action=ignore -r requirements-dev.txt && make check && make validate PYTHON=python3 && make test'
|
|
} | tee evidence/public-tests.txt
|
|
|
|
echo '== instances behind LB (one session, 10 requests)'
|
|
{ stamp
|
|
compose ps --format 'table {{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'
|
|
echo
|
|
tester 'python student-tests/show_instances.py'
|
|
} | tee evidence/instances.txt
|
|
|
|
echo '== failover: stop-one for each replica (restore between runs)'
|
|
{ stamp
|
|
for i in 1 2 3 4; do
|
|
tester 'make test-failover ACTION_SCRIPT=scripts/stop-one.sh'
|
|
# Тест останавливает реплику, обслужившую его первое сообщение; round-robin детерминирован,
|
|
# поэтому лишний запрос через LB сдвигает фазу и следующей целью становится другая реплика.
|
|
tester 'sh scripts/restore.sh && curl -s -o /dev/null http://lb:8080/health/live'
|
|
[ "$(cut -d' ' -f4 evidence/stop-one.log | sort -u | wc -l)" -ge 2 ] && break
|
|
done
|
|
echo; echo '# evidence/stop-one.log (what the hook really stopped):'; cat evidence/stop-one.log
|
|
} | tee evidence/failover-hook.txt
|
|
|
|
echo '== persistence: restart of lb, api, postgres, valkey with volumes'
|
|
{ stamp
|
|
sh scripts/restart.sh
|
|
tester 'until curl -fs http://lb:8080/health/ready >/dev/null; do sleep 0.5; done; echo ready'
|
|
tester 'make test-persistence ACTION_SCRIPT=scripts/restart.sh'
|
|
} | tee evidence/persistence.txt
|
|
|
|
echo '== failover series under load'
|
|
python student-tests/failover_series.py --scenario stop --output evidence/failover-stop.json | tail -n +1 > /dev/null
|
|
python student-tests/failover_series.py --scenario kill --output evidence/failover-kill.json > /dev/null
|
|
echo 'saved evidence/failover-{stop,kill}.json'
|