forked from mtusi2026/mtusi2026lab3
86 lines
4.4 KiB
Plaintext
86 lines
4.4 KiB
Plaintext
# Публичный failover: два прогона подряд с восстановлением реплики между ними
|
|
# дата: 2026-10-30T18:43Z, commit: 269b449
|
|
# стенд: Apple M3 Pro, 11 CPU, 18 GB RAM, macOS 26.1, Docker 29.3.0, Compose 5.1.0
|
|
|
|
## прогон 1
|
|
# реплики до отказа
|
|
NAME STATE STATUS
|
|
mtusi-messenger-lab3-api-1 running Up 10 seconds (healthy)
|
|
mtusi-messenger-lab3-api-2 running Up 10 seconds (healthy)
|
|
|
|
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
|
|
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
|
|
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
|
{"observed_instances_before": 2, "successful_writes": 120, "failed_attempts": 0, "first_recovery_seconds": 1.822}
|
|
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
|
|
|
# какой контейнер реально остановлен
|
|
NAME STATE STATUS
|
|
mtusi-messenger-lab3-api-1 running Up 26 seconds (healthy)
|
|
mtusi-messenger-lab3-api-2 exited Exited (0) 14 seconds ago
|
|
|
|
$ docker compose logs lb | grep 'is DOWN' | tail -2
|
|
lb-1 | Server api/api2 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 1 active and 0 backup servers lef
|
|
|
|
$ make restore
|
|
docker compose --env-file .env up -d --no-recreate --no-build api
|
|
Container mtusi-messenger-lab3-redis-1 Running
|
|
Container mtusi-messenger-lab3-postgres-1 Running
|
|
Container mtusi-messenger-lab3-api-1 Running
|
|
Container mtusi-messenger-lab3-postgres-1 Waiting
|
|
Container mtusi-messenger-lab3-postgres-1 Healthy
|
|
Container mtusi-messenger-lab3-migrate-1 Starting
|
|
Container mtusi-messenger-lab3-migrate-1 Started
|
|
Container mtusi-messenger-lab3-redis-1 Waiting
|
|
Container mtusi-messenger-lab3-migrate-1 Waiting
|
|
Container mtusi-messenger-lab3-redis-1 Healthy
|
|
Container mtusi-messenger-lab3-migrate-1 Exited
|
|
Container mtusi-messenger-lab3-api-2 Starting
|
|
Container mtusi-messenger-lab3-api-2 Started
|
|
BASE_URL="http://localhost:8080" ./scripts/wait-ready.sh
|
|
готов: http://localhost:8080
|
|
|
|
## прогон 2
|
|
# реплики до отказа
|
|
NAME STATE STATUS
|
|
mtusi-messenger-lab3-api-1 running Up 32 seconds (healthy)
|
|
mtusi-messenger-lab3-api-2 running Up 4 seconds (healthy)
|
|
|
|
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
|
|
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
|
|
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
|
{"observed_instances_before": 2, "successful_writes": 120, "failed_attempts": 0, "first_recovery_seconds": 1.585}
|
|
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
|
|
|
# какой контейнер реально остановлен
|
|
NAME STATE STATUS
|
|
mtusi-messenger-lab3-api-1 running Up 47 seconds (healthy)
|
|
mtusi-messenger-lab3-api-2 exited Exited (0) 14 seconds ago
|
|
|
|
$ docker compose logs lb | grep 'is DOWN' | tail -2
|
|
lb-1 | Server api/api2 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 1 active and 0 backup servers lef
|
|
lb-1 | Server api/api2 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 1 active and 0 backup servers lef
|
|
|
|
$ make restore
|
|
docker compose --env-file .env up -d --no-recreate --no-build api
|
|
Container mtusi-messenger-lab3-postgres-1 Running
|
|
Container mtusi-messenger-lab3-redis-1 Running
|
|
Container mtusi-messenger-lab3-api-1 Running
|
|
Container mtusi-messenger-lab3-postgres-1 Waiting
|
|
Container mtusi-messenger-lab3-postgres-1 Healthy
|
|
Container mtusi-messenger-lab3-migrate-1 Starting
|
|
Container mtusi-messenger-lab3-migrate-1 Started
|
|
Container mtusi-messenger-lab3-redis-1 Waiting
|
|
Container mtusi-messenger-lab3-migrate-1 Waiting
|
|
Container mtusi-messenger-lab3-redis-1 Healthy
|
|
Container mtusi-messenger-lab3-migrate-1 Exited
|
|
Container mtusi-messenger-lab3-api-2 Starting
|
|
Container mtusi-messenger-lab3-api-2 Started
|
|
BASE_URL="http://localhost:8080" ./scripts/wait-ready.sh
|
|
готов: http://localhost:8080
|
|
|
|
# реплики в конце
|
|
NAME STATE STATUS
|
|
mtusi-messenger-lab3-api-1 running Up 53 seconds (healthy)
|
|
mtusi-messenger-lab3-api-2 running Up 4 seconds (healthy)
|