MCPcopy Create free account
hub / github.com/tailscale/tailcat / WaitForDERPForTest

Function WaitForDERPForTest

export_test.go:14–32  ·  view source on GitHub ↗

WaitForDERPForTest waits for the server's and client's DERP connections. Integration tests should use this instead of guessing how long startup takes.

(t testing.TB, s *Server, c *Client)

Source from the content-addressed store, hash-verified

12// WaitForDERPForTest waits for the server's and client's DERP connections.
13// Integration tests should use this instead of guessing how long startup takes.
14func WaitForDERPForTest(t testing.TB, s *Server, c *Client) {
15 t.Helper()
16 ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
17 defer cancel()
18 if err := c.ensureStarted(ctx); err != nil {
19 t.Fatalf("starting client: %v", err)
20 }
21
22 for name, lb := range map[string]*locoBackend{"server": s.lb, "client": c.lb} {
23 regionID := lb.derpRegionID()
24 for lb.sys.HealthTracker.Get().GetDERPRegionReceivedTime(regionID).IsZero() {
25 select {
26 case <-ctx.Done():
27 t.Fatalf("waiting for %s DERP connection: %v", name, ctx.Err())
28 case <-time.After(time.Millisecond):
29 }
30 }
31 }
32}
33
34// PingForTest waits for the client's DERP connection and performs the
35// meow/meowed handshake.

Callers 2

PingForTestFunction · 0.85
TestTailcatFunction · 0.85

Calls 3

ensureStartedMethod · 0.80
derpRegionIDMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected