[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/30] iotests/055: refactor compressed backup to vmdk
From: |
Kevin Wolf |
Subject: |
[PULL 05/30] iotests/055: refactor compressed backup to vmdk |
Date: |
Fri, 8 May 2020 14:41:10 +0200 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Instead of looping in each test, let's better refactor vmdk target case
as a subclass.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/qemu-iotests/055 | 70 ++++++++++++++++++++------------------
tests/qemu-iotests/055.out | 4 +--
2 files changed, 39 insertions(+), 35 deletions(-)
diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055
index 4175fff5e4..d9e8985167 100755
--- a/tests/qemu-iotests/055
+++ b/tests/qemu-iotests/055
@@ -450,10 +450,9 @@ class TestSingleTransaction(iotests.QMPTestCase):
self.assert_no_active_block_jobs()
-class TestDriveCompression(iotests.QMPTestCase):
+class TestCompressedToQcow2(iotests.QMPTestCase):
image_len = 64 * 1024 * 1024 # MB
- fmt_supports_compression = [{'type': 'qcow2', 'args': ()},
- {'type': 'vmdk', 'args': ('-o',
'subformat=streamOptimized')}]
+ target_fmt = {'type': 'qcow2', 'args': ()}
def tearDown(self):
self.vm.shutdown()
@@ -463,19 +462,20 @@ class TestDriveCompression(iotests.QMPTestCase):
except OSError:
pass
- def do_prepare_drives(self, fmt, args, attach_target):
+ def do_prepare_drives(self, attach_target):
self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
- qemu_img('create', '-f', fmt, blockdev_target_img,
- str(TestDriveCompression.image_len), *args)
+ qemu_img('create', '-f', self.target_fmt['type'], blockdev_target_img,
+ str(self.image_len), *self.target_fmt['args'])
if attach_target:
self.vm.add_drive(blockdev_target_img,
- img_format=fmt, interface="none")
+ img_format=self.target_fmt['type'],
+ interface="none")
self.vm.launch()
- def do_test_compress_complete(self, cmd, format, attach_target, **args):
- self.do_prepare_drives(format['type'], format['args'], attach_target)
+ def do_test_compress_complete(self, cmd, attach_target, **args):
+ self.do_prepare_drives(attach_target)
self.assert_no_active_block_jobs()
@@ -486,21 +486,21 @@ class TestDriveCompression(iotests.QMPTestCase):
self.vm.shutdown()
self.assertTrue(iotests.compare_images(test_img, blockdev_target_img,
- iotests.imgfmt, format['type']),
+ iotests.imgfmt,
+ self.target_fmt['type']),
'target image does not match source after backup')
def test_complete_compress_drive_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_complete('drive-backup', format, False,
- target=blockdev_target_img,
mode='existing')
+ self.do_test_compress_complete('drive-backup', False,
+ target=blockdev_target_img,
+ mode='existing')
def test_complete_compress_blockdev_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_complete('blockdev-backup', format, True,
- target='drive1')
+ self.do_test_compress_complete('blockdev-backup',
+ True, target='drive1')
- def do_test_compress_cancel(self, cmd, format, attach_target, **args):
- self.do_prepare_drives(format['type'], format['args'], attach_target)
+ def do_test_compress_cancel(self, cmd, attach_target, **args):
+ self.do_prepare_drives(attach_target)
self.assert_no_active_block_jobs()
@@ -514,17 +514,16 @@ class TestDriveCompression(iotests.QMPTestCase):
self.vm.shutdown()
def test_compress_cancel_drive_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_cancel('drive-backup', format, False,
- target=blockdev_target_img,
mode='existing')
+ self.do_test_compress_cancel('drive-backup', False,
+ target=blockdev_target_img,
+ mode='existing')
def test_compress_cancel_blockdev_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_cancel('blockdev-backup', format, True,
- target='drive1')
+ self.do_test_compress_cancel('blockdev-backup', True,
+ target='drive1')
- def do_test_compress_pause(self, cmd, format, attach_target, **args):
- self.do_prepare_drives(format['type'], format['args'], attach_target)
+ def do_test_compress_pause(self, cmd, attach_target, **args):
+ self.do_prepare_drives(attach_target)
self.assert_no_active_block_jobs()
@@ -550,18 +549,23 @@ class TestDriveCompression(iotests.QMPTestCase):
self.vm.shutdown()
self.assertTrue(iotests.compare_images(test_img, blockdev_target_img,
- iotests.imgfmt, format['type']),
+ iotests.imgfmt,
+ self.target_fmt['type']),
'target image does not match source after backup')
def test_compress_pause_drive_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_pause('drive-backup', format, False,
- target=blockdev_target_img,
mode='existing')
+ self.do_test_compress_pause('drive-backup', False,
+ target=blockdev_target_img,
+ mode='existing')
def test_compress_pause_blockdev_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_pause('blockdev-backup', format, True,
- target='drive1')
+ self.do_test_compress_pause('blockdev-backup', True,
+ target='drive1')
+
+
+class TestCompressedToVmdk(TestCompressedToQcow2):
+ target_fmt = {'type': 'vmdk', 'args': ('-o', 'subformat=streamOptimized')}
+
if __name__ == '__main__':
iotests.main(supported_fmts=['raw', 'qcow2'],
diff --git a/tests/qemu-iotests/055.out b/tests/qemu-iotests/055.out
index 5ce2f9a2ed..5c26d15c0d 100644
--- a/tests/qemu-iotests/055.out
+++ b/tests/qemu-iotests/055.out
@@ -1,5 +1,5 @@
-..............................
+....................................
----------------------------------------------------------------------
-Ran 30 tests
+Ran 36 tests
OK
--
2.25.3
- [PULL 00/30] Block layer patches, Kevin Wolf, 2020/05/08
- [PULL 01/30] iotests: handle tmpfs, Kevin Wolf, 2020/05/08
- [PULL 02/30] iotests/082: require bochs, Kevin Wolf, 2020/05/08
- [PULL 04/30] iotests/041: drop self.assert_no_active_block_jobs(), Kevin Wolf, 2020/05/08
- [PULL 03/30] iotests/148: use skip_if_unsupported, Kevin Wolf, 2020/05/08
- [PULL 06/30] iotests/055: skip vmdk target tests if vmdk is not whitelisted, Kevin Wolf, 2020/05/08
- [PULL 05/30] iotests/055: refactor compressed backup to vmdk,
Kevin Wolf <=
- [PULL 07/30] iotests/109: mark required formats as required to support whitelisting, Kevin Wolf, 2020/05/08
- [PULL 08/30] iotests/113: mark bochs as required to support whitelisting, Kevin Wolf, 2020/05/08
- [PULL 10/30] vmdk: Rename VmdkMetaData.valid to new_allocation, Kevin Wolf, 2020/05/08
- [PULL 13/30] vmdk: Don't update L2 table for zero write on zero cluster, Kevin Wolf, 2020/05/08
- [PULL 12/30] vmdk: Fix partial overwrite of zero cluster, Kevin Wolf, 2020/05/08
- [PULL 11/30] vmdk: Fix zero cluster allocation, Kevin Wolf, 2020/05/08
- [PULL 09/30] qcow2: Avoid integer wraparound in qcow2_co_truncate(), Kevin Wolf, 2020/05/08
- [PULL 14/30] vmdk: Flush only once in vmdk_L2update(), Kevin Wolf, 2020/05/08
- [PULL 16/30] iotests/283: Use consistent size for source and target, Kevin Wolf, 2020/05/08
- [PULL 15/30] iotests: vmdk: Enable zeroed_grained=on by default, Kevin Wolf, 2020/05/08