lesavka/tests/contract/testing/quality_ratchet_evidence_contract.rs

208 lines
7.3 KiB
Rust

// Contracts for quality-ratchet evidence coverage.
//
// Scope: inspect the root test taxonomy and explicit Cargo test registrations.
// Targets: repository-level `tests/` and root `Cargo.toml`.
// Why: the quality ratchet only protects Lesavka if each critical product path
// has happy-path, negative/degraded, performance, and observability angles that
// cannot silently disappear during future refactors.
const CARGO_TOML: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml"));
#[derive(Clone, Copy)]
struct EvidencePath {
category: &'static str,
path: &'static str,
}
fn registered(path: &str) -> bool {
let marker = format!("path = \"{path}\"");
CARGO_TOML.contains(&marker)
}
fn assert_evidence_set(name: &str, paths: &[EvidencePath]) {
for evidence in paths {
let full_path = format!("{}/{}", env!("CARGO_MANIFEST_DIR"), evidence.path);
assert!(
std::path::Path::new(&full_path).exists(),
"{name} should keep {} evidence file {}",
evidence.category,
evidence.path
);
assert!(
registered(evidence.path),
"{name} should register {} evidence test {} in root Cargo.toml",
evidence.category,
evidence.path
);
}
}
#[test]
fn upstream_media_has_happy_negative_degraded_and_performance_evidence() {
assert_evidence_set(
"upstream media",
&[
EvidencePath {
category: "unit",
path: "tests/unit/client/uplink/client_upstream_bundle_queue_unit.rs",
},
EvidencePath {
category: "integration",
path: "tests/integration/client/server/upstream/client_server_upstream_bundle_integration.rs",
},
EvidencePath {
category: "api",
path: "tests/api/server/upstream_media_runtime/server_upstream_media_bundle_contract.rs",
},
EvidencePath {
category: "performance",
path: "tests/performance/client/uplink/client_uplink_performance_contract.rs",
},
EvidencePath {
category: "chaos",
path: "tests/chaos/client/uplink/uplink_backpressure_chaos_contract.rs",
},
EvidencePath {
category: "reliability",
path: "tests/reliability/client/uplink/client_uplink_freshness_contract.rs",
},
],
);
}
#[test]
fn final_rct_route_has_sync_freshness_smoothness_and_artifact_evidence() {
assert_evidence_set(
"client/server/RCT route",
&[
EvidencePath {
category: "e2e",
path: "tests/e2e/client/server/rct/client_server_rct_blind_route_e2e_contract.rs",
},
EvidencePath {
category: "performance",
path: "tests/performance/client/server/rct/client_server_rct_timing_budget_contract.rs",
},
EvidencePath {
category: "chaos",
path: "tests/chaos/client/server/rct/client_server_rct_route_chaos_contract.rs",
},
EvidencePath {
category: "manual",
path: "tests/manual/client/sync_probe/client_rct_transport_probe_contract.rs",
},
EvidencePath {
category: "manual",
path: "tests/manual/artifacts/probe_artifact_contract.rs",
},
EvidencePath {
category: "performance",
path: "tests/performance/diagnostics/stage_timing_contract.rs",
},
],
);
}
#[test]
fn corrupt_video_and_codec_modes_have_guard_compatibility_and_chaos_evidence() {
assert_evidence_set(
"HEVC/MJPEG video output",
&[
EvidencePath {
category: "unit",
path: "tests/unit/server/video_sinks/hevc_mjpeg_guard_unit.rs",
},
EvidencePath {
category: "integration",
path: "tests/integration/server/video_sinks/hevc_mjpeg_spool_integration.rs",
},
EvidencePath {
category: "compatibility",
path: "tests/compatibility/server/video/hevc_mjpeg_profile_matrix_contract.rs",
},
EvidencePath {
category: "chaos",
path: "tests/chaos/server/video_sinks/hevc_mjpeg_guard_chaos_contract.rs",
},
EvidencePath {
category: "performance",
path: "tests/performance/server/video_sinks/hevc_mjpeg_handoff_performance_contract.rs",
},
],
);
}
#[test]
fn audio_epoch_ui_security_install_and_diagnostics_are_backstopped() {
assert_evidence_set(
"cross-cutting product controls",
&[
EvidencePath {
category: "unit",
path: "tests/unit/client/app/client_audio_recovery_config_unit.rs",
},
EvidencePath {
category: "ui",
path: "tests/ui/client/launcher/client_audio_recovery_ui_contract.rs",
},
EvidencePath {
category: "integration",
path: "tests/integration/client/runtime_controls/client_live_media_control_integration.rs",
},
EvidencePath {
category: "security",
path: "tests/security/server/tls/server_tls_security_contract.rs",
},
EvidencePath {
category: "security",
path: "tests/security/server/upstream_media/upstream_media_payload_security_contract.rs",
},
EvidencePath {
category: "installer",
path: "tests/installer/scripts/install/install_version_path_contract.rs",
},
EvidencePath {
category: "contract",
path: "tests/contract/diagnostics/report_schema_contract.rs",
},
EvidencePath {
category: "golden",
path: "tests/golden/diagnostics/client_rct_transport_summary_golden_contract.rs",
},
EvidencePath {
category: "reliability",
path: "tests/reliability/diagnostics/log_spam_prevention_contract.rs",
},
],
);
}
#[test]
fn opus_transport_has_schema_client_server_and_budget_evidence() {
assert_evidence_set(
"optional Opus audio transport",
&[
EvidencePath {
category: "unit",
path: "tests/unit/common/audio/common_audio_transport_unit.rs",
},
EvidencePath {
category: "integration",
path: "tests/integration/common/proto/relay_opus_proto_integration_contract.rs",
},
EvidencePath {
category: "compatibility",
path: "tests/compatibility/client/audio/client_opus_transport_contract.rs",
},
EvidencePath {
category: "contract",
path: "tests/contract/server/audio/server_opus_uac_contract.rs",
},
EvidencePath {
category: "performance",
path: "tests/performance/client/uplink/opus_transport_budget_contract.rs",
},
],
);
}