This is an automated email from the ASF dual-hosted git repository. dahn pushed a commit to branch 4.20 in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.20 by this push: new c1923a2dcb3 test: cleanup test_guest_os.py for multiple execution (#10818) c1923a2dcb3 is described below commit c1923a2dcb3c0902e21a4369ac1ee6e2b4dc1a5c Author: Abhishek Kumar <abhishek.mr...@gmail.com> AuthorDate: Wed May 7 12:20:36 2025 +0530 test: cleanup test_guest_os.py for multiple execution (#10818) Signed-off-by: Abhishek Kumar <abhishek.mr...@gmail.com> --- test/integration/smoke/test_guest_os.py | 21 +++++++++++++++------ tools/marvin/marvin/lib/base.py | 15 +++++++++++---- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/test/integration/smoke/test_guest_os.py b/test/integration/smoke/test_guest_os.py index c9d50a7c523..bb09b2b86a1 100644 --- a/test/integration/smoke/test_guest_os.py +++ b/test/integration/smoke/test_guest_os.py @@ -47,19 +47,14 @@ class TestGuestOS(cloudstackTestCase): cls.hypervisor = cls.get_hypervisor_type() - @classmethod def setUp(self): self.apiclient = self.testClient.getApiClient() #build cleanup list self.cleanup = [] - @classmethod def tearDown(self): - try: - cleanup_resources(self.apiclient, self.cleanup) - except Exception as e: - self.debug("Warning! Exception in tearDown: %s" % e) + super(TestGuestOS, self).tearDown() @classmethod def get_hypervisor_type(cls): @@ -95,6 +90,7 @@ class TestGuestOS(cloudstackTestCase): osdisplayname="testCentOS", oscategoryid=os_category.id ) + self.cleanup.append(self.guestos1) list_guestos = GuestOS.list(self.apiclient, id=self.guestos1.id, listall=True) self.assertNotEqual( len(list_guestos), @@ -112,6 +108,7 @@ class TestGuestOS(cloudstackTestCase): self.apiclient, id=self.guestos1.id ) + self.cleanup.remove(self.guestos1) @attr(tags=['advanced', 'simulator', 'basic', 'sg'], required_hardware=False) def test_CRUD_operations_guest_OS_mapping(self): @@ -127,6 +124,7 @@ class TestGuestOS(cloudstackTestCase): osdisplayname="testCentOS", oscategoryid=os_category.id ) + self.cleanup.append(self.guestos1) if self.hypervisor.hypervisor.lower() not in ["xenserver", "vmware"]: raise unittest.SkipTest("OS name check with hypervisor is supported only on XenServer and VMware") @@ -138,6 +136,7 @@ class TestGuestOS(cloudstackTestCase): hypervisorversion=self.hypervisor.hypervisorversion, osnameforhypervisor="testOSMappingName" ) + self.cleanup.append(self.guestosmapping1) list_guestos_mapping = GuestOsMapping.list(self.apiclient, id=self.guestosmapping1.id, listall=True) self.assertNotEqual( @@ -156,11 +155,13 @@ class TestGuestOS(cloudstackTestCase): self.apiclient, id=self.guestosmapping1.id ) + self.cleanup.remove(self.guestosmapping1) GuestOS.remove( self.apiclient, id=self.guestos1.id ) + self.cleanup.remove(self.guestos1) @attr(tags=['advanced', 'simulator', 'basic', 'sg'], required_hardware=False) def test_guest_OS_mapping_check_with_hypervisor(self): @@ -176,6 +177,7 @@ class TestGuestOS(cloudstackTestCase): osdisplayname="testOSname1", oscategoryid=os_category.id ) + self.cleanup.append(self.guestos1) if self.hypervisor.hypervisor.lower() not in ["xenserver", "vmware"]: raise unittest.SkipTest("OS name check with hypervisor is supported only on XenServer and VMware") @@ -193,6 +195,7 @@ class TestGuestOS(cloudstackTestCase): osnameforhypervisor=testosname, osmappingcheckenabled=True ) + self.cleanup.append(self.guestosmapping1) list_guestos_mapping = GuestOsMapping.list(self.apiclient, id=self.guestosmapping1.id, listall=True) self.assertNotEqual( @@ -211,11 +214,13 @@ class TestGuestOS(cloudstackTestCase): self.apiclient, id=self.guestosmapping1.id ) + self.cleanup.remove(self.guestosmapping1) GuestOS.remove( self.apiclient, id=self.guestos1.id ) + self.cleanup.remove(self.guestos1) @attr(tags=['advanced', 'simulator', 'basic', 'sg'], required_hardware=False) def test_guest_OS_mapping_check_with_hypervisor_failure(self): @@ -231,6 +236,7 @@ class TestGuestOS(cloudstackTestCase): osdisplayname="testOSname2", oscategoryid=os_category.id ) + self.cleanup.append(self.guestos1) if self.hypervisor.hypervisor.lower() not in ["xenserver", "vmware"]: raise unittest.SkipTest("OS name check with hypervisor is supported only on XenServer and VMware") @@ -246,10 +252,12 @@ class TestGuestOS(cloudstackTestCase): osnameforhypervisor=testosname, osmappingcheckenabled=True ) + self.cleanup.append(self.guestosmapping1) GuestOsMapping.remove( self.apiclient, id=self.guestosmapping1.id ) + self.cleanup.remove(self.guestosmapping1) self.fail("Since os mapping name is wrong, this API should fail") except CloudstackAPIException as e: self.debug("Addition guest OS mapping failed as expected %s " % e) @@ -257,4 +265,5 @@ class TestGuestOS(cloudstackTestCase): self.apiclient, id=self.guestos1.id ) + self.cleanup.remove(self.guestos1) return diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 557434ea2ee..3d232d887c8 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -4576,6 +4576,7 @@ class Project: def __init__(self, items): self.__dict__.update(items) + @classmethod def create(cls, apiclient, services, account=None, domainid=None, userid=None, accountid=None): """Create project""" @@ -6720,7 +6721,7 @@ class GuestOSCategory: class GuestOS: """Manage Guest OS""" - def __init__(self, items, services): + def __init__(self, items): self.__dict__.update(items) @classmethod @@ -6735,7 +6736,7 @@ class GuestOS: if details is not None: cmd.details = details - return (apiclient.addGuestOs(cmd)) + return GuestOS(apiclient.addGuestOs(cmd).__dict__) @classmethod def remove(cls, apiclient, id): @@ -6772,10 +6773,13 @@ class GuestOS: return (apiclient.listOsTypes(cmd)) + def delete(self, apiclient): + self.remove(apiclient, self.id) + class GuestOsMapping: """Manage Guest OS Mappings""" - def __init__(self, items, services): + def __init__(self, items): self.__dict__.update(items) @classmethod @@ -6793,7 +6797,7 @@ class GuestOsMapping: if forced is not None: cmd.forced = forced - return (apiclient.addGuestOsMapping(cmd)) + return GuestOsMapping(apiclient.addGuestOsMapping(cmd).__dict__) @classmethod def remove(cls, apiclient, id): @@ -6837,6 +6841,9 @@ class GuestOsMapping: return (apiclient.listGuestOsMapping(cmd)) + def delete(self, apiclient): + self.remove(apiclient, self.id) + class VMSchedule: def __init__(self, items):