From fb00cd2c1a4fbe19ff1b926f4d4ad0a0a1d44ba7 Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Thu, 17 Jul 2025 10:59:02 +0100 Subject: [PATCH] fix(agent/agentcontainers): fix `TestAPI/NoUpdaterLoopLogspam` flake (#18905) --- agent/agentcontainers/api_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/agent/agentcontainers/api_test.go b/agent/agentcontainers/api_test.go index 9451461bb3..eb75d5a62b 100644 --- a/agent/agentcontainers/api_test.go +++ b/agent/agentcontainers/api_test.go @@ -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)