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

View File

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

View File

@ -125,7 +125,7 @@ class TestAdapterTypeForNic(cloudstackTestCase):
""" """
if self.hypervisor.lower() not in ["vmware"]: 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") for Vmware hypervisor")
# Register a private template in the account with nic adapter vmxnet3 # Register a private template in the account with nic adapter vmxnet3

View File

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

View File

@ -44,6 +44,10 @@ class TestCreateTemplate(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection() self.dbclient = self.testClient.getDbConnection()
self.cleanup = [] self.cleanup = []
if self.unsupportedHypervisor:
self.skipTest("Skipping test because unsupported hypervisor\
%s" % self.hypervisor)
return return
def tearDown(self): def tearDown(self):
@ -59,17 +63,19 @@ class TestCreateTemplate(cloudstackTestCase):
def setUpClass(cls): def setUpClass(cls):
testClient = super(TestCreateTemplate, cls).getClsTestClient() testClient = super(TestCreateTemplate, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient() cls.apiclient = testClient.getApiClient()
cls._cleanup = []
cls.services = testClient.getParsedTestDataConfig() cls.services = testClient.getParsedTestDataConfig()
cls.unsupportedHypervisor = False
cls.hypervisor = testClient.getHypervisorInfo() cls.hypervisor = testClient.getHypervisorInfo()
if cls.hypervisor.lower() in ['lxc']: 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 # Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient) cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests()) cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype cls.services['mode'] = cls.zone.networktype
cls._cleanup = []
try: try:
cls.disk_offering = DiskOffering.create( cls.disk_offering = DiskOffering.create(
cls.apiclient, cls.apiclient,
@ -210,10 +216,14 @@ class TestTemplates(cloudstackTestCase):
testClient = super(TestTemplates, cls).getClsTestClient() testClient = super(TestTemplates, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient() cls.apiclient = testClient.getApiClient()
cls._cleanup = []
cls.services = testClient.getParsedTestDataConfig() cls.services = testClient.getParsedTestDataConfig()
cls.unsupportedHypervisor = False
cls.hypervisor = testClient.getHypervisorInfo() cls.hypervisor = testClient.getHypervisorInfo()
if cls.hypervisor.lower() in ['lxc']: 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 # Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient) cls.domain = get_domain(cls.apiclient)
@ -325,6 +335,10 @@ class TestTemplates(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection() self.dbclient = self.testClient.getDbConnection()
self.cleanup = [] self.cleanup = []
if self.unsupportedHypervisor:
self.skipTest("Skipping test because unsupported hypervisor\
%s" % self.hypervisor)
return return
def tearDown(self): def tearDown(self):

View File

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

View File

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