(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func 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 | |
| 54 | func TestSystemdCgroupMemoryController(t *testing.T) { |
| 55 | checkCgroupMode(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…