[control] Tests: a 15 s trial margin and waits on state, not fixed sleeps, for a loaded runner

This commit is contained in:
2026-12-02 16:47:58 +01:00
parent c626db8f25
commit f9e8ac801c
5 changed files with 37 additions and 30 deletions
+3 -2
View File
@@ -15,8 +15,9 @@ env:
CARGO_BUILD_JOBS: "8"
# Each of control's integration tests starts its own edge, Caddy and upstreams. With the tests' old 2 s margin for
# control's confirmation (production: 30 s), a status call on the loaded shared runner took longer and edge
# reverted the trial by itself, as designed (runs rc344zj96yjz1, rqzephjsp7983, rzqmqbvx970f8; 2026-12-02). The
# margin is 5 s now (crates/control/tests/common/mod.rs), and four tests at a time keep the runner's load down.
# reverted the trial by itself, as designed (runs rc344zj96yjz1, rqzephjsp7983, rzqmqbvx970f8, rja3pbbd14fk1;
# 2026-12-02). The margin is 15 s now (crates/control/tests/common/mod.rs), and four tests at a time keep the
# runner's load down.
RUST_TEST_THREADS: "4"
steps:
- id: workspace-tests
-19
View File
@@ -1,19 +0,0 @@
{
"commit": "2d45087145a124c90d6404ca2a3c31d45b7b6619",
"nixpkgs": "c56a87d8e41ce69bd2af57eb35dcc117a9dfca33",
"outputs": {
"ianitor": {
"narHash": "sha256-hlX5oiJQPTieETbjojaZnPUGcSgPrKqO2vPsr2o2Xok=",
"narSize": 24455232,
"storePath": "/nix/store/pds604zcl2ydvbvynrjvmbgn9dhkxwk8-ianitor-1.0.0"
},
"ianitor-web": {
"narHash": "sha256-cR8Lq5LNQoQ7xWa40jpjmRybUC8tS9XuXAtojDmCg2c=",
"narSize": 598000,
"storePath": "/nix/store/vsrm3326zm440gwp17nqg3g3bixb3cmm-ianitor-web-1.0.0"
}
},
"sourceTree": "2b9ebb0bdebcb088276dadcb89e9111362ebf17b9a2b4c665543b6f0fc12157c",
"system": "x86_64-linux",
"version": "1.0.0"
}
+27 -5
View File
@@ -237,10 +237,16 @@ mod unix {
"{stage}: edge.json untouched"
);
}
// A trial edge was serving reverts by itself at its deadline (watch 2 s + margin 5 s,
// common/mod.rs: room for a loaded runner between the watch's end and the confirmation).
tokio::time::sleep(Duration::from_secs(8)).await;
let st = env.edge_status().await;
// A trial edge was serving reverts by itself at its deadline (watch 2 s + margin 15 s,
// common/mod.rs: room for a loaded runner between the trial's load and the confirmation).
let deadline = std::time::Instant::now() + Duration::from_secs(30);
let st = loop {
let st = env.edge_status().await;
if st["trial"].is_null() || std::time::Instant::now() > deadline {
break st;
}
tokio::time::sleep(Duration::from_millis(250)).await;
};
assert!(st["trial"].is_null(), "{stage}: trial still running: {st}");
if !confirmed {
assert_eq!(
@@ -789,7 +795,23 @@ mod unix {
)
.await;
let id = r.json["apply"]["id"].as_str().unwrap().to_owned();
tokio::time::sleep(Duration::from_millis(1500)).await;
// Edge goes once the trial is loaded and watched (a fixed 1.5 s was before the reload on
// a loaded runner, layers run rja3pbbd14fk1).
let deadline = std::time::Instant::now() + Duration::from_secs(20);
loop {
let s = env
.call("GET", &format!("/api/v1/applies/{id}"), None)
.await;
if s.json["state"] == "watching" {
break;
}
assert!(
std::time::Instant::now() < deadline,
"never watched: {}",
s.text
);
tokio::time::sleep(Duration::from_millis(50)).await;
}
env.stop_edge();
let rec = env.wait_apply(&id).await;
assert_eq!(rec["state"], "needs_attention", "{rec}");
+4 -1
View File
@@ -174,7 +174,10 @@ state_dir = "{state}"
credentials_dir = "{creds}"
watch_secs = {watch}
watch_every_secs = 1
trial_margin_secs = 5
# Production: 30 s. Control starts its watch after the trial's journal is written, which took
# over 5 s on the loaded shared runner (layers run rja3pbbd14fk1); edge's deadline counts from
# the trial's load. The tests that wait out a deadline use this value (apply.rs, engine_switch.rs).
trial_margin_secs = 15
health_poll_secs = 1
[routes]
+3 -3
View File
@@ -575,10 +575,10 @@ esac
let st = ce.env.wait_control_exit(Duration::from_secs(30));
eprintln!("QC control exit: {st:?}");
assert!(st.is_some());
// Longer than edge's trial deadline would allow.
tokio::time::sleep(Duration::from_secs(15)).await;
// Past the Caddy guard's deadline: watch 2 s + margin 15 s (common/mod.rs) + 5 s.
tokio::time::sleep(Duration::from_secs(27)).await;
let during = visit(&ce.env, ce.https, "b.test").await;
eprintln!("QC b.test through Caddy 15 s after the crash, control down: {during}");
eprintln!("QC b.test through Caddy 27 s after the crash, control down: {during}");
ce.env.start_control(None);
tokio::time::sleep(Duration::from_secs(3)).await;
let after = visit(&ce.env, ce.https, "b.test").await;