Blame SOURCES/kvm-iotests-Mirror-with-different-source-target-size.patch

77c23f
From aff543186ff316d66b2c7acb434c6c17bdb8da78 Mon Sep 17 00:00:00 2001
77c23f
From: Kevin Wolf <kwolf@redhat.com>
77c23f
Date: Wed, 3 Jun 2020 16:03:25 +0100
77c23f
Subject: [PATCH 26/26] iotests: Mirror with different source/target size
77c23f
77c23f
RH-Author: Kevin Wolf <kwolf@redhat.com>
77c23f
Message-id: <20200603160325.67506-12-kwolf@redhat.com>
77c23f
Patchwork-id: 97109
77c23f
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH v2 11/11] iotests: Mirror with different source/target size
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
This tests that the mirror job catches situations where the target node
77c23f
has a different size than the source node. It must also forbid resize
77c23f
operations when the job is already running.
77c23f
77c23f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
77c23f
Reviewed-by: Eric Blake <eblake@redhat.com>
77c23f
Message-Id: <20200511135825.219437-5-kwolf@redhat.com>
77c23f
Reviewed-by: Max Reitz <mreitz@redhat.com>
77c23f
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
77c23f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
77c23f
(cherry picked from commit 16cea4ee1c8e5a69a058e76f426b2e17974d8d7d)
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/041     | 45 +++++++++++++++++++++++++++++++++++++++++++++
77c23f
 tests/qemu-iotests/041.out |  4 ++--
77c23f
 2 files changed, 47 insertions(+), 2 deletions(-)
77c23f
77c23f
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
77c23f
index a543b15..20fb68a 100755
77c23f
--- a/tests/qemu-iotests/041
77c23f
+++ b/tests/qemu-iotests/041
77c23f
@@ -240,6 +240,49 @@ class TestSingleBlockdev(TestSingleDrive):
77c23f
                              target=self.qmp_target)
77c23f
         self.assert_qmp(result, 'error/class', 'GenericError')
77c23f
 
77c23f
+    def do_test_resize(self, device, node):
77c23f
+        def pre_finalize():
77c23f
+            if device:
77c23f
+                result = self.vm.qmp('block_resize', device=device, size=65536)
77c23f
+                self.assert_qmp(result, 'error/class', 'GenericError')
77c23f
+
77c23f
+            result = self.vm.qmp('block_resize', node_name=node, size=65536)
77c23f
+            self.assert_qmp(result, 'error/class', 'GenericError')
77c23f
+
77c23f
+        result = self.vm.qmp(self.qmp_cmd, job_id='job0', device='drive0',
77c23f
+                             sync='full', target=self.qmp_target,
77c23f
+                             auto_finalize=False, auto_dismiss=False)
77c23f
+        self.assert_qmp(result, 'return', {})
77c23f
+
77c23f
+        result = self.vm.run_job('job0', auto_finalize=False,
77c23f
+                                 pre_finalize=pre_finalize, use_log=False)
77c23f
+        self.assertEqual(result, None)
77c23f
+
77c23f
+    def test_source_resize(self):
77c23f
+        self.do_test_resize('drive0', 'top')
77c23f
+
77c23f
+    def test_target_resize(self):
77c23f
+        self.do_test_resize(None, self.qmp_target)
77c23f
+
77c23f
+    def do_test_target_size(self, size):
77c23f
+        result = self.vm.qmp('block_resize', node_name=self.qmp_target,
77c23f
+                             size=size)
77c23f
+        self.assert_qmp(result, 'return', {})
77c23f
+
77c23f
+        result = self.vm.qmp(self.qmp_cmd, job_id='job0',
77c23f
+                             device='drive0', sync='full', auto_dismiss=False,
77c23f
+                             target=self.qmp_target)
77c23f
+        self.assert_qmp(result, 'return', {})
77c23f
+
77c23f
+        result = self.vm.run_job('job0', use_log=False)
77c23f
+        self.assertEqual(result, 'Source and target image have different sizes')
77c23f
+
77c23f
+    def test_small_target(self):
77c23f
+        self.do_test_target_size(self.image_len // 2)
77c23f
+
77c23f
+    def test_large_target(self):
77c23f
+        self.do_test_target_size(self.image_len * 2)
77c23f
+
77c23f
     test_large_cluster = None
77c23f
     test_image_not_found = None
77c23f
     test_small_buffer2 = None
77c23f
@@ -251,6 +294,8 @@ class TestSingleDriveZeroLength(TestSingleDrive):
77c23f
 
77c23f
 class TestSingleBlockdevZeroLength(TestSingleBlockdev):
77c23f
     image_len = 0
77c23f
+    test_small_target = None
77c23f
+    test_large_target = None
77c23f
 
77c23f
 class TestSingleDriveUnalignedLength(TestSingleDrive):
77c23f
     image_len = 1025 * 1024
77c23f
diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out
77c23f
index 2c448b4..3ea6aa4 100644
77c23f
--- a/tests/qemu-iotests/041.out
77c23f
+++ b/tests/qemu-iotests/041.out
77c23f
@@ -1,5 +1,5 @@
77c23f
-..........................................................................................
77c23f
+....................................................................................................
77c23f
 ----------------------------------------------------------------------
77c23f
-Ran 90 tests
77c23f
+Ran 100 tests
77c23f
 
77c23f
 OK
77c23f
-- 
77c23f
1.8.3.1
77c23f