Skip to content

Commit 3083bd4

Browse files
kolyshkinlifubang
authored andcommitted
tests/cgroups: separate cgroup v2 swap test
There are cgroup v2 systems out there that do not have cgroup swap enabled, and this test will probably fail in there. Move it to a separate case, guarded with requires cgroups_swap. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 4209439 commit 3083bd4

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

tests/integration/cgroups.bats

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ convert_hugetlb_size() {
272272
"memory.low": "524288",
273273
"memory.high": "5242880",
274274
"memory.max": "20484096",
275-
"memory.swap.max": "20971520",
276275
"pids.max": "99",
277276
"cpu.max": "10000 100000",
278277
"cpu.weight": "42"
@@ -289,20 +288,41 @@ convert_hugetlb_size() {
289288
echo "$output" | grep -q '^memory.low:524288$'
290289
echo "$output" | grep -q '^memory.high:5242880$'
291290
echo "$output" | grep -q '^memory.max:20484096$'
292-
echo "$output" | grep -q '^memory.swap.max:20971520$'
293291
echo "$output" | grep -q '^pids.max:99$'
294292
echo "$output" | grep -q '^cpu.max:10000 100000$'
295293

296294
check_systemd_value "MemoryMin" 131072
297295
check_systemd_value "MemoryLow" 524288
298296
check_systemd_value "MemoryHigh" 5242880
299297
check_systemd_value "MemoryMax" 20484096
300-
check_systemd_value "MemorySwapMax" 20971520
301298
check_systemd_value "TasksMax" 99
302299
check_cpu_quota 10000 100000 "100ms"
303300
check_cpu_weight 42
304301
}
305302

303+
@test "runc run (cgroup v2 resources.unified swap)" {
304+
requires root cgroups_v2 cgroups_swap
305+
306+
set_cgroups_path
307+
update_config ' .linux.resources.unified |= {
308+
"memory.max": "20484096",
309+
"memory.swap.max": "20971520"
310+
}'
311+
312+
runc run -d --console-socket "$CONSOLE_SOCKET" test_cgroups_unified
313+
[ "$status" -eq 0 ]
314+
315+
runc exec test_cgroups_unified sh -c 'cd /sys/fs/cgroup && grep . *.max'
316+
[ "$status" -eq 0 ]
317+
echo "$output"
318+
319+
echo "$output" | grep -q '^memory.max:20484096$'
320+
echo "$output" | grep -q '^memory.swap.max:20971520$'
321+
322+
check_systemd_value "MemoryMax" 20484096
323+
check_systemd_value "MemorySwapMax" 20971520
324+
}
325+
306326
@test "runc run (cgroup v2 resources.unified override)" {
307327
requires root cgroups_v2
308328

0 commit comments

Comments
 (0)