@@ -35,11 +35,14 @@ func TestCgroupv2CpuStats(t *testing.T) {
3535 quota int64 = 10000
3636 period uint64 = 8000
3737 weight uint64 = 100
38+ // The burst in the range [0, $quota].
39+ burst uint64 = 1000
3840 )
3941 max := "10000 8000"
4042 res := Resources {
4143 CPU : & CPU {
4244 Weight : & weight ,
45+ Burst : & burst ,
4346 Max : NewCPUMax (& quota , & period ),
4447 Cpus : "0" ,
4548 Mems : "0" ,
@@ -53,10 +56,33 @@ func TestCgroupv2CpuStats(t *testing.T) {
5356
5457 checkFileContent (t , c .path , "cpu.weight" , strconv .FormatUint (weight , 10 ))
5558 checkFileContent (t , c .path , "cpu.max" , max )
59+ checkFileContent (t , c .path , "cpu.max.burst" , strconv .FormatUint (burst , 10 ))
5660 checkFileContent (t , c .path , "cpuset.cpus" , "0" )
5761 checkFileContent (t , c .path , "cpuset.mems" , "0" )
5862}
5963
64+ func TestCgroupv2CpuIdle (t * testing.T ) {
65+ checkCgroupMode (t )
66+ group := "/cpu-test-cg-idle"
67+ groupPath := fmt .Sprintf ("%s-%d" , group , os .Getpid ())
68+ var (
69+ idle uint64 = 1
70+ )
71+ res := Resources {
72+ CPU : & CPU {
73+ Idle : & idle ,
74+ },
75+ }
76+ c , err := NewManager (defaultCgroup2Path , groupPath , & res )
77+ require .NoError (t , err , "failed to init new cgroup manager" )
78+ t .Cleanup (func () {
79+ os .Remove (c .path )
80+ })
81+
82+ checkFileContent (t , c .path , "cpu.weight" , "0" )
83+ checkFileContent (t , c .path , "cpu.idle" , "1" )
84+ }
85+
6086func TestSystemdCgroupCpuController (t * testing.T ) {
6187 checkCgroupMode (t )
6288 group := fmt .Sprintf ("testing-cpu-%d.scope" , os .Getpid ())
0 commit comments