cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-iotests-055-refactor-compressed-backup-to-vmdk.patch

902636
From a5bf39550e82dbbe18f8debe07fa5d968a3fcf51 Mon Sep 17 00:00:00 2001
902636
From: Kevin Wolf <kwolf@redhat.com>
902636
Date: Wed, 3 Jun 2020 16:03:17 +0100
902636
Subject: [PATCH 18/26] iotests/055: refactor compressed backup to vmdk
902636
902636
RH-Author: Kevin Wolf <kwolf@redhat.com>
902636
Message-id: <20200603160325.67506-4-kwolf@redhat.com>
902636
Patchwork-id: 97104
902636
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH v2 03/11] iotests/055: refactor compressed backup to vmdk
902636
Bugzilla: 1778593
902636
RH-Acked-by: Eric Blake <eblake@redhat.com>
902636
RH-Acked-by: Max Reitz <mreitz@redhat.com>
902636
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
902636
902636
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
902636
902636
Instead of looping in each test, let's better refactor vmdk target case
902636
as a subclass.
902636
902636
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
902636
Message-Id: <20200430124713.3067-6-vsementsov@virtuozzo.com>
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
(cherry picked from commit 8e8372944e5e097e98844b4db10f867689065e16)
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 tests/qemu-iotests/055     | 70 ++++++++++++++++++++++++----------------------
902636
 tests/qemu-iotests/055.out |  4 +--
902636
 2 files changed, 39 insertions(+), 35 deletions(-)
902636
902636
diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055
902636
index eb50c9f..8666601 100755
902636
--- a/tests/qemu-iotests/055
902636
+++ b/tests/qemu-iotests/055
902636
@@ -450,10 +450,9 @@ class TestSingleTransaction(iotests.QMPTestCase):
902636
         self.assert_no_active_block_jobs()
902636
 
902636
 
902636
-class TestDriveCompression(iotests.QMPTestCase):
902636
+class TestCompressedToQcow2(iotests.QMPTestCase):
902636
     image_len = 64 * 1024 * 1024 # MB
902636
-    fmt_supports_compression = [{'type': 'qcow2', 'args': ()},
902636
-                                {'type': 'vmdk', 'args': ('-o', 'subformat=streamOptimized')}]
902636
+    target_fmt = {'type': 'qcow2', 'args': ()}
902636
 
902636
     def tearDown(self):
902636
         self.vm.shutdown()
902636
@@ -463,19 +462,20 @@ class TestDriveCompression(iotests.QMPTestCase):
902636
         except OSError:
902636
             pass
902636
 
902636
-    def do_prepare_drives(self, fmt, args, attach_target):
902636
+    def do_prepare_drives(self, attach_target):
902636
         self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
902636
 
902636
-        qemu_img('create', '-f', fmt, blockdev_target_img,
902636
-                 str(TestDriveCompression.image_len), *args)
902636
+        qemu_img('create', '-f', self.target_fmt['type'], blockdev_target_img,
902636
+                 str(self.image_len), *self.target_fmt['args'])
902636
         if attach_target:
902636
             self.vm.add_drive(blockdev_target_img,
902636
-                              img_format=fmt, interface="none")
902636
+                              img_format=self.target_fmt['type'],
902636
+                              interface="none")
902636
 
902636
         self.vm.launch()
902636
 
902636
-    def do_test_compress_complete(self, cmd, format, attach_target, **args):
902636
-        self.do_prepare_drives(format['type'], format['args'], attach_target)
902636
+    def do_test_compress_complete(self, cmd, attach_target, **args):
902636
+        self.do_prepare_drives(attach_target)
902636
 
902636
         self.assert_no_active_block_jobs()
902636
 
902636
@@ -486,21 +486,21 @@ class TestDriveCompression(iotests.QMPTestCase):
902636
 
902636
         self.vm.shutdown()
902636
         self.assertTrue(iotests.compare_images(test_img, blockdev_target_img,
902636
-                                               iotests.imgfmt, format['type']),
902636
+                                               iotests.imgfmt,
902636
+                                               self.target_fmt['type']),
902636
                         'target image does not match source after backup')
902636
 
902636
     def test_complete_compress_drive_backup(self):
902636
-        for format in TestDriveCompression.fmt_supports_compression:
902636
-            self.do_test_compress_complete('drive-backup', format, False,
902636
-                                           target=blockdev_target_img, mode='existing')
902636
+        self.do_test_compress_complete('drive-backup', False,
902636
+                                       target=blockdev_target_img,
902636
+                                       mode='existing')
902636
 
