Skip to content

Commit fb00cd2

Browse files
fix(agent/agentcontainers): fix TestAPI/NoUpdaterLoopLogspam flake (#18905)
1 parent aae5fc2 commit fb00cd2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

agent/agentcontainers/api_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,22 @@ func TestAPI(t *testing.T) {
358358
fakeCLI = &fakeContainerCLI{
359359
listErr: firstErr,
360360
}
361+
fWatcher = newFakeWatcher(t)
361362
)
362363

363364
api := agentcontainers.NewAPI(logger,
365+
agentcontainers.WithWatcher(fWatcher),
364366
agentcontainers.WithClock(mClock),
365367
agentcontainers.WithContainerCLI(fakeCLI),
366368
)
367369
api.Start()
368370
defer api.Close()
369371

372+
// The watcherLoop writes a log when it is initialized.
373+
// We want to ensure this has happened before we start
374+
// the test so that it does not intefere.
375+
fWatcher.waitNext(ctx)
376+
370377
// Make sure the ticker function has been registered
371378
// before advancing the clock.
372379
tickerTrap.MustWait(ctx).MustRelease(ctx)

0 commit comments

Comments
 (0)