Skip to content

Commit 8466806

Browse files
committed
TestRunCgroupV2: remove --cpu-shares checks
The behavior of CPU shares was changed intentionally in runc v1.4.0-rc.1. See runc PR 4896 Fix 4519 Signed-off-by: Akihiro Suda <[email protected]>
1 parent df8d558 commit 8466806

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

cmd/nerdctl/container/container_run_cgroup_linux_test.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ func TestRunCgroupV2(t *testing.T) {
6161
if !info.SwapLimit {
6262
t.Skip("test requires SwapLimit")
6363
}
64-
if !info.CPUShares {
65-
t.Skip("test requires CPUShares")
66-
}
6764
if !info.CPUSet {
6865
t.Skip("test requires CPUSet")
6966
}
@@ -74,7 +71,6 @@ func TestRunCgroupV2(t *testing.T) {
7471
44040192
7572
44040192
7673
42
77-
77
7874
0-1
7975
0
8076
`
@@ -83,34 +79,32 @@ func TestRunCgroupV2(t *testing.T) {
8379
60817408
8480
6291456
8581
42
86-
77
8782
0-1
8883
0
8984
`
9085

91-
// In CgroupV2 CPUWeight replace CPUShares => weight := 1 + ((shares-2)*9999)/262142
9286
base.Cmd("run", "--rm",
9387
"--cpus", "0.42", "--cpuset-mems", "0",
9488
"--memory", "42m",
9589
"--pids-limit", "42",
96-
"--cpu-shares", "2000", "--cpuset-cpus", "0-1",
90+
"--cpuset-cpus", "0-1",
9791
"-w", "/sys/fs/cgroup", testutil.AlpineImage,
9892
"cat", "cpu.max", "memory.max", "memory.swap.max",
99-
"pids.max", "cpu.weight", "cpuset.cpus", "cpuset.mems").AssertOutExactly(expected1)
93+
"pids.max", "cpuset.cpus", "cpuset.mems").AssertOutExactly(expected1)
10094
base.Cmd("run", "--rm",
10195
"--cpu-quota", "42000", "--cpuset-mems", "0",
10296
"--cpu-period", "100000", "--memory", "42m", "--memory-reservation", "6m", "--memory-swap", "100m",
103-
"--pids-limit", "42", "--cpu-shares", "2000", "--cpuset-cpus", "0-1",
97+
"--pids-limit", "42", "--cpuset-cpus", "0-1",
10498
"-w", "/sys/fs/cgroup", testutil.AlpineImage,
10599
"cat", "cpu.max", "memory.max", "memory.swap.max", "memory.low", "pids.max",
106-
"cpu.weight", "cpuset.cpus", "cpuset.mems").AssertOutExactly(expected2)
100+
"cpuset.cpus", "cpuset.mems").AssertOutExactly(expected2)
107101

108102
base.Cmd("run", "--name", testutil.Identifier(t)+"-testUpdate1", "-w", "/sys/fs/cgroup", "-d",
109103
testutil.AlpineImage, "sleep", nerdtest.Infinity).AssertOK()
110104
defer base.Cmd("rm", "-f", testutil.Identifier(t)+"-testUpdate1").Run()
111105
update := []string{"update", "--cpu-quota", "42000", "--cpuset-mems", "0", "--cpu-period", "100000",
112106
"--memory", "42m",
113-
"--pids-limit", "42", "--cpu-shares", "2000", "--cpuset-cpus", "0-1"}
107+
"--pids-limit", "42", "--cpuset-cpus", "0-1"}
114108
if nerdtest.IsDocker() && info.CgroupVersion == "2" && info.SwapLimit {
115109
// Workaround for Docker with cgroup v2:
116110
// > Error response from daemon: Cannot update container 67c13276a13dd6a091cdfdebb355aa4e1ecb15fbf39c2b5c9abee89053e88fce:
@@ -121,7 +115,7 @@ func TestRunCgroupV2(t *testing.T) {
121115
base.Cmd(update...).AssertOK()
122116
base.Cmd("exec", testutil.Identifier(t)+"-testUpdate1",
123117
"cat", "cpu.max", "memory.max", "memory.swap.max",
124-
"pids.max", "cpu.weight", "cpuset.cpus", "cpuset.mems").AssertOutExactly(expected1)
118+
"pids.max", "cpuset.cpus", "cpuset.mems").AssertOutExactly(expected1)
125119

126120
defer base.Cmd("rm", "-f", testutil.Identifier(t)+"-testUpdate2").Run()
127121
base.Cmd("run", "--name", testutil.Identifier(t)+"-testUpdate2", "-w", "/sys/fs/cgroup", "-d",
@@ -130,11 +124,11 @@ func TestRunCgroupV2(t *testing.T) {
130124

131125
base.Cmd("update", "--cpu-quota", "42000", "--cpuset-mems", "0", "--cpu-period", "100000",
132126
"--memory", "42m", "--memory-reservation", "6m", "--memory-swap", "100m",
133-
"--pids-limit", "42", "--cpu-shares", "2000", "--cpuset-cpus", "0-1",
127+
"--pids-limit", "42", "--cpuset-cpus", "0-1",
134128
testutil.Identifier(t)+"-testUpdate2").AssertOK()
135129
base.Cmd("exec", testutil.Identifier(t)+"-testUpdate2",
136130
"cat", "cpu.max", "memory.max", "memory.swap.max", "memory.low",
137-
"pids.max", "cpu.weight", "cpuset.cpus", "cpuset.mems").AssertOutExactly(expected2)
131+
"pids.max", "cpuset.cpus", "cpuset.mems").AssertOutExactly(expected2)
138132
base.Cmd("run", "--rm", "--security-opt", "writable-cgroups=true", testutil.AlpineImage, "mkdir", "/sys/fs/cgroup/foo").AssertOK()
139133
base.Cmd("run", "--rm", "--security-opt", "writable-cgroups=false", testutil.AlpineImage, "mkdir", "/sys/fs/cgroup/foo").AssertFail()
140134
base.Cmd("run", "--rm", testutil.AlpineImage, "mkdir", "/sys/fs/cgroup/foo").AssertFail()

0 commit comments

Comments
 (0)