Skip to content
Snippets Groups Projects
Unverified Commit 5a4251c9 authored by Utku Ozdemir's avatar Utku Ozdemir
Browse files

test: fix a data race in `MachineStatusSnapshotController` unit tests


Fix the flaky test due to the race caused by the test ending before the last log, `task finished`, is written by the task runner.

Signed-off-by: default avatarUtku Ozdemir <utku.ozdemir@siderolabs.com>
parent 09650914
No related branches found
No related tags found
No related merge requests found
......@@ -27,13 +27,17 @@ type MachineStatusSnapshotControllerSuite struct {
}
func (suite *MachineStatusSnapshotControllerSuite) TestReconcile() {
ctx, cancel := context.WithTimeout(suite.ctx, time.Second*5)
defer cancel()
require := suite.Require()
suite.startRuntime()
// wait for the runtime to stop, including all controllers and the tasks they started.
// this is necessary to prevent a data race on the test logger when a task finishes after the test ends.
suite.T().Cleanup(suite.wg.Wait)
ctx, cancel := context.WithTimeout(suite.ctx, time.Second*5)
suite.T().Cleanup(cancel)
siderolinkEventsCh := make(chan *omni.MachineStatusSnapshot)
suite.Require().NoError(suite.runtime.RegisterQController(omnictrl.NewMachineStatusSnapshotController(siderolinkEventsCh)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment