From fc67a956d16c012f3d41ffae2bfbdc3d0bd6d4fb Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:05:14 +0000 Subject: [PATCH] Give native timer-fixture observations a bounded startup allowance CI run 46069881067 failed on the no-procfs ps witness after its 100 ms subprocess deadline. Allow two seconds for the observation command while preserving the installer suite's 60-second bound, strict state parsing and unknown-read failures. Add a delayed real-PID witness that still rejects a live process. Contract-Neutral: Installer regression fixture timing only; production installer, consent, timer, saved-state and runtime behavior are unchanged. Change-source: pulse-maintainer --- scripts/tests/test_server_update_timer.py | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/tests/test_server_update_timer.py b/scripts/tests/test_server_update_timer.py index d2c2add41b..34e1b0ba82 100644 --- a/scripts/tests/test_server_update_timer.py +++ b/scripts/tests/test_server_update_timer.py @@ -134,8 +134,11 @@ class FixtureProcessState: def read_text(self): if self.proc is not None: return self.proc.read_text() + # This bounds the observation command, not installer completion. Native + # process startup can exceed 100 ms on a busy CI host; an unknown read + # must still fail rather than count as termination. result = subprocess.run(["ps", "-p", str(self.pid), "-o", "stat="], - capture_output=True, text=True, timeout=0.1) + capture_output=True, text=True, timeout=2) state = result.stdout.strip() if result.returncode == 1 and not state and not result.stderr: raise FileNotFoundError("owned fixture PID is absent") @@ -224,6 +227,25 @@ class FixtureExitObservationTest(unittest.TestCase): process.wait(timeout=2) self.assertTrue(wait_for_fixture_exit(observer)) + def test_slow_native_ps_still_observes_a_live_owned_process(self): + native_run = subprocess.run + + def delayed_ps(argv, **kwargs): + # Model scheduling/command startup beyond the former 100 ms bound, + # then read the actual PID. Keep the real subprocess timeout active. + return native_run(["sh", "-c", 'sleep 0.15; exec "$@"', "delayed-ps", *argv], + **kwargs) + + with subprocess.Popen(["sleep", "30"]) as process: + try: + with patch("subprocess.run", side_effect=delayed_ps): + self.assertFalse(wait_for_fixture_exit( + FixtureProcessState(process.pid, use_proc=False), timeout=0)) + self.assertIsNone(process.poll()) + finally: + process.kill() + process.wait(timeout=2) + def test_native_ps_states_preserve_live_and_zombie_distinctions(self): for state, exited in (("S+\n", False), ("R\n", False), ("Z+\n", True)): with self.subTest(state=state), patch("subprocess.run") as run: @@ -231,7 +253,7 @@ class FixtureExitObservationTest(unittest.TestCase): observer = FixtureProcessState(123, use_proc=False) self.assertEqual(wait_for_fixture_exit(observer, timeout=0), exited) run.assert_called_once_with(["ps", "-p", "123", "-o", "stat="], - capture_output=True, text=True, timeout=0.1) + capture_output=True, text=True, timeout=2) def test_native_ps_absence_requires_both_empty_output_and_the_absent_exit(self): with patch("subprocess.run", return_value=subprocess.CompletedProcess([], 1, "", "")):