Fix race in TestPodWatcher on Windows: listen before Create

What does this MR do?

TestPodWatcher was flaky on Windows because waitForError was called after Create. The error sent on the unbuffered channel could arrive before the test was listening, causing it to be dropped and waitForError to return nil.

Fixed by starting a goroutine that calls waitForError before Create, ensuring the channel always has a receiver when the error is sent.

Why was this MR needed?

windows 21H2 unit tests was failing intermittently with TestPodWatcher subtests returning nil instead of the expected error.

What's the best way to test this MR?

The Windows unit test jobs should now pass consistently. Locally, the race can be reproduced by adding a time.Sleep(5 * time.Millisecond) after Create and before waitForError — all error-expecting subtests fail with not consumed in time without the fix, and all pass with it.

What are the relevant issue numbers?

Edited by Ashvin Sharma

Merge request reports

Loading