From 46dac589c1ed4b61c04660249f9a764735489260 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 14 Jul 2025 17:05:20 -0700 Subject: [PATCH] tests/int/update: fix getting block major Apparently, having a minor of 0 does not always mean it's the whole device (not a partition): === /proc/partitions (using major: 259) === major minor #blocks name 8 16 78643200 sdb 8 17 77593583 sdb1 8 30 4096 sdb14 8 31 108544 sdb15 259 0 934912 sdb16 8 0 78643200 sda 8 1 78641152 sda1 Rewrite the test to not assume minor is 0, and use lsblk -d to find out whole devices. This fixes a test case which was added in commit 7696402da. Signed-off-by: Kir Kolyshkin --- tests/integration/update.bats | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/integration/update.bats b/tests/integration/update.bats index 7ed1d8d206a..e3d1922efba 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -895,22 +895,23 @@ EOF @test "update per-device iops/bps values" { [ $EUID -ne 0 ] && requires rootless_cgroup - # We need a major number of any disk device. Usually those are partitioned, - # with the device itself having minor of 0, and partitions are 1, 2... - major=$(awk '$2 == 0 {print $1; exit}' /proc/partitions) - if [ "$major" = "0" ] || [ "$major" = "" ]; then - echo "=== /proc/partitions ===" - cat /proc/partitions - echo "===" - skip "can't get device major number from /proc/partitions (got $major)" + # Need major:minor for any block device (but not a partition). + dev=$(lsblk -dno MAJ:MIN | head -1 | tr -d ' \t\n') + if [ -z "$dev" ]; then + echo "=== lsblk -d ===" >&2 + lsblk -d >&2 + echo "===" >&2 + fail "can't get device from lsblk" fi + IFS=':' read -r major minor <<<"$dev" + # Add an entry to check that # - existing devices can be updated; # - duplicates are handled properly; # (see func upsert* in update.go). update_config ' .linux.resources.blockIO.throttleReadBpsDevice |= [ - { major: '"$major"', minor: 0, rate: 485760 }, - { major: '"$major"', minor: 0, rate: 485760 } + { major: '"$major"', minor: '"$minor"', rate: 485760 }, + { major: '"$major"', minor: '"$minor"', rate: 485760 } ]' runc run -d --console-socket "$CONSOLE_SOCKET" test_update @@ -922,28 +923,28 @@ EOF "throttleReadBpsDevice": [ { "major": $major, - "minor": 0, + "minor": $minor, "rate": 10485760 } ], "throttleWriteBpsDevice": [ { "major": $major, - "minor": 0, + "minor": $minor, "rate": 9437184 } ], "throttleReadIOPSDevice": [ { "major": $major, - "minor": 0, + "minor": $minor, "rate": 1000 } ], "throttleWriteIOPSDevice": [ { "major": $major, - "minor": 0, + "minor": $minor, "rate": 900 } ] @@ -951,5 +952,5 @@ EOF } EOF [ "$status" -eq 0 ] - check_cgroup_dev_iops "$major:0" 10485760 9437184 1000 900 + check_cgroup_dev_iops "$dev" 10485760 9437184 1000 900 }