From patchwork Thu Oct 6 13:02:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9364787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3EBDE6075E for ; Thu, 6 Oct 2016 13:22:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FCC7286A7 for ; Thu, 6 Oct 2016 13:22:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2260B28FE2; Thu, 6 Oct 2016 13:22:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E73328F81 for ; Thu, 6 Oct 2016 13:22:44 +0000 (UTC) Received: from localhost ([::1]:56069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs8dH-0005MW-E5 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 06 Oct 2016 09:22:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs8Km-0005pF-VE for qemu-devel@nongnu.org; Thu, 06 Oct 2016 09:03:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bs8Kh-0001BH-DE for qemu-devel@nongnu.org; Thu, 06 Oct 2016 09:03:35 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:63667 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs8Kg-0001Ar-Th; Thu, 06 Oct 2016 09:03:31 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CKBQCgSvZX/5tjdVtdHAEBBAEBCgEBgz0BAQEBAR5XfKMPAQEFAYEWjCqFd4QaHoYCAoF/OxEBAgEBAQEBAQFeJ4RiAgR5ED8SPBsZiFIBvmEBMYVygk+MdgWIO4V/dIpRhiiDBIZPgjyNOEmQLTQgPwUHghmCRG+IQAEBAQ X-IPAS-Result: A2CKBQCgSvZX/5tjdVtdHAEBBAEBCgEBgz0BAQEBAR5XfKMPAQEFAYEWjCqFd4QaHoYCAoF/OxEBAgEBAQEBAQFeJ4RiAgR5ED8SPBsZiFIBvmEBMYVygk+MdgWIO4V/dIpRhiiDBIZPgjyNOEmQLTQgPwUHghmCRG+IQAEBAQ X-IronPort-AV: E=Sophos;i="5.31,454,1473112800"; d="scan'208";a="195926243" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 06 Oct 2016 15:03:29 +0200 Received: from a88-114-146-170.elisa-laajakaista.fi ([88.114.146.170] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1bs8Kf-0001gE-2D; Thu, 06 Oct 2016 15:03:29 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bs8KH-0007YA-Ny; Thu, 06 Oct 2016 16:03:05 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 6 Oct 2016 16:02:58 +0300 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Subject: [Qemu-devel] [PATCH v10 15/16] qemu-iotests: Add iotests.supports_quorum() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP There's many tests that need Quorum support in order to run. At the moment each test implements its own check to see if Quorum is enabled. This patch centralizes all those checks in a new function called iotests.supports_quorum(). Signed-off-by: Alberto Garcia --- tests/qemu-iotests/041 | 27 ++++++++++++--------------- tests/qemu-iotests/139 | 3 ++- tests/qemu-iotests/iotests.py | 5 ++++- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index d1e1ad8..b4f3748 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -761,9 +761,6 @@ class TestRepairQuorum(iotests.QMPTestCase): image_len = 1 * 1024 * 1024 # MB IMAGES = [ quorum_img1, quorum_img2, quorum_img3 ] - def has_quorum(self): - return 'quorum' in iotests.qemu_img_pipe('--help') - def setUp(self): self.vm = iotests.VM() @@ -784,7 +781,7 @@ class TestRepairQuorum(iotests.QMPTestCase): #assemble the quorum block device from the individual files args = { "options" : { "driver": "quorum", "node-name": "quorum0", "vote-threshold": 2, "children": [ "img0", "img1", "img2" ] } } - if self.has_quorum(): + if iotests.supports_quorum(): result = self.vm.qmp("blockdev-add", **args) self.assert_qmp(result, 'return', {}) @@ -799,7 +796,7 @@ class TestRepairQuorum(iotests.QMPTestCase): pass def test_complete(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return self.assert_no_active_block_jobs() @@ -818,7 +815,7 @@ class TestRepairQuorum(iotests.QMPTestCase): 'target image does not match source after mirroring') def test_cancel(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return self.assert_no_active_block_jobs() @@ -835,7 +832,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.vm.shutdown() def test_cancel_after_ready(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return self.assert_no_active_block_jobs() @@ -854,7 +851,7 @@ class TestRepairQuorum(iotests.QMPTestCase): 'target image does not match source after mirroring') def test_pause(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return self.assert_no_active_block_jobs() @@ -884,7 +881,7 @@ class TestRepairQuorum(iotests.QMPTestCase): 'target image does not match source after mirroring') def test_medium_not_found(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return if iotests.qemu_default_machine != 'pc': @@ -898,7 +895,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_image_not_found(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', @@ -908,7 +905,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_device_not_found(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return result = self.vm.qmp('drive-mirror', job_id='job0', @@ -919,7 +916,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_wrong_sync_mode(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return result = self.vm.qmp('drive-mirror', device='quorum0', job_id='job0', @@ -929,7 +926,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_no_node_name(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', @@ -938,7 +935,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_nonexistent_replaces(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', @@ -947,7 +944,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_qmp(result, 'error/class', 'GenericError') def test_after_a_quorum_snapshot(self): - if not self.has_quorum(): + if not iotests.supports_quorum(): return result = self.vm.qmp('blockdev-snapshot-sync', node_name='img1', diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139 index 47a4c26..376b16d 100644 --- a/tests/qemu-iotests/139 +++ b/tests/qemu-iotests/139 @@ -336,8 +336,9 @@ class TestBlockdevDel(iotests.QMPTestCase): self.checkBlockDriverState('node1', False) def testQuorum(self): - if not 'quorum' in iotests.qemu_img_pipe('--help'): + if not iotests.supports_quorum(): return + self.addQuorum('quorum0', 'node0', 'node1') # We cannot remove the children of a Quorum device self.delBlockDriverState('node0', expect_error = True) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 3329bc1..ef63ee4 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -318,9 +318,12 @@ def verify_platform(supported_oses=['linux']): if True not in [sys.platform.startswith(x) for x in supported_oses]: notrun('not suitable for this OS: %s' % sys.platform) +def supports_quorum(): + return 'quorum' in qemu_img_pipe('--help') + def verify_quorum(): '''Skip test suite if quorum support is not available''' - if 'quorum' not in qemu_img_pipe('--help'): + if not supports_quorum(): notrun('quorum support missing') def main(supported_fmts=[], supported_oses=['linux']):