#!/usr/bin/env python3 """Resume scripts/collect_evidence.py after an interruption, on the SAME clean-clone stand. python scripts/collect_evidence_resume.py Used once in this work: during the clean-clone run Docker Desktop itself stopped after the own tests (every later step failed with "cannot connect to the docker API"). This script re-runs, with the same logging, the tests that failed in that run and the steps that never executed: level 4 incidents, the read-only audit and the final state. Earlier evidence files are kept unchanged. """ from __future__ import annotations import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "scripts")) import collect_evidence as ce # noqa: E402 FAILED = [ "student-tests/test_pipeline_flow.py::test_cleanup_racing_a_replay_never_deletes_the_replayed_source", "student-tests/test_storage_failures.py::test_upload_survives_failover_of_the_serving_replica", "student-tests/test_storage_failures.py::test_bucket_is_private_outside_the_api", "student-tests/test_storage_failures.py::test_s3_restart_keeps_objects", ] def main() -> int: log = ce.Log("student-tests-rerun.txt", "Re-run of the 4 tests that failed in student-tests.txt (Docker Desktop " "degraded and then stopped at the end of that run)") log.note("Containers BEFORE:\n" + "\n".join(ce.states())) log.run([ce.VENV_PY, "-m", "pytest", *FAILED, "-v", "-p", "no:cacheprovider"], shown="python -m pytest <4 tests> -v", timeout=3600) log = ce.Log("incidents-runs.txt", "bench/incidents.py all: worker stop, DB lock, slow handler, Tempo+Loki down, " "Collector down (details: evidence/incidents/*.txt)") log.run([ce.VENV_PY, "bench/incidents.py", "all"], shown="python bench/incidents.py all", timeout=5400) log.run(["docker", "compose", "run", "--rm", "--no-deps", "-T", "auditor"], shown="docker compose run --rm auditor", timeout=900) log = ce.Log("final-state.txt", "Final state of the stand") log.run([ce.PYTHON, "scripts/obs.py", "alerts"], shown="python scripts/obs.py alerts") log.run(["docker", "compose", "ps", "-a", "--format", "table {{.Service}}\t{{.Status}}"]) print("done:", ce.EVIDENCE) return 0 if __name__ == "__main__": raise SystemExit(main())