mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00

[ Clean cherry-pick of #19302. This is a low-risk change with potentially very high ROI: the opportunity to catch interaction problems with updates in other system components. ] BATS 1.8.0 introduces tags: metadata that can be applied to a single test or one entire file, then used for filtering in a test run. Issue #19299 introduces the possibility of using OpenQA for podman reverse dependency testing: continuous CI on all packages that can affect podman, so we don't go two months with no bodhi builds then get caught by surprise when systemd or kernel or crun change in ways that break us. This PR introduces one bats tag, "distro-integration". The intention is for OpenQA (or other) tests to install the podman-tests package and run: bats --filter-tags distro-integration /usr/share/podman/test/system Goal is to keep the test list short and sweet: we do not need to test command-line option parsing. We *DO* need to test interactions with systemd, kernel, nethack, and other critical components. Signed-off-by: Ed Santiago <santiago@redhat.com>
73 lines
2.4 KiB
Bash
73 lines
2.4 KiB
Bash
#!/usr/bin/env bats -*- bats -*-
|
|
#
|
|
# podman blkio-related tests
|
|
#
|
|
# bats file_tags=distro-integration
|
|
#
|
|
|
|
load helpers
|
|
|
|
function teardown() {
|
|
lofile=${PODMAN_TMPDIR}/disk.img
|
|
if [ -f ${lofile} ]; then
|
|
run_podman '?' rm -t 0 --all --force --ignore
|
|
|
|
while read path dev; do
|
|
if [[ "$path" == "$lofile" ]]; then
|
|
losetup -d $dev
|
|
fi
|
|
done < <(losetup -l --noheadings --output BACK-FILE,NAME)
|
|
|
|
rm ${lofile}
|
|
fi
|
|
basic_teardown
|
|
}
|
|
|
|
@test "podman run --blkio-weight-device" {
|
|
|
|
skip_if_rootless "cannot create devices in rootless mode"
|
|
|
|
# create loopback device
|
|
lofile=${PODMAN_TMPDIR}/disk.img
|
|
fallocate -l 1k ${lofile}
|
|
losetup -f ${lofile}
|
|
|
|
run losetup -l --noheadings --output BACK-FILE,NAME,MAJ:MIN
|
|
assert "$status" -eq 0 "losetup: status"
|
|
assert "$output" != "" "losetup: output"
|
|
|
|
lodevice=$(awk "\$1 == \"$lofile\" { print \$2 }" <<<"$output")
|
|
lomajmin=$(awk "\$1 == \"$lofile\" { print \$3 }" <<<"$output")
|
|
|
|
is "$lodevice" ".\+" "Could not determine device for $lofile"
|
|
is "$lomajmin" ".\+" "Could not determine major/minor for $lofile"
|
|
|
|
# use bfq io scheduler
|
|
run grep -w bfq /sys/block/$(basename ${lodevice})/queue/scheduler
|
|
if [ $status -ne 0 ]; then
|
|
skip "BFQ scheduler is not supported on the system"
|
|
fi
|
|
echo bfq > /sys/block/$(basename ${lodevice})/queue/scheduler
|
|
|
|
# run podman
|
|
if is_cgroupsv2; then
|
|
if [ ! -f /sys/fs/cgroup/system.slice/io.bfq.weight ]; then
|
|
skip "Kernel does not support BFQ IO scheduler"
|
|
fi
|
|
run_podman run --device ${lodevice}:${lodevice} --blkio-weight-device ${lodevice}:123 --rm $IMAGE \
|
|
/bin/sh -c "cat /sys/fs/cgroup/\$(sed -e 's/0:://' < /proc/self/cgroup)/io.bfq.weight"
|
|
is "${lines[1]}" "${lomajmin}\s\+123"
|
|
else
|
|
if [ ! -f /sys/fs/cgroup/blkio/system.slice/blkio.bfq.weight_device ]; then
|
|
skip "Kernel does not support BFQ IO scheduler"
|
|
fi
|
|
if [ $(podman_runtime) = "crun" ]; then
|
|
# As of crun 1.2, crun doesn't support blkio.bfq.weight_device
|
|
skip "crun doesn't support blkio.bfq.weight_device"
|
|
fi
|
|
run_podman run --device ${lodevice}:${lodevice} --blkio-weight-device ${lodevice}:123 --rm $IMAGE \
|
|
/bin/sh -c "cat /sys/fs/cgroup/blkio/blkio.bfq.weight_device"
|
|
is "${lines[1]}" "${lomajmin}\s\+123"
|
|
fi
|
|
}
|