MCPcopy Create free account
hub / github.com/efficientgo/e2e / waitForRunning

Method waitForRunning

env_docker.go:568–612  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

566}
567
568func (d *dockerRunnable) waitForRunning() (err error) {
569 if !d.IsRunning() {
570 return errors.Newf("service %s is stopped", d.Name())
571 }
572
573 var out []byte
574 for d.waitBackoffReady.Reset(); d.waitBackoffReady.Ongoing(); {
575 // Enforce a timeout on the command execution because we've seen some flaky tests
576 // stuck here.
577
578 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
579 defer cancel()
580 out, err = d.env.execContext(
581 ctx,
582 "docker",
583 "inspect",
584 "--format={{json .State.Running}}",
585 d.containerName(),
586 ).CombinedOutput()
587 if err != nil {
588 d.waitBackoffReady.Wait()
589 continue
590 }
591
592 if out == nil {
593 err = errors.Newf("nil output")
594 d.waitBackoffReady.Wait()
595 continue
596 }
597
598 str := strings.TrimSpace(string(out))
599 if str != "true" {
600 err = errors.Newf("unexpected output: %q", str)
601 d.waitBackoffReady.Wait()
602 continue
603 }
604
605 return nil
606 }
607
608 if len(out) > 0 {
609 d.logger.Log(string(out))
610 }
611 return errors.Wrapf(err, "docker container %s failed to start", d.Name())
612}
613
614func (d *dockerRunnable) prePullImage(ctx context.Context) (err error) {
615 if d.IsRunning() {

Callers 1

StartMethod · 0.95

Calls 5

IsRunningMethod · 0.95
NameMethod · 0.95
containerNameMethod · 0.95
execContextMethod · 0.80
LogMethod · 0.65

Tested by

no test coverage detected