netann: make ChanStatusManager tests deterministic#10623
netann: make ChanStatusManager tests deterministic#10623erickcestari wants to merge 2 commits intolightningnetwork:masterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the reliability and determinism of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the ChanStatusManager to use injectable clock and ticker interfaces, which is a great step towards making the tests fully deterministic and eliminating flakiness. The changes in chan_status_manager.go are well-implemented for dependency injection. The test file chan_status_manager_test.go is updated to use a test clock and ticker, with new helper functions to control time.
However, I've found that the new test implementation in chan_status_manager_test.go still contains sources of non-determinism by using time.Sleep and time.After. This goes against the primary goal of the PR. My review comments focus on these areas with suggestions for improvement to achieve fully deterministic tests.
e3e2b5e to
02beffb
Compare
02beffb to
4b371b3
Compare
|
@erickcestari I think you introduced a race look at the CI test for more infos. |
Replace wall-clock timing with injectable clock and ticker interfaces to eliminate flaky failures under CPU contention. - Add Clock and StatusSampleTicker fields to ChanStatusConfig - Replace time.NewTicker with ticker.Ticker interface - Replace time.Now() calls with injected clock - Replace time.Sleep and safeDisableTimeout with explicit tick/advanceTime/triggerDisable helpers - assertNoUpdates/assertUpdates no longer accept duration parameters - Add dedicated no-op Sync method to the manager's event loop for side-effect-free test synchronization, replacing the prior approach of using RequestAuto which could silently mutate ManuallyDisabled channel state - Add timeout guards on Force channel send and update channel receive to prevent indefinite hangs - Reorder Stop() to call ticker.Stop() after the goroutine exits, eliminating a theoretical data race and fixing a pre-existing ticker resource leak - Use time.Hour for Force ticker interval to prevent phantom real-time ticks during tests
dd11c6a to
0d9ffe6
Compare
I believe those were other non-deterministic tests. |
|
@ziggie1984: review reminder |
Replace wall-clock timing with injectable clock and ticker interfaces to eliminate flaky failures under CPU contention.
Before:
after: