Skip to content

Commit b62ec53

Browse files
test(runner): generate the nextest profile from shared timeout constants (#5450)
* test(runner): pass an explicit per-test timeout and grace to program rows Program rows relied on the program's 900 s default, so one hung test could use much of the 45-minute run timeout. Derive the per-test timeout from the same constants as the nextest profile (120 s) and pass it with a 10 s grace to the program. Part of #5416. Signed-off-by: Evan Lezar <elezar@nvidia.com> * test(runner): keep program rows on the program's default timeout Passing the runner's 120 s limit to the program would stop a test before testkit's own step timeouts (up to 10 minutes) can report which step stalled, contrary to the program's documented contract. Keep program rows on the program's default until testkit learns the per-test deadline (#5333). Write nextest's grace period into the generated profile from the same constants, rather than relying on nextest's default. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> --------- Signed-off-by: Evan Lezar <elezar@nvidia.com> Signed-off-by: Matthew Grossman <mgrossman@nvidia.com> Co-authored-by: Matthew Grossman <mgrossman@nvidia.com>
1 parent cb85c09 commit b62ec53

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

‎tests/runner/src/bundle.rs‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,27 @@ pub const PROFILE: &str = "openshell";
3131
/// The readiness check every bundle carries, at the bundle root.
3232
pub const READY_BINARY: &str = "testkit-ready";
3333

34-
/// Nextest flags a test as slow after the period and terminates it after
35-
/// `terminate-after` periods, so a hung test fails after two minutes instead
36-
/// of holding the lane until the job times out.
37-
const NEXTEST_CONFIG: &str = r#"# Written by the OpenShell test runner.
34+
/// Nextest flags a test as slow after this period and terminates it after
35+
/// [`SLOW_TERMINATE_AFTER`] periods, so a hung test fails after two minutes
36+
/// instead of holding the lane until the job times out.
37+
const SLOW_PERIOD_SECS: u64 = 30;
38+
const SLOW_TERMINATE_AFTER: u64 = 4;
39+
/// How long a terminated test has between SIGTERM and SIGKILL.
40+
const GRACE_PERIOD_SECS: u64 = 10;
41+
42+
/// The nextest configuration written into a nextest bundle.
43+
fn nextest_config() -> String {
44+
format!(
45+
r#"# Written by the OpenShell test runner.
3846
[profile.openshell]
3947
fail-fast = false
40-
slow-timeout = { period = "30s", terminate-after = 4 }
48+
slow-timeout = {{ period = "{SLOW_PERIOD_SECS}s", terminate-after = {SLOW_TERMINATE_AFTER}, grace-period = "{GRACE_PERIOD_SECS}s" }}
4149
4250
[profile.openshell.junit]
4351
path = "junit.xml"
44-
"#;
52+
"#
53+
)
54+
}
4555

4656
/// The prebuilt program's name in a program bundle.
4757
pub const PROGRAM_BINARY: &str = "test-program";
@@ -204,7 +214,7 @@ pub fn build(root: &Path, family: &str, packages: &[String], out: &Path) -> Resu
204214
run(&mut command).with_context(|| format!("build the {} test archive", workspace.display()))?;
205215

206216
copy_manifests(&workspace, out)?;
207-
std::fs::write(out.join(CONFIG), NEXTEST_CONFIG)?;
217+
std::fs::write(out.join(CONFIG), nextest_config())?;
208218
std::fs::copy(&ready, out.join(READY_BINARY))
209219
.with_context(|| format!("copy {}", ready.display()))?;
210220
let manifest = Manifest {
@@ -343,6 +353,14 @@ fn run(command: &mut Command) -> Result<()> {
343353
mod tests {
344354
use super::*;
345355

356+
#[test]
357+
fn nextest_profile_stops_a_hung_test_after_two_minutes() {
358+
let config = nextest_config();
359+
assert!(config.contains(
360+
r#"slow-timeout = { period = "30s", terminate-after = 4, grace-period = "10s" }"#
361+
));
362+
}
363+
346364
#[test]
347365
fn program_bundle_holds_only_the_program() {
348366
let dir = tempfile::tempdir().unwrap();

‎tests/runner/src/execute.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ const NEXTEST_LOG: &str = "nextest.log";
3131
// Matches the installers' own wait: an HA k3s gateway booted from a cached
3232
// disk can take minutes to report healthy.
3333
const READY_TIMEOUT_SECS: u64 = 300;
34-
/// How long the nextest run may take in total. Individual tests are bounded
35-
/// by the nextest profile's slow-timeout; this catches a run that stops
36-
/// making progress some other way.
34+
/// How long the test run may take in total. Individual tests are bounded by
35+
/// the nextest profile's slow-timeout, or by a program's own `run --timeout`
36+
/// default; this catches a run that stops making progress some other way.
3737
const RUN_TIMEOUT: Duration = Duration::from_mins(45);
3838
/// Slack beyond the readiness check's own timeout for SSH and process start.
3939
const READY_SLACK: Duration = Duration::from_mins(1);

0 commit comments

Comments
 (0)