From nobody Thu Oct 31 00:17:59 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 1489188067357777.2618469601775; Fri, 10 Mar 2017 15:21:07 -0800 (PST) Received: from lists.phx.ovirt.org (localhost [127.0.0.1]) by lists.ovirt.org (Postfix) with ESMTP id 57069820616; Fri, 10 Mar 2017 23:21:06 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lists.ovirt.org (Postfix) with ESMTPS id C753E8204B4 for ; Fri, 10 Mar 2017 23:20:20 +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 v2ANIr5S124706 for ; Fri, 10 Mar 2017 18:20:20 -0500 Received: from e24smtp02.br.ibm.com (e24smtp02.br.ibm.com [32.104.18.86]) by mx0a-001b2d01.pphosted.com with ESMTP id 2941dx1muy-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Mar 2017 18:20:19 -0500 Received: from localhost by e24smtp02.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Mar 2017 20:20:18 -0300 Received: from d24relay03.br.ibm.com (9.18.232.225) by e24smtp02.br.ibm.com (10.172.0.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Mar 2017 20:20:16 -0300 Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.8.31.93]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2ANKBeT33554478 for ; Fri, 10 Mar 2017 20:20:16 -0300 Received: from d24av02.br.ibm.com (localhost [127.0.0.1]) by d24av02.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v2ANJuwt029288 for ; Fri, 10 Mar 2017 20:19:56 -0300 Received: from jarvis.ibmmodules.com ([9.80.203.207]) by d24av02.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v2ANJmdb029204 for ; Fri, 10 Mar 2017 20:19:55 -0300 X-Original-To: kimchi-devel@ovirt.org From: Ramon Medeiros To: Kimchi Devel Date: Fri, 10 Mar 2017 20:19:36 -0300 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170310231936.19434-1-ramonn@linux.vnet.ibm.com> References: <20170310231936.19434-1-ramonn@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable x-cbid: 17031023-0020-0000-0000-00000290EFDB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031023-0021-0000-0000-000030AD06A8 Message-Id: <20170310231936.19434-5-ramonn@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-10_17:, , 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-1703100182 Subject: [Kimchi-devel] [PATCH 4/4] Add tests to verify if cache and io of a disk can be changed 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 Tests run both on update and template creation Signed-off-by: Ramon Medeiros --- tests/test_rest.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/tests/test_rest.py b/tests/test_rest.py index 852e4bd..a704283 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -151,8 +151,17 @@ class RestTests(unittest.TestCase): self.assertEquals(200, resp.status) =20 def test_edit_vm(self): + disks =3D [ + {'index': 0, 'size': 10, 'format': 'qcow2', + 'pool': {"name": "/plugins/kimchi/storagepools/default-pool"}= }, + {'index': 1, 'size': 10, 'format': 'qcow2', 'io': 'threads', + 'cache': 'unsafe', 'bus': 'scsi', + 'pool': {"name": "/plugins/kimchi/storagepools/default-pool"}= }] + req =3D json.dumps({'name': 'test', - 'source_media': {'type': 'disk', 'path': fake_is= o}}) + 'source_media': {'type': 'disk', 'path': fake_is= o}, + 'disks': disks}) + resp =3D self.request('/plugins/kimchi/templates', req, 'POST') self.assertEquals(201, resp.status) =20 @@ -166,6 +175,23 @@ class RestTests(unittest.TestCase): vm =3D json.loads(self.request('/plugins/kimchi/vms/vm-1').read()) self.assertEquals('vm-1', vm['name']) =20 + # test vm storage + storages =3D json.loads( + self.request('/plugins/kimchi/vms/vm-1/storages').read()) + self.assertEquals(len(storages), 3) + + # test sdb disk + resp =3D self.request('/plugins/kimchi/vms/vm-1/storages/sdb', 'GE= T') + self.assertEquals(resp.status, 200) + scsi_disk =3D json.loads(resp.read()) + self.assertEquals(scsi_disk['cache'], 'unsafe') + self.assertEquals(scsi_disk['io'], 'threads') + + # remove sdb disk + resp =3D self.request('/plugins/kimchi/vms/vm-1/storages/sdb', + '', 'DELETE') + self.assertEquals(resp.status, 204) + req =3D json.dumps({'cpu_info': {'maxvcpus': 5, 'vcpus': 3}}) resp =3D self.request('/plugins/kimchi/vms/vm-1', req, 'PUT') self.assertEquals(200, resp.status) @@ -330,6 +356,34 @@ class RestTests(unittest.TestCase): resp =3D self.request('/plugins/kimchi/vms/=E2=88=A8=D0=BC-=D1=86= =D1=80d=CE=B1t=D0=B5d', req, 'PUT') self.assertEquals(400, resp.status) =20 + # add volume as scsi + mock_base =3D '/tmp/mock.img' + os.system("qemu-img create -f qcow2 %s 100M" % mock_base) + req =3D json.dumps({'type': 'disk', + 'path': mock_base, + 'bus': 'scsi'}) + resp =3D self.request('/plugins/kimchi/vms/=E2=88=A8=D0=BC-=D1=86= =D1=80d=CE=B1t=D0=B5d/storages', + req, 'POST') + self.assertEquals(201, resp.status) + resp =3D json.loads(resp.read()) + self.assertEquals("scsi", resp["bus"]) + dev =3D resp["dev"] + + # change io/cache + req =3D json.dumps({"io": "threads", "cache": "unsafe"}) + resp =3D self.request('/plugins/kimchi/vms/=E2=88=A8=D0=BC-=D1=86= =D1=80d=CE=B1t=D0=B5d/storages/' + + str(dev), req, 'PUT') + self.assertEquals(200, resp.status) + resp =3D json.loads(resp.read()) + self.assertEquals('threads', resp['io']) + self.assertEquals('unsafe', resp['cache']) + + # remove disk + resp =3D self.request('/plugins/kimchi/vms/=E2=88=A8=D0=BC-=D1=86= =D1=80d=CE=B1t=D0=B5d/storages/' + + str(dev), req, 'DELETE') + os.system("rm -rf " + mock_base) + self.assertEquals(204, resp.status) + def test_vm_lifecycle(self): # Create a Template req =3D json.dumps({'name': 'test', --=20 2.9.3 _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel