Skip to content

Commit

Permalink
tests/int/cgroups: add test for io.bfq device weight
Browse files Browse the repository at this point in the history
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Jun 14, 2021
1 parent 4b46f72 commit 487f620
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/integration/cgroups.bats
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,44 @@ function setup() {
fi
}

@test "runc run (per-device io weight for bfq)" {
requires root # to create a loop device

dd if=/dev/zero of=backing.img bs=4096 count=16
dev=$(losetup --find --show backing.img) || true
test -z "$dev" && skip "unable to create a loop device"

# See if BFQ scheduler is available.
if ! echo bfq >"/sys/block/${dev#/dev/}/queue/scheduler"; then
losetup -d "$dev"
skip "unable to set BFQ scheduler for $dev"
fi

set_cgroups_path

IFS=$' \t:' read -r major minor <<<"$(lsblk -nd -o MAJ:MIN "$dev")"
update_config ' .linux.devices += [{path: "'"$dev"'", type: "b", major: '"$major"', minor: '"$minor"'}]
| .linux.resources.blockIO.weight |= 333
| .linux.resources.blockIO.weightDevice |= [
{ major: '"$major"', minor: '"$minor"', weight: 444 }
]'
runc run -d --console-socket "$CONSOLE_SOCKET" test_dev_weight
[ "$status" -eq 0 ]

# The loop device itself is no longer needed.
losetup -d "$dev"

if [ "$CGROUP_UNIFIED" = "yes" ]; then
runc exec test_dev_weight cat /sys/fs/cgroup/io.bfq.weight
[ "$status" -eq 0 ]
[[ "$output" == *"default 333"* ]]
[[ "$output" == *"$major:$minor 444"* ]]
else
check_cgroup_value blkio.bfq.weight 333
check_cgroup_value blkio.bfq.weight_device "$major:$minor 444"
fi
}

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

Expand Down

0 comments on commit 487f620

Please sign in to comment.