Skip to content

Commit

Permalink
tests/cgroups: separate cgroup v2 swap test
Browse files Browse the repository at this point in the history
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 <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Mar 26, 2024
1 parent 6b2d7fb commit 829ab48
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tests/integration/cgroups.bats
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ convert_hugetlb_size() {
"memory.low": "524288",
"memory.high": "5242880",
"memory.max": "20484096",
"memory.swap.max": "20971520",
"pids.max": "99",
"cpu.max": "10000 100000",
"cpu.weight": "42"
Expand All @@ -289,20 +288,41 @@ convert_hugetlb_size() {
echo "$output" | grep -q '^memory.low:524288$'
echo "$output" | grep -q '^memory.high:5242880$'
echo "$output" | grep -q '^memory.max:20484096$'
echo "$output" | grep -q '^memory.swap.max:20971520$'
echo "$output" | grep -q '^pids.max:99$'
echo "$output" | grep -q '^cpu.max:10000 100000$'

check_systemd_value "MemoryMin" 131072
check_systemd_value "MemoryLow" 524288
check_systemd_value "MemoryHigh" 5242880
check_systemd_value "MemoryMax" 20484096
check_systemd_value "MemorySwapMax" 20971520
check_systemd_value "TasksMax" 99
check_cpu_quota 10000 100000 "100ms"
check_cpu_weight 42
}

@test "runc run (cgroup v2 resources.unified swap)" {
requires root cgroups_v2 cgroups_swap

set_cgroups_path
update_config ' .linux.resources.unified |= {
"memory.max": "20484096",
"memory.swap.max": "20971520"
}'

runc run -d --console-socket "$CONSOLE_SOCKET" test_cgroups_unified
[ "$status" -eq 0 ]

runc exec test_cgroups_unified sh -c 'cd /sys/fs/cgroup && grep . *.max'
[ "$status" -eq 0 ]
echo "$output"

echo "$output" | grep -q '^memory.max:20484096$'
echo "$output" | grep -q '^memory.swap.max:20971520$'

check_systemd_value "MemoryMax" 20484096
check_systemd_value "MemorySwapMax" 20971520
}

@test "runc run (cgroup v2 resources.unified override)" {
requires root cgroups_v2

Expand Down

0 comments on commit 829ab48

Please sign in to comment.