You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by su...@apache.org on 2021/07/01 04:15:55 UTC

[cloudstack] branch main updated: tests: Fix test failures for Local storage and Basic zones (#5106)

This is an automated email from the ASF dual-hosted git repository.

sureshanaparti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 4645863  tests: Fix test failures for Local storage and Basic zones (#5106)
4645863 is described below

commit 4645863b25acc8510a75aa1d26ed73bd99339f01
Author: davidjumani <dj...@gmail.com>
AuthorDate: Thu Jul 1 09:45:21 2021 +0530

    tests: Fix test failures for Local storage and Basic zones (#5106)
    
    tests: Fix test failures for Local storage and Basic (SG) zones
    
    * Skip migrate vm when localstorage enabled
    * Fix test_direct_download.py
    * Skip test_03_create_network_domain_network_offering in basic zones
    * Skip test_03_create_vpc_domain_vpc_offering in basic zones
    * Skip test_01_add_primary_storage_disabled_host if localstorageenabled
---
 test/integration/smoke/test_direct_download.py     | 80 ++++++++++++----------
 .../smoke/test_domain_network_offerings.py         |  1 -
 .../integration/smoke/test_domain_vpc_offerings.py |  1 -
 test/integration/smoke/test_primary_storage.py     |  3 +
 test/integration/smoke/test_vm_life_cycle.py       |  3 +
 5 files changed, 48 insertions(+), 40 deletions(-)

diff --git a/test/integration/smoke/test_direct_download.py b/test/integration/smoke/test_direct_download.py
index 324fb59..b894f08 100644
--- a/test/integration/smoke/test_direct_download.py
+++ b/test/integration/smoke/test_direct_download.py
@@ -184,20 +184,28 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
                 cls.services["service_offerings"]["tiny"]
             )
             cls._cleanup.append(cls.service_offering)
-            cls.network_offering = NetworkOffering.create(
-                cls.apiclient,
-                cls.services["l2-network_offering"],
-            )
-            cls.network_offering.update(cls.apiclient, state='Enabled')
-            cls.services["network"]["networkoffering"] = cls.network_offering.id
-            cls.l2_network = Network.create(
-                cls.apiclient,
-                cls.services["l2-network"],
-                zoneid=cls.zone.id,
-                networkofferingid=cls.network_offering.id
-            )
-            cls._cleanup.append(cls.l2_network)
-            cls._cleanup.append(cls.network_offering)
+
+            if cls.zone.networktype == 'Basic' :
+                networks = Network.list(cls.apiclient)
+                if len(networks) == 0 :
+                    self.skipTest("Skipping test since no network found in basic zone")
+                else :
+                    cls.network = networks[0]
+            else :
+                cls.network_offering = NetworkOffering.create(
+                    cls.apiclient,
+                    cls.services["l2-network_offering"],
+                )
+                cls._cleanup.append(cls.network_offering)
+                cls.network_offering.update(cls.apiclient, state='Enabled')
+                cls.services["network"]["networkoffering"] = cls.network_offering.id
+                cls.network = Network.create(
+                    cls.apiclient,
+                    cls.services["l2-network"],
+                    zoneid=cls.zone.id,
+                    networkofferingid=cls.network_offering.id
+                )
+                cls._cleanup.append(cls.network)
 
             storage_pools = StoragePool.list(
                 cls.apiclient,
@@ -221,11 +229,7 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
 
     @classmethod
     def tearDownClass(cls):
-        try:
-            cleanup_resources(cls.apiclient, cls._cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
+        super(TestDirectDownloadTemplates, cls).tearDownClass()
 
     def setUp(self):
         self.apiclient = self.testClient.getApiClient()
@@ -234,11 +238,7 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
         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(TestDirectDownloadTemplates, self).tearDown()
 
     def getCurrentStoragePoolTags(self, poolId):
         local_pool = StoragePool.list(
@@ -269,6 +269,22 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
             tags=tags
         )
 
+    def deployVM(self, offering) :
+        if self.zone.networktype == 'Basic' :
+            vm = VirtualMachine.create(
+                self.apiclient,
+                self.services["virtual_machine"],
+                serviceofferingid=offering.id
+            )
+        else :
+            vm = VirtualMachine.create(
+                self.apiclient,
+                self.services["virtual_machine"],
+                serviceofferingid=offering.id,
+                networkids=self.network.id
+            )
+        self.cleanup.append(vm)
+        return vm
 
     @skipTestIf("nfsKvmNotAvailable")
     @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="false")
@@ -282,12 +298,7 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
         self.updateStoragePoolTags(self.nfsPoolId, test_tag)
         nfs_storage_offering = self.createServiceOffering("TestNFSStorageDirectDownload", "shared", test_tag)
 
-        vm = VirtualMachine.create(
-            self.apiclient,
-            self.services["virtual_machine"],
-            serviceofferingid=nfs_storage_offering.id,
-            networkids=self.l2_network.id
-        )
+        vm = self.deployVM(nfs_storage_offering)
         self.assertEqual(
             vm.state,
             "Running",
@@ -296,7 +307,6 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
 
         # Revert storage tags for the storage pool used in this test
         self.updateStoragePoolTags(self.nfsPoolId, tags)
-        self.cleanup.append(vm)
         self.cleanup.append(nfs_storage_offering)
         return
 
@@ -313,12 +323,7 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
         local_storage_offering = self.createServiceOffering("TestLocalStorageDirectDownload", "local", test_tag)
 
         # Deploy VM
-        vm = VirtualMachine.create(
-            self.apiclient,
-            self.services["virtual_machine"],
-            serviceofferingid=local_storage_offering.id,
-            networkids=self.l2_network.id,
-        )
+        vm = self.deployVM(local_storage_offering)
         self.assertEqual(
             vm.state,
             "Running",
@@ -327,7 +332,6 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
 
         # Revert storage tags for the storage pool used in this test
         self.updateStoragePoolTags(self.localPoolId, tags)
-        self.cleanup.append(vm)
         self.cleanup.append(local_storage_offering)
         return
 
diff --git a/test/integration/smoke/test_domain_network_offerings.py b/test/integration/smoke/test_domain_network_offerings.py
index 0bab9a1..d2d6120 100644
--- a/test/integration/smoke/test_domain_network_offerings.py
+++ b/test/integration/smoke/test_domain_network_offerings.py
@@ -274,7 +274,6 @@ class TestDomainsNetworkOfferings(cloudstackTestCase):
     @attr(
         tags=[
             "advanced",
-            "basic",
             "eip",
             "sg",
             "advancedns",
diff --git a/test/integration/smoke/test_domain_vpc_offerings.py b/test/integration/smoke/test_domain_vpc_offerings.py
index 928c24a..f3d31b2 100644
--- a/test/integration/smoke/test_domain_vpc_offerings.py
+++ b/test/integration/smoke/test_domain_vpc_offerings.py
@@ -319,7 +319,6 @@ class TestDomainsVpcOfferings(cloudstackTestCase):
     @attr(
         tags=[
             "advanced",
-            "basic",
             "eip",
             "sg",
             "advancedns",
diff --git a/test/integration/smoke/test_primary_storage.py b/test/integration/smoke/test_primary_storage.py
index 7c0a948..4e630b7 100644
--- a/test/integration/smoke/test_primary_storage.py
+++ b/test/integration/smoke/test_primary_storage.py
@@ -256,6 +256,9 @@ class TestPrimaryStorageServices(cloudstackTestCase):
         """Test add primary storage pool with disabled host
         """
 
+        if self.zone.localstorageenabled :
+            self.skipTest("Skipping since localstorageenabled")
+
         # Disable a host
         clusters = list_clusters(
             self.apiclient,
diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py
index d6a7890..61b3a22 100644
--- a/test/integration/smoke/test_vm_life_cycle.py
+++ b/test/integration/smoke/test_vm_life_cycle.py
@@ -613,6 +613,9 @@ class TestVMLifeCycle(cloudstackTestCase):
         # 2. DeployVM on suitable host (with another host in the cluster)
         # 3. Migrate the VM and assert migration successful
 
+        if self.zone.localstorageenabled :
+            self.skipTest("Migration is not supported on zones with local storage")
+
         suitable_hosts = None
 
         hosts = Host.list(