MCPcopy
hub / github.com/google/cadvisor / waitForContainer

Function waitForContainer

integration/tests/api/docker_test.go:52–67  ·  view source on GitHub ↗

Waits up to 5s for a container with the specified alias to appear.

(alias string, fm framework.Framework)

Source from the content-addressed store, hash-verified

50
51// Waits up to 5s for a container with the specified alias to appear.
52func waitForContainer(alias string, fm framework.Framework) {
53 err := framework.RetryForDuration(func() error {
54 ret, err := fm.Cadvisor().Client().DockerContainer(alias, &info.ContainerInfoRequest{
55 NumStats: 1,
56 })
57 if err != nil {
58 return err
59 }
60 if len(ret.Stats) != 1 {
61 return fmt.Errorf("no stats returned for container %q", alias)
62 }
63
64 return nil
65 }, 5*time.Second)
66 require.NoError(fm.T(), err, "Timed out waiting for container %q to be available in cAdvisor: %v", alias, err)
67}
68
69// A Docker container in /docker/<ID>
70func TestDockerContainerById(t *testing.T) {

Calls 6

RetryForDurationFunction · 0.92
ErrorfMethod · 0.80
DockerContainerMethod · 0.65
ClientMethod · 0.65
CadvisorMethod · 0.65
TMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…