On Sun, Feb 16, 2020 at 3:53 PM Nir Soffer <nsoffer@redhat.com> wrote:
On Sun, Feb 16, 2020 at 11:52 AM Amit Bawer <abawer@redhat.com> wrote:
>
> Hi,
>
> This occurs on CI every now and then,
> taken from: https://jenkins.ovirt.org/job/vdsm_standard-check-patch/18302//artifact/check-patch.tests-py3.el8.x86_64/mock_logs/script/stdout_stderr.log
>
> Thanks
>
>
>
> ________ TestConvertPreallocation.test_qcow2_to_raw_preallocated[full] _________
>
> self = <storage.qemuimg_test.TestConvertPreallocation object at 0x7f9bac7c3ef0>
> preallocation = 'full'
>
>     @pytest.mark.parametrize("preallocation", [
>         qemuimg.PREALLOCATION.FALLOC,
>         qemuimg.PREALLOCATION.FULL,
>     ])
>     def test_qcow2_to_raw_preallocated(self, preallocation):
>         virtual_size = 10 * MiB
>         with namedTemporaryDir() as tmpdir:
>             src = os.path.join(tmpdir, 'src')
>             dst = os.path.join(tmpdir, 'dst')
>
>             op = qemuimg.create(src, size=virtual_size, format="qcow2")
>             op.run()
>
>             op = qemuimg.convert(src, dst, srcFormat="qcow2", dstFormat="raw",
>                                  preallocation=preallocation)
>             op.run()
> >           check_raw_preallocated_image(dst, virtual_size)
>
> storage/qemuimg_test.py:561:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> path = '/var/tmp/tmpxr0emprz/dst', virtual_size = 10485760
>
>     def check_raw_preallocated_image(path, virtual_size):
>         image_stat = os.stat(path)
>         assert image_stat.st_size == virtual_size
> >       assert image_stat.st_blocks * 512 == virtual_size
> E       assert (20488 * 512) == 10485760
> E        +  where 20488 = os.stat_result(st_mode=33188, st_ino=411528, st_dev=2049, st_nlink=1, st_uid=0, st_gid=0, st_size=10485760, st_atime=1581845207, st_mtime=1581845207, st_ctime=1581845207).st_blocks

Depending on the filesystem, the file system may report more blocks
than expected.

In that case, shouldn't it happen on every test run? this only happens on part of the time.


We can change the assert to:

    assert image_stat.st_blocks * 512 >= virtual_size

In qemu iotests this is solved in a more precise way:
https://github.com/qemu/qemu/blob/b29c3e23f64938784c42ef9fca896829e3c19120/tests/qemu-iotests/175#L82
https://github.com/qemu/qemu/blob/b29c3e23f64938784c42ef9fca896829e3c19120/tests/qemu-iotests/175#L87

I think we can adapt these checks and use them in every test checking
for allocation. We have several tests
that can use this.

> storage/qemuimg_test.py:621: AssertionError
>
> _______________________________________________
> Devel mailing list -- devel@ovirt.org
> To unsubscribe send an email to devel-leave@ovirt.org
> Privacy Statement: https://www.ovirt.org/site/privacy-policy/
> oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
> List Archives: https://lists.ovirt.org/archives/list/devel@ovirt.org/message/G7PRFHNYMDKAMI7XZ2K7XGTHUBR4QWBZ/