cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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