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)
| 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. |
| 14 | func 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. |
no test coverage detected