CLOUDSTACK-8394: Skip test cases through setUp() instead of setUpClass()

Signed-off-by: Gaurav Aradhye <gaurav.aradhye@clogeny.com>
This closes #203
This commit is contained in:
Gaurav Aradhye 2015-04-28 12:25:23 +05:30
parent 04365601da
commit bede34d297
7 changed files with 86 additions and 48 deletions

View File

@ -18,7 +18,7 @@
# Test from the Marvin - Testing in Python wiki
# All tests inherit from cloudstackTestCase
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.cloudstackTestCase import cloudstackTestCase
# Import Integration Libraries
@ -49,6 +49,9 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
testClient = super(TestDeployvGPUenabledVM, self).getClsTestClient()
self.apiclient = testClient.getApiClient()
self.testdata = self.testClient.getParsedTestDataConfig()
self._cleanup = []
self.unsupportedHypervisor = False
self.noSuitableHost = False
# Need to add check whether zone containing the xen hypervisor or not
# as well
hosts = list_hosts(
@ -56,8 +59,9 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
hypervisor="XenServer"
)
if hosts is None:
raise unittest.SkipTest(
"There are no XenServers available. GPU feature is supported only on XenServer.Check listhosts response")
# GPU feature is supported only on XenServer.Check listhosts response
self.unsupportedHypervisor = True
return
else:
gpuhosts = 0
for ghost in hosts:
@ -79,8 +83,9 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
else:
continue
if gpuhosts == 0:
raise unittest.SkipTest(
"No XenServer available with GPU Drivers installed")
# No XenServer available with GPU Drivers installed
self.noSuitableHost = True
return
self.domain = get_domain(self.apiclient)
self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
@ -90,13 +95,14 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
self.testdata["account"],
domainid=self.domain.id
)
self._cleanup = [
self.account
]
self._cleanup.append(self.account)
def setUp(self):
self.testdata = self.testClient.getParsedTestDataConfig()["vgpu"]
self.apiclient = self.testClient.getApiClient()
if self.noSuitableHost or self.unsupportedHypervisor:
self.skipTest("Skipping test because suitable hypervisor/host not\
present")
# Get Zone, Domain and Default Built-in template
self.domain = get_domain(self.apiclient)

View File

