[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/19] qemu-iotests: 041: More robust assertion on qu
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 16/19] qemu-iotests: 041: More robust assertion on quorum node |
Date: |
Fri, 15 Apr 2016 19:02:19 +0200 |
From: Fam Zheng <address@hidden>
Block nodes are now assigned names automatically, therefore the test
case is fragile in using fixed indices in result. Introduce a method in
iotests.py and do the matching more sensibly.
Signed-off-by: Fam Zheng <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
tests/qemu-iotests/041 | 12 ++++--------
tests/qemu-iotests/iotests.py | 14 ++++++++++++++
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index c7da95d..b1c542f 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -810,8 +810,7 @@ class TestRepairQuorum(iotests.QMPTestCase):
self.assert_qmp(result, 'return', {})
self.complete_and_wait(drive="quorum0")
- result = self.vm.qmp('query-named-block-nodes')
- self.assert_qmp(result, 'return[0]/file', quorum_repair_img)
+ self.assert_has_block_node("repair0", quorum_repair_img)
# TODO: a better test requiring some QEMU infrastructure will be added
# to check that this file is really driven by quorum
self.vm.shutdown()
@@ -833,8 +832,7 @@ class TestRepairQuorum(iotests.QMPTestCase):
self.cancel_and_wait(drive="quorum0", force=True)
# here we check that the last registered quorum file has not been
# swapped out and unref
- result = self.vm.qmp('query-named-block-nodes')
- self.assert_qmp(result, 'return[1]/file', quorum_img3)
+ self.assert_has_block_node(None, quorum_img3)
self.vm.shutdown()
def test_cancel_after_ready(self):
@@ -850,10 +848,9 @@ class TestRepairQuorum(iotests.QMPTestCase):
self.assert_qmp(result, 'return', {})
self.wait_ready_and_cancel(drive="quorum0")
- result = self.vm.qmp('query-named-block-nodes')
# here we check that the last registered quorum file has not been
# swapped out and unref
- self.assert_qmp(result, 'return[1]/file', quorum_img3)
+ self.assert_has_block_node(None, quorum_img3)
self.vm.shutdown()
self.assertTrue(iotests.compare_images(quorum_img2, quorum_repair_img),
'target image does not match source after mirroring')
@@ -974,8 +971,7 @@ class TestRepairQuorum(iotests.QMPTestCase):
self.assert_qmp(result, 'return', {})
self.complete_and_wait(drive="quorum0")
- result = self.vm.qmp('query-named-block-nodes')
- self.assert_qmp(result, 'return[0]/file', quorum_repair_img)
+ self.assert_has_block_node("repair0", quorum_repair_img)
# TODO: a better test requiring some QEMU infrastructure will be added
# to check that this file is really driven by quorum
self.vm.shutdown()
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 0c0b533..d9ef60e 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -348,6 +348,20 @@ class QMPTestCase(unittest.TestCase):
result = self.vm.qmp('query-block-jobs')
self.assert_qmp(result, 'return', [])
+ def assert_has_block_node(self, node_name=None, file_name=None):
+ """Issue a query-named-block-nodes and assert node_name and/or
+ file_name is present in the result"""
+ def check_equal_or_none(a, b):
+ return a == None or b == None or a == b
+ assert node_name or file_name
+ result = self.vm.qmp('query-named-block-nodes')
+ for x in result["return"]:
+ if check_equal_or_none(x.get("node-name"), node_name) and \
+ check_equal_or_none(x.get("file"), file_name):
+ return
+ self.assertTrue(False, "Cannot find %s %s in result:\n%s" % \
+ (node_name, file_name, result))
+
def cancel_and_wait(self, drive='drive0', force=False, resume=False):
'''Cancel a block job and wait for it to finish, returning the event'''
result = self.vm.qmp('block-job-cancel', device=drive, force=force)
--
1.8.3.1
- [Qemu-devel] [PULL 04/19] vpc: use current_size field for XenServer VHD images, (continued)
- [Qemu-devel] [PULL 04/19] vpc: use current_size field for XenServer VHD images, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 01/19] qemu-io: Support 'aio_write -z', Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 08/19] block/vpc: set errp in vpc_open, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 05/19] block/vpc: use current_size field for XenConverter VHD images, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 10/19] block: Don't ignore flags in blk_{, co, aio}_write_zeroes(), Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 11/19] Fix pflash migration, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 12/19] qemu-iotests: drop unused _within_tolerance() filter, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 13/19] qemu-iotests: common.rc: drop unused _do(), Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 09/19] block/vpc: update comments to be compliant w/coding guidelines, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 19/19] nbd: Don't kill server on client that doesn't request TLS, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 16/19] qemu-iotests: 041: More robust assertion on quorum node,
Kevin Wolf <=
- [Qemu-devel] [PULL 14/19] qemu-iotests: tests: do not set unused tmp variable, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 15/19] qemu-iotests: place valgrind log file in scratch dir, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 17/19] nbd: Don't fail handshake on NBD_OPT_LIST descriptions, Kevin Wolf, 2016/04/15
- [Qemu-devel] [PULL 18/19] nbd: fix assert() on qemu-nbd stop, Kevin Wolf, 2016/04/15
- Re: [Qemu-devel] [PULL 00/19] Block layer patches for 2.6.0-rc3, Peter Maydell, 2016/04/18