# python tests/resilience.py --mode failover --action-script scripts/stop-one.sh --base-url http://127.0.0.1:8084
# Same public test as: make test-failover ACTION_SCRIPT=scripts/stop-one.sh BASE_URL=http://127.0.0.1:8084
# On this Windows host the hook process was Git bash, because CreateProcess cannot exec a #!/bin/sh file.
# The script and its arguments are scripts/stop-one.sh. git index mode of the hook is 100755.

=== before ===
api-1      606d8436f093 status=running started=2026-11-12T15:27:01.000430042Z
api-2      2d9cb0ed8adc status=running started=2026-11-12T15:27:00.68343251Z
lb-1       a708afda6620 status=running started=2026-11-12T15:27:06.923950206Z
postgres-1 9c54ddd911ba status=running started=2026-11-12T15:26:49.628819651Z
minio-1    4aa69397a7e9 status=running started=2026-11-12T15:26:49.732842597Z

Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 128, "failed_attempts": 0, "first_recovery_seconds": 5.699}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.

=== after the hook, before any restore ===
api-1      606d8436f093 status=running started=2026-11-12T15:27:01.000430042Z
api-2      2d9cb0ed8adc status=exited  finished=2026-11-12T15:27:30.226687078Z
lb-1       a708afda6620 status=running started=2026-11-12T15:27:06.923950206Z
postgres-1 9c54ddd911ba status=running started=2026-11-12T15:26:49.628819651Z
minio-1    4aa69397a7e9 status=running started=2026-11-12T15:26:49.732842597Z

The test saw two instance ids before the stop. Writes recovered in 5.699 s, with 128 successes and 0 failures. api-2 stayed exited. PostgreSQL, MinIO, the LB and api-1 kept the start times from before the hook.

After this snapshot the stopped replica was started again with `docker compose --env-file .env up -d --wait api`. Both API replicas were healthy. That restore is not part of the hook: the hook left api-2 exited.
