CLOUDSTACK-8620 :skip test cases if rbd storage is not available in lxc setup

Signed-off-by: Daan Hoogland <daan.hoogland@gmail.com>
This commit is contained in:
nitt10prashant 2015-07-09 14:39:51 +05:30 committed by Daan Hoogland
parent 42940a8828
commit efee194b91

View File

@ -15,14 +15,16 @@
# specific language governing permissions and limitations
# under the License.
""" P1 tests for testing resize volume functionality with primary storage limit constraints on
account/domain
""" P1 tests for testing resize volume functionality with primary storage
imit constraints on account/domain
Test Plan: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Limit+Resources+to+domain+or+accounts
Test Plan: https://cwiki.apache.org/confluence/display/CLOUDSTACK/
Limit+Resources+to+domain+or+accounts
Issue Link: https://issues.apache.org/jira/browse/CLOUDSTACK-1466
Feature Specifications: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Limit+Resources+to+domains+and+accounts
Feature Specifications: https://cwiki.apache.org/confluence/display/
CLOUDSTACK/Limit+Resources+to+domains+and+accounts
"""
# Import Local Modules
from nose.plugins.attrib import attr
@ -38,7 +40,8 @@ from marvin.lib.common import (get_domain,
get_zone,
get_template,
matchResourceCount,
isDomainResourceCountEqualToExpectedCount)
isDomainResourceCountEqualToExpectedCount,
find_storage_pool_type)
from marvin.lib.utils import (cleanup_resources,
get_hypervisor_type)
from marvin.codes import (PASS,
@ -48,6 +51,7 @@ from marvin.codes import (PASS,
RESOURCE_SECONDARY_STORAGE,
XEN_SERVER)
class TestResizeVolume(cloudstackTestCase):
@classmethod
@ -55,17 +59,24 @@ class TestResizeVolume(cloudstackTestCase):
cloudstackTestClient = super(TestResizeVolume,
cls).getClsTestClient()
cls.api_client = cloudstackTestClient.getApiClient()
cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
# Fill services from the external config file
cls.services = cloudstackTestClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(cls.api_client, cloudstackTestClient.getZoneForTests())
cls.zone = get_zone(
cls.api_client,
cloudstackTestClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls._cleanup = []
cls.unsupportedStorageType = False
if cls.hypervisor.lower() == 'lxc':
if not find_storage_pool_type(cls.api_client, storagetype='rbd'):
cls.unsupportedStorageType = True
return
cls.resourcetypemapping = {RESOURCE_PRIMARY_STORAGE: 10,
RESOURCE_SECONDARY_STORAGE: 11}
cls.template = get_template(
cls.api_client,
cls.zone.id,
@ -76,13 +87,13 @@ class TestResizeVolume(cloudstackTestCase):
cls.services["virtual_machine"]["template"] = cls.template.id
cls.services["volume"]["zoneid"] = cls.zone.id
cls._cleanup = []
try:
cls.hypervisor = str(get_hypervisor_type(cls.api_client)).lower()
# Creating service offering with normal config
cls.service_offering = ServiceOffering.create(cls.api_client,
cls.services["service_offering"])
cls.services["\
service_offering"])
cls._cleanup.append(cls.service_offering)
cls.services["disk_offering"]["disksize"] = 5
@ -100,7 +111,9 @@ class TestResizeVolume(cloudstackTestCase):
cls._cleanup.append(cls.disk_offering_20_GB)
except Exception as e:
cls.tearDownClass()
raise unittest.SkipTest("Failure while creating disk offering: %s" % e)
raise unittest.SkipTest(
"Failure while creating disk offering: %s" %
e)
return
@classmethod
@ -113,6 +126,9 @@ class TestResizeVolume(cloudstackTestCase):
return
def setUp(self):
if self.unsupportedStorageType:
self.skipTest(
"unsupported storage type")
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
@ -139,8 +155,10 @@ class TestResizeVolume(cloudstackTestCase):
domainid=self.parent_domain.id)
if accountLimit:
# Update resource limit for domain
Resources.updateLimit(self.apiclient, resourcetype=10,
max=accountLimit, account=self.parentd_admin.name,
Resources.updateLimit(self.apiclient,
resourcetype=10,
max=accountLimit,
account=self.parentd_admin.name,
domainid=self.parent_domain.id)
except Exception as e:
return [FAIL, e]
@ -149,10 +167,13 @@ class TestResizeVolume(cloudstackTestCase):
def setupAccounts(self):
try:
self.parent_domain = Domain.create(self.apiclient,
services=self.services["domain"],
services=self.services[
"domain"],
parentdomainid=self.domain.id)
self.parentd_admin = Account.create(self.apiclient, self.services["account"],
admin=True, domainid=self.parent_domain.id)
self.parentd_admin = Account.create(self.apiclient,
self.services["account"],
admin=True,
domainid=self.parent_domain.id)
# Cleanup the resources created at end of test
self.cleanup.append(self.parentd_admin)
@ -163,16 +184,18 @@ class TestResizeVolume(cloudstackTestCase):
@attr(tags=["advanced"], required_hardware="true")
def test_01_increase_volume_size_within_account_limit(self):
"""Test increasing volume size within the account limit and verify primary storage usage
"""Test increasing volume size within the account limit and verify
primary storage usage
# Validate the following
# 1. Create a domain and its admin account
# 2. Set account primary storage limit well beyond (20 GB volume + template size of VM)
# 2. Set account primary storage limit well beyond (20 GB volume +
# template size of VM)
# 3. Deploy a VM without any disk offering (only root disk)
# 4. Create a volume of 5 GB in the account and attach it to the VM
# 5. Increase (resize) the volume to 20 GB
# 6. Resize opearation should be successful and primary storage counnt for
# account should be updated successfully"""
# 6. Resize operation should be successful and primary storage count
# for account should be updated successfully"""
# Setting up account and domain hierarchy
result = self.setupAccounts()
@ -191,13 +214,16 @@ class TestResizeVolume(cloudstackTestCase):
try:
virtualMachine = VirtualMachine.create(
apiclient, self.services["virtual_machine"],
accountid=self.parentd_admin.name, domainid=self.parent_domain.id,
accountid=self.parentd_admin.name,
domainid=self.parent_domain.id,
serviceofferingid=self.service_offering.id
)
volume = Volume.create(
apiclient,self.services["volume"],zoneid=self.zone.id,
account=self.parentd_admin.name,domainid=self.parent_domain.id,
apiclient, self.services["volume"],
zoneid=self.zone.id,
account=self.parentd_admin.name,
domainid=self.parent_domain.id,
diskofferingid=self.disk_offering_5_GB.id)
virtualMachine.attach_volume(apiclient, volume=volume)
@ -212,7 +238,9 @@ class TestResizeVolume(cloudstackTestCase):
if self.hypervisor == str(XEN_SERVER).lower():
virtualMachine.stop(self.apiclient)
volume.resize(apiclient, diskofferingid=self.disk_offering_20_GB.id)
volume.resize(
apiclient,
diskofferingid=self.disk_offering_20_GB.id)
expectedCount = (templateSize + self.disk_offering_20_GB.disksize)
response = matchResourceCount(
@ -231,8 +259,9 @@ class TestResizeVolume(cloudstackTestCase):
# Validate the following
# 1. Create a domain and its admin account
# 2. Set account primary storage limit more than (5 GB volume + template size of VM)
# and less than (20 GB volume+ template size of VM)
# 2. Set account primary storage limit more than (5 GB volume +
# template size of VM) and less than (20 GB volume+ template
# size of VM)
# 3. Deploy a VM without any disk offering (only root disk)
# 4. Create a volume of 5 GB in the account and attach it to the VM
# 5. Try to (resize) the volume to 20 GB
@ -256,13 +285,16 @@ class TestResizeVolume(cloudstackTestCase):
try:
virtualMachine = VirtualMachine.create(
apiclient, self.services["virtual_machine"],
accountid=self.parentd_admin.name, domainid=self.parent_domain.id,
accountid=self.parentd_admin.name,
domainid=self.parent_domain.id,
serviceofferingid=self.service_offering.id
)
volume = Volume.create(
apiclient,self.services["volume"],zoneid=self.zone.id,
account=self.parentd_admin.name,domainid=self.parent_domain.id,
apiclient, self.services["volume"],
zoneid=self.zone.id,
account=self.parentd_admin.name,
domainid=self.parent_domain.id,
diskofferingid=self.disk_offering_5_GB.id)
virtualMachine.attach_volume(apiclient, volume=volume)
@ -280,7 +312,9 @@ class TestResizeVolume(cloudstackTestCase):
if self.hypervisor == str(XEN_SERVER).lower():
virtualMachine.stop(self.apiclient)
with self.assertRaises(Exception):
volume.resize(apiclient, diskofferingid=self.disk_offering_20_GB.id)
volume.resize(
apiclient,
diskofferingid=self.disk_offering_20_GB.id)
return
@attr(tags=["advanced"], required_hardware="true")
@ -289,8 +323,9 @@ class TestResizeVolume(cloudstackTestCase):
# Validate the following
# 1. Create a domain and its admin account
# 2. Set domain primary storage limit more than (5 GB volume + template size of VM)
# and less than (20 GB volume+ template size of VM)
# 2. Set domain primary storage limit more than (5 GB volume +
# template size of VM) and less than (20 GB volume+
# template size of VM)
# 3. Deploy a VM without any disk offering (only root disk)
# 4. Create a volume of 5 GB in the account and attach it to the VM
# 5. Try to (resize) the volume to 20 GB
@ -314,13 +349,16 @@ class TestResizeVolume(cloudstackTestCase):
try:
virtualMachine = VirtualMachine.create(
apiclient, self.services["virtual_machine"],
accountid=self.parentd_admin.name, domainid=self.parent_domain.id,
accountid=self.parentd_admin.name,
domainid=self.parent_domain.id,
serviceofferingid=self.service_offering.id
)
volume = Volume.create(
apiclient,self.services["volume"],zoneid=self.zone.id,
account=self.parentd_admin.name,domainid=self.parent_domain.id,
apiclient, self.services["volume"],
zoneid=self.zone.id,
account=self.parentd_admin.name,
domainid=self.parent_domain.id,
diskofferingid=self.disk_offering_5_GB.id)
virtualMachine.attach_volume(apiclient, volume=volume)
@ -337,5 +375,7 @@ class TestResizeVolume(cloudstackTestCase):
if self.hypervisor == str(XEN_SERVER).lower():
virtualMachine.stop(self.apiclient)
with self.assertRaises(Exception):
volume.resize(apiclient, diskofferingid=self.disk_offering_20_GB.id)
volume.resize(
apiclient,
diskofferingid=self.disk_offering_20_GB.id)
return