@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
""" NIC tests for VM """
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.lib.base import (Account,
ServiceOffering,
Network,
@ -47,7 +47,7 @@ class TestNic(cloudstackTestCase):
self.hypervisor = self.testClient.getHypervisorInfo()
if self.hypervisor.lower() == "hyperv":
raise unittest.SkipTest("Not supported on Hyper-V")
self.skipTest("Not supported on Hyper-V")
try:
self.apiclient = self.testClient.getApiClient()

View File

@ -125,7 +125,7 @@ class TestAdapterTypeForNic(cloudstackTestCase):
"""
if self.hypervisor.lower() not in ["vmware"]:
raise unittest.SkipTest("This test case is written specifically\
self.skipTest("This test case is written specifically\
for Vmware hypervisor")
# Register a private template in the account with nic adapter vmxnet3

View File

@ -18,7 +18,7 @@
"""
# Import Local Modules
from marvin.codes import FAILED
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.cloudstackAPI import scaleVirtualMachine
from marvin.lib.utils import cleanup_resources
from marvin.lib.base import (Account,
@ -39,11 +39,12 @@ class TestScaleVm(cloudstackTestCase):
testClient = super(TestScaleVm, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.services = testClient.getParsedTestDataConfig()
cls._cleanup = []
cls.unsupportedHypervisor = False
cls.hypervisor = cls.testClient.getHypervisorInfo()
if cls.hypervisor.lower() in ('kvm', 'hyperv', 'lxc'):
raise unittest.SkipTest(
"ScaleVM is not supported on KVM, Hyper-V or LXC.\
Hence, skipping the test")
cls.unsupportedHypervisor = True
return
# Get Zone, Domain and templates
domain = get_domain(cls.apiclient)
@ -107,6 +108,10 @@ class TestScaleVm(cloudstackTestCase):
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
if self.unsupportedHypervisor:
self.skipTest("Skipping test because unsupported hypervisor\
%s" % self.hypervisor)
def tearDown(self):
# Clean up, terminate the created ISOs
cleanup_resources(self.apiclient, self.cleanup)

View File

@ -44,6 +44,10 @@ class TestCreateTemplate(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
if self.unsupportedHypervisor:
self.skipTest("Skipping test because unsupported hypervisor\
%s" % self.hypervisor)
return
def tearDown(self):
@ -59,17 +63,19 @@ class TestCreateTemplate(cloudstackTestCase):
def setUpClass(cls):
testClient = super(TestCreateTemplate, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls._cleanup = []
cls.services = testClient.getParsedTestDataConfig()
cls.unsupportedHypervisor = False
cls.hypervisor = testClient.getHypervisorInfo()
if cls.hypervisor.lower() in ['lxc']:
raise unittest.SkipTest("Template creation from root volume is not supported in LXC")
# Template creation from root volume is not supported in LXC
cls.unsupportedHypervisor = True
return
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls._cleanup = []
try:
cls.disk_offering = DiskOffering.create(
cls.apiclient,
@ -210,10 +216,14 @@ class TestTemplates(cloudstackTestCase):
testClient = super(TestTemplates, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls._cleanup = []
cls.services = testClient.getParsedTestDataConfig()
cls.unsupportedHypervisor = False
cls.hypervisor = testClient.getHypervisorInfo()
if cls.hypervisor.lower() in ['lxc']:
raise unittest.SkipTest("Template creation from root volume is not supported in LXC")
# Template creation from root volume is not supported in LXC
cls.unsupportedHypervisor = True
return
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
@ -325,6 +335,10 @@ class TestTemplates(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
if self.unsupportedHypervisor:
self.skipTest("Skipping test because unsupported hypervisor\
%s" % self.hypervisor)
return
def tearDown(self):

View File

@ -18,7 +18,7 @@
# Import Local Modules
from marvin.codes import FAILED, KVM, PASS
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.lib.utils import random_gen, cleanup_resources, validateList
from marvin.lib.base import (Account,
ServiceOffering,
@ -37,13 +37,14 @@ class TestVmSnapshot(cloudstackTestCase):
@classmethod
def setUpClass(cls):
testClient = super(TestVmSnapshot, cls).getClsTestClient()
hypervisor = testClient.getHypervisorInfo()
if hypervisor.lower() in (KVM.lower(), "hyperv", "lxc"):
raise unittest.SkipTest(
"VM snapshot feature is not supported on KVM, Hyper-V or LXC")
cls.apiclient = testClient.getApiClient()
cls._cleanup = []
cls.unsupportedHypervisor = False
cls.hypervisor = testClient.getHypervisorInfo()
if cls.hypervisor.lower() in (KVM.lower(), "hyperv", "lxc"):
cls.unsupportedHypervisor = True
return
cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
@ -69,11 +70,13 @@ class TestVmSnapshot(cloudstackTestCase):
cls.services["account"],
domainid=cls.domain.id
)
cls._cleanup.append(cls.account)
cls.service_offering = ServiceOffering.create(
cls.apiclient,
cls.services["service_offerings"]
)
cls._cleanup.append(cls.service_offering)
cls.virtual_machine = VirtualMachine.create(
cls.apiclient,
cls.services["server"],
@ -86,10 +89,6 @@ class TestVmSnapshot(cloudstackTestCase):
cls.random_data_0 = random_gen(size=100)
cls.test_dir = "/tmp"
cls.random_data = "random.data"
cls._cleanup = [
cls.service_offering,
cls.account,
]
return
@classmethod
@ -105,6 +104,10 @@ class TestVmSnapshot(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
if self.unsupportedHypervisor:
self.skipTest("Skipping test because unsupported hypervisor\
%s" % self.hypervisor)
return
def tearDown(self):
@ -285,10 +288,11 @@ class TestSnapshots(cloudstackTestCase):
cls.testClient = super(TestSnapshots, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = cls.testClient.getParsedTestDataConfig()
cls.unsupportedHypervisor = False
cls.hypervisor = cls.testClient.getHypervisorInfo()
if cls.hypervisor.lower() in (KVM.lower(), "hyperv", "lxc"):
raise unittest.SkipTest(
"VM snapshot feature is not supported on KVM, Hyper-V or LXC")
cls.unsupportedHypervisor = True
return
# Get Domain, Zone, Template
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(
@ -335,6 +339,10 @@ class TestSnapshots(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient()
self.cleanup = []
if self.unsupportedHypervisor:
self.skipTest("Skipping test because unsupported\
hypervisor %s" % self.hypervisor)
def tearDown(self):
# Clean up, terminate the created resources
cleanup_resources(self.apiclient, self.cleanup)

View File

@ -17,7 +17,7 @@
""" BVT tests for Volumes
"""
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.cloudstackTestCase import cloudstackTestCase
#from marvin.cloudstackException import *
from marvin.cloudstackAPI import (deleteVolume,
extractVolume,
@ -57,12 +57,16 @@ class TestCreateVolume(cloudstackTestCase):
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls._cleanup = []
cls.hypervisor = testClient.getHypervisorInfo()
cls.services['mode'] = cls.zone.networktype
cls.invalidStoragePoolType = False
#for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
if cls.hypervisor.lower() == 'lxc':
if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
raise unittest.SkipTest("RBD storage type is required for data volumes for LXC")
# RBD storage type is required for data volumes for LXC
cls.invalidStoragePoolType = True
return
cls.disk_offering = DiskOffering.create(
cls.apiclient,
cls.services["disk_offering"]
@ -120,6 +124,10 @@ class TestCreateVolume(cloudstackTestCase):
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
if self.invalidStoragePoolType:
self.skipTest("Skipping test because of valid storage\
pool not available")
@attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
def test_01_create_volume(self):
"""Test Volume creation for all Disk Offerings (incl. custom)
@ -264,16 +272,19 @@ class TestVolumes(cloudstackTestCase):
testClient = super(TestVolumes, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.services = testClient.getParsedTestDataConfig()
cls._cleanup = []
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.hypervisor = testClient.getHypervisorInfo()
cls.invalidStoragePoolType = False
#for LXC if the storage pool of type 'rbd' ex: ceph is not available, skip the test
if cls.hypervisor.lower() == 'lxc':
if not find_storage_pool_type(cls.apiclient, storagetype='rbd'):
raise unittest.SkipTest("RBD storage type is required for data volumes for LXC")
# RBD storage type is required for data volumes for LXC
cls.invalidStoragePoolType = True
return
cls.disk_offering = DiskOffering.create(
cls.apiclient,
cls.services["disk_offering"]
@ -321,16 +332,7 @@ class TestVolumes(cloudstackTestCase):
serviceofferingid=cls.service_offering.id,
mode=cls.services["mode"]
)
pools = StoragePool.list(cls.apiclient)
# cls.assertEqual(
# validateList(pools)[0],
# PASS,
# "storage pool list validation failed")
if cls.hypervisor.lower() == 'lxc' and cls.storage_pools.type.lower() != 'rbd':
raise unittest.SkipTest("Snapshots not supported on Hyper-V or LXC")
cls.volume = Volume.create(
cls.apiclient,
cls.services,
@ -359,6 +361,10 @@ class TestVolumes(cloudstackTestCase):
self.attached = False
self.cleanup = []
if self.invalidStoragePoolType:
self.skipTest("Skipping test because valid storage pool not\
available")
def tearDown(self):
#Clean up, terminate the created volumes
if self.attached:
@ -590,7 +596,6 @@ class TestVolumes(cloudstackTestCase):
cmd.id = self.volume.id
cmd.diskofferingid = self.services['diskofferingid']
cmd.size = 4
currentSize = self.volume.size
self.debug(
"Attaching volume (ID: %s) to VM (ID: %s)" % (