From nobody Thu May 2 17:16:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1625073150; cv=none; d=zohomail.com; s=zohoarc; b=dQrgrzk70BCuVxWO3tL7UTRNlsUNiXpiNtBCTtnpp2dDGhBMaGCeY/P5aWnhFcpGSEEpXXnif0l8YUKIeCXY7vpuClF64ar8x2SvvQcorWhV+u0Izxqgyv+S+jJoyeSNnyqvPZ3rRZxjfDLfKJ8ul/AeX//Z8BYn2GhOqpmZPGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625073150; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dnVHAjjD+hrf0VY1woBC5OwILcgU9CKidsf3FVMWO5o=; b=Rs8eWFSeEoMNl8rv0OmOzkUHB8SdIPn78wEy6o1JFjZsnBtSHpHdU+swNkSXcgNun5DDVNyjcfBdLd75J3+jXrNLK8FCXWFdZOyIzO3hlwVDcVB3bTq1SGiFkfSvM1MhXmU+gFuBTDRUAQqBmbkUDwsU9+A+ZSfg+EIbebp0Gg8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1625073150116888.796123912991; Wed, 30 Jun 2021 10:12:30 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-484-0Jhx1Bv9N0ex5LRMZ2tIGQ-1; Wed, 30 Jun 2021 13:11:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3BE6BCC648; Wed, 30 Jun 2021 17:11:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8DA15D6AD; Wed, 30 Jun 2021 17:11:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A7C2B4EA2A; Wed, 30 Jun 2021 17:11:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15UGannO025790 for ; Wed, 30 Jun 2021 12:36:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 02C982026D46; Wed, 30 Jun 2021 16:36:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F2EB8207B2C3 for ; Wed, 30 Jun 2021 16:36:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F69718A01A0 for ; Wed, 30 Jun 2021 16:36:43 +0000 (UTC) Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-531-D3vLZDY7MCmmEHk4inaNPA-1; Wed, 30 Jun 2021 12:36:42 -0400 Received: by mail-pj1-f70.google.com with SMTP id u12-20020a17090abb0cb029016ee12ec9a1so1758464pjr.3 for ; Wed, 30 Jun 2021 09:36:41 -0700 (PDT) Received: from localhost ([181.191.236.153]) by smtp.gmail.com with ESMTPSA id 10sm22479979pfh.174.2021.06.30.09.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 09:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625073149; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dnVHAjjD+hrf0VY1woBC5OwILcgU9CKidsf3FVMWO5o=; b=bWbHvbfbGT4mIiqi5SeK1kHDcT+SJ4VnXK+MRFOZczObVOmM4NDo30rBUlyiEK5DrbuZ8c nUcrkbduOr2B+yEfcYYiVQPq5ElFhQJgBhnEXCvf+fhuamUISMWO4hXlD3jEC/MNaW++my iaBsmxxlFuslxmCgjrcrmsjuMxX8yxw= X-MC-Unique: 0Jhx1Bv9N0ex5LRMZ2tIGQ-1 X-MC-Unique: D3vLZDY7MCmmEHk4inaNPA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dnVHAjjD+hrf0VY1woBC5OwILcgU9CKidsf3FVMWO5o=; b=nQuX2/lxrDChPfxZ1HHz0SLz6D1QuCQREJ2MGrRjI9NMnkXzK6QBI5E21rOi1Z3Yct wtjBDPXnAbDNeN7j5tIC2h+WC2OeEhUpL/svQX6KTYPoEeaTs6g2rDssM1OK0nU/q2DZ ktAXtO4fh+Zd2CPupXr5pvlnMje9LfCu/ki3kPOEoXjNJLQAJHbyaINzWxqQdpSQ3VvQ enP7r3XHxFIDn/17lEPOyXy+TAMQXM7402Xbz8o7EGT4Jt/yo5rC9+bxqQGT7Wq34vcX 629pXUUZgKneDJxTk00j9EpKNYwRyfUBj3qfXMhk/BV+76Bm9dpS9P6r9wR+8bikKX7E hQ1g== X-Gm-Message-State: AOAM531Y8+aHJstwtwVE50aQ3CQ4ad09wKjZBTQS1HZSpSCSlBTaf8DC 2BVyQJka6bjylCzAqbz/olPqSq/ziJ7N1hS1oX8egi2ytT2dKfmENKh0dLYdk2mDnFz8DUgLBZJ D3LmTNzbQ6HeeGxmAvY2GL6/Fr1uz/kBy/oxFCpaUNickZDR/870bLwHndSsG0ksEGaU= X-Received: by 2002:a05:6a00:23d0:b029:2de:c1a2:f1e with SMTP id g16-20020a056a0023d0b02902dec1a20f1emr37054491pfc.60.1625071000566; Wed, 30 Jun 2021 09:36:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU+O4M2FC69ptVQWan9uxTxsCLD8oPxW/SdColaeqGOalHAKRBkNpPV3+uIRlNSMyPXUH7mQ== X-Received: by 2002:a05:6a00:23d0:b029:2de:c1a2:f1e with SMTP id g16-20020a056a0023d0b02902dec1a20f1emr37054458pfc.60.1625071000115; Wed, 30 Jun 2021 09:36:40 -0700 (PDT) From: Beraldo Leal To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] tests: introduce lavocado: initial code structure Date: Wed, 30 Jun 2021 13:36:31 -0300 Message-Id: <20210630163634.2801636-2-bleal@redhat.com> In-Reply-To: <20210630163634.2801636-1-bleal@redhat.com> References: <20210630163634.2801636-1-bleal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Beraldo Leal X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" lavocado aims to be an alternative test framework for the libvirt project using Python, python-libvirt and Avocado. This can be used to write unit, functional and integration tests and it is inspired by the libvirt-tck framework. Documentation, helper classes and templates will be provided to speed up common test writing scenarios. Signed-off-by: Beraldo Leal --- tests/lavocado/lavocado/__init__.py | 0 tests/lavocado/lavocado/defaults.py | 11 ++ tests/lavocado/lavocado/exceptions.py | 20 +++ tests/lavocado/lavocado/helpers/__init__.py | 0 tests/lavocado/lavocado/helpers/domains.py | 75 ++++++++++ tests/lavocado/lavocado/test.py | 144 ++++++++++++++++++++ tests/lavocado/requirements.txt | 3 + tests/lavocado/templates/domain.xml.jinja | 20 +++ 8 files changed, 273 insertions(+) create mode 100644 tests/lavocado/lavocado/__init__.py create mode 100644 tests/lavocado/lavocado/defaults.py create mode 100644 tests/lavocado/lavocado/exceptions.py create mode 100644 tests/lavocado/lavocado/helpers/__init__.py create mode 100644 tests/lavocado/lavocado/helpers/domains.py create mode 100644 tests/lavocado/lavocado/test.py create mode 100644 tests/lavocado/requirements.txt create mode 100644 tests/lavocado/templates/domain.xml.jinja diff --git a/tests/lavocado/lavocado/__init__.py b/tests/lavocado/lavocado/= __init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/lavocado/lavocado/defaults.py b/tests/lavocado/lavocado/= defaults.py new file mode 100644 index 0000000000..47f1299cf4 --- /dev/null +++ b/tests/lavocado/lavocado/defaults.py @@ -0,0 +1,11 @@ +LIBVIRT_URI =3D "qemu:///system" + +TEMPLATE_PATH =3D "./templates/domain.xml.jinja" + +VMIMAGE =3D { + 'provider': 'fedora', + 'version': '33', + 'checksum': '67daa956d8c82ef799f8b0a191c1753c9bda3bca' + } + +CACHE_DIR =3D '/tmp/lavocado-cache' diff --git a/tests/lavocado/lavocado/exceptions.py b/tests/lavocado/lavocad= o/exceptions.py new file mode 100644 index 0000000000..d89cbb3eef --- /dev/null +++ b/tests/lavocado/lavocado/exceptions.py @@ -0,0 +1,20 @@ +# Copyright (C) 2021 Red Hat, Inc. +# Author: Beraldo Leal +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see +# . + + +class TestSetupException(Exception): + pass diff --git a/tests/lavocado/lavocado/helpers/__init__.py b/tests/lavocado/l= avocado/helpers/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/lavocado/lavocado/helpers/domains.py b/tests/lavocado/la= vocado/helpers/domains.py new file mode 100644 index 0000000000..cddee1b4b7 --- /dev/null +++ b/tests/lavocado/lavocado/helpers/domains.py @@ -0,0 +1,75 @@ +# Copyright (C) 2021 Red Hat, Inc. +# Author: Beraldo Leal +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see +# . + + +import os + +from avocado.utils.genio import read_file +from jinja2 import Template + +from lavocado import defaults +from lavocado.exceptions import TestSetupException + + +class Domain: + @classmethod + def from_xml_path(cls, conn, xml_path): + """Create a new domain from a XML file. + + :param conn: a connection object to the Hypervisor. + :type conn: libvirt.virConnect + :param xml_path: XML file path. + :type xml_path: str + :returns: : the created domain object + :rtype: libvirt.virDomain + """ + xml_content =3D read_file(xml_path) + return conn.createXML(xml_content) + + @classmethod + def from_xml_template(cls, conn, suffix, arguments=3DNone): + """Create a new domain from the default XML template. + + This will use the `defaults.TEMPLATE_PATH` file, parsing some argu= ments + defined there. + + :param conn: a connection object to the Hypervisor. + :type conn: libvirt.virConnect + :param suffix: A suffix string to be added to the domain domain. + :type suffix: str + :param arguments: a key/value dict to be used during + template parse. currently supported keys are: na= me, + memory, vcpus, arch, machine and image. Visit the + template file for details. + :rtype arguments: dict + :returns: : the created domain object + :rtype: libvirt.virDomain + """ + template_path =3D defaults.TEMPLATE_PATH + arguments =3D arguments or {} + + if not os.path.isfile(template_path): + error =3D f"Template {template_path} not found." + raise TestSetupException(error) + + # Adding a suffix to the name + name =3D arguments.get('name', 'lavocado-test') + arguments['name'] =3D f"{name}-{suffix}" + + template =3D Template(read_file(template_path)) + xml_content =3D template.render(**arguments) + return conn.createXML(xml_content) diff --git a/tests/lavocado/lavocado/test.py b/tests/lavocado/lavocado/test= .py new file mode 100644 index 0000000000..b77ecaed58 --- /dev/null +++ b/tests/lavocado/lavocado/test.py @@ -0,0 +1,144 @@ +# Copyright (C) 2021 Red Hat, Inc. +# Author: Beraldo Leal +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see +# . + +"""Basic test helper module to avoid code redundancy.""" + +import os +import libvirt + +from avocado import Test +from avocado.utils import vmimage + +from lavocado import defaults +from lavocado.exceptions import TestSetupException +from lavocado.helpers.domains import Domain + + +class LibvirtTest(Test): + """Main class helper for tests. + + Any test that inherits from this class, will have some methods and + properties to assist on their jobs. + """ + def setUp(self): + """Setup to be executed before each test. + + Currently, this method is creating just a basic hypervisor connect= ion. + Please, extend this method when writing your tests for your own ne= eds. + + Any error that happens here *will not* flag the test as "FAIL", in= stead + tests will be flagged as "ERROR", meaning that some bootstrap erro= r has + happened. + """ + self.defaults =3D defaults + self.conn =3D self.connect() + + def connect(self): + """Try to open a new connection with the hypervisor. + + This method uses the value defined at `defaults.LIBVIRT_URI` as UR= I. + + :returns: a libvirt connection. + :rtype: libvirt.virConnect + """ + try: + return libvirt.open(self.defaults.LIBVIRT_URI) + except libvirt.libvirtError: + msg =3D ("Failed to open connection with the hypervisor using " + + self.defaults.LIBVIRT_URI) + self.cancel(msg) + + def create_domain(self, arguments=3DNone): + """Creates a libvirt domain based on the default template. + + This will receive some arguments that will be rendered on the + template. For more information about the arguments, see + templates/domain.xml.jinja. For now, at least the 'image' argument= must + be informed, with the path for the image to boot. + + If you are using this method from a test method (different from + setUp()), AND you would like to count its call as a "setup/bootstr= ap" + stage, consider using the following Avocado decorator: + + from avocado.core.decorators import cancel_on + + @cancel_on(TestSetupException) + def test_foo(self): + ... + + In that way, your test will not FAIL, instead it will be cancelled= in + case of any problem during this bootstrap. + + :param dict arguments: A key,value dictionary with the arguments + to be replaced on the template. If + any missing argument, template will be + rendered with default values. + """ + try: + return Domain.from_xml_template(self.conn, self.id(), argument= s) + # This will catch any avocado exception plus any os error + except Exception as ex: + msg =3D f"Failed to create domain: {ex}" + raise TestSetupException(msg) from ex + + def get_generic_image(self): + """Ask Avocado to fetch an VM image snapshot. + + Avocado will handle if image is already downloaded into the + cache dir and also will make sure the checksum is matching. + + This will return an Image object pointing to a snapshot file. So + multiple calls of this method will never return the same object. + + If you are using this method from a test method (different from + setUp()), AND you would like to count its call as a "setup/bootstr= ap" + stage, consider using the following Avocado decorator: + + from avocado.core.decorators import cancel_on + + @cancel_on(TestSetupException) + def test_foo(self): + ... + + In that way, your test will not FAIL, instead it will be cancelled= in + case of any problem during this bootstrap. + """ + image =3D self.defaults.VMIMAGE + try: + return vmimage.get(name=3Dimage.get('provider'), + version=3Dimage.get('version'), + cache_dir=3Dself.defaults.CACHE_DIR, + checksum=3Dimage.get('checksum')) + # This will catch any error, including avocado exceptions + OS err= ors + except Exception as ex: + msg =3D f"Failed to get a generic image: {ex}" + raise TestSetupException(msg) from ex + + def tearDown(self): + """Shutdown after each test. + + This will destroy all previously created domains by this test, and + remove any image snapshot if created. + """ + for domain in self.conn.listAllDomains(): + if domain.name().endswith(self.id()): + domain.destroy() + + if hasattr(self, 'image') and isinstance(self.image, vmimage.Image= ): + if os.path.exists(self.image.path): + os.remove(self.image.path) + self.conn.close() diff --git a/tests/lavocado/requirements.txt b/tests/lavocado/requirements.= txt new file mode 100644 index 0000000000..6927528323 --- /dev/null +++ b/tests/lavocado/requirements.txt @@ -0,0 +1,3 @@ +git+https://github.com/avocado-framework/avocado@8c87bfe5e8a1895d772260644= 33453f158a3ce56#egg=3Davocado_framework +libvirt-python +Jinja2 diff --git a/tests/lavocado/templates/domain.xml.jinja b/tests/lavocado/tem= plates/domain.xml.jinja new file mode 100644 index 0000000000..a7bd57e5b0 --- /dev/null +++ b/tests/lavocado/templates/domain.xml.jinja @@ -0,0 +1,20 @@ + + {{name|default("lavocado-test")}} + {{memory|default(4194304)}} + {{vcpus|default(4)}} + + hvm + + + + /usr/bin/qemu-system-x86_64 + + + + + + + + + + --=20 2.26.3 From nobody Thu May 2 17:16:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1625073244; cv=none; d=zohomail.com; s=zohoarc; b=Uw3bFUl8OlAPg1bVDGHm5Axf/PswJ5ycqjxLrt55yh3cv/VBndg0Fwlq9pLV2K77lRhnZkB/NkxGpvfwu3HP+3Jasehxw7cyUoyHt65p1caVvNw82j12tOGr3lgtARps7W2v82iEC6hUyy0lDqhCe0HVnxWNFr8XB1auowXP64U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625073244; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IhrjGAlCJd5+6TBluXGNhwxPUzl+nbNaOGY8QSHv+J0=; b=kWgUTdTfFDQN6+cnEfVXtvh7t9hWgvQy5cf2mEUWPMyNwwKgeONyxYtxt0Y8saXjW5xo2RGjw3DT/A0SZ+UrtAz6Thii6CzKpD5S0f+93rrvWcyCByvykYDnN1CLgbqLmMHjhBYn0Su7pgoyYnOb5giefRNZr5m3Xy3IQwcZWWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1625073244031150.60424462128367; Wed, 30 Jun 2021 10:14:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-121-A3vdtUJtNoCKsqSHjdqhwg-1; Wed, 30 Jun 2021 13:13:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE631106B7DE; Wed, 30 Jun 2021 17:13:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7DF63100164A; Wed, 30 Jun 2021 17:13:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 47C4A4EA2F; Wed, 30 Jun 2021 17:13:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15UGakVA025784 for ; Wed, 30 Jun 2021 12:36:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 20A2D101B745; Wed, 30 Jun 2021 16:36:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C8FA1018E59 for ; Wed, 30 Jun 2021 16:36:46 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 03F61108C06F for ; Wed, 30 Jun 2021 16:36:46 +0000 (UTC) Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-rwBKzRVEOaORh11HuRmdUA-1; Wed, 30 Jun 2021 12:36:44 -0400 Received: by mail-pl1-f199.google.com with SMTP id v16-20020a170902e8d0b0290124e63feb68so1433147plg.17 for ; Wed, 30 Jun 2021 09:36:44 -0700 (PDT) Received: from localhost ([181.191.236.153]) by smtp.gmail.com with ESMTPSA id r10sm23685515pga.48.2021.06.30.09.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 09:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625073243; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IhrjGAlCJd5+6TBluXGNhwxPUzl+nbNaOGY8QSHv+J0=; b=ioK3EGOCrdIqgJ3GolYzaVV8Vlh+yUAI+S+MZuRUif9f55aBzLIrmyEUs0EC4MWbePCOe5 yephwJ+1r1jTiBR7f24V82teR1QKc71nSAOughIuAPaq6KSAnVY7kY+eVhWfdKfeSNrFU4 2W1BP+V79cZNEvPy5BcAVArKfINz5ro= X-MC-Unique: A3vdtUJtNoCKsqSHjdqhwg-1 X-MC-Unique: rwBKzRVEOaORh11HuRmdUA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IhrjGAlCJd5+6TBluXGNhwxPUzl+nbNaOGY8QSHv+J0=; b=qTaBGcNrNrJ3o7TRKelJD5ta+HlFHunXHrK5PscZ8rUumvzIQrnQhimo56jtbXks9W 32v9JivD7pKtH9TKmmGh/3kbE5cUWv+ljaX5vgoGvJNycsiSTyh4nPb2as1ijrEs3cmj X81wjLndOBMbGWGrdo6D8u0a0lxX2apnmktM6oEYZZKckdsrvydzrpMyP7UxKklHyLrv XroIwSz3RhqdN+lJdITC6QCM95DAbGyeKPOC71bCSnbQJxxkgSmXAghbo/A3GdeUfK2V cayKfvb+bC7ID1xj9gXcTyKT03ZbULV2MeQT2qeh0Kjw8YmBTMO2xo6jLqgsKOCV7Qog w4Ng== X-Gm-Message-State: AOAM530+Ajr4xbrOFmN4gZt/bEquM5PFTxdmqFtfH5pPQMMyv9GVhJoH /li/DL69B6cmierIOTAer26vo7y4pxUeqeaNLWIH0MWzwPXLvUMnJj4wIL85LwWfVYQ5+iG2Ic4 QtkrcxlDW1wj7PaXLtlpyVD1fAEFS9Mgj57W+qmETxhe4M4mSWwklnrm1U+fw6aCOVag= X-Received: by 2002:a63:a44:: with SMTP id z4mr34371901pgk.379.1625071003059; Wed, 30 Jun 2021 09:36:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwagy0okZQ78/1KaxGrhfA/VcHTVOgdCni+q7PTTYgKkNcWZ9GqxSfEQrOcT5WG1mxIDk4jYA== X-Received: by 2002:a63:a44:: with SMTP id z4mr34371877pgk.379.1625071002719; Wed, 30 Jun 2021 09:36:42 -0700 (PDT) From: Beraldo Leal To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] tests.lavocado: adding basic transient domain tests Date: Wed, 30 Jun 2021 13:36:32 -0300 Message-Id: <20210630163634.2801636-3-bleal@redhat.com> In-Reply-To: <20210630163634.2801636-1-bleal@redhat.com> References: <20210630163634.2801636-1-bleal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Beraldo Leal X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This basic test case validates the core lifecycle and operations on transient domains and came from libvirt-tck as an exercise in porting tests. Signed-off-by: Beraldo Leal --- tests/lavocado/tests/domain/transient.py | 102 +++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tests/lavocado/tests/domain/transient.py diff --git a/tests/lavocado/tests/domain/transient.py b/tests/lavocado/test= s/domain/transient.py new file mode 100644 index 0000000000..f96906c41b --- /dev/null +++ b/tests/lavocado/tests/domain/transient.py @@ -0,0 +1,102 @@ +# Copyright (C) 2021 Red Hat, Inc. +# Author: Beraldo Leal +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see +# . + +import libvirt + +from lavocado.test import LibvirtTest + + +class TransientDomain(LibvirtTest): + """Transient domain basic operations. + + The test case validates the core lifecycle and operations on transient + domains. + """ + + def setUp(self): + super().setUp() + self.image =3D self.get_generic_image() + self.domain =3D self.create_domain(arguments=3D{'image': self.imag= e.path}) + + def test_lifecycle(self): + """Creating and destroying a new transient domain. + + A transient domain has no configuration file so, once destroyed, a= ll + trace of the domain should disappear. + """ + name =3D self.domain.name() + state, _ =3D self.domain.state() + self.assertTrue(state, libvirt.VIR_DOMAIN_RUNNING) + + try: + self.domain.destroy() + except Exception as ex: + self.fail(f"destroy() raised an exception: {ex}") + + with self.assertRaises(libvirt.libvirtError) as context: + self.conn.lookupByName(name) + + expected =3D f"no domain with matching name '{self.domain.name()}'" + self.assertTrue(expected in str(context.exception)) + + def test_autostart(self): + """Makes sure autostart is disabled and not allowed on a transient= domain. + + The test case validates that the autostart command returns a suita= ble + error message when used on a transient domain. + """ + self.assertFalse(self.domain.autostart()) + + with self.assertRaises(libvirt.libvirtError) as context: + self.domain.setAutostart(True) + + expected =3D "cannot set autostart for transient domain" + self.assertTrue(expected in str(context.exception)) + + def test_convert_transient_to_persistent(self): + """Converting transient to persistent should work fine. + + This test case validates that a transient domain can be converted = to a + persistent one. This is achieved by defining a configuration file = while + the transient domain is running. + """ + name =3D self.domain.name() + + # Make sure is running and not persistent + state, _ =3D self.domain.state() + self.assertTrue(state, libvirt.VIR_DOMAIN_RUNNING) + self.assertFalse(self.domain.isPersistent()) + + # Defining config for transient guest + new_domain =3D self.conn.defineXML(self.domain.XMLDesc()) + self.assertTrue(new_domain.isPersistent()) + + # Destroying active domain + self.domain.destroy() + + # Checking that an inactive domain config still exists + found =3D self.conn.lookupByName(name) + self.assertEqual(found.name(), name) + + # Removing inactive domain config + new_domain.undefine() + + # Checking that inactive domain has really gone + with self.assertRaises(libvirt.libvirtError) as context: + self.conn.lookupByName(name) + expected =3D f"no domain with matching name '{name}'" + self.assertTrue(expected in str(context.exception)) --=20 2.26.3 From nobody Thu May 2 17:16:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1625073242; cv=none; d=zohomail.com; s=zohoarc; b=A5f5UJlITClO2wrXcy2wbW5QJvZVSUwlgpAYC5cCwC2H8vyvdcYRK/w1XBM/PcmknhmAYEAxnY5hbnFLsmWyNc3wBxZsyJx5HdcX2COY1Nf0m8/NwVvYKgLjywqCG+6Fbsqe7Q/Y1GIPFaJqPGyqxXxGCyqqQIKWoU17j+IWsJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625073242; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ALEbkQ0n+EcSjJYTDT/m52bmeb8rRpq9f7mJ5dOK258=; b=YONsY9a3xJzReUHuFVAGmgSjNlq5xtPJBERmhkwJAIgMNMdZAcOVOu9OJA7t7AXaRO19RFvuufM7Kzi3PkWMGFmern2MwhCs6bUwcsC832w6bESWfxuJ/DglW97urzM23bIKWQXTJyDww7BEsiL5ERnRqCd8aTcND6NnTS6axXM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1625073242567213.3109967406948; Wed, 30 Jun 2021 10:14:02 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-391--fu6drILODKhPC4ESSd6qg-1; Wed, 30 Jun 2021 13:13:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E65B800D62; Wed, 30 Jun 2021 17:13:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11DF960875; Wed, 30 Jun 2021 17:13:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CD6234EA38; Wed, 30 Jun 2021 17:13:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15UGapSO025804 for ; Wed, 30 Jun 2021 12:36:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id D77F621F1B0A; Wed, 30 Jun 2021 16:36:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D280C2028775 for ; Wed, 30 Jun 2021 16:36:48 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 711EF18A01AC for ; Wed, 30 Jun 2021 16:36:48 +0000 (UTC) Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-RUcz2DYwOcqziKuJl9l0wA-1; Wed, 30 Jun 2021 12:36:46 -0400 Received: by mail-pf1-f198.google.com with SMTP id s5-20020aa78d450000b02902ace63a7e93so2102182pfe.8 for ; Wed, 30 Jun 2021 09:36:46 -0700 (PDT) Received: from localhost ([181.191.236.153]) by smtp.gmail.com with ESMTPSA id p29sm22426198pfq.55.2021.06.30.09.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 09:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625073241; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ALEbkQ0n+EcSjJYTDT/m52bmeb8rRpq9f7mJ5dOK258=; b=PGwgWkRLBD3kTXawTw8b3rEwHo9xAzeYZYupmEeBHQUsvXzrRt0skxa6tDtvVgFCs3Gn3p FqGFRk8GCaoQh4pgRgfL5gHq4yVtah1ZBjNTOelXCrP3kaX/UjTDmWKIuBA7IJVX4bxdBs 0MNlAC3jrAlwQZiKN32IrfXCxtCx/Ag= X-MC-Unique: -fu6drILODKhPC4ESSd6qg-1 X-MC-Unique: RUcz2DYwOcqziKuJl9l0wA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ALEbkQ0n+EcSjJYTDT/m52bmeb8rRpq9f7mJ5dOK258=; b=a+/KKN8XhINiueeEKMIWd36la1FW/ctCH3mFbhEwIV3xfFAtqjeNajMZJAFpBIEp2k eJpxRJDedNAh11lCuWo3CVic8QcVvT9fZ3SPhmZ4Cx0qXkC5VxAJu/lb/hfTay7mcZxI wSnJXyQYhg/HN5Va+aK4Racy5RCJK+cS8P3KkK/fSs2EsPHIfmziZHDCoBKgePG1MkIS UA6x3sWXxjncEkLrEOqioASUR2xax2ULLtcb+NAno08nfSe3ug84XbVStTrDFS37GZUP o45Hnt22H6VN/YyFU5IoKeIhm4AXPLaGpl2NUe+iEtkIgSLp2CahrbWAxcHRCgyrQ7Yo XO7A== X-Gm-Message-State: AOAM533PC52KSDOtq1v+rr0MaczZXBL2vZMoQndf+XzOztoXZxP3QNwq iMRe9yN4j6N5O8C93kg1dLMHyBKHXmoOlo/LFu4RLpKkfd5pGa9Oq7C8KqyRYwKSfw3k603I61f C+Wg+Zh/pK9ZGCi3sp3A0o+ShF099xhxJLsS4nExySpgw+P7NEinoWx9JzW9myyk+YG4= X-Received: by 2002:a62:52cd:0:b029:305:ece5:5a78 with SMTP id g196-20020a6252cd0000b0290305ece55a78mr36486378pfb.69.1625071005646; Wed, 30 Jun 2021 09:36:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNxrK5a6NMszciCWD7N/dz5peDmuRMxR4khSJs/x8la7y/1xgevuujEdn3arVOrBvt0A3mwQ== X-Received: by 2002:a62:52cd:0:b029:305:ece5:5a78 with SMTP id g196-20020a6252cd0000b0290305ece55a78mr36486349pfb.69.1625071005319; Wed, 30 Jun 2021 09:36:45 -0700 (PDT) From: Beraldo Leal To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] tests.lavocado: adding a .gitignore Date: Wed, 30 Jun 2021 13:36:33 -0300 Message-Id: <20210630163634.2801636-4-bleal@redhat.com> In-Reply-To: <20210630163634.2801636-1-bleal@redhat.com> References: <20210630163634.2801636-1-bleal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Beraldo Leal X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This will prevent unnecessary Python object and temporary files to be tracked by git. Signed-off-by: Beraldo Leal --- tests/lavocado/.gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/lavocado/.gitignore diff --git a/tests/lavocado/.gitignore b/tests/lavocado/.gitignore new file mode 100644 index 0000000000..59c71f50f9 --- /dev/null +++ b/tests/lavocado/.gitignore @@ -0,0 +1,3 @@ +*.pyc +__pycache__ +*~ --=20 2.26.3 From nobody Thu May 2 17:16:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1625073308; cv=none; d=zohomail.com; s=zohoarc; b=atIOS4z3ds+lG1ktiSKFU8ypzuHRZdsSS3XXr8aWFpCb1AF91n3UWplcx7PuseRlmEik4c4DVEhJ+/xrkXEUwxnEGqKu90PAL+hAbaO3UXh6q8n3hKT50QfuvQWYjlTb3qhxogYPUgr+T8QiwTats9K9Y+rPRT3hiDLiaONjKQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625073308; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V6ZNFkxaNf/CGssdZjqufS/KznGcZtC6ju33T6qINH8=; b=ZrOSaIfvkrwxaUA29lc3pW+nqpOIZKIbyT+9vy7QjphLMBORPiTWz6VpdS2v3ZaV06G8INUlMUgjWgRfGHue1crh69OnqvzzUc1kD5n3zRpURqOW8tKVCuxtlqk2ayBE3GfovW3y8Yx1TSGZPTbYyiIWH+llD389wVlidpmPcGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1625073308092117.44087069159707; Wed, 30 Jun 2021 10:15:08 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-d1sil5FdOimGvVFcIkC4-g-1; Wed, 30 Jun 2021 13:14:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CD2881C863; Wed, 30 Jun 2021 17:13:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 40876131F7; Wed, 30 Jun 2021 17:13:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 089A11809C9A; Wed, 30 Jun 2021 17:13:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15UGapsC025803 for ; Wed, 30 Jun 2021 12:36:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id D7685202877C; Wed, 30 Jun 2021 16:36:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D29F2202877B for ; Wed, 30 Jun 2021 16:36:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B6D380D2B7 for ; Wed, 30 Jun 2021 16:36:51 +0000 (UTC) Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-PB-JTA7CNyekojFmI6Dy2w-1; Wed, 30 Jun 2021 12:36:50 -0400 Received: by mail-pf1-f199.google.com with SMTP id h6-20020a056a001a46b029030cacfca7bdso2089533pfv.13 for ; Wed, 30 Jun 2021 09:36:49 -0700 (PDT) Received: from localhost ([181.191.236.153]) by smtp.gmail.com with ESMTPSA id l22sm6957056pjy.1.2021.06.30.09.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 09:36:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625073306; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=V6ZNFkxaNf/CGssdZjqufS/KznGcZtC6ju33T6qINH8=; b=D85kHk54aRBK2YgoIGail92jLJtnyvS6Gz1hngPuvqT5Td5kvESsCeMPBhxC8sjXeBkOsE maGIUJ9JKZjjYd9YPL6aglNDXE7Uvn8/1P/F2WtKGEzBym2t7jUVwlmowZC9PuK79I91/0 sw7O59tnd+G5qUr6eWLDdhKWum/62ts= X-MC-Unique: d1sil5FdOimGvVFcIkC4-g-1 X-MC-Unique: PB-JTA7CNyekojFmI6Dy2w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V6ZNFkxaNf/CGssdZjqufS/KznGcZtC6ju33T6qINH8=; b=ukPBDBAHLVL8nzDn3ujDBIbSDEU45fx/FRlq6Q8nm1mCt5Y2ffVqbhPqFoRLfKYt9i QcggzlBFeRQK0tqWrqU2pWwN4Ry5KUjuJsMqxHD9v3VlBjZDFUNuiQQlgcCA0/KbVvAl kvkuKWNHn0LMZpWkJzYsVYIkV2UzwvA+3K2BuB1D3STUZ/nDpye7PknmTqSRPKktTEUC 4oAd3wWs2m4z+m9zuFo8QIIeyguNE1GX7sOnPoPZa7h0Bt+syp9zVZweGuI8xbC3z2yd VdSaxQMH1dJ58Lgxfln1MqxR1d/e8fde5FhISAPM5RM0N6JLkZQa39wl5OpqMzBmOvTC yqag== X-Gm-Message-State: AOAM530vx7iac8ioKzg8YYzETWlA+IxQm25a0zG84/H2kVLms92nL+Ga 5IFHVhD/d3FDLFPEQWgYl+TRIAutl+T+ZNyKxdPy1Pbiy/U1fRJ01kpaCYW2nJm8K6RfpuYxDJV J0iwAlcydOdKKqPRNjPyDpmw2M0+SLqMB1CrW+3O2ZQlWuqLfoKiQoNkunDWRfrTRMPI= X-Received: by 2002:a63:338d:: with SMTP id z135mr15753346pgz.314.1625071008715; Wed, 30 Jun 2021 09:36:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxULi5rPRaEVJq0hSj8PAREkj6YG1dnYL9RwaM/AnaA3saiUKfDlw7iP/Iaw8RAXpxRijIr6w== X-Received: by 2002:a63:338d:: with SMTP id z135mr15753328pgz.314.1625071008435; Wed, 30 Jun 2021 09:36:48 -0700 (PDT) From: Beraldo Leal To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] tests.lavocado: adding a README and Makefile for convenience Date: Wed, 30 Jun 2021 13:36:34 -0300 Message-Id: <20210630163634.2801636-5-bleal@redhat.com> In-Reply-To: <20210630163634.2801636-1-bleal@redhat.com> References: <20210630163634.2801636-1-bleal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Beraldo Leal X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Beraldo Leal --- tests/lavocado/Makefile | 2 + tests/lavocado/README.md | 124 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 tests/lavocado/Makefile create mode 100644 tests/lavocado/README.md diff --git a/tests/lavocado/Makefile b/tests/lavocado/Makefile new file mode 100644 index 0000000000..33df604105 --- /dev/null +++ b/tests/lavocado/Makefile @@ -0,0 +1,2 @@ +libvirt-tests: + avocado run --test-runner=3D'nrunner' tests/ diff --git a/tests/lavocado/README.md b/tests/lavocado/README.md new file mode 100644 index 0000000000..b22015fe46 --- /dev/null +++ b/tests/lavocado/README.md @@ -0,0 +1,124 @@ +# lavocado - libvirt test framework based on Avocado + +The lavocado aims to be an alternative test framework for the libvirt proj= ect +using as muscles only Avocado and python-libvirt. This can be used to write +unit, functional and integration tests and it is inspired on the libvirt-t= ck +framework, but instead of Perl it written in Python. + +The idea is to provide to the test writers helper classes to avoid boilerp= late +code, improve code readability and maintenance. + +## Disclaimer + +**For now, this framework assumes that you are going to run the tests in a= fresh +clean environment, i.e. a VM. If you decide to use your local system, bewa= re +that execution of the tests may affect your system.** + +One of the future goals of this framework is to utilize nested virtualizat= ion +technologies and hence make sure an L1 guest is provisioned automatically = for +the tests to be executed in this environment and not tamper with your main +system. + +## Requirements + +The libvirt interactions will all be done via the libvirt Python bindings +(libvirt-python), we also rely on Avocado, not only to execute the tests b= ut +also to generate multiple output format artifacts (that can be uploaded to= CI +environments) and also the image fetch, so we don't need to handle with lo= cal +cache, checksum and any other test's requirement task. + +In order to install the requirements, please execute the following command: + +```bash + $ pip3 install -r requirements.txt +``` + +If you wish you can run this command under a virtual environment. + +## Features + +Bellow, we list some features that can be explored from this proposal: + + * Parallel execution: If your tests are independent of each other, you ca= n run + those in parallel, when getting images, Avocado will create a snapshot = to + avoid conflicts. Also domains created by tests have unique names to avo= id + collisions. + + * Creating domains easily: You can use the `.create_domain()` method to c= reate + a generic domain which is based on a Jinja2 template. If you want to us= e an + already existing XML domain description, no problem, use + `Domain.from_xml_path()` instead. + + * Multiple output formats: TAP, HTML, JSON, xUnit (Gitlab CI ready). + + * Test tags: Ability to mark tests with tags, for filtering during execut= ion + and/or results. + + * Different isolation models: By default the avocado runner will spawn ea= ch + test on local processes (subprocess), but we can configure for specific= use + cases, running the tests on different isolation models (containers for + instance). + + * Requirements resolver: Avocado has implemented the 'requirements resolv= er' + feature that makes it easy to define test requirements. Currently, The + RequirementsResolver can handle `assets` (any local or remote files) and + `packages` but new requirements are on the roadmap, including `ansible + playbooks`. For now, it is still only an experimental feature though. + + * Test result artifacts for future analysis: you can take a look at `avoc= ado + jobs` command or inspect your `~/avocado/test-results/` folder for more + detailed results. + + * Multiple test execution with variants: the variants subsystem is what a= llows + the creation of multiple variations of parameters, and the execution of + tests with those parameter variations. + + * Clear separation between tests and bootstrap stages: If something fails + during the setUp() metod execution, your test will be not marked as FAI= L, + instead it will be flagged as ERROR. You can also use some decorators + (@cancel_on, @skipUnless, ...) around your test to avoid false positive= s. + + * Ready-to-use utility libraries: `avocado.utils` are rich, and cover + common operating system level needs, such as service managment, + hardware introspection, storage management, networking, etc. + + * Avocado Job API: a programmable interface for defining test jobs, which + allows one to create custom test jobs that are suitable to developer's + systems and CI enviroments. + + * Output artifacts for debug: Avocado stores all job results in + `~/avocado/job-results/` (you can also see details with `avocado jobs` + command). If any test fails we can debug the files there. Besides that,= using + `sysinfo` plugin, we could collect additional system information (such = as + libvirt/qemu logs). + +## Running + +After installing the requirements, you can run the tests with the following +commands: + +```bash + $ export PYTHONPATH=3D.:$PYTHONPATH + $ avocado run --test-runner=3D'nrunner' ./tests/domain/*.py +``` + +Please note that the Next Runner (nrunner) will be the default runner soon= in +Avocado, and so the `--test-runner=3D'nrunner'` option will no longer be n= eeded. + +Or, if you prefer, you can also execute the tests with `make`: + +```bash + $ make libvirt-tests +``` + +## Writing Tests + +You can write your tests here the same way you write for the [Avocado +Framework](https://avocado-framework.readthedocs.io/en/latest/). +Avocado supports "simple tests" (just executables) and "instrumented tests" +(Python tests). + +See the `tests/` folder for some references and ideas. In addition, feel f= ree +to read the [Avocado Test Writer=E2=80=99s +Guide](https://avocado-framework.readthedocs.io/en/latest/guides/writer/) = to +play with some advanced features of the framework. --=20 2.26.3