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