MCPcopy Index your code
hub / github.com/coder/coder / waitForServerAvailable

Function waitForServerAvailable

tailnet/test/integration/integration_test.go:334–360  ·  view source on GitHub ↗
(t *testing.T, serverURL *url.URL)

Source from the content-addressed store, hash-verified

332}
333
334func waitForServerAvailable(t *testing.T, serverURL *url.URL) {
335 const delay = 100 * time.Millisecond
336 const reqTimeout = 2 * time.Second
337 const timeout = 30 * time.Second
338 client := http.Client{
339 Timeout: reqTimeout,
340 }
341
342 u, err := url.Parse(serverURL.String() + "/derp/latency-check")
343 require.NoError(t, err)
344 for start := time.Now(); time.Since(start) < timeout; time.Sleep(delay) {
345 //nolint:noctx
346 resp, err := client.Get(u.String())
347 if err != nil {
348 t.Logf("waiting for server to be available: %v", err)
349 continue
350 }
351 _ = resp.Body.Close()
352 if resp.StatusCode != http.StatusOK {
353 t.Logf("waiting for server to be available: got status %d", resp.StatusCode)
354 continue
355 }
356 return
357 }
358
359 t.Fatalf("server did not become available after %v", timeout)
360}
361
362func startServerSubprocess(t *testing.T, topologyName string, networking integration.TestNetworking) func() error {
363 _, closeFn := startSubprocess(t, "server", networking.Server.Process.NetNS, []string{

Callers 1

handleTestSubprocessFunction · 0.85

Calls 6

ParseMethod · 0.65
GetMethod · 0.65
LogfMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45
FatalfMethod · 0.45

Tested by

no test coverage detected