mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8394: Use custom decorator to skip test case
Signed-off-by: Gaurav Aradhye <gaurav.aradhye@clogeny.com> This closes #190
This commit is contained in:
parent
23f4c022c2
commit
9a58794a04
@ -17,11 +17,19 @@
|
|||||||
|
|
||||||
from marvin.codes import FAILED
|
from marvin.codes import FAILED
|
||||||
from nose.plugins.attrib import attr
|
from nose.plugins.attrib import attr
|
||||||
from marvin.cloudstackTestCase import *
|
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||||
from marvin.cloudstackAPI import *
|
from marvin.lib.utils import (cleanup_resources,
|
||||||
from marvin.lib.utils import *
|
is_snapshot_on_nfs)
|
||||||
from marvin.lib.base import *
|
from marvin.lib.base import (VirtualMachine,
|
||||||
from marvin.lib.common import *
|
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):
|
class TestSnapshotRootDisk(cloudstackTestCase):
|
||||||
|
|
||||||
@ -36,34 +44,39 @@ class TestSnapshotRootDisk(cloudstackTestCase):
|
|||||||
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.hypervisorNotSupported = False
|
||||||
cls.hypervisor = cls.testClient.getHypervisorInfo()
|
cls.hypervisor = cls.testClient.getHypervisorInfo()
|
||||||
if cls.hypervisor.lower() in ['hyperv', 'lxc']:
|
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.apiclient,
|
||||||
cls.zone.id,
|
cls.zone.id,
|
||||||
cls.services["ostype"]
|
cls.services["ostype"]
|
||||||
)
|
)
|
||||||
if template == FAILED:
|
if template == FAILED:
|
||||||
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
|
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
|
||||||
|
|
||||||
cls.services["domainid"] = cls.domain.id
|
cls.services["domainid"] = cls.domain.id
|
||||||
cls.services["server_without_disk"]["zoneid"] = cls.zone.id
|
cls.services["server_without_disk"]["zoneid"] = cls.zone.id
|
||||||
cls.services["templates"]["ostypeid"] = template.ostypeid
|
cls.services["templates"]["ostypeid"] = template.ostypeid
|
||||||
cls.services["zoneid"] = cls.zone.id
|
cls.services["zoneid"] = cls.zone.id
|
||||||
|
|
||||||
# Create VMs, NAT Rules etc
|
# Create VMs, NAT Rules etc
|
||||||
cls.account = Account.create(
|
cls.account = Account.create(
|
||||||
cls.apiclient,
|
cls.apiclient,
|
||||||
cls.services["account"],
|
cls.services["account"],
|
||||||
domainid=cls.domain.id
|
domainid=cls.domain.id
|
||||||
)
|
)
|
||||||
cls.service_offering = ServiceOffering.create(
|
cls._cleanup.append(cls.account)
|
||||||
|
cls.service_offering = ServiceOffering.create(
|
||||||
cls.apiclient,
|
cls.apiclient,
|
||||||
cls.services["service_offerings"]
|
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(
|
VirtualMachine.create(
|
||||||
cls.apiclient,
|
cls.apiclient,
|
||||||
cls.services["server_without_disk"],
|
cls.services["server_without_disk"],
|
||||||
@ -73,10 +86,6 @@ class TestSnapshotRootDisk(cloudstackTestCase):
|
|||||||
serviceofferingid=cls.service_offering.id,
|
serviceofferingid=cls.service_offering.id,
|
||||||
mode=cls.services["mode"]
|
mode=cls.services["mode"]
|
||||||
)
|
)
|
||||||
cls._cleanup = [
|
|
||||||
cls.service_offering,
|
|
||||||
cls.account,
|
|
||||||
]
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -102,6 +111,7 @@ class TestSnapshotRootDisk(cloudstackTestCase):
|
|||||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@skipTestIf("hypervisorNotSupported")
|
||||||
@attr(tags = ["advanced", "advancedns", "smoke"], required_hardware="true")
|
@attr(tags = ["advanced", "advancedns", "smoke"], required_hardware="true")
|
||||||
def test_01_snapshot_root_disk(self):
|
def test_01_snapshot_root_disk(self):
|
||||||
"""Test Snapshot Root Disk
|
"""Test Snapshot Root Disk
|
||||||
@ -166,8 +176,6 @@ class TestSnapshotRootDisk(cloudstackTestCase):
|
|||||||
qresult = qresultset[0]
|
qresult = qresultset[0]
|
||||||
|
|
||||||
snapshot_uuid = qresult[0] # backup_snap_id = snapshot UUID
|
snapshot_uuid = qresult[0] # backup_snap_id = snapshot UUID
|
||||||
account_id = qresult[1]
|
|
||||||
volume_id = qresult[2]
|
|
||||||
|
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
str(snapshot_uuid),
|
str(snapshot_uuid),
|
||||||
|
|||||||
34
tools/marvin/marvin/lib/decoratorGenerators.py
Normal file
34
tools/marvin/marvin/lib/decoratorGenerators.py
Normal file
@ -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
|
||||||
Loading…
x
Reference in New Issue
Block a user