[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 28/42] qemu-iotests: test backup compression in 055
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 28/42] qemu-iotests: test backup compression in 055 |
Date: |
Mon, 5 Sep 2016 20:13:40 +0200 |
From: Pavel Butsykin <address@hidden>
Added cases to check the backup compression out of qcow2, raw in qcow2
on drive-backup and blockdev-backup.
Signed-off-by: Pavel Butsykin <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Denis V. Lunev <address@hidden>
CC: Jeff Cody <address@hidden>
CC: Markus Armbruster <address@hidden>
CC: Eric Blake <address@hidden>
CC: John Snow <address@hidden>
CC: Stefan Hajnoczi <address@hidden>
CC: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/qemu-iotests/055 | 97 +++++++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/055.out | 4 +-
tests/qemu-iotests/iotests.py | 10 ++---
3 files changed, 104 insertions(+), 7 deletions(-)
diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055
index 8113c61..0e1326c 100755
--- a/tests/qemu-iotests/055
+++ b/tests/qemu-iotests/055
@@ -448,5 +448,102 @@ class TestSingleTransaction(iotests.QMPTestCase):
self.assert_qmp(result, 'error/class', 'GenericError')
self.assert_no_active_block_jobs()
+
+class TestDriveCompression(iotests.QMPTestCase):
+ image_len = 64 * 1024 * 1024 # MB
+ outfmt = 'qcow2'
+
+ def setUp(self):
+ # Write data to the image so we can compare later
+ qemu_img('create', '-f', iotests.imgfmt, test_img,
str(TestDriveCompression.image_len))
+ qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x11 0 64k', test_img)
+ qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x00 64k 128k', test_img)
+ qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x22 162k 32k', test_img)
+ qemu_io('-f', iotests.imgfmt, '-c', 'write -P0x33 67043328 64k',
test_img)
+
+ qemu_img('create', '-f', TestDriveCompression.outfmt,
blockdev_target_img,
+ str(TestDriveCompression.image_len))
+ self.vm =
iotests.VM().add_drive(test_img).add_drive(blockdev_target_img,
+
format=TestDriveCompression.outfmt)
+ self.vm.launch()
+
+ def tearDown(self):
+ self.vm.shutdown()
+ os.remove(test_img)
+ os.remove(blockdev_target_img)
+ try:
+ os.remove(target_img)
+ except OSError:
+ pass
+
+ def do_test_compress_complete(self, cmd, **args):
+ self.assert_no_active_block_jobs()
+
+ result = self.vm.qmp(cmd, device='drive0', sync='full', compress=True,
**args)
+ self.assert_qmp(result, 'return', {})
+
+ self.wait_until_completed()
+
+ self.vm.shutdown()
+ self.assertTrue(iotests.compare_images(test_img, blockdev_target_img,
+ iotests.imgfmt,
TestDriveCompression.outfmt),
+ 'target image does not match source after backup')
+
+ def test_complete_compress_drive_backup(self):
+ self.do_test_compress_complete('drive-backup',
target=blockdev_target_img, mode='existing')
+
+ def test_complete_compress_blockdev_backup(self):
+ self.do_test_compress_complete('blockdev-backup', target='drive1')
+
+ def do_test_compress_cancel(self, cmd, **args):
+ self.assert_no_active_block_jobs()
+
+ result = self.vm.qmp(cmd, device='drive0', sync='full', compress=True,
**args)
+ self.assert_qmp(result, 'return', {})
+
+ event = self.cancel_and_wait()
+ self.assert_qmp(event, 'data/type', 'backup')
+
+ def test_compress_cancel_drive_backup(self):
+ self.do_test_compress_cancel('drive-backup',
target=blockdev_target_img, mode='existing')
+
+ def test_compress_cancel_blockdev_backup(self):
+ self.do_test_compress_cancel('blockdev-backup', target='drive1')
+
+ def do_test_compress_pause(self, cmd, **args):
+ self.assert_no_active_block_jobs()
+
+ self.vm.pause_drive('drive0')
+ result = self.vm.qmp(cmd, device='drive0', sync='full', compress=True,
**args)
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm.qmp('block-job-pause', device='drive0')
+ self.assert_qmp(result, 'return', {})
+
+ self.vm.resume_drive('drive0')
+ time.sleep(1)
+ result = self.vm.qmp('query-block-jobs')
+ offset = self.dictpath(result, 'return[0]/offset')
+
+ time.sleep(1)
+ result = self.vm.qmp('query-block-jobs')
+ self.assert_qmp(result, 'return[0]/offset', offset)
+
+ result = self.vm.qmp('block-job-resume', device='drive0')
+ self.assert_qmp(result, 'return', {})
+
+ self.wait_until_completed()
+
+ self.vm.shutdown()
+ self.assertTrue(iotests.compare_images(test_img, blockdev_target_img,
+ iotests.imgfmt,
TestDriveCompression.outfmt),
+ 'target image does not match source after backup')
+
+ def test_compress_pause_drive_backup(self):
+ self.do_test_compress_pause('drive-backup',
target=blockdev_target_img, mode='existing')
+
+ def test_compress_pause_blockdev_backup(self):
+ self.do_test_compress_pause('blockdev-backup', target='drive1')
+
if __name__ == '__main__':
iotests.main(supported_fmts=['raw', 'qcow2'])
diff --git a/tests/qemu-iotests/055.out b/tests/qemu-iotests/055.out
index 42314e9..5ce2f9a 100644
--- a/tests/qemu-iotests/055.out
+++ b/tests/qemu-iotests/055.out
@@ -1,5 +1,5 @@
-........................
+..............................
----------------------------------------------------------------------
-Ran 24 tests
+Ran 30 tests
OK
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index dbe0ee5..69aa41e 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -86,10 +86,10 @@ def qemu_io(*args):
sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, '
'.join(args)))
return subp.communicate()[0]
-def compare_images(img1, img2):
+def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt):
'''Return True if two image files are identical'''
- return qemu_img('compare', '-f', imgfmt,
- '-F', imgfmt, img1, img2) == 0
+ return qemu_img('compare', '-f', fmt1,
+ '-F', fmt2, img1, img2) == 0
def create_image(name, size):
'''Create a fully-allocated raw image with sector markers'''
@@ -141,14 +141,14 @@ class VM(qtest.QEMUQtestMachine):
self._args.append(opts)
return self
- def add_drive(self, path, opts='', interface='virtio'):
+ def add_drive(self, path, opts='', interface='virtio', format=imgfmt):
'''Add a virtio-blk drive to the VM'''
options = ['if=%s' % interface,
'id=drive%d' % self._num_drives]
if path is not None:
options.append('file=%s' % path)
- options.append('format=%s' % imgfmt)
+ options.append('format=%s' % format)
options.append('cache=%s' % cachemode)
if opts:
--
1.8.3.1
- [Qemu-block] [PULL 16/42] block/io: reuse bdrv_co_pwritev() for write compressed, (continued)
- [Qemu-block] [PULL 16/42] block/io: reuse bdrv_co_pwritev() for write compressed, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 15/42] block: Convert bdrv_pwrite_compressed() to BdrvChild, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 19/42] vmdk: add vmdk_co_pwritev_compressed, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 11/42] block: Accept node-name for drive-mirror, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 13/42] nbd-server: Allow node name for nbd-server-add, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 17/42] qcow2: add qcow2_co_pwritev_compressed, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 18/42] qcow2: cleanup qcow2_co_pwritev_compressed to avoid the recursion, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 21/42] qcow: cleanup qcow_co_pwritev_compressed to avoid the recursion, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 20/42] qcow: add qcow_co_pwritev_compressed, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 22/42] block: remove BlockDriver.bdrv_write_compressed, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 28/42] qemu-iotests: test backup compression in 055,
Kevin Wolf <=
- [Qemu-block] [PULL 23/42] block/io: turn on dirty_bitmaps for the compressed writes, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 24/42] block: simplify drive-backup, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 25/42] block: simplify blockdev-backup, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 29/42] qemu-iotests: add vmdk for test backup compression in 055, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 26/42] drive-backup: added support for data compression, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 27/42] blockdev-backup: added support for data compression, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 30/42] test-coroutine: Fix coroutine pool corruption, Kevin Wolf, 2016/09/05
- [Qemu-block] [PULL 32/42] coroutine: Let CoMutex remember who holds it, Kevin Wolf, 2016/09/05