From nobody Tue Feb 10 06:52:30 2026 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