| 112 | } |
| 113 | |
| 114 | func waitForServerToStart(s *service.LivekitServer) { |
| 115 | // wait till ready |
| 116 | ctx, cancel := context.WithTimeout(context.Background(), testutils.ConnectTimeout) |
| 117 | defer cancel() |
| 118 | for { |
| 119 | select { |
| 120 | case <-ctx.Done(): |
| 121 | panic("could not start server after timeout") |
| 122 | case <-time.After(10 * time.Millisecond): |
| 123 | if s.IsRunning() { |
| 124 | // ensure we can connect to it |
| 125 | res, err := http.Get(fmt.Sprintf("http://localhost:%d", s.HTTPPort())) |
| 126 | if err == nil && res.StatusCode == http.StatusOK { |
| 127 | return |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | func waitUntilConnected(t *testing.T, clients ...*testclient.RTCClient) { |
| 135 | logger.Infow("waiting for clients to become connected") |