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

Function TestBasicDockerContainer

integration/tests/api/docker_test.go:149–176  ·  view source on GitHub ↗

Check expected properties of a Docker container.

(t *testing.T)

Source from the content-addressed store, hash-verified

147
148// Check expected properties of a Docker container.
149func TestBasicDockerContainer(t *testing.T) {
150 fm := framework.New(t)
151 defer fm.Cleanup()
152
153 containerName := fmt.Sprintf("test-basic-docker-container-%d", os.Getpid())
154 containerID := fm.Docker().Run(framework.DockerRunArgs{
155 Image: "registry.k8s.io/pause",
156 Args: []string{
157 "--name", containerName,
158 },
159 })
160
161 // Wait for the container to show up.
162 waitForContainer(containerID, fm)
163
164 request := &info.ContainerInfoRequest{
165 NumStats: 1,
166 }
167 containerInfo, err := fm.Cadvisor().Client().DockerContainer(containerID, request)
168 require.NoError(t, err)
169
170 // Check that the container is known by both its name and ID.
171 sanityCheck(containerID, containerInfo, t)
172 sanityCheck(containerName, containerInfo, t)
173
174 assert.Empty(t, containerInfo.Subcontainers, "Should not have subcontainers")
175 assert.Len(t, containerInfo.Stats, 1, "Should have exactly one stat")
176}
177
178// TODO(vmarmol): Handle if CPU or memory is not isolated on this system.
179// Check the ContainerSpec.

Callers

nothing calls this directly

Calls 10

NewFunction · 0.92
waitForContainerFunction · 0.85
sanityCheckFunction · 0.70
CleanupMethod · 0.65
RunMethod · 0.65
DockerMethod · 0.65
DockerContainerMethod · 0.65
ClientMethod · 0.65
CadvisorMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…