Skip to content

test: stop timing-sensitive tests from racing a loaded runner - #5901

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/timing-flake-highs
Nov 11, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/timing-flake-highs

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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 16 on 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

  • Checkpoint participant workers.
    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.
  • Deadlines that must not fire.
    These now have enough margin for a slow runner:
    • the per-callback cleanup budget in the environment server;
    • the episode deadline in legacy deadline collection;
    • the request timeouts in the vllm_model retry bound and the simple_agent outcome policy.
  • terminal_bench_4 verifier boundary.
    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.
  • remote_agent queue wait.
    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

  • I ran every changed test file on this branch, rebased onto current main. I used the root development venv, and for terminal_bench_4 a venv built from the server's lock file.
  • fix(model): keepalive cleanup and conversion option checks #5205 already fixed the recovered-response-timeout test in model failure observations with a controlled timeout, so this PR no longer changes it.
  • I then reran every changed file repeatedly with pytest -n 16, while 60 busy-loop processes loaded a 24-core host. There were no failures.
  • Mutation checks:
    • With stale-copy deletion forced to run one at a time, both deletion tests fail through the checkpoint deadline, before the gate's own check runs.
      With the checkpoint deadline raised to 60 s, they still fail, this time at the gate's own check.
    • With the remote_agent run timeout started before the permit is acquired, the queue-wait test fails.
  • pre-commit run --files passes 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.

@ananthsub ananthsub added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers area:agent Agent harnesses and Responses API agent behavior area:model Model servers, inference providers, and model adapters area:core Shared APIs, servers, telemetry, health, and registries labels Nov 10, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 10, 2026 00:58

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ananthsub
ananthsub marked this pull request as draft November 10, 2026 01:17
@copy-pr-bot

copy-pr-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

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.

ananthsub added a commit that referenced this pull request Nov 10, 2026
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]>
@ananthsub
ananthsub force-pushed the ananthsub/timing-flake-highs branch from c2d6e48 to 73e20a0 Compare November 10, 2026 16:39
@ananthsub
ananthsub marked this pull request as ready for review November 10, 2026 16:49

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

ananthsub added a commit that referenced this pull request Nov 10, 2026
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]>
ananthsub added a commit that referenced this pull request Nov 10, 2026
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]>
ananthsub added a commit that referenced this pull request Nov 10, 2026
…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]>
@ananthsub
ananthsub force-pushed the ananthsub/timing-flake-highs branch from 73e20a0 to 7d1e34d Compare November 10, 2026 21:16
@ananthsub
ananthsub merged commit 6af7fbf into main Nov 11, 2026
66 of 69 checks passed
@ananthsub
ananthsub deleted the ananthsub/timing-flake-highs branch November 11, 2026 00:31

This branch was previously deployed

1 inactive deployment
public — 7d1e34db Deployed Nov 10, 2026 by copy-pr-bot[bot] via release / finalize / notify #11591
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior area:core Shared APIs, servers, telemetry, health, and registries area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers area:model Model servers, inference providers, and model adapters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants