On Wed, Aug 04, 2021 at 10:47:34AM +0200, Martin Kletzander wrote:
>+# Run nbdkit with the caching filter.
>+start_nbdkit -P cache-block-size.pid -U $sock --filter=cache \
>+ file cache-block-size.img cache-min-block-size=64K
>+
>+nbdsh --connect "nbd+unix://?socket=$sock" \
>+ -c '
>+# Write some pattern data to the overlay and check it reads back OK.
>+buf = b"abcd" * 16384
>+h.pwrite(buf, 32768)
>+zero = h.pread(32768, 0)
>+assert zero == bytearray(32768)
>+buf2 = h.pread(65536, 32768)
>+assert buf == buf2
>+
>+# Flushing should write through to the underlying file.
>+h.flush()
>+
>+with open("cache-block-size.img", "rb") as file:
>+ zero = file.read(32768)
>+ assert zero == bytearray(32768)
>+ buf2 = file.read(65536)
>+ assert buf == buf2
>+'
I do not see how this checks that the min block size is respected. I
would expect something along the lines of:
1) read 32k
2) write to the underlying file past those 32k
3) read another 32k (from offset == 32k)
4) check that the last read returned original data and not those written
in step 2)
Yes this test is not great. I think it was basically copied from this
one:
https://gitlab.com/nbdkit/nbdkit/-/blob/master/tests/test-cache.sh
I'll see if I can rethink this once I've got the v2v stuff out of the
way unless someone else comes up with a fix.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top