Skip to content

fix(ci): stop the Tier 1 runner missing a Ctrl-C, and deflake timing-dependent tests - #568

Merged
chrisknvidia merged 1 commit into
mainfrom
test/christopherk/deflake-ci-tests
Nov 15, 2026
Merged

chrisknvidia merged 1 commit into
mainfrom
test/christopherk/deflake-ci-tests

Conversation

@chrisknvidia

@chrisknvidia chrisknvidia commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Last week 37 failed CI test jobs were flakes: a sibling job passed on the same commit, or the failure was on main. This PR fixes the tests behind 21 of them. Of the other 16, about half were already fixed on main (#349, #393, #439, #466). The rest are one Windows product timeout, listed below, and four tests that each failed on a single branch and were not investigated.

One fix is in product code. The rest are test-only, and no assertion was removed.

Product fix: the Tier 1 runner could miss a Ctrl-C

test_ctrl_c_ends_running_scans_and_their_tools failed on 4 jobs, one on main. The test was right. run() in ci/run_tier1.py waited for scan events with events.get() and no time limit. On Linux, subprocess.Popen blocks signals in the calling thread while it starts the child. A Ctrl-C that arrives in that window is handled on the scan thread, which does not wake the main thread's wait, so the run carried on until a scan ended.

The main loop now waits with events.get(timeout=POLL_SECONDS) (0.1 s), the same interval the scan threads already poll at. A new test, test_ctrl_c_handled_on_a_scan_thread_still_ends_the_run, sends the interrupt to a scan thread and checks that the run is aborted.

In a Linux container with the xdist workers pinned to one CPU, the Ctrl-C test failed 10 of 512 runs without the fix, with the same message as CI, and 0 of 576 with it.

Test-only fixes

Test file What failed in CI Cause Fix
tests/ci/test_run_tier1.py test_scan_timeout_also_ends_the_scanner_tools, is_alive() The test moved its fake clock before the scan had taken its deadline, so the deadline moved too The test waits for the scan to read the clock first
tests/test_harbor_local_mode.py invalid literal for int(): '' on Linux PID file read between create and write PID is written to a temp name and renamed
tests/test_harbor_local_mode.py DID NOT RAISE ProcessLookupError on macOS, 3 tests Cleanup returns while a SIGKILLed child is still finishing its exit; the test probed once Probe polls for up to 5 s, as #247 did for a sibling test
tests/test_harbor_local_mode.py 0.1 s cleanup bound missed on main Real-time bound on about 0.02 s of timers Bound is measured on a manual-clock event loop
tests/test_nvidia_build_bridge.py Setup error in 2 fixture tests Bridge thread got 1 s to bind and report ready 30 s hang guard that fails at once if the thread died
tests/test_harbor_secure_docker_environment.py 1.0 s bound missed under coverage, 2 tests Coverage tracing slows the pure-Python scan to 1.2 to 1.3 s Past 1.0 s, compare against 10x a one-secret scan of the same text
tests/test_model_catalog.py 0.5 s bound missed, 0.67 s and 0.86 s Runner stall close to the gap between correct (0.15 s) and broken (0.8 s) Body padded so broken takes 10 s; bound is 5 s
tests/tier3/test_judge_failure_artifacts.py RAGAS cleanup test, twice on main on 13 Nov 0.5 s real-time rescue timer fired on a stalled worker The test's event loop runs on a virtual clock

Two more changes are preventive, with no CI failure on record:

  • test_ragas_goal_judge_obeys_the_required_judge_time_budget[deadline_alarm] armed a 10 ms real timer that could fire before the scorer was suspended. The alarm is now raised from the loop's idle wait.
  • Two sidecar tests in tests/test_harbor_secure_docker_environment.py failed on any machine whose shell exports a sensitive-named variable with a short value, such as SOME_SESSION=1. They now clear those variables first. CI never hit this; developer machines do.

Please look at

  • The 0.1 s poll in run(). It is the only product change.
  • The macOS exit probes. They accept that cleanup can return a moment before a killed child's PID leaves the process table, as test: wait for descendant exit after streamed exec cleanup #247 already did. A child that was never signalled still fails the test at 5 s. If you would rather have cleanup keep polling until the PID is gone, the helper and its six call sites can be dropped without touching the other fixes.

Not in this PR

  • Windows: test_bounded_harbor_process_drops_partial_secret_at_output_limit failed once because taskkill /T /F took longer than the product's 5 s wait. That is a product budget, it needs a Windows machine, and it is not changed here.
  • The sidecar Compose check treats a one-character value of a sensitive-named host variable as a secret. With MY_AUTH=1 exported, a task whose own Compose file interpolates a value containing 1 is refused. The tests are isolated from it here; the product behaviour is unchanged.
  • Sibling tests with the same patterns and no CI failure yet were left alone: two redactor heartbeat tests, the header-trickle and DNS deadline tests, and test_exec_timeout_terminates_background_descendants.

Verification

  • I am familiar with the Contributing Guidelines
  • Added or updated focused tests
  • Updated documentation for user-visible changes (none needed)
  • Ran make lint (ruff check and ruff format --check on the changed files)
  • Ran make test
  • Ran make build
  • Did not add credentials, private datasets, or proprietary benchmark content

The six changed test files passed together on macOS, Python 3.12, under -n 4, before the rebase onto current main: 1137 passed.

A re-run after the rebase, on the same machine under much heavier load, gave 1135 passed and 2 timeouts. Both are in tests this PR does not change: test_local_callback_streams_safe_partial_line_before_process_exit and test_streaming_and_buffered_redaction_union_is_deterministic_for_offset_overlaps. The first fails the same way on plain main at that load (2 of 3 runs), and the second passed when run alone.

Each fix was written by one pass and checked by a second, independent one. For every changed test the reviewer broke the behaviour it guards and confirmed the test still fails. Where a CI failure could be reproduced by injecting the stall or the slow exit, the old test failed with the CI message and the new one passed.

Not verified:

  • Nothing ran on a GitHub runner before this PR. Its own CI run is the real check.
  • The full suite was not run locally.
  • The Ctrl-C race was reproduced in a Linux container, not on a hosted x86_64 runner. The other CI failures were reproduced by injection, not naturally.
  • The changed tests ran on Python 3.12 only, apart from the judge tests (3.13 and 3.14 on macOS).
  • No Windows test was run.

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

One entry under Fixed for the Ctrl-C change. The test changes need none.


Devin Review

…dependent tests

The Tier 1 runner waited for scan results with no time limit. On Linux a
Ctrl-C that arrives while a scan is starting can be handled on the scan
thread, which does not wake that wait, so the run went on until a scan
ended. The main loop now polls every 0.1 seconds. A new test sends the
interrupt to a scan thread and checks the run is aborted.

The rest is test-only. Each change removes a race or a wall-clock bound
that a busy runner could miss, without dropping an assertion:

- test_run_tier1: the timeout test moves its fake clock only after the
  scan has read it.
- test_harbor_local_mode: PID files are published with a rename, exit
  probes poll for up to 5 seconds, and one cleanup bound runs on a manual
  clock.
- test_nvidia_build_bridge: the 1 second bridge start wait is now a 30
  second hang guard that fails at once if the server thread died.
- test_harbor_secure_docker_environment, test_model_catalog: time bounds
  that coverage tracing or a stalled runner pushed past their limit.
- test_judge_failure_artifacts: the RAGAS cleanup test runs on a virtual
  clock and the deadline alarm is raised from the loop's idle wait.
- Two sidecar tests no longer depend on sensitive-named variables in the
  shell that runs pytest.

Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
@chrisknvidia
chrisknvidia marked this pull request as ready for review November 15, 2026 05:43

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 potential issue.

Devin Review

Comment thread ci/run_tier1.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant