test: Use dd for generating reads

On Debian testing dropping caches causes ext4 journal writes when
running grep on /usr. This caused CI to flake and made it unable to land
any changes to pkg/metrics.
Switching to dd and reading directly from the block device circumvents
these issues.

On Ubuntu uutils does not properly support iflag=direct, so we keep
using GNU dd:

dd if=/dev/vda of=/dev/null bs=4096 count=1 iflag=direct
dd: IO error: Invalid input
This commit is contained in:
Jelle van der Waa 2026-10-28 11:16:16 +01:00 committed by Jelle van der Waa
parent 3fbe9ee7e1
commit 124d811c45

View file

@ -1180,8 +1180,12 @@ BEGIN {{
# test env should be quiet enough to not transmit MB/s
b.wait(lambda: re.match(r'^(0|[0-9.]+ (kB|B)/s)$', b.text("#current-disks-read")))
b.wait(lambda: re.match(r'^(0|[0-9.]+ (kB|B)/s)$', b.text("#current-disks-write")))
# uutils dd fails with iflag=direct due to an unaligned buffer, using GNU dd.
dd_binary = "dd"
if m.image == "ubuntu-2604":
dd_binary = "gnudd"
# reading lots of data
m.execute("systemd-run --collect --slice cockpittest --unit disk-read-hog sh -ec 'while true; do echo 3 > /proc/sys/vm/drop_caches; grep -r . /usr >/dev/null; done'")
m.execute(f"systemd-run --collect --slice cockpittest --unit disk-read-hog sh -ec 'while true; do {dd_binary} if=/dev/vda of=/dev/null bs=1M iflag=direct 2>/dev/null; done'")
b.wait(lambda: re.match(r'^[0-9.]+ (MB|GB)/s$', b.text("#current-disks-read")))
b.wait(lambda: re.match(r'^(0|[0-9.]+ (kB|B)/s)$', b.text("#current-disks-write"))) # this should stay calm
# read in popover