Repository navigation
test: stop timing-sensitive tests from racing a loaded runner - #5901
Conversation
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
The timing changes preserve the intended assertions, but one RISK remains: a failed readiness wait can bypass supervisor cleanup in the three standalone sandbox-runner suites.
I reviewed all 18 changed files and their directly affected implementation paths. This was a source-only review; I couldn't execute tests or independently verify the reported loaded-run and mutation results.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| time.sleep(0.01) | ||
| (tmp_path / "stop.request").touch() | ||
| if ending != "natural": | ||
| wait_for(tmp_path / "ready") |
There was a problem hiding this comment.
RISK — Reap the supervisor when readiness fails
Could you include the launched supervisor in the outer cleanup? If startup exceeds the new 30-second readiness limit, wait_for() raises before result() runs. The finalizer kills only the detached task child, if its PID file exists. It never stops or reaps the supervisor, so the supervisor and harness can remain alive after the test fails, until their 60-second deadline and cleanup finish. This adds leftover processes to an already loaded CI runner. The same exit path exists in Codex and Pi. Previously, the timeout cases reached result() without this readiness assertion.
Correction: initialize a nullable process handle before the outer try, and ensure every post-launch exit requests shutdown through stop.request and collects/reaps the supervisor before completing owner teardown. Keep the original readiness exception if cleanup also fails. A PID-only kill isn't a complete fallback because the supervisor can detach behind a waiting shell. The fallback for an unresponsive detached supervisor needs care, so I haven't supplied an exact kill patch.
Proposed checks, not executed: force the readiness helper to raise after a real sleeping harness launches, both before and after child.pid appears. After unwinding, retain the readiness error and verify that neither the supervisor nor harness remains alive. Preserve all three successful cases: natural completion and cancellation report timed_out=False, expire-file termination reports True, and the detached task child survives through each receipt until the owner-teardown finalizer kills it.
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Make the polling helper raise with the last value it saw instead of returning False, matching the copy in #5901, and use it for the RECOVERED output wait in place of a silent fixed loop. Queue 1024 commands (about 95 KB) instead of 32768 (about 1.3 MB). That is still far beyond the 4 KB kernel input queue, so the test still needs the drain. The smaller payload keeps the input drain's fixed 5 s budget from running out on a busy runner. Signed-off-by: Ananth Subramaniam <[email protected]>
c2d6e48 to
73e20a0
Compare
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no remaining eligible concerns in this follow-up.
The prior supervisor-cleanup RISK is closed: the readiness-wait changes that introduced its failure path are absent from the current OpenCode, Codex, and Pi tests. Those paths match the base; this removes the reported regression rather than adding a general cleanup fix.
I inspected the eight current changed-file hunks. The previously reviewed tree is unavailable, so I couldn't reconstruct the complete inter-review delta. The supplied evidence establishes no new regression above the historical moderate-impact ceiling. This was a scoped, source-only follow-up, not a fresh full review; I didn't execute tests or independently verify the reported validation results.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
The interrupt case of the exited-shell recovery test sent Ctrl-C a fixed 0.3 s after typing `set -e; sleep 120`. When the Ctrl-C arrived before sleep started, bash took it at the prompt, survived, and the pane never died, so the test failed most runs even on an idle host. Poll until sleep is the pane's foreground command before pasting the queued input and sending Ctrl-C, and poll for the dead pane with a 30 s deadline instead of a fixed 10 s loop. The polling helper matches the one #5901 adds for the full-PTY test in the same file. Signed-off-by: Ananth Subramaniam <[email protected]>
Make the polling helper raise with the last value it saw instead of returning False, matching the copy in #5901, and use it for the RECOVERED output wait in place of a silent fixed loop. Queue 1024 commands (about 95 KB) instead of 32768 (about 1.3 MB). That is still far beyond the 4 KB kernel input queue, so the test still needs the drain. The smaller payload keeps the input drain's fixed 5 s budget from running out on a busy runner. Signed-off-by: Ananth Subramaniam <[email protected]>
…e pane log Bring the full-PTY Ctrl-C test fix over from #5901 so all terminus test fixes land together. The test now polls until sleep is the foreground command before sending the raw Ctrl-C, and polls the pane for TERMINAL_RECOVERED and the raw-mode bytes instead of reading it once. Under load it failed with `'bash' == 'sleep'` when the pane was read before sleep had started. The exited-shell recovery test also polls pane.log for the RECOVERED line. pipe-pane writes the log through a separate process, so the log can lag the screen that the earlier wait already checked. Signed-off-by: Ananth Subramaniam <[email protected]>
Several core, model, agent and terminal_bench_4 tests gave real work a deadline of tens of milliseconds, or bounded how long it took, and failed whenever a busy CI runner was slower. Give deadlines that must not fire room for a slow runner, replace the elapsed bound on concurrent stale-copy deletion with a gate that every deletion must reach, and apply the 25 ms verifier budget only to the terminal_bench_4 cases meant to run out of it. The exec-transport and supervision changes moved to #5933 and the terminus changes to #5943. Signed-off-by: Ananth Subramaniam <[email protected]>
73e20a0 to
7d1e34d
Compare
What and why
Several tests gave real work a deadline of tens of milliseconds to a few seconds, or bounded how long it took, and failed whenever a busy CI runner was slower.
CI runs the core suite with
pytest -n 16on shared runners, and runs the server suites under the same load, so these tests failed intermittently on unrelated pull requests.This PR fixes the highest-risk cases that an audit of timing assumptions in the tests found in core library, model, simple_agent, remote_agent and terminal_bench_4 tests.
It changes only tests, not library or server code.
The flaky-test fixes are grouped by area, so each PR touches different files:
Changes
The two tests that check stale copies are deleted together now use a gate that every deletion must reach before any can finish. Previously they used an elapsed-time bound equal to the time of serial deletion.
A deletion whose wait at the gate gives up marks the check as failed.
With the default checkpoint deadline, serial deletion fails even earlier, because the gate's wait outlasts the deadline.
The status test uses the real status timeout, and its elapsed bound now only guards against a hang.
These now have enough margin for a slow runner:
The 25 ms verifier budget now applies only to the cases that are meant to run out of it.
Cases that must finish get 5 s, and the artifact-timeout case runs out of a 1 s budget during a 30 s artifact cleanup.
test(terminal_bench_4): control verifier deadline phases #5860, already merged, fixed the preparation-window test and the transfer tests in the same file with a controlled event-loop clock.
The budget is now 3 s against 2 s runs, which leaves a second of slack, instead of 0.1 s.
The second run would still go a second over its budget if queue time counted against it.
Issues
Refs #5434: #5860 fixed the window that the issue reports, and this PR fixes the 25 ms budget in the same file.
Validation
main. I used the root development venv, and for terminal_bench_4 a venv built from the server's lock file.pytest -n 16, while 60 busy-loop processes loaded a 24-core host. There were no failures.With the checkpoint deadline raised to 60 s, they still fail, this time at the gate's own check.
pre-commit run --filespasses on the changed files.Rollout evidence
N/A: this is a test-only change, with no change to agent, verifier or library behavior.
Compatibility
None.