forked from mtusi2026/mtusi2026lab7
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Public failover plus explicit coverage of both distinct API replicas."""
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
from securitylib import ROOT, compose
|
|
|
|
(ROOT / "evidence/failover-events.jsonl").write_text("")
|
|
logs = []
|
|
try:
|
|
for command in [
|
|
[
|
|
sys.executable,
|
|
"tests/resilience.py",
|
|
"--mode",
|
|
"failover",
|
|
"--action-script",
|
|
"scripts/stop-one.sh",
|
|
"--base-url",
|
|
"https://localhost:8443",
|
|
"--ca-file",
|
|
str(ROOT / ".local/trust/ca.crt"),
|
|
],
|
|
[sys.executable, "tests/lab7_failovers.py"],
|
|
]:
|
|
result = subprocess.run(
|
|
command, cwd=ROOT, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
|
)
|
|
logs.append(result.stdout)
|
|
print(result.stdout, end="", flush=True)
|
|
assert result.returncode == 0, "Failover verification failed"
|
|
compose("start", "api")
|
|
compose("up", "-d", "--no-recreate", "--wait", "api")
|
|
(ROOT / "evidence/failover-checks.txt").write_text("\n".join(logs))
|
|
finally:
|
|
compose("start", "api")
|