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

Function TestContainerdContainerLabels

integration/tests/api/containerd_test.go:282–310  ·  view source on GitHub ↗

TestContainerdContainerLabels tests that container labels are correctly captured.

(t *testing.T)

Source from the content-addressed store, hash-verified

280
281// TestContainerdContainerLabels tests that container labels are correctly captured.
282func TestContainerdContainerLabels(t *testing.T) {
283 fm := framework.New(t)
284 defer fm.Cleanup()
285
286 // Use auto-generated 64-char hex ID (required by cAdvisor's containerd handler)
287 containerID := fm.Containerd().Run(framework.ContainerdRunArgs{
288 Image: "registry.k8s.io/pause:3.9",
289 Labels: map[string]string{
290 "test.label.key": "test-value",
291 },
292 })
293
294 // Wait for the container to show up
295 waitForContainerdContainer(containerID, fm)
296
297 // Query all containers via SubcontainersInfo
298 allInfo, err := fm.Cadvisor().Client().SubcontainersInfo("/", &info.ContainerInfoRequest{
299 NumStats: 1,
300 })
301 require.NoError(t, err)
302
303 // Find our container
304 containerInfo := findContainerdContainer(containerID, allInfo)
305 require.NotNil(t, containerInfo, "Container %q should be found", containerID)
306
307 // Check that labels are captured
308 assert.Contains(t, containerInfo.Spec.Labels, "test.label.key", "Labels should contain test.label.key")
309 assert.Equal(t, "test-value", containerInfo.Spec.Labels["test.label.key"], "Label value should match")
310}
311
312// TestContainerdContainerCreationTime tests that container creation time is valid.
313func TestContainerdContainerCreationTime(t *testing.T) {

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
findContainerdContainerFunction · 0.85
CleanupMethod · 0.65
RunMethod · 0.65
ContainerdMethod · 0.65
SubcontainersInfoMethod · 0.65
ClientMethod · 0.65
CadvisorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…