MCPcopy Create free account
hub / github.com/containerd/cgroups / TestCgroupv2MemoryStats

Function TestCgroupv2MemoryStats

cgroup2/memoryv2_test.go:28–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestCgroupv2MemoryStats(t *testing.T) {
29 checkCgroupMode(t)
30 group := "/memory-test-cg"
31 groupPath := fmt.Sprintf("%s-%d", group, os.Getpid())
32 res := Resources{
33 Memory: &Memory{
34 Max: pointerInt64(629145600),
35 Swap: pointerInt64(314572800),
36 High: pointerInt64(524288000),
37 },
38 }
39 c, err := NewManager(defaultCgroup2Path, groupPath, &res)
40 require.NoError(t, err, "failed to init new cgroup manager")
41 t.Cleanup(func() {
42 os.Remove(c.path)
43 })
44
45 stats, err := c.Stat()
46 require.NoError(t, err, "failed to get cgroup stats")
47
48 assert.Equal(t, uint64(314572800), stats.Memory.SwapLimit)
49 assert.Equal(t, uint64(629145600), stats.Memory.UsageLimit)
50 checkFileContent(t, c.path, "memory.swap.max", "314572800")
51 checkFileContent(t, c.path, "memory.max", "629145600")
52}
53
54func TestSystemdCgroupMemoryController(t *testing.T) {
55 checkCgroupMode(t)

Callers

nothing calls this directly

Calls 5

StatMethod · 0.95
checkCgroupModeFunction · 0.85
pointerInt64Function · 0.85
NewManagerFunction · 0.85
checkFileContentFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…