-
Notifications
You must be signed in to change notification settings - Fork 2.2k
tests/int/update: fix getting block major #4807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
722e819 to
d25fd1e
Compare
|
In ubuntu, maybe we can use this script: I see this test in all ubuntu are skipped: # skip can't get device major number from /proc/partitions (got ) In my machine: |
|
My machine has two physical disks and I can confirm that minor is not always zero: $ lsblk -d
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 1024M 0 rom
nvme0n1 259:0 0 953.9G 0 disk
nvme1n1 259:4 0 953.9G 0 disk However, it also seems that $ lsblk -dno MAJ
lsblk: unknown column: MAJ
$ lsblk -dno MAJ:MIN
11:0
259:0
259:4 Maybe it's a bit much since $ lsblk --nodeps --json | jq --raw-output 'first(.blockdevices[] | select(.type == "disk"))["maj:min"] | split(":")[0]'
259
$ lsblk -dno MAJ:MIN,TYPE -E TYPE | grep ' disk$' | cut -d: -f1
259
$ lsblk -dno MAJ:MIN,TYPE -E TYPE | awk -F '[ :]+' '$3 == "disk" { print $1 }'
259edit: if you want to hyper-minimize flags, you can get away with something like this: $ lsblk -do TYPE,MAJ:MIN | awk -F '[ :]+' '$1 == "disk" { print $2; exit }'
259(it feels kind of ironic that |
|
Another alternative could be $ grep 259 /proc/devices
259 blkext
$ awk '$2 == "blkext" { print $1; exit }' /proc/devices
259 |
|
Aha, here's a machine with a much wilder array of devices -- happy to do more testing of this one-liner on it, if that's helpful: $ lsblk -d
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 16.4T 0 disk
sdb 8:16 0 953.9G 0 disk
sdc 8:32 0 12.7T 0 disk
sdd 8:48 0 476.9G 0 disk
sde 8:64 0 7.3T 0 disk
sdf 8:80 0 14.6T 0 disk
sdg 8:96 0 16.4T 0 disk
sdh 8:112 0 14.6T 0 disk
nvme0n1 259:0 0 1.8T 0 disk
nvme1n1 259:1 0 1.8T 0 disk |
|
... oh, looking further down, the rest of this test does assume there exists a minor of zero with the given major, which I guess is probably fair? I don't know how those get assigned, but they appear to be assigned pretty reliably in a decent pattern that always starts at 0 on the very small sample size I've got handy. |
|
The assumption that minor is always 0 was incorrect in the test case, I am fixing that. Wonder if filtering on Assuming it's cgroup v2, this would be something like: IOMAX=/sys/fs/cgroup/$(cat /proc/self/cgroup | sed 's/^0:://')/io.max
tail -v $IOMAX
DEV=11:0
echo $DEV wiops=1000 > $IOMAX
echo $DEV riops=1000 > $IOMAX
echo $DEV wbps=100000 > $IOMAX
echo $DEV rbps=100000 > $IOMAX
tail -v $IOMAX
# To undo:
echo $DEV wiops=max riops=max rbps=max wbps=max > $IOMAX
tail -v $IOMAX |
cb3d27f to
e346830
Compare
|
Yep! 🤷 seems like it's fine: $ sudo systemd-run --scope bash
Running scope as unit: run-r91caaa1102d94a48be548a12cea6a06c.scope
# IOMAX=/sys/fs/cgroup/$(cat /proc/self/cgroup | sed 's/^0:://')/io.max
# tail -v $IOMAX
==> /sys/fs/cgroup//system.slice/run-r91caaa1102d94a48be548a12cea6a06c.scope/io.max <==
# DEV=11:0
# echo $DEV wiops=1000 > $IOMAX
# echo $DEV riops=1000 > $IOMAX
# echo $DEV wbps=100000 > $IOMAX
# echo $DEV rbps=100000 > $IOMAX
# tail -v $IOMAX
==> /sys/fs/cgroup//system.slice/run-r91caaa1102d94a48be548a12cea6a06c.scope/io.max <==
11:0 rbps=100000 wbps=100000 riops=1000 wiops=1000I tried changing |
tests/integration/update.bats
Outdated
| echo "=== lsblk -d ===" >&2 | ||
| lsblk -d >&2 | ||
| echo "===" >&2 | ||
| skip "can't get device from lsblk" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not skip this test, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, assuming that currently it works.
If it currently works, it's probably better to make it a hard failure, so that we can decide whether to skip or fail when we run into failures (which may be a more specific "skip" for expected conditions).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
FWIW, I recently learned that |
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, pending @AkihiroSuda's comment above.
rata
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
As others suggested, let's make the test fail if $dev is empty. So we don't stop testing this inadvertently. But I don't need to review again that small change :)
tests/integration/update.bats
Outdated
| echo "=== lsblk -d ===" >&2 | ||
| lsblk -d >&2 | ||
| echo "===" >&2 | ||
| skip "can't get device from lsblk" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 7696402. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
e346830 to
46dac58
Compare
|
To me, OTOH I agree that fail will help us debug the issue of getting a device. Also, with Fixed. |
Apparently, with GHA, having a minor of 0 does not always mean it's the
whole device (and not a partition):
Let's use
lsblk -dto find out whole devices.This fixes a test case which was added in commit 7696402 (PR #4775).