qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 4/4] tests/qemu-iotests: add case for block-stream compres


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [PATCH v4 4/4] tests/qemu-iotests: add case for block-stream compress
Date: Thu, 17 Oct 2019 17:46:14 +0000

16.10.2019 19:28, Andrey Shinkevich wrote:
> Add a case to the iotest #030 that tests the 'compress' option for a
> block-stream job.
> 
> Signed-off-by: Andrey Shinkevich <address@hidden>
> ---
>   tests/qemu-iotests/030     | 51 
> +++++++++++++++++++++++++++++++++++++++++++++-
>   tests/qemu-iotests/030.out |  4 ++--
>   2 files changed, 52 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
> index f3766f2..f0f0e26 100755
> --- a/tests/qemu-iotests/030
> +++ b/tests/qemu-iotests/030
> @@ -21,7 +21,8 @@
>   import time
>   import os
>   import iotests
> -from iotests import qemu_img, qemu_io
> +from iotests import qemu_img, qemu_io, qemu_img_pipe
> +import json
>   
>   backing_img = os.path.join(iotests.test_dir, 'backing.img')
>   mid_img = os.path.join(iotests.test_dir, 'mid.img')
> @@ -956,6 +957,54 @@ class TestSetSpeed(iotests.QMPTestCase):
>   
>           self.cancel_and_wait(resume=True)
>   
> +class TestCompressed(iotests.QMPTestCase):
> +    test_img_init_size = 0
> +
> +    def setUp(self):
> +        qemu_img('create', '-f', iotests.imgfmt, backing_img, '1M')
> +        qemu_img('create', '-f', iotests.imgfmt, '-o',
> +                 'backing_file=%s' % backing_img, mid_img)
> +        qemu_img('create', '-f', iotests.imgfmt, '-o',
> +                 'backing_file=%s' % mid_img, test_img)
> +        qemu_io('-c', 'write -P 0x1 0 512k', backing_img)
> +        top = json.loads(qemu_img_pipe('info', '--output=json', test_img))
> +        self.test_img_init_size = top['actual-size']
> +        self.vm = iotests.VM().add_drive(test_img, "backing.node-name=mid," +
> +                                         "backing.backing.node-name=base," +

base node-name is unused actually

> +                                         "compress=on")
> +        self.vm.launch()
> +
> +    def tearDown(self):
> +        self.vm.shutdown()
> +        os.remove(test_img)
> +        os.remove(mid_img)
> +        os.remove(backing_img)
> +
> +    def test_stream_compress(self):
> +        self.assert_no_active_block_jobs()
> +
> +        result = self.vm.qmp('block-stream', device='mid', 
> job_id='stream-mid')
> +        self.assert_qmp(result, 'return', {})
> +
> +        self.wait_until_completed(drive='stream-mid')
> +        # Remove other 'JOB_STATUS_CHANGE' events for the job 'stream-mid'
> +        self.vm.get_qmp_events(wait=True)

Hmm, I think it's unsafe.. One more event may be still in pipe...

I think, better is just do
self.vm.wait_event(name='BLOCK_JOB_COMPLETED), and ignore JOB_STATUS_CHANGE 
events.

> +
> +        result = self.vm.qmp('block-stream', device='drive0',
> +                             job_id='stream-top')
> +        self.assert_qmp(result, 'return', {})
> +
> +        self.wait_until_completed(drive='stream-top')
> +        self.vm.shutdown()
> +
> +        top = json.loads(qemu_img_pipe('info', '--output=json', test_img))
> +        mid = json.loads(qemu_img_pipe('info', '--output=json', mid_img))
> +        base = json.loads(qemu_img_pipe('info', '--output=json', 
> backing_img))
> +
> +        self.assertEqual(mid['actual-size'], base['actual-size'])
> +        self.assertLess(top['actual-size'], mid['actual-size'])
> +        self.assertLess(self.test_img_init_size, top['actual-size'])

I think last assertion is covered by previous two.

And I'm still unsure about using actual-size. Direct checking number of 
compressed
clusters by qemu-img check maybe better.

> +
>   if __name__ == '__main__':
>       iotests.main(supported_fmts=['qcow2', 'qed'],
>                    supported_protocols=['file'])
> diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out
> index 6d9bee1..af8dac1 100644
> --- a/tests/qemu-iotests/030.out
> +++ b/tests/qemu-iotests/030.out
> @@ -1,5 +1,5 @@
> -...........................
> +............................
>   ----------------------------------------------------------------------
> -Ran 27 tests
> +Ran 28 tests
>   
>   OK
> 


-- 
Best regards,
Vladimir

reply via email to

[Prev in Thread] Current Thread [Next in Thread]