From 20b2c509829900e9b94ec7d1cd79503b36911cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 23 Oct 2026 17:53:29 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20forge-runner=20signal=20t?= =?UTF-8?q?ests=20stop=20interfering=20inside=20the=20merged=20test=20bina?= =?UTF-8?q?ry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: sigkilled_helper_leaves_no_process_behind found its helper by scanning every __sandbox child of the test process. The sandbox tests spawn their helpers from that same process, all with job id job_01. Under plain cargo test (threads in one process) the killer SIGKILLed sigterm_kills_the_container_and_the_helper_exits' helper. That helper's sleep 60 job survived, held the stdout pipe, and wait_with_output blocked about 60 s, tripping the 20 s check. The sigkill test's own helper was never killed, so its sleep 300 ran to Success, which made the run take about 300 s. Fix: the sigkill test uses its own job id (job_sigkill), and the helper search matches only that job's cgroup name. No assertions changed and no tests removed. --- .../forge-runner/tests/integration/builtin.rs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/forge-runner/tests/integration/builtin.rs b/crates/forge-runner/tests/integration/builtin.rs index 5802d1b..c73964e 100644 --- a/crates/forge-runner/tests/integration/builtin.rs +++ b/crates/forge-runner/tests/integration/builtin.rs @@ -197,8 +197,8 @@ async fn sandbox_setup_failure_is_an_error_with_the_reason() { ); } -/// The builtin tests run in one process. Each takes this lock, so the helper-finding test below -/// never sees another test's helper as its own child. +/// The builtin tests run in one process. Each takes this lock, so their jobs do not run at once. +/// The helper-finding test below matches its own job cgroup, not any helper child of the process. static SERIAL: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(()); async fn serial() -> tokio::sync::MutexGuard<'static, ()> { @@ -226,9 +226,9 @@ fn helper_children() -> Vec { .collect() } -/// The job cgroup directory of the helper with pid `helper`, for job `job_01`. -fn job_cgroup_dir(helper: u32) -> PathBuf { - let rel = job_cgroup_path("job_01", helper).expect("job cgroup path"); +/// The job cgroup directory of the helper with pid `helper`, for job `job_id`. +fn job_cgroup_dir(job_id: &str, helper: u32) -> PathBuf { + let rel = job_cgroup_path(job_id, helper).expect("job cgroup path"); Path::new("/sys/fs/cgroup").join(rel.strip_prefix("/").unwrap_or(&rel)) } @@ -278,14 +278,18 @@ async fn sigkilled_helper_leaves_no_process_behind() { let (exec, workspace) = executor(dir.path()); // `trap '' TERM` makes the job ignore SIGTERM. Only the helper's SIGKILL path can stop it. let run = "trap '' TERM; sleep 300"; - let job_spec = job(run); + // A job id of its own. `helper_children` also finds the helpers of the other tests in this + // process, and only this job's cgroup name identifies this test's helper. + let job_id = "job_sigkill"; + let mut job_spec = job(run); + job_spec.job_id = job_id.to_owned(); let killer = async { let deadline = Instant::now() + Duration::from_secs(30); let (helper, cgroup, procs) = loop { assert!(Instant::now() < deadline, "the job never started"); let found = helper_children().into_iter().find_map(|pid| { - let cgroup = job_cgroup_dir(pid); + let cgroup = job_cgroup_dir(job_id, pid); let procs = procs_in(&cgroup); (!procs.is_empty()).then_some((pid, cgroup, procs)) }); @@ -316,5 +320,5 @@ async fn sigkilled_helper_leaves_no_process_behind() { "job process {pid} survived the helper" ); } - assert!(!dir.path().join("jobs/job_01").exists(), "job dir was kept"); + assert!(!dir.path().join("jobs").join(job_id).exists(), "job dir was kept"); }