Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Fleet Manager metrics reporting loop to be testable and adds a new sync test to validate reporting behavior across interval/enablement changes.
Changes:
- Extracted the Fleet Manager reporting goroutine body into
runFleetManagerReportLoopfor direct invocation in tests. - Added a
testing/synctest-based unit test to simulate time passing and verify enable/disable and interval changes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rest/fleet_manager_reporter.go | Extracts the ticker-based reporting loop into a helper function and launches it as a goroutine. |
| rest/fleet_manager_reporter_test.go | Adds a sync test that simulates ticker intervals and verifies reporting behavior and interval reset handling. |
Comment on lines
+261
to
+263
| time.Sleep(2 * time.Hour) | ||
| synctest.Wait() // wait for report goroutine to block again after another report interval | ||
| require.Equal(t, 3, reportCount()) // should only report once (on the next 1 hour tick, then tick resets to 2 hours so no 4th report on second hour) |
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.
CBG-5596
Use new synctest for mocking time to pass intervals. Requires a bit of a refactor as you cannot yet use sync test on real network I/O. It can can only have in-bubble clocking channels (channels, mutexes or timers). The fake timer will never advance on goroutine using httptest.Server for example as its making calls to OS kernal which is outside the bubble.
Pre-review checklist
fmt.Print,log.Print, ...)base.UD(docID),base.MD(dbName))docs/apiDependencies (if applicable)
Integration Tests