From nobody Thu Dec 26 22:20:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489183610334914.1846810893464; Fri, 10 Mar 2017 14:06:50 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 48B3E82063D; Fri, 10 Mar 2017 22:06:49 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 4CB1982052A for ; Fri, 10 Mar 2017 22:06:23 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AM5ZAO039382 for ; Fri, 10 Mar 2017 17:06:22 -0500 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0a-001b2d01.pphosted.com with ESMTP id 293ry601ue-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 17:06:22 -0500 Received: from localhost by e24smtp03.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:06:19 -0300 Received: from d24relay02.br.ibm.com (9.18.232.42) by e24smtp03.br.ibm.com (10.172.0.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:06:17 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AM6G1P36372536 for ; Fri, 10 Mar 2017 19:06:16 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2AM6G5Z018145 for ; Fri, 10 Mar 2017 19:06:16 -0300 Received: from t440.ibm.com ([9.80.210.122]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2AM6BK7018086; Fri, 10 Mar 2017 19:06:14 -0300 X-Original-To: kimchi-devel@ovirt.org From: Lucio Correia To: Kimchi Devel Date: Fri, 10 Mar 2017 19:06:04 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> References: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17031022-0024-0000-0000-0000015CF4CA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031022-0025-0000-0000-0000162305C0 Message-Id: <1489183571-10933-2-git-send-email-luciojhc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703100171 Subject: [Kimchi-devel] [PATCH] [Kimchi 1/8] Do not hardcode default directories X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Do not hardcode default directories in storagepools and osinfo code and at the same time make those directories overwritable by tests. Signed-off-by: Lucio Correia --- model/storagepools.py | 5 +++-- osinfo.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/model/storagepools.py b/model/storagepools.py index e6f5e58..3bd7086 100644 --- a/model/storagepools.py +++ b/model/storagepools.py @@ -31,6 +31,7 @@ from wok.plugins.kimchi.config import config, get_kimchi_= version, kimchiPaths from wok.plugins.kimchi.model.config import CapabilitiesModel from wok.plugins.kimchi.model.host import DeviceModel from wok.plugins.kimchi.model.libvirtstoragepool import StoragePoolDef +from wok.plugins.kimchi.osinfo import get_default_pools from wok.plugins.kimchi.osinfo import defaults as tmpl_defaults from wok.plugins.kimchi.scan import Scanner from wok.plugins.kimchi.utils import pool_name_from_uri, is_s390x @@ -83,10 +84,10 @@ class StoragePoolsModel(object): =20 pools[default_pool] =3D {} if default_pool =3D=3D 'default': - pools[default_pool] =3D {'path': '/var/lib/libvirt/images'} + pools[default_pool] =3D {'path': get_default_pools()[default_p= ool]} =20 if config.get('kimchi', {}).get('create_iso_pool', False): - pools['ISO'] =3D {'path': '/var/lib/kimchi/isos'} + pools['ISO'] =3D {'path': get_default_pools()['ISO']} =20 conn =3D self.conn.get() for pool_name in pools: diff --git a/osinfo.py b/osinfo.py index 8de917f..60a454f 100644 --- a/osinfo.py +++ b/osinfo.py @@ -31,6 +31,11 @@ from wok.utils import wok_log from wok.exception import InvalidParameter from wok.plugins.kimchi.config import kimchiPaths =20 + +DEFAULT_POOLS =3D { + 'default': '/var/lib/libvirt/images', + 'ISO': '/var/lib/kimchi/isos', +} SUPPORTED_ARCHS =3D {'x86': ('i386', 'i686', 'x86_64'), 'power': ('ppc', 'ppc64'), 'ppc64le': ('ppc64le'), @@ -108,6 +113,10 @@ icon_available_distros =3D [icon[5:-4] for icon in glo= b.glob1('%s/images/' % PluginPaths('kimchi').ui_dir, 'icon-*.png')] =20 =20 +def get_default_pools(): + return DEFAULT_POOLS + + def _get_arch(): for arch, sub_archs in SUPPORTED_ARCHS.iteritems(): if os.uname()[4] in sub_archs: @@ -167,7 +176,8 @@ def _get_tmpl_defaults(): is_on_s390x =3D True if _get_arch() =3D=3D 's390x' else False =20 if is_on_s390x: - tmpl_defaults['storage']['disk.0']['path'] =3D '/var/lib/libvirt/i= mages/' + tmpl_defaults['storage']['disk.0']['path'] =3D \ + get_default_pools()['default'] del tmpl_defaults['storage']['disk.0']['pool'] =20 tmpl_defaults['processor']['vcpus'] =3D 1 --=20 2.7.4 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Thu Dec 26 22:20:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489183621863814.5578076411807; Fri, 10 Mar 2017 14:07:01 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id C442A82063D; Fri, 10 Mar 2017 22:06:59 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 40FA38205D8 for ; Fri, 10 Mar 2017 22:06:25 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AM52VV103041 for ; Fri, 10 Mar 2017 17:06:24 -0500 Received: from e24smtp05.br.ibm.com (e24smtp05.br.ibm.com [32.104.18.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 29431dkmku-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 17:06:24 -0500 Received: from localhost by e24smtp05.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:06:21 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) by e24smtp05.br.ibm.com (10.172.0.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:06:18 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AM6IU629556938 for ; Fri, 10 Mar 2017 19:06:18 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2AM6HrC018163 for ; Fri, 10 Mar 2017 19:06:17 -0300 Received: from t440.ibm.com ([9.80.210.122]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2AM6BK8018086; Fri, 10 Mar 2017 19:06:16 -0300 X-Original-To: kimchi-devel@ovirt.org From: Lucio Correia To: Kimchi Devel Date: Fri, 10 Mar 2017 19:06:05 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> References: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17031022-0032-0000-0000-00000547A71C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031022-0033-0000-0000-000011CBC5A4 Message-Id: <1489183571-10933-3-git-send-email-luciojhc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703100171 Subject: [Kimchi-devel] [PATCH] [Kimchi 2/8] Always use /var/tmp to store test files X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lucio Correia --- tests/test_model.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 95c9e08..e1b957c 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -31,6 +31,7 @@ import platform import pwd import re import shutil +import tempfile import time import unittest =20 @@ -65,8 +66,12 @@ invalid_repository_urls =3D ['www.fedora.org', # m= issing protocol 'http://www.fedora', # invalid domain name 'file:///home/foobar'] # invalid path =20 -TMP_DIR =3D '/var/lib/kimchi/tests/' +BASE_DIR =3D tempfile.mkdtemp(dir=3D'/var/tmp') +DEFAULT_DIR =3D os.path.join(BASE_DIR, 'libvirt/images') +ISO_DIR =3D os.path.join(BASE_DIR, 'kimchi/isos') +TMP_DIR =3D os.path.join(BASE_DIR, 'kimchi/tests') UBUNTU_ISO =3D TMP_DIR + 'ubuntu14.04.iso' + NON_NUMA_XML =3D """ non-numa-kimchi-test @@ -83,8 +88,10 @@ NON_NUMA_XML =3D """ =20 =20 def setUpModule(): - if not os.path.exists(TMP_DIR): - os.makedirs(TMP_DIR) + print __file__, "creating pools at", BASE_DIR + os.makedirs(DEFAULT_DIR) + os.makedirs(ISO_DIR) + os.makedirs(TMP_DIR) =20 iso_gen.construct_fake_iso(UBUNTU_ISO, True, '14.04', 'ubuntu') =20 @@ -98,7 +105,21 @@ def setUpModule(): =20 =20 def tearDownModule(): - shutil.rmtree(TMP_DIR) + # Model will create default and ISO storagepools at /var/tmp: delete t= hem. + conn =3D libvirt.open('qemu:///session') + + pool =3D conn.storagePoolLookupByName('default') + pool and pool.isActive() and pool.destroy() + pool and pool.undefine() + + pool =3D conn.storagePoolLookupByName('ISO') + pool and pool.isActive() and pool.destroy() + pool and pool.undefine() + + conn.close() + + # delete temporary directory contents + shutil.rmtree(BASE_DIR) =20 =20 def get_remote_iso_path(): --=20 2.7.4 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Thu Dec 26 22:20:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489183631083842.3951482663772; Fri, 10 Mar 2017 14:07:11 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 001FB82063D; Fri, 10 Mar 2017 22:07:08 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 5D01A8205D8 for ; Fri, 10 Mar 2017 22:06:26 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AM51vh103000 for ; Fri, 10 Mar 2017 17:06:26 -0500 Received: from e24smtp01.br.ibm.com (e24smtp01.br.ibm.com [32.104.18.85]) by mx0a-001b2d01.pphosted.com with ESMTP id 29431dkmm6-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 17:06:25 -0500 Received: from localhost by e24smtp01.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:06:22 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) by e24smtp01.br.ibm.com (10.172.0.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:06:21 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AM6Kwd28573758 for ; Fri, 10 Mar 2017 19:06:20 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2AM6JBs018203 for ; Fri, 10 Mar 2017 19:06:19 -0300 Received: from t440.ibm.com ([9.80.210.122]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2AM6BK9018086; Fri, 10 Mar 2017 19:06:18 -0300 X-Original-To: kimchi-devel@ovirt.org From: Lucio Correia To: Kimchi Devel Date: Fri, 10 Mar 2017 19:06:06 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> References: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17031022-1523-0000-0000-00000288ED6F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031022-1524-0000-0000-00002A1F05F2 Message-Id: <1489183571-10933-4-git-send-email-luciojhc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703100171 Subject: [Kimchi-devel] [PATCH] [Kimchi 3/8] Mock default storage pools and networks for testing X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lucio Correia --- tests/test_model.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_model.py b/tests/test_model.py index e1b957c..64085a0 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -86,8 +86,28 @@ NON_NUMA_XML =3D """ """ =20 +net_validate_patch =3D None +net_validate =3D None + =20 def setUpModule(): + global net_validate_patch + global net_validate + + # mock default networks + config =3D {'method.return_value': True} + net_validate_patch =3D mock.patch('wok.plugins.kimchi.model.templates.' + 'LibvirtVMTemplate._network_validate', + **config) + net_validate =3D net_validate_patch.start() + + # mock osinfo defaults + osinfo.defaults['networks'] =3D [] + osinfo.DEFAULT_POOLS =3D { + 'default': DEFAULT_DIR, + 'ISO': ISO_DIR, + } + print __file__, "creating pools at", BASE_DIR os.makedirs(DEFAULT_DIR) os.makedirs(ISO_DIR) @@ -105,6 +125,9 @@ def setUpModule(): =20 =20 def tearDownModule(): + global net_validate_patch + net_validate_patch.stop() + # Model will create default and ISO storagepools at /var/tmp: delete t= hem. conn =3D libvirt.open('qemu:///session') =20 --=20 2.7.4 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Thu Dec 26 22:20:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489183652563205.78373922699632; Fri, 10 Mar 2017 14:07:32 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 80F1782063D; Fri, 10 Mar 2017 22:07:30 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lists.ovirt.org (Postfix) with ESMTPS id 1E24D8205D8 for ; Fri, 10 Mar 2017 22:06:29 +0000 (UTC) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AM4E9I066803 for ; Fri, 10 Mar 2017 17:06:28 -0500 Received: from e24smtp01.br.ibm.com (e24smtp01.br.ibm.com [32.104.18.85]) by mx0a-001b2d01.pphosted.com with ESMTP id 293p3b67uk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 17:06:28 -0500 Received: from localhost by e24smtp01.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:06:25 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) by e24smtp01.br.ibm.com (10.172.0.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:06:22 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AM6M6I32047198 for ; Fri, 10 Mar 2017 19:06:22 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2AM6LlL018211 for ; Fri, 10 Mar 2017 19:06:21 -0300 Received: from t440.ibm.com ([9.80.210.122]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2AM6BKA018086; Fri, 10 Mar 2017 19:06:20 -0300 X-Original-To: kimchi-devel@ovirt.org From: Lucio Correia To: Kimchi Devel Date: Fri, 10 Mar 2017 19:06:07 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> References: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17031022-1523-0000-0000-00000288ED70 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031022-1524-0000-0000-00002A1F05F3 Message-Id: <1489183571-10933-5-git-send-email-luciojhc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703100171 Subject: [Kimchi-devel] [PATCH] [Kimchi 4/8] Use "qemu:///session" as test_model libvirt uri X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lucio Correia --- tests/test_model.py | 59 +++++++++++++++++++------------------------------= ---- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 64085a0..78c291e 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -164,16 +164,6 @@ def get_remote_iso_path(): return remote_path =20 =20 -def _setDiskPoolDefault(): - osinfo.defaults['disks'][0]['pool'] =3D { - 'name': '/plugins/kimchi/storagepools/default'} - - -def _setDiskPoolDefaultTest(): - osinfo.defaults['disks'][0]['pool'] =3D { - 'name': '/plugins/kimchi/storagepools/default-pool'} - - class ModelTests(unittest.TestCase): def setUp(self): self.tmp_store =3D '/tmp/kimchi-store-test' @@ -181,7 +171,7 @@ class ModelTests(unittest.TestCase): def tearDown(self): # FIXME: Tests using 'test:///default' URI should be moved to # test_rest or test_mockmodel to avoid overriding problems - LibvirtConnection._connections['test:///default'] =3D {} + LibvirtConnection._connections['qemu:///session'] =3D {} =20 if os.path.isfile(self.tmp_store): os.unlink(self.tmp_store) @@ -1120,7 +1110,7 @@ class ModelTests(unittest.TestCase): =20 def test_vm_memory_hotplug(self): config.set("authentication", "method", "pam") - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) orig_params =3D {'name': 'test', 'memory': {'current': 1024, 'maxmemory': 4096 @@ -1226,7 +1216,7 @@ class ModelTests(unittest.TestCase): @unittest.skipUnless(('ppc64' in os.uname()[4]), msg) def test_non_numa_vm_memory_hotplug(self): config.set("authentication", "method", "pam") - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) conn =3D inst.conn.get() vm =3D 'non-numa-kimchi-test' =20 @@ -1471,21 +1461,21 @@ class ModelTests(unittest.TestCase): xml =3D """\ \ """ - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual('2', inst.vm_get_vm_cpu_cores(xml)) =20 def test_get_vm_cpu_sockets(self): xml =3D """\ \ """ - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual('3', inst.vm_get_vm_cpu_sockets(xml)) =20 def test_get_vm_cpu_threads(self): xml =3D """\ \ """ - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual('8', inst.vm_get_vm_cpu_threads(xml)) =20 @mock.patch('wok.plugins.kimchi.model.vms.VMModel.has_topology') @@ -1502,7 +1492,7 @@ class ModelTests(unittest.TestCase): mock_has_topology.return_value =3D True expected_topology =3D {'sockets': 3, 'cores': 2, 'threads': 8} =20 - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual(expected_topology, inst.vm_get_vm_cpu_topology(FakeDom())) =20 @@ -1518,12 +1508,12 @@ class ModelTests(unittest.TestCase): mock_has_topology.return_value =3D False expected_topology =3D {} =20 - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual(expected_topology, inst.vm_get_vm_cpu_topology(FakeDom())) =20 def test_vm_cpu_hotplug_invalidparam_fail(self): - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 with self.assertRaisesRegexp(InvalidParameter, 'KCHCPUHOTP0001E'): params =3D {"cpu_info": {"vcpus": 1, 'maxvcpus': 4}} @@ -1541,7 +1531,7 @@ class ModelTests(unittest.TestCase): return 'fakedom' =20 mock_has_topology.return_value =3D False - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 with self.assertRaisesRegexp(InvalidParameter, 'KCHCPUINF0001E'): params =3D {"cpu_info": {"vcpus": 16}} @@ -1563,7 +1553,7 @@ class ModelTests(unittest.TestCase): mock_has_topology.return_value =3D True mock_topology.return_value =3D {'sockets': 3, 'cores': 2, 'threads= ': 8} =20 - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 with self.assertRaisesRegexp(InvalidParameter, 'KCHCPUINF0005E'): params =3D {"cpu_info": {"vcpus": 10}} @@ -1574,13 +1564,12 @@ class ModelTests(unittest.TestCase): def setVcpusFlags(self, vcpu, flags): raise libvirt.libvirtError('') =20 - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) with self.assertRaisesRegexp(OperationFailed, 'KCHCPUHOTP0002E'): inst.vm_update_cpu_live(FakeDom(), '') =20 def test_get_interfaces(self): - inst =3D model.Model('test:///default', - objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) expected_ifaces =3D netinfo.all_favored_interfaces() ifaces =3D inst.interfaces_get_list() self.assertEquals(len(expected_ifaces), len(ifaces)) @@ -1616,8 +1605,7 @@ class ModelTests(unittest.TestCase): time.sleep(2) cb("step 3 OK", params.get('result', True)) =20 - inst =3D model.Model('test:///default', - objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) taskid =3D AsyncTask('', quick_op, 'Hello').id inst.task_wait(taskid) self.assertEquals('finished', inst.task_lookup(taskid)['status']) @@ -1742,21 +1730,17 @@ class ModelTests(unittest.TestCase): self.assertEquals(original_vm, clone_vm) =20 def test_use_test_host(self): - inst =3D model.Model('test:///default', - objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: params =3D { 'name': 'test', 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}, - 'domain': 'test', + 'domain': 'kvm', 'arch': 'i686', 'disks': [] } =20 - _setDiskPoolDefaultTest() - rollback.prependDefer(_setDiskPoolDefault) - inst.templates_create(params) rollback.prependDefer(inst.template_delete, 'test') =20 @@ -1771,8 +1755,7 @@ class ModelTests(unittest.TestCase): self.assertTrue('kimchi-vm' in vms) =20 def test_get_distros(self): - inst =3D model.Model('test:///default', - objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) distros =3D inst.distros_get_list() for d in distros: distro =3D inst.distro_lookup(d) @@ -1814,7 +1797,7 @@ class ModelTests(unittest.TestCase): @unittest.skipUnless(_host_is_power(), 'Only required for Power hosts') def test_pci_hotplug_requires_usb_controller(self): config.set("authentication", "method", "pam") - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) tpl_params =3D {'name': 'test', 'memory': 1024, 'cdrom': UBUNTU_IS= O} inst.templates_create(tpl_params) =20 @@ -1913,7 +1896,7 @@ multifunction=3D'on'/> """ =20 def test_vmhostdev_is_hostdev_multifunction(self): - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 hostdev_multi_elem =3D objectify.fromstring( self.get_hostdev_multifunction_xml() @@ -1930,7 +1913,7 @@ multifunction=3D'on'/> ) =20 def test_vmhostdev_get_devices_same_addr(self): - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 root =3D objectify.fromstring(self.get_hostdevs_xml()) hostdevs =3D root.devices.hostdev @@ -1971,7 +1954,7 @@ multifunction=3D'on'/> =20 mock_conf_flag.return_value =3D '' =20 - inst =3D model.Model(None, objstore_loc=3Dself.tmp_store) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 root =3D objectify.fromstring(self.get_hostdevs_xml()) hostdevs =3D root.devices.hostdev --=20 2.7.4 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Thu Dec 26 22:20:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489183642364914.6147263440215; Fri, 10 Mar 2017 14:07:22 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 4120982063D; Fri, 10 Mar 2017 22:07:21 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 834598205D8 for ; Fri, 10 Mar 2017 22:06:28 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AM4DRI121412 for ; Fri, 10 Mar 2017 17:06:27 -0500 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0a-001b2d01.pphosted.com with ESMTP id 2941dwyh2b-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 17:06:27 -0500 Received: from localhost by e24smtp03.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:06:25 -0300 Received: from d24relay03.br.ibm.com (9.18.232.225) by e24smtp03.br.ibm.com (10.172.0.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:06:24 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AM6NYF34865320 for ; Fri, 10 Mar 2017 19:06:23 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2AM6NjI018218 for ; Fri, 10 Mar 2017 19:06:23 -0300 Received: from t440.ibm.com ([9.80.210.122]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2AM6BKB018086; Fri, 10 Mar 2017 19:06:22 -0300 X-Original-To: kimchi-devel@ovirt.org From: Lucio Correia To: Kimchi Devel Date: Fri, 10 Mar 2017 19:06:08 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> References: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable x-cbid: 17031022-0024-0000-0000-0000015CF4CD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031022-0025-0000-0000-0000162305C3 Message-Id: <1489183571-10933-6-git-send-email-luciojhc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703100171 Subject: [Kimchi-devel] [PATCH] [Kimchi 5/8] Remove 'run as root' requirement from some tests X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Lucio Correia --- tests/test_model.py | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 78c291e..8595862 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -381,11 +381,10 @@ class ModelTests(unittest.TestCase): info =3D inst.vm_lookup('kimchi-vm') self.assertEquals('running', info['state']) =20 - @unittest.skipUnless(utils.running_as_root() and - os.uname()[4] !=3D "s390x", 'Must be run as root') + @unittest.skipUnless(os.uname()[4] !=3D "s390x", 'Not applicable to s3= 90x') def test_vm_graphics(self): - inst =3D model.Model(objstore_loc=3Dself.tmp_store) - params =3D {'name': 'test', + inst =3D model.Model('qemu:///session', self.tmp_store) + params =3D {'name': 'test', 'domain': 'kvm', 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} inst.templates_create(params) with RollbackContext() as rollback: @@ -409,10 +408,9 @@ class ModelTests(unittest.TestCase): =20 inst.template_delete('test') =20 - @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_virtviewerfile_vmnotrunning(self): - inst =3D model.Model(objstore_loc=3Dself.tmp_store) - params =3D {'name': 'test', + inst =3D model.Model('qemu:///session', self.tmp_store) + params =3D {'name': 'test', 'domain': 'kvm', 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} inst.templates_create(params) =20 @@ -972,14 +970,14 @@ class ModelTests(unittest.TestCase): cur_cdrom_path =3D re.sub(":80/", '/', cdrom_info['path']) self.assertEquals(valid_remote_iso_path, cur_cdrom_path) =20 - @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_storage_provisioning(self): - inst =3D model.Model(objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: params =3D {'name': 'test', 'disks': [{'size': 1, 'pool': { 'name': '/plugins/kimchi/storagepools/default'}}], - 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} + 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}, + 'domain': 'kvm'} =20 inst.templates_create(params) rollback.prependDefer(inst.template_delete, 'test') @@ -1029,9 +1027,8 @@ class ModelTests(unittest.TestCase): xpath =3D "/domain/devices/disk[@device=3D'disk']/driver/@type" return xpath_get_text(xml, xpath)[0] =20 - @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_template_get_default_vol_format_from_conf(self): - inst =3D model.Model(objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: self._create_template_conf_with_disk_format('vmdk') @@ -1039,7 +1036,8 @@ class ModelTests(unittest.TestCase): =20 params =3D {'name': 'test', 'disks': [{'size': 1, 'pool': { 'name': '/plugins/kimchi/storagepools/default'}}], - 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} + 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}, + 'domain': 'kvm'} inst.templates_create(params) rollback.prependDefer(inst.template_delete, 'test') =20 @@ -1054,9 +1052,8 @@ class ModelTests(unittest.TestCase): ) self.assertEqual(created_disk_format, 'vmdk') =20 - @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_template_creates_user_defined_vol_format_instead_default(self= ): - inst =3D model.Model(objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 default_vol =3D 'vmdk' user_vol =3D 'raw' @@ -1064,7 +1061,7 @@ class ModelTests(unittest.TestCase): self._create_template_conf_with_disk_format(default_vol) rollback.prependDefer(self._restore_template_conf_file) =20 - params =3D {'name': 'test', 'disks': [{ + params =3D {'name': 'test', 'domain': 'kvm', 'disks': [{ 'size': 1, 'format': user_vol, 'pool': {'name': '/plugins/kimchi/storagepools/default'}}], 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} @@ -1083,9 +1080,8 @@ class ModelTests(unittest.TestCase): ) self.assertEqual(created_disk_format, user_vol) =20 - @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_template_uses_qcow2_format_if_no_user_or_default_defined(self= ): - inst =3D model.Model(objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: self._create_template_conf_with_disk_format(None) @@ -1093,7 +1089,8 @@ class ModelTests(unittest.TestCase): =20 params =3D {'name': 'test', 'disks': [{'size': 1, 'pool': { 'name': '/plugins/kimchi/storagepools/default'}}], - 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} + 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}, + 'domain': 'kvm'} inst.templates_create(params) rollback.prependDefer(inst.template_delete, 'test') =20 @@ -1659,12 +1656,11 @@ class ModelTests(unittest.TestCase): vms =3D inst.vms_get_list() self.assertFalse(u'k=C4=AB=D0=BC=D1=81h=C4=AB-=E2=88=A8=D0=BC'= in vms) =20 - @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_list_sorted(self): - inst =3D model.Model(objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: - params =3D {'name': 'test', 'disks': [], + params =3D {'name': 'test', 'disks': [], 'domain': 'kvm', 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} inst.templates_create(params) rollback.prependDefer(inst.template_delete, 'test') @@ -1765,10 +1761,9 @@ class ModelTests(unittest.TestCase): self.assertIn('os_arch', distro) self.assertIn('path', distro) =20 - @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_deep_scan(self): - inst =3D model.Model(None, - objstore_loc=3Dself.tmp_store) + inst =3D model.Model('qemu:///session', self.tmp_store) + with RollbackContext() as rollback: deep_path =3D os.path.join(TMP_DIR, 'deep-scan') subdir_path =3D os.path.join(deep_path, 'isos') --=20 2.7.4 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Thu Dec 26 22:20:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489183660603879.2408926297098; Fri, 10 Mar 2017 14:07:40 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id B305482063D; Fri, 10 Mar 2017 22:07:39 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id DAFA88205D8 for ; Fri, 10 Mar 2017 22:06:30 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AM4DrQ060348 for ; Fri, 10 Mar 2017 17:06:30 -0500 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0b-001b2d01.pphosted.com with ESMTP id 2942mnmfjd-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 17:06:29 -0500 Received: from localhost by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:06:28 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:06:26 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AM6PWa29556950 for ; Fri, 10 Mar 2017 19:06:25 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2AM6PhN018254 for ; Fri, 10 Mar 2017 19:06:25 -0300 Received: from t440.ibm.com ([9.80.210.122]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2AM6BKC018086; Fri, 10 Mar 2017 19:06:23 -0300 X-Original-To: kimchi-devel@ovirt.org From: Lucio Correia To: Kimchi Devel Date: Fri, 10 Mar 2017 19:06:09 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> References: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17031022-0028-0000-0000-0000019EA796 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031022-0029-0000-0000-0000149CC861 Message-Id: <1489183571-10933-7-git-send-email-luciojhc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703100171 Subject: [Kimchi-devel] [PATCH] [Kimchi 6/8] Skip tests that need to run as root X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lucio Correia --- tests/test_model.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 8595862..8f7f147 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -512,6 +512,7 @@ class ModelTests(unittest.TestCase): mock_handleVMOff.assert_called_once_with('kimchi-vm') mock_add_port.assert_called_once_with('kimchi-vm', '6660') =20 + @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') @mock.patch('wok.plugins.kimchi.model.virtviewerfile.run_command') def test_firewall_provider_firewallcmd(self, mock_run_cmd): mock_run_cmd.side_effect =3D [ @@ -530,6 +531,7 @@ class ModelTests(unittest.TestCase): mock.call(['firewall-cmd', '--add-port=3D5905/tcp']), mock.call(['firewall-cmd', '--remove-port=3D5905/tcp'])]) =20 + @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') @mock.patch('wok.plugins.kimchi.model.virtviewerfile.run_command') def test_firewall_provider_ufw(self, mock_run_cmd): mock_run_cmd.side_effect =3D [ @@ -549,6 +551,7 @@ class ModelTests(unittest.TestCase): mock.call(['ufw', 'allow', '5905/tcp']), mock.call(['ufw', 'deny', '5905/tcp'])]) =20 + @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') @mock.patch('wok.plugins.kimchi.model.virtviewerfile.run_command') def test_firewall_provider_iptables(self, mock_run_cmd): mock_run_cmd.side_effect =3D [ @@ -1105,6 +1108,7 @@ class ModelTests(unittest.TestCase): ) self.assertEqual(created_disk_format, 'qcow2') =20 + @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_memory_hotplug(self): config.set("authentication", "method", "pam") inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) @@ -1208,9 +1212,12 @@ class ModelTests(unittest.TestCase): self.assertRaises(InvalidOperation, inst.vm_update, 'kimchi-vm1', params) =20 + def _host_is_power(): + return platform.machine().startswith('ppc') + msg =3D "Memory hotplug in non-numa guests only for PowerPC arch." =20 - @unittest.skipUnless(('ppc64' in os.uname()[4]), msg) + @unittest.skipUnless(utils.running_as_root() and _host_is_power(), msg) def test_non_numa_vm_memory_hotplug(self): config.set("authentication", "method", "pam") inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) @@ -1254,6 +1261,7 @@ class ModelTests(unittest.TestCase): self.assertEquals(params['memory']['current'], inst.vm_lookup(vm)['memory']['current']) =20 + @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_edit(self): config.set("authentication", "method", "pam") inst =3D model.Model(None, @@ -1786,10 +1794,8 @@ class ModelTests(unittest.TestCase): volumes =3D inst.storagevolumes_get_list(args['name']) self.assertEquals(len(volumes), 2) =20 - def _host_is_power(): - return platform.machine().startswith('ppc') - - @unittest.skipUnless(_host_is_power(), 'Only required for Power hosts') + @unittest.skipUnless(utils.running_as_root() and _host_is_power(), + 'Only required for Power hosts') def test_pci_hotplug_requires_usb_controller(self): config.set("authentication", "method", "pam") inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) --=20 2.7.4 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Thu Dec 26 22:20:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489183670774637.1536810823512; Fri, 10 Mar 2017 14:07:50 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id E4AE182063D; Fri, 10 Mar 2017 22:07:49 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id EE5AC8205D8 for ; Fri, 10 Mar 2017 22:06:32 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AM4ESQ060360 for ; Fri, 10 Mar 2017 17:06:32 -0500 Received: from e24smtp03.br.ibm.com (e24smtp03.br.ibm.com [32.104.18.24]) by mx0b-001b2d01.pphosted.com with ESMTP id 2942mnmfkc-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 17:06:31 -0500 Received: from localhost by e24smtp03.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:06:29 -0300 Received: from d24relay03.br.ibm.com (9.18.232.225) by e24smtp03.br.ibm.com (10.172.0.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:06:28 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AM6RXe21692574 for ; Fri, 10 Mar 2017 19:06:27 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2AM6QUi018274 for ; Fri, 10 Mar 2017 19:06:26 -0300 Received: from t440.ibm.com ([9.80.210.122]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2AM6BKD018086; Fri, 10 Mar 2017 19:06:25 -0300 X-Original-To: kimchi-devel@ovirt.org From: Lucio Correia To: Kimchi Devel Date: Fri, 10 Mar 2017 19:06:10 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> References: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17031022-0024-0000-0000-0000015CF4D1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031022-0025-0000-0000-0000162305C7 Message-Id: <1489183571-10933-8-git-send-email-luciojhc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703100171 Subject: [Kimchi-devel] [PATCH] [Kimchi 7/8] Make test_use_test_host architecture independent X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lucio Correia --- tests/test_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_model.py b/tests/test_model.py index 8f7f147..4579ded 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -1741,7 +1741,7 @@ class ModelTests(unittest.TestCase): 'name': 'test', 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}, 'domain': 'kvm', - 'arch': 'i686', + 'arch': os.uname()[4], 'disks': [] } =20 --=20 2.7.4 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel From nobody Thu Dec 26 22:20:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) client-ip=66.187.230.42; envelope-from=kimchi-devel-bounces@ovirt.org; helo=lists.ovirt.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of ovirt.org designates 66.187.230.42 as permitted sender) smtp.mailfrom=kimchi-devel-bounces@ovirt.org; Return-Path: Received: from lists.ovirt.org (lists.phx.ovirt.org [66.187.230.42]) by mx.zohomail.com with SMTPS id 1489183681923254.8447457902421; Fri, 10 Mar 2017 14:08:01 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 15C7A8205D8; Fri, 10 Mar 2017 22:08:01 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id 462708205D8 for ; Fri, 10 Mar 2017 22:06:37 +0000 (UTC) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2AM4Gjn104634 for ; Fri, 10 Mar 2017 17:06:36 -0500 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0b-001b2d01.pphosted.com with ESMTP id 293f4vcmjx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 17:06:36 -0500 Received: from localhost by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 19:06:31 -0300 Received: from d24relay03.br.ibm.com (9.18.232.225) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 19:06:30 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.8.31.91]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2AM6TO031588542 for ; Fri, 10 Mar 2017 19:06:29 -0300 Received: from d24av01.br.ibm.com (localhost [127.0.0.1]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2AM6SnZ018299 for ; Fri, 10 Mar 2017 19:06:28 -0300 Received: from t440.ibm.com ([9.80.210.122]) by d24av01.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2AM6BKE018086; Fri, 10 Mar 2017 19:06:27 -0300 X-Original-To: kimchi-devel@ovirt.org From: Lucio Correia To: Kimchi Devel Date: Fri, 10 Mar 2017 19:06:11 -0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> References: <1489183571-10933-1-git-send-email-luciojhc@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable x-cbid: 17031022-0028-0000-0000-0000019EA799 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031022-0029-0000-0000-0000149CC863 Message-Id: <1489183571-10933-9-git-send-email-luciojhc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703100171 Subject: [Kimchi-devel] [PATCH] [Kimchi 8/8] Mock user probe functions X-BeenThere: kimchi-devel@ovirt.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: kimchi-devel-bounces@ovirt.org Errors-To: kimchi-devel-bounces@ovirt.org X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Lucio Correia --- tests/test_model.py | 237 +++++++++++++++++++++++++++++++++++++++++++++---= ---- 1 file changed, 208 insertions(+), 29 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 4579ded..11c6fab 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -176,7 +176,13 @@ class ModelTests(unittest.TestCase): if os.path.isfile(self.tmp_store): os.unlink(self.tmp_store) =20 - def test_vm_info(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_info(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('test:///default', self.tmp_store) vms =3D inst.vms_get_list() self.assertEquals(1, len(vms)) @@ -381,8 +387,14 @@ class ModelTests(unittest.TestCase): info =3D inst.vm_lookup('kimchi-vm') self.assertEquals('running', info['state']) =20 - @unittest.skipUnless(os.uname()[4] !=3D "s390x", 'Not applicable to s3= 90x') - def test_vm_graphics(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + @unittest.skipUnless(os.uname()[4] !=3D 's390x', "Not applicable to s3= 90x") + def test_vm_graphics(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) params =3D {'name': 'test', 'domain': 'kvm', 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} @@ -408,7 +420,14 @@ class ModelTests(unittest.TestCase): =20 inst.template_delete('test') =20 - def test_vm_virtviewerfile_vmnotrunning(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_virtviewerfile_vmnotrunning(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) params =3D {'name': 'test', 'domain': 'kvm', 'source_media': {'type': 'disk', 'path': UBUNTU_ISO}} @@ -973,7 +992,14 @@ class ModelTests(unittest.TestCase): cur_cdrom_path =3D re.sub(":80/", '/', cdrom_info['path']) self.assertEquals(valid_remote_iso_path, cur_cdrom_path) =20 - def test_vm_storage_provisioning(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_storage_provisioning(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1030,7 +1056,15 @@ class ModelTests(unittest.TestCase): xpath =3D "/domain/devices/disk[@device=3D'disk']/driver/@type" return xpath_get_text(xml, xpath)[0] =20 - def test_template_get_default_vol_format_from_conf(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_template_get_default_vol_format_from_conf(self, + mock_probe_file_per= m, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1055,7 +1089,14 @@ class ModelTests(unittest.TestCase): ) self.assertEqual(created_disk_format, 'vmdk') =20 - def test_template_creates_user_defined_vol_format_instead_default(self= ): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_template_creates_user_defined_vol_format_instead_default( + self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 default_vol =3D 'vmdk' @@ -1083,7 +1124,14 @@ class ModelTests(unittest.TestCase): ) self.assertEqual(created_disk_format, user_vol) =20 - def test_template_uses_qcow2_format_if_no_user_or_default_defined(self= ): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_template_uses_qcow2_format_if_no_user_or_default_defined( + self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1218,7 +1266,14 @@ class ModelTests(unittest.TestCase): msg =3D "Memory hotplug in non-numa guests only for PowerPC arch." =20 @unittest.skipUnless(utils.running_as_root() and _host_is_power(), msg) - def test_non_numa_vm_memory_hotplug(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_non_numa_vm_memory_hotplug(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + config.set("authentication", "method", "pam") inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) conn =3D inst.conn.get() @@ -1462,29 +1517,51 @@ class ModelTests(unittest.TestCase): inst.vm_update(u'=D0=BFe=CF=89-=E2=88=A8=D0=BC', {"bootmenu": = False}) self.assertEquals("no", inst.vm_lookup(u'=D0=BFe=CF=89-=E2=88= =A8=D0=BC')['bootmenu']) =20 - def test_get_vm_cpu_cores(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_vm_cpu_cores(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + xml =3D """\ \ """ inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual('2', inst.vm_get_vm_cpu_cores(xml)) =20 - def test_get_vm_cpu_sockets(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_vm_cpu_sockets(self, mock_probe_file_perm, mock_probe_use= r): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + xml =3D """\ \ """ inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual('3', inst.vm_get_vm_cpu_sockets(xml)) =20 - def test_get_vm_cpu_threads(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_vm_cpu_threads(self, mock_probe_file_perm, mock_probe_use= r): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + xml =3D """\ \ """ inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) self.assertEqual('8', inst.vm_get_vm_cpu_threads(xml)) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.has_topology') - def test_get_vm_cpu_topology(self, mock_has_topology): + def test_get_vm_cpu_topology(self, mock_has_topology, mock_probe_file_= perm, + mock_probe_user): class FakeDom(): def XMLDesc(self, flag): return """\ @@ -1494,6 +1571,8 @@ class ModelTests(unittest.TestCase): def name(self): return 'fakedom' =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_has_topology.return_value =3D True expected_topology =3D {'sockets': 3, 'cores': 2, 'threads': 8} =20 @@ -1501,8 +1580,12 @@ class ModelTests(unittest.TestCase): self.assertEqual(expected_topology, inst.vm_get_vm_cpu_topology(FakeDom())) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.has_topology') - def test_get_vm_cpu_topology_blank(self, mock_has_topology): + def test_get_vm_cpu_topology_blank(self, mock_has_topology, + mock_probe_file_perm, mock_probe_us= er): class FakeDom(): def XMLDesc(self, flag): return """""" @@ -1510,6 +1593,8 @@ class ModelTests(unittest.TestCase): def name(self): return 'fakedom' =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_has_topology.return_value =3D False expected_topology =3D {} =20 @@ -1517,15 +1602,27 @@ class ModelTests(unittest.TestCase): self.assertEqual(expected_topology, inst.vm_get_vm_cpu_topology(FakeDom())) =20 - def test_vm_cpu_hotplug_invalidparam_fail(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_cpu_hotplug_invalidparam_fail(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 with self.assertRaisesRegexp(InvalidParameter, 'KCHCPUHOTP0001E'): params =3D {"cpu_info": {"vcpus": 1, 'maxvcpus': 4}} inst.vm_cpu_hotplug_precheck('', params) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.has_topology') - def test_vm_cpu_hotplug_abovemax_fail(self, mock_has_topology): + def test_vm_cpu_hotplug_abovemax_fail(self, mock_has_topology, + mock_probe_file_perm, + mock_probe_user): class FakeDom(): def XMLDesc(self, flag): return """\ @@ -1535,6 +1632,8 @@ class ModelTests(unittest.TestCase): def name(self): return 'fakedom' =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_has_topology.return_value =3D False inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 @@ -1542,10 +1641,15 @@ class ModelTests(unittest.TestCase): params =3D {"cpu_info": {"vcpus": 16}} inst.vm_cpu_hotplug_precheck(FakeDom(), params) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.has_topology') @mock.patch('wok.plugins.kimchi.model.vms.VMModel.get_vm_cpu_topology') def test_vm_cpu_hotplug_topology_mismatch_fail(self, mock_topology, - mock_has_topology): + mock_has_topology, + mock_probe_file_perm, + mock_probe_user): class FakeDom(): def XMLDesc(self, flag): return """\ @@ -1555,6 +1659,8 @@ class ModelTests(unittest.TestCase): def name(self): return 'fakedom' =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_has_topology.return_value =3D True mock_topology.return_value =3D {'sockets': 3, 'cores': 2, 'threads= ': 8} =20 @@ -1564,16 +1670,28 @@ class ModelTests(unittest.TestCase): params =3D {"cpu_info": {"vcpus": 10}} inst.vm_cpu_hotplug_precheck(FakeDom(), params) =20 - def test_vm_cpu_hotplug_error(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_cpu_hotplug_error(self, mock_probe_file_perm, mock_probe_u= ser): class FakeDom(): def setVcpusFlags(self, vcpu, flags): raise libvirt.libvirtError('') =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) with self.assertRaisesRegexp(OperationFailed, 'KCHCPUHOTP0002E'): inst.vm_update_cpu_live(FakeDom(), '') =20 - def test_get_interfaces(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_interfaces(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) expected_ifaces =3D netinfo.all_favored_interfaces() ifaces =3D inst.interfaces_get_list() @@ -1586,7 +1704,10 @@ class ModelTests(unittest.TestCase): self.assertIn('ipaddr', iface) self.assertIn('netmask', iface) =20 - def test_async_tasks(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_async_tasks(self, mock_probe_file_perm, mock_probe_user): class task_except(Exception): pass =20 @@ -1610,6 +1731,9 @@ class ModelTests(unittest.TestCase): time.sleep(2) cb("step 3 OK", params.get('result', True)) =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) taskid =3D AsyncTask('', quick_op, 'Hello').id inst.task_wait(taskid) @@ -1664,7 +1788,13 @@ class ModelTests(unittest.TestCase): vms =3D inst.vms_get_list() self.assertFalse(u'k=C4=AB=D0=BC=D1=81h=C4=AB-=E2=88=A8=D0=BC'= in vms) =20 - def test_vm_list_sorted(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_list_sorted(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1683,7 +1813,13 @@ class ModelTests(unittest.TestCase): =20 self.assertEquals(vms, sorted(vms, key=3Dunicode.lower)) =20 - def test_vm_clone(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vm_clone(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('test:///default', objstore_loc=3Dself.tmp_st= ore) =20 all_vm_names =3D inst.vms_get_list() @@ -1733,7 +1869,13 @@ class ModelTests(unittest.TestCase): # (and removed) above (i.e. 'name' and 'uuid') self.assertEquals(original_vm, clone_vm) =20 - def test_use_test_host(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_use_test_host(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1758,7 +1900,13 @@ class ModelTests(unittest.TestCase): =20 self.assertTrue('kimchi-vm' in vms) =20 - def test_get_distros(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_get_distros(self, mock_probe_file_perm, mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model('qemu:///session', self.tmp_store) distros =3D inst.distros_get_list() for d in distros: @@ -1769,7 +1917,10 @@ class ModelTests(unittest.TestCase): self.assertIn('os_arch', distro) self.assertIn('path', distro) =20 - def test_deep_scan(self): + @mock.patch('wok.plugins.kimchi.model.storagevolumes.UserTests.probe_u= ser') + def test_deep_scan(self, mock_probe_user): + mock_probe_user.return_value =3D '' + inst =3D model.Model('qemu:///session', self.tmp_store) =20 with RollbackContext() as rollback: @@ -1796,7 +1947,14 @@ class ModelTests(unittest.TestCase): =20 @unittest.skipUnless(utils.running_as_root() and _host_is_power(), 'Only required for Power hosts') - def test_pci_hotplug_requires_usb_controller(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_pci_hotplug_requires_usb_controller(self, mock_probe_file_per= m, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + config.set("authentication", "method", "pam") inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) tpl_params =3D {'name': 'test', 'memory': 1024, 'cdrom': UBUNTU_IS= O} @@ -1896,7 +2054,14 @@ multifunction=3D'on'/> """ =20 - def test_vmhostdev_is_hostdev_multifunction(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vmhostdev_is_hostdev_multifunction(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 hostdev_multi_elem =3D objectify.fromstring( @@ -1913,7 +2078,14 @@ multifunction=3D'on'/> inst.vmhostdev_is_hostdev_multifunction(hostdev_nomulti_elem) ) =20 - def test_vmhostdev_get_devices_same_addr(self): + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') + def test_vmhostdev_get_devices_same_addr(self, mock_probe_file_perm, + mock_probe_user): + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) + inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) =20 root =3D objectify.fromstring(self.get_hostdevs_xml()) @@ -1947,12 +2119,19 @@ multifunction=3D'on'/> [ET.tostring(nomatch_elem)] ) =20 + @mock.patch('wok.plugins.kimchi.model.templates.UserTests.probe_user') + @mock.patch('wok.plugins.kimchi.model.templates.' + 'probe_file_permission_as_user') @mock.patch('wok.plugins.kimchi.model.vmhostdevs.get_vm_config_flag') - def test_vmhostdev_unplug_multifunction_pci(self, mock_conf_flag): + def test_vmhostdev_unplug_multifunction_pci(self, mock_conf_flag, + mock_probe_file_perm, + mock_probe_user): class FakeDom(): def detachDeviceFlags(self, xml, config_flag): pass =20 + mock_probe_user.return_value =3D '' + mock_probe_file_perm.return_value =3D (True, None) mock_conf_flag.return_value =3D '' =20 inst =3D model.Model("qemu:///session", objstore_loc=3Dself.tmp_st= ore) --=20 2.7.4 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel