From 271e4c220b395df250e1576cd366b482a372a48e Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Wed, 16 Jul 2025 19:20:18 +0000 Subject: [PATCH 1/4] fix(agent/agentcontainers): fix `TestAPI/NoUpdaterLoopLogspam` flake --- 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 9451461bb3215..3f47a86011a39 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() + // Wait for the watcher to have initialized. As the + // watcher logs, it can interfere with the test and + // cause a flake. + testutil.RequireReceive(ctx, t, fWatcher.nextCalled) + // Make sure the ticker function has been registered // before advancing the clock. tickerTrap.MustWait(ctx).MustRelease(ctx) From e4152993eac6b73bbaf132b3cf71f97841b05d51 Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Wed, 16 Jul 2025 19:39:40 +0000 Subject: [PATCH 2/4] chore: comment --- agent/agentcontainers/api_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/agentcontainers/api_test.go b/agent/agentcontainers/api_test.go index 3f47a86011a39..4ed4455b218a4 100644 --- a/agent/agentcontainers/api_test.go +++ b/agent/agentcontainers/api_test.go @@ -369,9 +369,9 @@ func TestAPI(t *testing.T) { api.Start() defer api.Close() - // Wait for the watcher to have initialized. As the - // watcher logs, it can interfere with the test and - // cause a flake. + // 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. testutil.RequireReceive(ctx, t, fWatcher.nextCalled) // Make sure the ticker function has been registered From ba49527819799b3852ba6c30d3f95b45d2ac0303 Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Thu, 17 Jul 2025 09:51:56 +0100 Subject: [PATCH 3/4] fix: typo Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- agent/agentcontainers/api_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/agentcontainers/api_test.go b/agent/agentcontainers/api_test.go index 4ed4455b218a4..0760c78d953c7 100644 --- a/agent/agentcontainers/api_test.go +++ b/agent/agentcontainers/api_test.go @@ -371,7 +371,7 @@ func TestAPI(t *testing.T) { // 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. + // the test so that it does not interfere. testutil.RequireReceive(ctx, t, fWatcher.nextCalled) // Make sure the ticker function has been registered From 5bb2756f6f4fa8575bb0225562bfc5a8b757e3d8 Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Thu, 17 Jul 2025 09:48:35 +0000 Subject: [PATCH 4/4] chore: waitNext is more common with the watcher --- agent/agentcontainers/api_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/agentcontainers/api_test.go b/agent/agentcontainers/api_test.go index 0760c78d953c7..eb75d5a62b661 100644 --- a/agent/agentcontainers/api_test.go +++ b/agent/agentcontainers/api_test.go @@ -371,8 +371,8 @@ func TestAPI(t *testing.T) { // 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 interfere. - testutil.RequireReceive(ctx, t, fWatcher.nextCalled) + // the test so that it does not intefere. + fWatcher.waitNext(ctx) // Make sure the ticker function has been registered // before advancing the clock.