From d167a977efd351c03ce581d8723dee4846cdbd80 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Sat, 7 Feb 2026 11:37:54 -0600 Subject: [PATCH] test: fix race condition in TestAPI/Delete/OK_with_container_and_subagent (#21982) Closes https://github.com/coder/internal/issues/1345#event-22592902899 --- agent/agentcontainers/api_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/agent/agentcontainers/api_test.go b/agent/agentcontainers/api_test.go index faf91d06ae..777f8c78c2 100644 --- a/agent/agentcontainers/api_test.go +++ b/agent/agentcontainers/api_test.go @@ -1477,14 +1477,6 @@ func TestAPI(t *testing.T) { ) } - api := agentcontainers.NewAPI(logger, apiOpts...) - - api.Start() - defer api.Close() - - r := chi.NewRouter() - r.Mount("/", api.Routes()) - var ( agentRunningCh chan struct{} stopAgentCh chan struct{} @@ -1501,6 +1493,14 @@ func TestAPI(t *testing.T) { } } + api := agentcontainers.NewAPI(logger, apiOpts...) + + api.Start() + defer api.Close() + + r := chi.NewRouter() + r.Mount("/", api.Routes()) + tickerTrap.MustWait(ctx).MustRelease(ctx) tickerTrap.Close()