mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-22 18:21:16 +00:00
[AZ-238] [AZ-239] Add resource restart tests
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
from pathlib import Path
|
||||
|
||||
from e2e.replay.harness import (
|
||||
BlackboxReplayRunner,
|
||||
ScenarioConfig,
|
||||
ScenarioGroup,
|
||||
ScenarioResult,
|
||||
relocalization_required,
|
||||
summarize_cold_start_trials,
|
||||
)
|
||||
|
||||
|
||||
def test_disconnected_segment_triggers_relocalization_request_check() -> None:
|
||||
# Act / Assert
|
||||
assert relocalization_required(visual_overlap_fraction=0.03, disconnected_duration_s=0.5) is True
|
||||
assert relocalization_required(visual_overlap_fraction=0.5, disconnected_duration_s=4.0) is True
|
||||
assert relocalization_required(visual_overlap_fraction=0.5, disconnected_duration_s=1.0) is False
|
||||
|
||||
|
||||
def test_restart_scenario_records_first_output_or_blocked_prerequisite(tmp_path: Path) -> None:
|
||||
# Arrange
|
||||
scenario = ScenarioConfig(
|
||||
scenario_id="NFT-RES-03",
|
||||
name="Companion restart recovery",
|
||||
group=ScenarioGroup.RESILIENCE,
|
||||
input_dataset="restart_trace",
|
||||
required_paths=(tmp_path / "restart-trace.tlog",),
|
||||
)
|
||||
|
||||
# Act
|
||||
result = BlackboxReplayRunner(output_root=tmp_path, scenarios=(scenario,)).run()
|
||||
|
||||
# Assert
|
||||
report = result.reports[0]
|
||||
assert report.result == ScenarioResult.BLOCKED
|
||||
assert "restart-trace.tlog" in report.error_message
|
||||
assert report.artifacts[0].exists()
|
||||
|
||||
|
||||
def test_cold_start_trials_report_p95_first_fix_and_resource_spike() -> None:
|
||||
# Arrange
|
||||
first_fix_latencies_s = tuple(20.0 + (index % 5) for index in range(50))
|
||||
peak_memory_bytes = tuple(2_500_000_000 + index * 1_000_000 for index in range(50))
|
||||
|
||||
# Act
|
||||
summary = summarize_cold_start_trials(first_fix_latencies_s, peak_memory_bytes)
|
||||
|
||||
# Assert
|
||||
assert summary["trial_count"] == 50.0
|
||||
assert summary["p95_first_fix_s"] < 30.0
|
||||
assert summary["first_fix_passed"] is True
|
||||
assert summary["memory_passed"] is True
|
||||
|
||||
|
||||
def test_cold_start_hardware_prerequisites_are_blocked_not_passed(tmp_path: Path) -> None:
|
||||
# Arrange
|
||||
scenario = ScenarioConfig(
|
||||
scenario_id="NFT-RES-LIM-05",
|
||||
name="Cold-start resource spike",
|
||||
group=ScenarioGroup.RESOURCE_LIMIT,
|
||||
input_dataset="jetson_resource_monitor",
|
||||
required_services=("jetson",),
|
||||
)
|
||||
|
||||
# Act
|
||||
result = BlackboxReplayRunner(output_root=tmp_path, scenarios=(scenario,)).run()
|
||||
|
||||
# Assert
|
||||
report = result.reports[0]
|
||||
assert report.result == ScenarioResult.BLOCKED
|
||||
assert "Jetson prerequisite blocked" in report.error_message
|
||||
Reference in New Issue
Block a user