From 5e97dd54038c7fd204963b4ff55c903007b5a07c Mon Sep 17 00:00:00 2001 From: abh1sar Date: Mon, 1 Jul 2024 19:14:09 +0530 Subject: [PATCH 1/4] test_primary_storage_scope should only run with kvm, vmware and simulator --- test/integration/smoke/test_primary_storage_scope.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/smoke/test_primary_storage_scope.py b/test/integration/smoke/test_primary_storage_scope.py index e85a06b99f07..35c26ca3248e 100644 --- a/test/integration/smoke/test_primary_storage_scope.py +++ b/test/integration/smoke/test_primary_storage_scope.py @@ -35,11 +35,11 @@ def setUp(self): self._cleanup = [] self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.pod = get_pod(self.apiclient, self.zone.id) - self.debug("here") self.debug(self.services) self.cluster1 = list_clusters(self.apiclient)[0] - self.debug("here1") self.debug(self.cluster1) + if (self.cluster1.hypervisortype not in ['KVM', 'VMware', 'Simulator']): + cloudstackTestCase.skipTest(self, "Supported hypervisors (KVM, VMware, Simulator) not found. Skipping test.") self.cluster = { 'clustername': 'C0_testScope', 'clustertype': 'CloudManaged' From 16b40d5dab67f4c615ffdf4401bf2757f94caa47 Mon Sep 17 00:00:00 2001 From: abh1sar Date: Mon, 1 Jul 2024 19:30:54 +0530 Subject: [PATCH 2/4] move cluster create and storage pool create from setup to test so that they are cleaned up in case of failure --- .../smoke/test_primary_storage_scope.py | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/test/integration/smoke/test_primary_storage_scope.py b/test/integration/smoke/test_primary_storage_scope.py index 35c26ca3248e..41fca0175b09 100644 --- a/test/integration/smoke/test_primary_storage_scope.py +++ b/test/integration/smoke/test_primary_storage_scope.py @@ -38,12 +38,29 @@ def setUp(self): self.debug(self.services) self.cluster1 = list_clusters(self.apiclient)[0] self.debug(self.cluster1) + if (self.cluster1 == None): + cloudstackTestCase.skipTest(self, "Cluster not found. Skipping test.") if (self.cluster1.hypervisortype not in ['KVM', 'VMware', 'Simulator']): cloudstackTestCase.skipTest(self, "Supported hypervisors (KVM, VMware, Simulator) not found. Skipping test.") self.cluster = { 'clustername': 'C0_testScope', 'clustertype': 'CloudManaged' } + return + + def tearDown(self): + try: + cleanup_resources(self.apiclient, self._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + @attr(tags=["advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true") + def test_01_primary_storage_scope_change(self): + """Test primary storage pool scope change + """ + + # Create cluster self.cluster2 = Cluster.create(self.apiclient, self.cluster, zoneid=self.zone.id, @@ -51,6 +68,8 @@ def setUp(self): hypervisor=self.cluster1.hypervisortype ) self._cleanup.append(self.cluster2) + + # Create zone-wide storage pool self.storage = StoragePool.create(self.apiclient, self.services["nfs"], scope = 'ZONE', @@ -59,20 +78,7 @@ def setUp(self): ) self._cleanup.append(self.storage) self.debug("Created storage pool %s in zone scope", self.storage.id) - return - - def tearDown(self): - try: - cleanup_resources(self.apiclient, self._cleanup) - except Exception as e: - raise Exception("Warning: Exception during cleanup : %s" % e) - return - - @attr(tags=["advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true") - def test_01_primary_storage_scope_change(self): - """Test primary storage pool scope change - """ - + # Disable storage pool cmd = updateStoragePool.updateStoragePoolCmd() cmd.id = self.storage.id From d0ed67b27825a5a45c717ac29aa01577478ec489 Mon Sep 17 00:00:00 2001 From: abh1sar Date: Mon, 1 Jul 2024 19:40:13 +0530 Subject: [PATCH 3/4] fixed lint failure --- test/integration/smoke/test_primary_storage_scope.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/smoke/test_primary_storage_scope.py b/test/integration/smoke/test_primary_storage_scope.py index 41fca0175b09..3c17ebcc5c15 100644 --- a/test/integration/smoke/test_primary_storage_scope.py +++ b/test/integration/smoke/test_primary_storage_scope.py @@ -78,7 +78,7 @@ def test_01_primary_storage_scope_change(self): ) self._cleanup.append(self.storage) self.debug("Created storage pool %s in zone scope", self.storage.id) - + # Disable storage pool cmd = updateStoragePool.updateStoragePoolCmd() cmd.id = self.storage.id From e28e40f2d42ee06fbfcaf573b7e7889199abda1d Mon Sep 17 00:00:00 2001 From: abh1sar Date: Wed, 3 Jul 2024 10:14:12 +0530 Subject: [PATCH 4/4] using super class' tearDown --- test/integration/smoke/test_primary_storage_scope.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/integration/smoke/test_primary_storage_scope.py b/test/integration/smoke/test_primary_storage_scope.py index 3c17ebcc5c15..db2cd09b6169 100644 --- a/test/integration/smoke/test_primary_storage_scope.py +++ b/test/integration/smoke/test_primary_storage_scope.py @@ -32,7 +32,7 @@ def setUp(self): self.apiclient = self.testClient.getApiClient() self.dbclient = self.testClient.getDbConnection() self.services = self.testClient.getParsedTestDataConfig() - self._cleanup = [] + self.cleanup = [] self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests()) self.pod = get_pod(self.apiclient, self.zone.id) self.debug(self.services) @@ -49,11 +49,7 @@ def setUp(self): return def tearDown(self): - try: - cleanup_resources(self.apiclient, self._cleanup) - except Exception as e: - raise Exception("Warning: Exception during cleanup : %s" % e) - return + super(TestPrimaryStorageScope, self).tearDown() @attr(tags=["advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true") def test_01_primary_storage_scope_change(self): @@ -67,7 +63,7 @@ def test_01_primary_storage_scope_change(self): podid=self.pod.id, hypervisor=self.cluster1.hypervisortype ) - self._cleanup.append(self.cluster2) + self.cleanup.append(self.cluster2) # Create zone-wide storage pool self.storage = StoragePool.create(self.apiclient, @@ -76,7 +72,7 @@ def test_01_primary_storage_scope_change(self): zoneid=self.zone.id, hypervisor=self.cluster1.hypervisortype ) - self._cleanup.append(self.storage) + self.cleanup.append(self.storage) self.debug("Created storage pool %s in zone scope", self.storage.id) # Disable storage pool