Fix two flaky Windows unit tests in jobsupervisor#440
Draft
neddp wants to merge 1 commit into
Draft
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
2633b35 to
1343eca
Compare
Windows Job Supervisor (AfterEach/AfterSuite): After Stop()+RemoveAllJobs(), the Windows SCM marks services deleted but the underlying WinSW/pipe.exe process may still hold file handles on job-service-wrapper.exe and its log files briefly. With multiple services and flapping restart cycles on a busy CI runner, this can exceed 60 seconds. Increase the Eventually timeout to 2 minutes with a 1s poll interval, and apply the same pattern to logDir (AfterEach) and TempDir (AfterSuite) which previously used a hard Expect. Monit Job Supervisor (StopAndWait timer test): The test used a racy Eventually(WatcherCount)+Increment pattern. Between the Eventually seeing count=2 and Increment running, the goroutine could transition through checkServices() (where count drops to 1), causing Increment to miss the stop-loop Sleep watcher and leave the goroutine blocked on a fake timer that would never fire. Replace both pairs with advanceTime(), which atomically waits for the required watcher count before incrementing.
1343eca to
5b0beed
Compare
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
Two independent flaky tests in the Windows
test-unitCI job.1. Windows Job Supervisor — file handle race in test cleanup
After
Stop()+RemoveAllJobs(), the Windows SCM marks services as deleted but the underlying WinSW/pipe.exe process may still hold file handles onjob-service-wrapper.exeand its log files briefly.logDir(inAfterEach) andTempDir(inAfterSuite) used hardExpectcalls that failed immediately onAccess is denied/file is being used by another process. Wrap them inEventually(..., 60s)to match the existingjobDirpattern.Symptoms:
2. Monit Job Supervisor — fake clock race in
StopAndWaittimer testThe test
uses the same timer for waiting for pending and waiting for services to stopused a racyEventually(WatcherCount) + Incrementpattern. Between theEventuallyseeingcount=2andIncrementrunning, the goroutine could transition throughcheckServices()(where count drops to 1), causingIncrementto miss the stop-loopSleepwatcher and leave the goroutine blocked on a fake timer that would never fire. Replace both pairs withadvanceTime(), which atomically waits for the required watcher count before incrementing.Symptoms: