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/24 12:59:48 UTC
git commit: updated refs/heads/master to 9a58794
Repository: cloudstack
Updated Branches:
refs/heads/master 23f4c022c -> 9a58794a0
CLOUDSTACK-8394: Use custom decorator to skip test case
Signed-off-by: Gaurav Aradhye <ga...@clogeny.com>
This closes #190
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9a58794a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9a58794a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9a58794a
Branch: refs/heads/master
Commit: 9a58794a04f8f94c5b04b93b39e5544eb75b5a8e
Parents: 23f4c02
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Fri Apr 24 14:15:37 2015 +0530
Committer: Gaurav Aradhye <ga...@clogeny.com>
Committed: Fri Apr 24 16:29:09 2015 +0530
----------------------------------------------------------------------
test/integration/smoke/test_snapshots.py | 54 ++++++++++++---------
tools/marvin/marvin/lib/decoratorGenerators.py | 34 +++++++++++++
2 files changed, 65 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a58794a/test/integration/smoke/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py
index 2df1778..d230c67 100644
--- a/test/integration/smoke/test_snapshots.py
+++ b/test/integration/smoke/test_snapshots.py
@@ -17,11 +17,19 @@
from marvin.codes import FAILED
from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import (cleanup_resources,
+ is_snapshot_on_nfs)
+from marvin.lib.base import (VirtualMachine,
+ Account,
+ ServiceOffering,
+ Snapshot)
+from marvin.lib.common import (get_domain,
+ get_template,
+ get_zone,
+ list_volumes,
+ list_snapshots)
+from marvin.lib.decoratorGenerators import skipTestIf
class TestSnapshotRootDisk(cloudstackTestCase):
@@ -36,34 +44,39 @@ class TestSnapshotRootDisk(cloudstackTestCase):
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
+ cls.hypervisorNotSupported = False
cls.hypervisor = cls.testClient.getHypervisorInfo()
if cls.hypervisor.lower() in ['hyperv', 'lxc']:
- raise unittest.SkipTest("Snapshots not supported on Hyper-V or LXC")
+ cls.hypervisorNotSupported = True
- template = get_template(
+ cls._cleanup = []
+ if not cls.hypervisorNotSupported:
+ template = get_template(
cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
- if template == FAILED:
- assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
- cls.services["domainid"] = cls.domain.id
- cls.services["server_without_disk"]["zoneid"] = cls.zone.id
- cls.services["templates"]["ostypeid"] = template.ostypeid
- cls.services["zoneid"] = cls.zone.id
+ cls.services["domainid"] = cls.domain.id
+ cls.services["server_without_disk"]["zoneid"] = cls.zone.id
+ cls.services["templates"]["ostypeid"] = template.ostypeid
+ cls.services["zoneid"] = cls.zone.id
- # Create VMs, NAT Rules etc
- cls.account = Account.create(
+ # Create VMs, NAT Rules etc
+ cls.account = Account.create(
cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
- cls.service_offering = ServiceOffering.create(
+ cls._cleanup.append(cls.account)
+ cls.service_offering = ServiceOffering.create(
cls.apiclient,
cls.services["service_offerings"]
)
- cls.virtual_machine = cls.virtual_machine_with_disk = \
+ cls._cleanup.append(cls.service_offering)
+ cls.virtual_machine = cls.virtual_machine_with_disk = \
VirtualMachine.create(
cls.apiclient,
cls.services["server_without_disk"],
@@ -73,10 +86,6 @@ class TestSnapshotRootDisk(cloudstackTestCase):
serviceofferingid=cls.service_offering.id,
mode=cls.services["mode"]
)
- cls._cleanup = [
- cls.service_offering,
- cls.account,
- ]
return
@classmethod
@@ -102,6 +111,7 @@ class TestSnapshotRootDisk(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e)
return
+ @skipTestIf("hypervisorNotSupported")
@attr(tags = ["advanced", "advancedns", "smoke"], required_hardware="true")
def test_01_snapshot_root_disk(self):
"""Test Snapshot Root Disk
@@ -166,8 +176,6 @@ class TestSnapshotRootDisk(cloudstackTestCase):
qresult = qresultset[0]
snapshot_uuid = qresult[0] # backup_snap_id = snapshot UUID
- account_id = qresult[1]
- volume_id = qresult[2]
self.assertNotEqual(
str(snapshot_uuid),
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a58794a/tools/marvin/marvin/lib/decoratorGenerators.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/decoratorGenerators.py b/tools/marvin/marvin/lib/decoratorGenerators.py
new file mode 100644
index 0000000..8bc43b8
--- /dev/null
+++ b/tools/marvin/marvin/lib/decoratorGenerators.py
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Custom decorator generators used across test cases
+"""
+
+from functools import wraps
+
+def skipTestIf(attribute):
+ def decorator(test):
+ @wraps(test)
+ def test_wrapper(self, *args, **kwargs):
+ if hasattr(self, attribute):
+ if getattr(self, attribute):
+ self.skipTest("Skipping test: Reason - %s" % attribute)
+ else:
+ return test(self, *args, **kwargs)
+ else:
+ return test(self, *args, **kwargs)
+ return test_wrapper
+ return decorator