Repository navigation
test: fix four flaky tests that keep CI failing - #1819
Conversation
- librarymonitor: TestFailedBackendIsReplaced waited for a status report the status loop may skip, since a fast backend swap leaves the rows unchanged. Wait for the re-attach attempt and read the rows instead. - librarymonitor: block the walk before the monitor starts in TestStalledWalkStopsHoldingOthersBack and TestRemovingARootCancelsItsWalk, so the walk cannot finish first. - adminjob: a slow progress write can push the second prefix's first stall into its own claim; stall it one fewer time so the count stays below the limit either way. - web: fake setTimeout in ItemGrid.scroll.test.tsx so the virtualizer's scroll-reset timer cannot fire after the DOM is torn down. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Related issue: N/A
Validation tasks: none
CI on
mainhas failed on every push today, so no Docker image has been published since. Four tests fail intermittently on both GitHub-hosted and self-hosted runners, and PRs pick up the same failures without touching the code involved. This change fixes the races in the tests. No product code changes.librarymonitorTestFailedBackendIsReplacedwaited for a new status report after the backend was replaced. The status loop only reports rows that changed, and a replacement fast enough to skip the intermediate "starting" state leaves the rows exactly as they were, so no report comes and the test times out after 10s. WithGOMAXPROCS=1it failed on every run.librarymonitorTestStalledWalkStopsHoldingOthersBackblocked the walk after the monitor had already started, so the walk could finish first and the hung library reportedmonitoring.TestRemovingARootCancelsItsWalkhas the same setup.adminjobTestImageCacheCleanupProgressResetsStalledClaimsdepends on prefix 1's first stall sharing a claim with prefix 0's success. On a loaded runner the progress write can run past the 150ms slice,Executestops before prefix 1, and the job records 12 stalled claims instead of 11.ItemGrid.scroll.test.tsxpasses every assertion, but each scroll arms the virtualizer's 150ms is-scrolling reset timer, and unmounting does not clear it. When the file finishes first, the timer fires against a torn-down DOM and vitest fails the run on the unhandledReferenceError: window is not defined.This supersedes #1737 by @Tobechukwu-Njoku, which fixes
TestFailedBackendIsReplacedthe same way. This PR carries that fix along with the other three somainturns green in one merge.Approach
TestFailedBackendIsReplacedwaits on theafterAttempthook until the root is recorded again, then reads the rows directly, as other tests in the file already do.TestWalksRunOneAtATimeInSortOrder.mosttimes instead ofmost+1. Neither prefix can reach the limit alone however the claims line up, but the two together still exceed it, so the test still fails if progress stops resetting the count.setTimeout/clearTimeoutand clears pending timers after unmount.Validation
librarymonitorunder-raceon Linux: the whole package passes; the changed tests pass 150 runs each at-cpu1, 2 and 8. The originalTestFailedBackendIsReplacedfailed 59 of 59 runs at-cpu=1.adminjobimage cache cleanup tests against a fresh pgvector PG18 database: pass, and the changed test passes 30 runs at-cpu1 and 4 under-race.ItemGrid.scroll.test.tsx: passes 5 runs; a check during the fix confirmed one pending virtualizer timer per test is now captured and discarded.Risks
None identified. Test-only change.
Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Fix flaky image cache, library monitor, and ItemGrid scroll tests
TestImageCacheCleanupProgressResetsStalledClaimsby making the second stalled range end at twice the max stalled-claim count, so neither prefix alone hits the failure threshold in image_cache_cleanup_runner_test.goMacroscope summarized 2f0cd5f.