yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-qemu-iotests-Test-commit-with-top-node-base-node.patch

ae23c9
From 8e6b5a2696e10066c65f047624c32e40ecd8ff8c Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Wed, 10 Oct 2018 13:50:55 +0100
ae23c9
Subject: [PATCH 5/5] qemu-iotests: Test commit with top-node/base-node
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20181010135055.3874-3-kwolf@redhat.com>
ae23c9
Patchwork-id: 82568
ae23c9
O-Subject: [RHEL-8 qemu-kvm PATCH 2/2] qemu-iotests: Test commit with top-node/base-node
ae23c9
Bugzilla: 1637970
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Fam Zheng <famz@redhat.com>
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
ae23c9
This adds some tests for block-commit with the new options top-node and
ae23c9
base-node (taking node names) instead of top and base (taking file
ae23c9
names).
ae23c9
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
(cherry picked from commit d57177a48fc604e5427921bf20b22ee0e6d578b3)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 tests/qemu-iotests/040     | 52 ++++++++++++++++++++++++++++++++++++++++++++--
ae23c9
 tests/qemu-iotests/040.out |  4 ++--
ae23c9
 2 files changed, 52 insertions(+), 4 deletions(-)
ae23c9
ae23c9
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
ae23c9
index 1beb5e6..1cb1cee 100755
ae23c9
--- a/tests/qemu-iotests/040
ae23c9
+++ b/tests/qemu-iotests/040
ae23c9
@@ -57,9 +57,12 @@ class ImageCommitTestCase(iotests.QMPTestCase):
ae23c9
         self.assert_no_active_block_jobs()
ae23c9
         self.vm.shutdown()
ae23c9
 
ae23c9
-    def run_commit_test(self, top, base, need_ready=False):
ae23c9
+    def run_commit_test(self, top, base, need_ready=False, node_names=False):
ae23c9
         self.assert_no_active_block_jobs()
ae23c9
-        result = self.vm.qmp('block-commit', device='drive0', top=top, base=base)
ae23c9
+        if node_names:
ae23c9
+            result = self.vm.qmp('block-commit', device='drive0', top_node=top, base_node=base)
ae23c9
+        else:
ae23c9
+            result = self.vm.qmp('block-commit', device='drive0', top=top, base=base)
ae23c9
         self.assert_qmp(result, 'return', {})
ae23c9
         self.wait_for_complete(need_ready)
ae23c9
 
ae23c9
@@ -101,6 +104,11 @@ class TestSingleDrive(ImageCommitTestCase):
ae23c9
         self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
ae23c9
         self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
ae23c9
 
ae23c9
+    def test_commit_node(self):
ae23c9
+        self.run_commit_test("mid", "base", node_names=True)
ae23c9
+        self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
ae23c9
+        self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
ae23c9
+
ae23c9
     def test_device_not_found(self):
ae23c9
         result = self.vm.qmp('block-commit', device='nonexistent', top='%s' % mid_img)
ae23c9
         self.assert_qmp(result, 'error/class', 'DeviceNotFound')
ae23c9
@@ -123,6 +131,30 @@ class TestSingleDrive(ImageCommitTestCase):
ae23c9
         self.assert_qmp(result, 'error/class', 'GenericError')
ae23c9
         self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found')
ae23c9
 
ae23c9
+    def test_top_node_invalid(self):
ae23c9
+        self.assert_no_active_block_jobs()
ae23c9
+        result = self.vm.qmp('block-commit', device='drive0', top_node='badfile', base_node='base')
ae23c9
+        self.assert_qmp(result, 'error/class', 'GenericError')
ae23c9
+        self.assert_qmp(result, 'error/desc', "Cannot find device= nor node_name=badfile")
ae23c9
+
ae23c9
+    def test_base_node_invalid(self):
ae23c9
+        self.assert_no_active_block_jobs()
ae23c9
+        result = self.vm.qmp('block-commit', device='drive0', top_node='mid', base_node='badfile')
ae23c9
+        self.assert_qmp(result, 'error/class', 'GenericError')
ae23c9
+        self.assert_qmp(result, 'error/desc', "Cannot find device= nor node_name=badfile")
ae23c9
+
ae23c9
+    def test_top_path_and_node(self):
ae23c9
+        self.assert_no_active_block_jobs()
ae23c9
+        result = self.vm.qmp('block-commit', device='drive0', top_node='mid', base_node='base', top='%s' % mid_img)
ae23c9
+        self.assert_qmp(result, 'error/class', 'GenericError')
ae23c9
+        self.assert_qmp(result, 'error/desc', "'top-node' and 'top' are mutually exclusive")
ae23c9
+
ae23c9
+    def test_base_path_and_node(self):
ae23c9
+        self.assert_no_active_block_jobs()
ae23c9
+        result = self.vm.qmp('block-commit', device='drive0', top_node='mid', base_node='base', base='%s' % backing_img)
ae23c9
+        self.assert_qmp(result, 'error/class', 'GenericError')
ae23c9
+        self.assert_qmp(result, 'error/desc', "'base-node' and 'base' are mutually exclusive")
ae23c9
+
ae23c9
     def test_top_is_active(self):
ae23c9
         self.run_commit_test(test_img, backing_img, need_ready=True)
ae23c9
         self.assertEqual(-1, qemu_io('-f', 'raw', '-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
ae23c9
@@ -139,6 +171,22 @@ class TestSingleDrive(ImageCommitTestCase):
ae23c9
         self.assert_qmp(result, 'error/class', 'GenericError')
ae23c9
         self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % mid_img)
ae23c9
 
ae23c9
+    def test_top_and_base_node_reversed(self):
ae23c9
+        self.assert_no_active_block_jobs()
ae23c9
+        result = self.vm.qmp('block-commit', device='drive0', top_node='base', base_node='top')
ae23c9
+        self.assert_qmp(result, 'error/class', 'GenericError')
ae23c9
+        self.assert_qmp(result, 'error/desc', "'top' is not in this backing file chain")
ae23c9
+
ae23c9
+    def test_top_node_in_wrong_chain(self):
ae23c9
+        self.assert_no_active_block_jobs()
ae23c9
+
ae23c9
+        result = self.vm.qmp('blockdev-add', driver='null-co', node_name='null')
ae23c9
+        self.assert_qmp(result, 'return', {})
ae23c9
+
ae23c9
+        result = self.vm.qmp('block-commit', device='drive0', top_node='null', base_node='base')
ae23c9
+        self.assert_qmp(result, 'error/class', 'GenericError')
ae23c9
+        self.assert_qmp(result, 'error/desc', "'null' is not in this backing file chain")
ae23c9
+
ae23c9
     # When the job is running on a BB that is automatically deleted on hot
ae23c9
     # unplug, the job is cancelled when the device disappears
ae23c9
     def test_hot_unplug(self):
ae23c9
diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out
ae23c9
index e20a75c..802ffaa 100644
ae23c9
--- a/tests/qemu-iotests/040.out
ae23c9
+++ b/tests/qemu-iotests/040.out
ae23c9
@@ -1,5 +1,5 @@
ae23c9
-.............................
ae23c9
+...........................................
ae23c9
 ----------------------------------------------------------------------
ae23c9
-Ran 29 tests
ae23c9
+Ran 43 tests
ae23c9
 
ae23c9
 OK
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9