# failover: stop the API replica that served the test, twice (restore in between)
# date: 2026-11-10T13:49:42Z

## run 1: 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": 113, "failed_attempts": 0, "first_recovery_seconds": 3.483}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
NAME                   STATUS
messenger-lab5-api-1   Up 5 seconds (healthy)
messenger-lab5-api-2   Up 39 seconds (healthy)

## run 2: 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": 113, "failed_attempts": 0, "first_recovery_seconds": 2.809}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
NAME                   STATUS
messenger-lab5-api-1   Up 5 seconds (healthy)
messenger-lab5-api-2   Up About a minute (healthy)

## stop-one.sh log
2026-11-10T13:49:45Z stopped messenger-lab5-api-1 (45db2233b0c2) instance=api-cf4d97a2 state=exited
2026-11-10T13:50:09Z stopped messenger-lab5-api-1 (45db2233b0c2) instance=api-3423c899 state=exited
