TODO make this as options to use for dead container tests
(t *testing.T, s *runtime.ContainerStats, config *runtime.ContainerConfig, )
| 400 | |
| 401 | // TODO make this as options to use for dead container tests |
| 402 | func testStats(t *testing.T, |
| 403 | s *runtime.ContainerStats, |
| 404 | config *runtime.ContainerConfig, |
| 405 | ) { |
| 406 | require.NotEmpty(t, s.GetAttributes().GetId()) |
| 407 | require.NotEmpty(t, s.GetAttributes().GetMetadata()) |
| 408 | require.NotEmpty(t, s.GetAttributes().GetAnnotations()) |
| 409 | require.Equal(t, config.Labels, s.GetAttributes().GetLabels()) |
| 410 | require.Equal(t, config.Annotations, s.GetAttributes().GetAnnotations()) |
| 411 | require.Equal(t, config.Metadata.Name, s.GetAttributes().GetMetadata().Name) |
| 412 | require.NotEmpty(t, s.GetAttributes().GetLabels()) |
| 413 | require.NotEmpty(t, s.GetCpu().GetTimestamp()) |
| 414 | require.NotEmpty(t, s.GetCpu().GetUsageCoreNanoSeconds().GetValue()) |
| 415 | require.NotEmpty(t, s.GetMemory().GetTimestamp()) |
| 416 | require.NotEmpty(t, s.GetMemory().GetWorkingSetBytes().GetValue()) |
| 417 | require.NotEmpty(t, s.GetWritableLayer().GetTimestamp()) |
| 418 | require.NotEmpty(t, s.GetWritableLayer().GetFsId().GetMountpoint()) |
| 419 | |
| 420 | // UsedBytes of a fresh container can be zero on Linux, depending on the backing filesystem. |
| 421 | // https://github.com/containerd/containerd/issues/7909 |
| 422 | if goruntime.GOOS == "windows" { |
| 423 | require.NotEmpty(t, s.GetWritableLayer().GetUsedBytes().GetValue()) |
| 424 | } |
| 425 | |
| 426 | // Windows does not collect inodes stats. |
| 427 | if goruntime.GOOS != "windows" { |
| 428 | require.NotEmpty(t, s.GetWritableLayer().GetInodesUsed().GetValue()) |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | func TestContainerSysfsStatsWithPrivilegedPod(t *testing.T) { |
| 433 | if goruntime.GOOS == "windows" { |
no test coverage detected
searching dependent graphs…