MCPcopy
hub / github.com/containerd/containerd / testStats

Function testStats

integration/container_stats_test.go:402–430  ·  view source on GitHub ↗

TODO make this as options to use for dead container tests

(t *testing.T,
	s *runtime.ContainerStats,
	config *runtime.ContainerConfig,
)

Source from the content-addressed store, hash-verified

400
401// TODO make this as options to use for dead container tests
402func 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
432func TestContainerSysfsStatsWithPrivilegedPod(t *testing.T) {
433 if goruntime.GOOS == "windows" {

Calls 5

GetMetadataMethod · 0.80
GetValueMethod · 0.80
GetAnnotationsMethod · 0.65
GetLabelsMethod · 0.65
GetTimestampMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…