agent/cli/tests/integration_latency_bench_twin.rs
//! Downscaled correctness twin of the `holger.latency_tail` Bencher.
//!
//! Bench: xtask/examples/nornir-bench.rs :: LatencyTail ("holger.latency_tail")
//! Ported from: integration_latency_tail.rs::test_tail_latency_gc_pressure
//!
//! Small-scale correctness check over the exact same
//! `holger_bench_scenarios::nexus::latency_tail` workload (512MB-heap GC-pressured
//! Nexus). The full-scale 60s tail-latency measurement lives in the bench so it
//! lands in `bench_history`.
//!
//! ## Fixture gate (NOT `--heavy`)
//!
//! The Nexus 3 testcontainer is a *fixture gate*: the scenario boots a
//! 512MB-heap Nexus and, when Docker/Podman is unavailable, returns an `is_skip`
//! error. This twin records that as a SKIP (test passes) and only asserts real
//! percentiles when a container is present. NORMAL (non-`--ignored`) test.
use holger_bench_scenarios::{nexus, Scale};
use traits::test_support::fstatus;
fn twin_scale() -> Scale {
Scale {
entries: 16,
bench_secs: 1,
threads_mt: 2,
// entry-driven twin bench (not byte-budgeted)
target_bytes: None,
}
}
#[tokio::test]
#[ignore = "heavy: needs Docker/Nexus container (container = heavy; fixture-gated, runs under --heavy)"]
async fn test_latency_tail_twin_small_scale() {
let scale = twin_scale();
match nexus::latency_tail(&scale).await {
Ok(o) => {
// Container present → assert real tail-latency numbers.
assert_eq!(o.heap_mb, 512, "GC-pressure heap must be 512 MB");
assert!(o.samples > 0, "must have recorded latency samples");
assert!(o.p50_ms >= 0.0, "p50 must be non-negative");
assert!(
o.p99_ms >= o.p50_ms,
"p99 ({}) must be >= p50 ({})",
o.p99_ms,
o.p50_ms
);
assert!(o.throughput_mbs >= 0.0, "throughput must be non-negative");
fstatus(
"agent-bench",
"latency_tail_twin",
true,
&format!(
"p50={:.2}ms p99={:.2}ms thr={:.1} MB/s n={}",
o.p50_ms, o.p99_ms, o.throughput_mbs, o.samples
),
);
}
Err(e) => {
assert!(
nexus::is_skip(&e),
"non-skip error from latency_tail twin: {e:#}"
);
eprintln!("latency_tail twin skipped (fixture gate): {e}");
fstatus(
"agent-bench",
"latency_tail_twin",
true,
&format!("skipped: {e}"),
);
}
}
}