fix(agent/agentcontainers): fix TestAPI/NoUpdaterLoopLogspam flake (#18905)

This commit is contained in:
Danielle Maywood
2025-07-17 10:59:02 +01:00
committed by GitHub
parent aae5fc243a
commit fb00cd2c1a
+7
View File
@@ -358,15 +358,22 @@ func TestAPI(t *testing.T) {
fakeCLI = &fakeContainerCLI{
listErr: firstErr,
}
fWatcher = newFakeWatcher(t)
)
api := agentcontainers.NewAPI(logger,
agentcontainers.WithWatcher(fWatcher),
agentcontainers.WithClock(mClock),
agentcontainers.WithContainerCLI(fakeCLI),
)
api.Start()
defer api.Close()
// The watcherLoop writes a log when it is initialized.
// We want to ensure this has happened before we start
// the test so that it does not intefere.
fWatcher.waitNext(ctx)
// Make sure the ticker function has been registered
// before advancing the clock.
tickerTrap.MustWait(ctx).MustRelease(ctx)