Content-Length: 882 | pFad | http://github.com/coder/coder/pull/18970.diff
thub.com 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)Fetched URL: http://github.com/coder/coder/pull/18970.diff
Alternative Proxies: