...
1
16
17 package v2
18
19 import (
20 "fmt"
21 "os"
22 "testing"
23
24 "github.com/stretchr/testify/assert"
25 )
26
27 func TestCgroupv2HugetlbStats(t *testing.T) {
28 checkCgroupControllerSupported(t, "hugetlb")
29 checkCgroupMode(t)
30 group := "/hugetlb-test-cg"
31 groupPath := fmt.Sprintf("%s-%d", group, os.Getpid())
32 hugeTlb := HugeTlb{HugeTlbEntry{HugePageSize: "2MB", Limit: 1073741824}}
33 res := Resources{
34 HugeTlb: &hugeTlb,
35 }
36 c, err := NewManager(defaultCgroup2Path, groupPath, &res)
37 if err != nil {
38 t.Fatal("failed to init new cgroup manager: ", err)
39 }
40 defer os.Remove(c.path)
41 stats, err := c.Stat()
42 if err != nil {
43 t.Fatal("failed to get cgroups stats: ", err)
44 }
45 for _, entry := range stats.Hugetlb {
46 if entry.Pagesize == "2MB" {
47 assert.Equal(t, uint64(1073741824), entry.Max)
48 break
49 }
50 }
51
52 }
53
View as plain text