[AZ-233] Add blackbox replay infrastructure

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-05 06:19:35 +03:00
parent 9812503abd
commit c30fd4f67d
19 changed files with 610 additions and 24 deletions
+5 -10
View File
@@ -1,17 +1,12 @@
"""Black-box runner entry point.
"""Black-box runner entry point."""
Future scenarios should call only public runtime inputs and outputs: replay frames,
telemetry, offline cache, MAVLink output, status events, and FDR artifacts.
"""
from collections.abc import Sequence
from pathlib import Path
from e2e.replay.harness import main as replay_main
def main() -> int:
reports_dir = Path("data/test-results")
reports_dir.mkdir(parents=True, exist_ok=True)
(reports_dir / "blackbox_smoke.txt").write_text("blackbox scaffold ready\n", encoding="utf-8")
return 0
def main(argv: Sequence[str] | None = None) -> int:
return replay_main(argv)
if __name__ == "__main__":
+77
View File
@@ -0,0 +1,77 @@
import csv
from pathlib import Path
from e2e.replay.harness import (
REPORT_COLUMNS,
BlackboxReplayRunner,
SatelliteCacheStub,
ScenarioConfig,
ScenarioGroup,
ScenarioResult,
)
def test_replay_environment_reports_missing_prerequisites_as_blocked(tmp_path: Path) -> None:
# Arrange
scenario = ScenarioConfig(
scenario_id="BLOCKED-INFRA",
name="Blocked prerequisite smoke",
group=ScenarioGroup.RESILIENCE,
input_dataset="sitl_spoofing_scenarios",
required_paths=(tmp_path / "missing-fixture.csv",),
required_services=("sitl",),
)
# Act
result = BlackboxReplayRunner(output_root=tmp_path, scenarios=(scenario,)).run()
# Assert
report = result.reports[0]
assert report.result == ScenarioResult.BLOCKED
assert "missing fixture path" in report.error_message
assert "SITL prerequisite blocked" in report.error_message
def test_satellite_cache_stub_is_deterministic_and_records_interactions() -> None:
# Arrange
stub = SatelliteCacheStub()
# Act
first = stub.query_manifest("FT-P-01", "valid")
second = stub.query_manifest("FT-P-01", "valid")
# Assert
assert first == second
assert first["network_fetch_attempted"] is False
assert len(stub.interactions) == 2
assert stub.interactions[0].service == "satellite-cache-stub"
def test_runner_executes_all_required_groups_and_writes_reports(tmp_path: Path) -> None:
# Act
result = BlackboxReplayRunner(output_root=tmp_path).run()
# Assert
assert result.completed_groups == set(ScenarioGroup)
rows = list(csv.DictReader(result.csv_path.open(encoding="utf-8")))
assert rows
assert rows[0].keys() == set(REPORT_COLUMNS)
assert {row["Result"] for row in rows} <= {"pass", "blocked"}
markdown = result.markdown_path.read_text(encoding="utf-8")
assert "FDR Validation Summary" in markdown
assert "SITL prerequisite blocked" in markdown
assert "Jetson prerequisite blocked" in markdown
def test_runner_keeps_generated_artifacts_run_scoped(tmp_path: Path) -> None:
# Act
result = BlackboxReplayRunner(output_root=tmp_path).run()
# Assert
assert result.run_dir.parent == tmp_path
assert result.csv_path.parent == result.run_dir
assert result.markdown_path.parent == result.run_dir
for report in result.reports:
assert report.artifacts
assert all(artifact.parent.parent == result.run_dir for artifact in report.artifacts)