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