Repository navigation
test(librarymonitor): check the replaced backend without waiting for a report - #1737
Tobechukwu-Njoku wants to merge 1 commit into
Conversation
…a report TestFailedBackendIsReplaced waited for a new status report after the backend closed. When the monitor records the root with the new backend before the status loop wakes, the row is unchanged and nothing is reported, so the test timed out. Wait for the new backend's attempt and read the rows instead. Closes Silo-Server#1736 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Providing Context (Files & MCPs)Add these hints in your PR description (or a comment) to unlock deeper checks:
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe backend replacement test now uses channels to observe backend creation and root registration. It checks monitoring status after attempts complete and verifies that one replacement backend was created and that it added the root once. ChangesBackend replacement test
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Other · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to The test now observes backend replacement directly rather than relying on an optional status report, while retaining its recovery assertions. No actionable merge-blocking risk remains after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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
Closes #1736
Related issue: N/A
Validation tasks: none
TestFailedBackendIsReplacedfails intermittently in the CI Go test job, onmainand on unrelated PRs. After closing the fake backend it waited for a new status report showingmonitoring. The status loop only reports rows that changed, and the monitor often records the root with the new backend before the loop wakes, so the row is the same as the last report and nothing is sent. The monitor behaves correctly; the test was waiting for a report that isn't guaranteed. This changes only the test.Approach
The test now receives each backend the fake constructor creates. After the close, it waits for the second backend to record the root, then reads
statusRowsLockedeach time an attempt finishes until the row ismonitoringagain, as other tests in this file do. It still checks that exactly one new backend was created and that the root was added to it once.Validation
go test -count=1000 -run '^TestFailedBackendIsReplaced$' ./internal/librarymonitor/failed before the change (after 511s, from repeated 10-second timeouts). After it, 2000 runs, 500 under-raceand 1000 with-cpu 1pass.go vetandgolangci-lint run --new-from-merge-base=origin/mainon the package are clean. The whole package passes five times in a row in a Linux container, withTestRemountIsRecordedAgainrun separately in a privileged container because it needs to mount.Risks
None identified. Test-only change.
Checklist
AI Disclosure
Note
Make backend replacement test deterministic in
librarymonitorReworks
TestFailedBackendIsReplacedin monitor_linux_test.go to observe backends and monitoring attempts through buffered channels instead of a mutex-protected collection. The test now waits explicitly for the replacement backend and for one completed attempt before checking status rows, then asserts exactly one replacement backend is created and the library root is added to it once. This removes timing-dependent checks.Macroscope summarized af388ad.