902636
     def test_complete_compress_blockdev_backup(self):
902636
-        for format in TestDriveCompression.fmt_supports_compression:
902636
-            self.do_test_compress_complete('blockdev-backup', format, True,
902636
-                                           target='drive1')
902636
+        self.do_test_compress_complete('blockdev-backup',
902636
+                                       True, target='drive1')
902636
 
902636
-    def do_test_compress_cancel(self, cmd, format, attach_target, **args):
902636
-        self.do_prepare_drives(format['type'], format['args'], attach_target)
902636
+    def do_test_compress_cancel(self, cmd, attach_target, **args):
902636
+        self.do_prepare_drives(attach_target)
902636
 
902636
         self.assert_no_active_block_jobs()
902636
 
902636
@@ -514,17 +514,16 @@ class TestDriveCompression(iotests.QMPTestCase):
902636
         self.vm.shutdown()
902636
 
902636
     def test_compress_cancel_drive_backup(self):
902636
-        for format in TestDriveCompression.fmt_supports_compression:
902636
-            self.do_test_compress_cancel('drive-backup', format, False,
902636
-                                         target=blockdev_target_img, mode='existing')
902636
+        self.do_test_compress_cancel('drive-backup', False,
902636
+                                     target=blockdev_target_img,
902636
+                                     mode='existing')
902636
 
902636
     def test_compress_cancel_blockdev_backup(self):
902636
-       for format in TestDriveCompression.fmt_supports_compression:
902636
-            self.do_test_compress_cancel('blockdev-backup', format, True,
902636
-                                         target='drive1')
902636
+        self.do_test_compress_cancel('blockdev-backup', True,
902636
+                                     target='drive1')
902636
 
902636
-    def do_test_compress_pause(self, cmd, format, attach_target, **args):
902636
-        self.do_prepare_drives(format['type'], format['args'], attach_target)
902636
+    def do_test_compress_pause(self, cmd, attach_target, **args):
902636
+        self.do_prepare_drives(attach_target)
902636
 
902636
         self.assert_no_active_block_jobs()
902636
 
902636
@@ -550,18 +549,23 @@ class TestDriveCompression(iotests.QMPTestCase):
902636
 
902636
         self.vm.shutdown()
902636
         self.assertTrue(iotests.compare_images(test_img, blockdev_target_img,
902636
-                                               iotests.imgfmt, format['type']),
902636
+                                               iotests.imgfmt,
902636
+                                               self.target_fmt['type']),
902636
                         'target image does not match source after backup')
902636
 
902636
     def test_compress_pause_drive_backup(self):
902636
-        for format in TestDriveCompression.fmt_supports_compression:
902636
-            self.do_test_compress_pause('drive-backup', format, False,
902636
-                                        target=blockdev_target_img, mode='existing')
902636
+        self.do_test_compress_pause('drive-backup', False,
902636
+                                    target=blockdev_target_img,
902636
+                                    mode='existing')
902636
 
902636
     def test_compress_pause_blockdev_backup(self):
902636
-        for format in TestDriveCompression.fmt_supports_compression:
902636
-            self.do_test_compress_pause('blockdev-backup', format, True,
902636
-                                        target='drive1')
902636
+        self.do_test_compress_pause('blockdev-backup', True,
902636
+                                    target='drive1')
902636
+
902636
+
902636
+class TestCompressedToVmdk(TestCompressedToQcow2):
902636
+    target_fmt = {'type': 'vmdk', 'args': ('-o', 'subformat=streamOptimized')}
902636
+
902636
 
902636
 if __name__ == '__main__':
902636
     iotests.main(supported_fmts=['raw', 'qcow2'],
902636
diff --git a/tests/qemu-iotests/055.out b/tests/qemu-iotests/055.out
902636
index 5ce2f9a..5c26d15 100644
902636
--- a/tests/qemu-iotests/055.out
902636
+++ b/tests/qemu-iotests/055.out
902636
@@ -1,5 +1,5 @@
902636
-..............................
902636
+....................................
902636
 ----------------------------------------------------------------------
902636
-Ran 30 tests
902636
+Ran 36 tests
902636
 
902636
 OK
902636
-- 
902636
1.8.3.1
902636