Content-Length: 1694 | pFad | http://github.com/coder/coder/pull/18970.patch

thub.com From f204a894274281f29b3595e7778056b3c3826c22 Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Mon, 21 Jul 2025 16:55:02 +0000 Subject: [PATCH] fix: resolve server initialization race condition in TestWorkspaceAgent/GoogleCloud The test was flaky due to a race condition where the agent CLI would start and attempt authentication before the HTTP server's handler was fully initialized. The test server starts immediately but the handler is set asynchronously, creating a window where requests return 404. This fix waits for the server to be ready by making a test request to /api/v2/buildinfo before starting the agent, ensuring the HTTP handler is properly set up. Fixes: https://github.com/coder/internal/issues/778 --- cli/agent_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/agent_test.go b/cli/agent_test.go index 0a948c0c84e9a..4a918cb61761e 100644 --- a/cli/agent_test.go +++ b/cli/agent_test.go @@ -159,6 +159,18 @@ func TestWorkspaceAgent(t *testing.T) { return agents }).Do() + // Wait for the server to be ready to handle requests. + // This prevents a race condition where the agent tries to authenticate + // before the server's HTTP handler is fully set up. + require.Eventually(t, func() bool { + resp, err := client.Request(context.Background(), "GET", "/api/v2/buildinfo", nil) + if err != nil { + return false + } + defer resp.Body.Close() + return resp.StatusCode == http.StatusOK + }, testutil.WaitMedium, testutil.IntervalFast) + inv, cfg := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String()) clitest.SetupConfig(t, member, cfg)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/coder/coder/pull/18970.patch

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy