MCPcopy Create free account
hub / github.com/cortexproject/cortex / WaitForRunning

Method WaitForRunning

integration/e2e/service.go:272–305  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

270}
271
272func (s *ConcreteService) WaitForRunning() (err error) {
273 if !s.isExpectedRunning() {
274 return fmt.Errorf("service %s is stopped", s.Name())
275 }
276
277 for s.retryBackoff.Reset(); s.retryBackoff.Ongoing(); {
278 // Enforce a timeout on the command execution because we've seen some flaky tests
279 // stuck here.
280
281 var out []byte
282 out, err = RunCommandWithTimeoutAndGetOutput(5*time.Second, "docker", "inspect", "--format={{json .State.Running}}", s.containerName())
283 if err != nil {
284 s.retryBackoff.Wait()
285 continue
286 }
287
288 if out == nil {
289 err = fmt.Errorf("nil output")
290 s.retryBackoff.Wait()
291 continue
292 }
293
294 str := strings.TrimSpace(string(out))
295 if str != "true" {
296 err = fmt.Errorf("unexpected output: %q", str)
297 s.retryBackoff.Wait()
298 continue
299 }
300
301 return nil
302 }
303
304 return fmt.Errorf("docker container %s failed to start: %v", s.name, err)
305}
306
307func (s *ConcreteService) WaitReady() (err error) {
308 if !s.isExpectedRunning() {

Callers 2

StartMethod · 0.95

Calls 7

isExpectedRunningMethod · 0.95
NameMethod · 0.95
containerNameMethod · 0.95
OngoingMethod · 0.80
ResetMethod · 0.45
WaitMethod · 0.45