Repository navigation
test(cloudxr): fix flaky cmdline-read race in test_background.py - #1209
Merged
Merged
Conversation
test_recognises_a_service_under_any_shipped_module_name intermittently failed with "assert None == <pid>" - background.read_pid() reads /proc/<pid>/cmdline right after Popen() returns, but on a loaded CI runner (e.g. parallel ctest matrix jobs) the child's /proc entry isn't always populated by then. Poll briefly instead of asserting on the first read. Confirmed pre-existing on main (reproduced the same way on commit 6960d4a, unrelated to any in-flight PR); ran the fixed test 5x with no failures. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Gareth Morgan <gmorgan@nvidia.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughThe service-recognition test now polls Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~5 minutes Merge Risk: ⚪ Minimal · up to No merge-blocking risk is identified in the described test-only change. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
gareth-morgan-nv
requested review from
AndreusNvidius,
jiwenc-nv and
sgrizan-nv
October 7, 2026 21:44
sgrizan-nv
approved these changes
Oct 7, 2026
gareth-morgan-nv
enabled auto-merge (squash)
October 7, 2026 22:00
6 tasks done
nv-jakob
added a commit
that referenced
this pull request
Oct 23, 2026
test_sigterm_and_clears_the_pid_file intermittently failed with "assert False is True" from terminate(). Its stand-in for the service, `python -m time run 30`, never slept: a builtin module has no code object, so the child exited within milliseconds. The test passed only if terminate() read /proc/<pid>/cmdline before then; a short stall on a loaded CI runner found a zombie with an empty cmdline instead, so read_pid() returned None. Unrelated to the CloudXR runtime, which this code path never loads. Add a stand_in_service fixture that runs a module sleeping for its last argument, and use it in the three tests that relied on `-m time`. Move the cmdline poll from #1209 into _poll_read_pid() and wait on it before terminate(), since a fresh child's cmdline can still be empty when Popen() returns. Record both pitfalls in tests/AGENTS.md. Reproduced by stalling 50 ms after spawn(): the old test fails as on CI, the new one passes. Signed-off-by: Jakob Bornecrantz <tbornecrantz@nvidia.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an intermittent CI failure in
test_recognises_a_service_under_any_shipped_module_name, which fails withAssertionError: assert None == <pid>roughly 1 in 10 runs.What changed
background.read_pid()reads/proc/<pid>/cmdlineimmediately aftersubprocess.Popen()returns, but on a loaded runner the child's/procentry isn't guaranteed to be populated that instantly.read_pid()for up to 2 seconds instead of asserting on the very first read.Validation
main(commit6960d4a59) and on test(cloudxr): reusable fake-adb mock (FakeAdb/mock_adb) #1147 (which doesn't touchbackground.pyat all).isaaccapture.cloudxr.serviceand legacyisaacteleop.cloudxr.serviceparametrizations roughly evenly — confirms it's a genuine timing race, not specific to either module string.ruff check/ruff format --checkclean.pre-commit run(matching CI'sSKIP=check-copyright-yearhook set) clean.Known limitations / follow-ups
None — this is a minimal, targeted fix to the test's own timing assumption;
background.py's production logic is untouched.Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Summary by CodeRabbit