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
This commit is contained in:
davidjumani 2021-07-01 09:45:21 +05:30 committed by GitHub
parent 7835c08120
commit 4645863b25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 40 deletions

View File

@ -184,20 +184,28 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
cls.services["service_offerings"]["tiny"] cls.services["service_offerings"]["tiny"]
) )
cls._cleanup.append(cls.service_offering) cls._cleanup.append(cls.service_offering)
cls.network_offering = NetworkOffering.create(
cls.apiclient, if cls.zone.networktype == 'Basic' :
cls.services["l2-network_offering"], networks = Network.list(cls.apiclient)
) if len(networks) == 0 :
cls.network_offering.update(cls.apiclient, state='Enabled') self.skipTest("Skipping test since no network found in basic zone")
cls.services["network"]["networkoffering"] = cls.network_offering.id else :
cls.l2_network = Network.create( cls.network = networks[0]
cls.apiclient, else :
cls.services["l2-network"], cls.network_offering = NetworkOffering.create(
zoneid=cls.zone.id, cls.apiclient,
networkofferingid=cls.network_offering.id cls.services["l2-network_offering"],
) )
cls._cleanup.append(cls.l2_network) cls._cleanup.append(cls.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( storage_pools = StoragePool.list(
cls.apiclient, cls.apiclient,
@ -221,11 +229,7 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: super(TestDirectDownloadTemplates, cls).tearDownClass()
cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
@ -234,11 +238,7 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
return return
def tearDown(self): def tearDown(self):
try: super(TestDirectDownloadTemplates, self).tearDown()
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def getCurrentStoragePoolTags(self, poolId): def getCurrentStoragePoolTags(self, poolId):
local_pool = StoragePool.list( local_pool = StoragePool.list(
@ -269,6 +269,22 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
tags=tags 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") @skipTestIf("nfsKvmNotAvailable")
@attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="false") @attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="false")
@ -282,12 +298,7 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
self.updateStoragePoolTags(self.nfsPoolId, test_tag) self.updateStoragePoolTags(self.nfsPoolId, test_tag)
nfs_storage_offering = self.createServiceOffering("TestNFSStorageDirectDownload", "shared", test_tag) nfs_storage_offering = self.createServiceOffering("TestNFSStorageDirectDownload", "shared", test_tag)
vm = VirtualMachine.create( vm = self.deployVM(nfs_storage_offering)
self.apiclient,
self.services["virtual_machine"],
serviceofferingid=nfs_storage_offering.id,
networkids=self.l2_network.id
)
self.assertEqual( self.assertEqual(
vm.state, vm.state,
"Running", "Running",
@ -296,7 +307,6 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
# Revert storage tags for the storage pool used in this test # Revert storage tags for the storage pool used in this test
self.updateStoragePoolTags(self.nfsPoolId, tags) self.updateStoragePoolTags(self.nfsPoolId, tags)
self.cleanup.append(vm)
self.cleanup.append(nfs_storage_offering) self.cleanup.append(nfs_storage_offering)
return return
@ -313,12 +323,7 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
local_storage_offering = self.createServiceOffering("TestLocalStorageDirectDownload", "local", test_tag) local_storage_offering = self.createServiceOffering("TestLocalStorageDirectDownload", "local", test_tag)
# Deploy VM # Deploy VM
vm = VirtualMachine.create( vm = self.deployVM(local_storage_offering)
self.apiclient,
self.services["virtual_machine"],
serviceofferingid=local_storage_offering.id,
networkids=self.l2_network.id,
)
self.assertEqual( self.assertEqual(
vm.state, vm.state,
"Running", "Running",
@ -327,7 +332,6 @@ class TestDirectDownloadTemplates(cloudstackTestCase):
# Revert storage tags for the storage pool used in this test # Revert storage tags for the storage pool used in this test
self.updateStoragePoolTags(self.localPoolId, tags) self.updateStoragePoolTags(self.localPoolId, tags)
self.cleanup.append(vm)
self.cleanup.append(local_storage_offering) self.cleanup.append(local_storage_offering)
return return

View File

@ -274,7 +274,6 @@ class TestDomainsNetworkOfferings(cloudstackTestCase):
@attr( @attr(
tags=[ tags=[
"advanced", "advanced",
"basic",
"eip", "eip",
"sg", "sg",
"advancedns", "advancedns",

View File

@ -319,7 +319,6 @@ class TestDomainsVpcOfferings(cloudstackTestCase):
@attr( @attr(
tags=[ tags=[
"advanced", "advanced",
"basic",
"eip", "eip",
"sg", "sg",
"advancedns", "advancedns",

View File

@ -256,6 +256,9 @@ class TestPrimaryStorageServices(cloudstackTestCase):
"""Test add primary storage pool with disabled host """Test add primary storage pool with disabled host
""" """
if self.zone.localstorageenabled :
self.skipTest("Skipping since localstorageenabled")
# Disable a host # Disable a host
clusters = list_clusters( clusters = list_clusters(
self.apiclient, self.apiclient,

View File

@ -613,6 +613,9 @@ class TestVMLifeCycle(cloudstackTestCase):
# 2. DeployVM on suitable host (with another host in the cluster) # 2. DeployVM on suitable host (with another host in the cluster)
# 3. Migrate the VM and assert migration successful # 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 suitable_hosts = None
hosts = Host.list( hosts = Host.list(