TestContainerdContainerLabels tests that container labels are correctly captured.
(t *testing.T)
| 280 | |
| 281 | // TestContainerdContainerLabels tests that container labels are correctly captured. |
| 282 | func 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. |
| 313 | func TestContainerdContainerCreationTime(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…