You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ga...@apache.org on 2015/04/28 09:04:18 UTC

git commit: updated refs/heads/master to bede34d

Repository: cloudstack
Updated Branches:
  refs/heads/master 04365601d -> bede34d29


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

Signed-off-by: Gaurav Aradhye <ga...@clogeny.com>
This closes #203


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/bede34d2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/bede34d2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/bede34d2

Branch: refs/heads/master
Commit: bede34d297a8578d0b7c412d0208ed00ad1fe144
Parents: 0436560
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Tue Apr 28 12:25:23 2015 +0530
Committer: Gaurav Aradhye <ga...@clogeny.com>
Committed: Tue Apr 28 12:33:54 2015 +0530

----------------------------------------------------------------------
 .../smoke/test_deploy_vgpu_enabled_vm.py        | 22 +++++++-----
 test/integration/smoke/test_nic.py              |  4 +--
 test/integration/smoke/test_nic_adapter_type.py |  2 +-
 test/integration/smoke/test_scale_vm.py         | 13 ++++---
 test/integration/smoke/test_templates.py        | 22 +++++++++---
 test/integration/smoke/test_vm_snapshots.py     | 34 +++++++++++-------
 test/integration/smoke/test_volumes.py          | 37 +++++++++++---------
 7 files changed, 86 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bede34d2/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vgpu_enabled_vm.py b/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
index 7cf46ea..e71bae1 100644
--- a/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
+++ b/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
@@ -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)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bede34d2/test/integration/smoke/test_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_nic.py b/test/integration/smoke/test_nic.py
index 86faa56..7067074 100644
--- a/test/integration/smoke/test_nic.py
+++ b/test/integration/smoke/test_nic.py
@@ -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()

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bede34d2/test/integration/smoke/test_nic_adapter_type.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_nic_adapter_type.py b/test/integration/smoke/test_nic_adapter_type.py
index 262dab5..91492eb 100644
--- a/test/integration/smoke/test_nic_adapter_type.py
+++ b/test/integration/smoke/test_nic_adapter_type.py
@@ -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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bede34d2/test/integration/smoke/test_scale_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py
index 4e1eade..6968277 100644
--- a/test/integration/smoke/test_scale_vm.py
+++ b/test/integration/smoke/test_scale_vm.py
@@ -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)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bede34d2/test/integration/smoke/test_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py
index 4153ca3..2170163 100644
--- a/test/integration/smoke/test_templates.py
+++ b/test/integration/smoke/test_templates.py
@@ -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):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bede34d2/test/integration/smoke/test_vm_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py
index 5d5cdc4..58ac7e5 100644
--- a/test/integration/smoke/test_vm_snapshots.py
+++ b/test/integration/smoke/test_vm_snapshots.py
@@ -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)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bede34d2/test/integration/smoke/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py
index 3362396..1b7ef33 100644
--- a/test/integration/smoke/test_volumes.py
+++ b/test/integration/smoke/test_volumes.py
@@ -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:
@@ -454,7 +460,7 @@ class TestVolumes(cloudstackTestCase):
         #with self.assertRaises(Exception):
         with self.assertRaises(Exception):
             self.apiClient.deleteVolume(cmd)
-        
+
     @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="false")
     def test_05_detach_volume(self):
         """Detach a Volume attached to a VM
@@ -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)" % (
@@ -619,7 +624,7 @@ class TestVolumes(cloudstackTestCase):
         if hosts[0].hypervisor == "XenServer":
             self.virtual_machine.start(self.apiClient)
             time.sleep(30)
-        return 
+        return
 
 
     @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")