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 # specific language governing permissions and limitations
# under the License. # under the License.
""" P1 tests for testing resize volume functionality with primary storage limit constraints on """ P1 tests for testing resize volume functionality with primary storage
account/domain 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 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 # Import Local Modules
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
@ -38,7 +40,8 @@ from marvin.lib.common import (get_domain,
get_zone, get_zone,
get_template, get_template,
matchResourceCount, matchResourceCount,
isDomainResourceCountEqualToExpectedCount) isDomainResourceCountEqualToExpectedCount,
find_storage_pool_type)
from marvin.lib.utils import (cleanup_resources, from marvin.lib.utils import (cleanup_resources,
get_hypervisor_type) get_hypervisor_type)
from marvin.codes import (PASS, from marvin.codes import (PASS,
@ -48,59 +51,69 @@ from marvin.codes import (PASS,
RESOURCE_SECONDARY_STORAGE, RESOURCE_SECONDARY_STORAGE,
XEN_SERVER) XEN_SERVER)
class TestResizeVolume(cloudstackTestCase): class TestResizeVolume(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cloudstackTestClient = super(TestResizeVolume, cloudstackTestClient = super(TestResizeVolume,
cls).getClsTestClient() cls).getClsTestClient()
cls.api_client = cloudstackTestClient.getApiClient() cls.api_client = cloudstackTestClient.getApiClient()
cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
# Fill services from the external config file # Fill services from the external config file
cls.services = cloudstackTestClient.getParsedTestDataConfig() cls.services = cloudstackTestClient.getParsedTestDataConfig()
# Get Zone, Domain and templates # Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client) 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.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, cls.resourcetypemapping = {RESOURCE_PRIMARY_STORAGE: 10,
RESOURCE_SECONDARY_STORAGE: 11} RESOURCE_SECONDARY_STORAGE: 11}
cls.template = get_template( cls.template = get_template(
cls.api_client, cls.api_client,
cls.zone.id, cls.zone.id,
cls.services["ostype"] cls.services["ostype"]
) )
cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id cls.services["virtual_machine"]["template"] = cls.template.id
cls.services["volume"]["zoneid"] = cls.zone.id cls.services["volume"]["zoneid"] = cls.zone.id
cls._cleanup = []
try: try:
cls.hypervisor = str(get_hypervisor_type(cls.api_client)).lower() cls.hypervisor = str(get_hypervisor_type(cls.api_client)).lower()
# Creating service offering with normal config # Creating service offering with normal config
cls.service_offering = ServiceOffering.create(cls.api_client, cls.service_offering = ServiceOffering.create(cls.api_client,
cls.services["service_offering"]) cls.services["\
service_offering"])
cls._cleanup.append(cls.service_offering) cls._cleanup.append(cls.service_offering)
cls.services["disk_offering"]["disksize"] = 5 cls.services["disk_offering"]["disksize"] = 5
cls.disk_offering_5_GB = DiskOffering.create( cls.disk_offering_5_GB = DiskOffering.create(
cls.api_client, cls.api_client,
cls.services["disk_offering"] cls.services["disk_offering"]
) )
cls._cleanup.append(cls.disk_offering_5_GB) cls._cleanup.append(cls.disk_offering_5_GB)
cls.services["disk_offering"]["disksize"] = 20 cls.services["disk_offering"]["disksize"] = 20
cls.disk_offering_20_GB = DiskOffering.create( cls.disk_offering_20_GB = DiskOffering.create(
cls.api_client, cls.api_client,
cls.services["disk_offering"] cls.services["disk_offering"]
) )
cls._cleanup.append(cls.disk_offering_20_GB) cls._cleanup.append(cls.disk_offering_20_GB)
except Exception as e: except Exception as e:
cls.tearDownClass() cls.tearDownClass()
raise unittest.SkipTest("Failure while creating disk offering: %s" % e) raise unittest.SkipTest(
"Failure while creating disk offering: %s" %
e)
return return
@classmethod @classmethod
@ -113,6 +126,9 @@ class TestResizeVolume(cloudstackTestCase):
return return
def setUp(self): def setUp(self):
if self.unsupportedStorageType:
self.skipTest(
"unsupported storage type")
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection() self.dbclient = self.testClient.getDbConnection()
self.cleanup = [] self.cleanup = []
@ -133,15 +149,17 @@ class TestResizeVolume(cloudstackTestCase):
try: try:
if domainLimit: if domainLimit:
#Update resource limit for domain # Update resource limit for domain
Resources.updateLimit(self.apiclient, resourcetype=10, Resources.updateLimit(self.apiclient, resourcetype=10,
max=domainLimit, max=domainLimit,
domainid=self.parent_domain.id) domainid=self.parent_domain.id)
if accountLimit: if accountLimit:
#Update resource limit for domain # Update resource limit for domain
Resources.updateLimit(self.apiclient, resourcetype=10, Resources.updateLimit(self.apiclient,
max=accountLimit, account=self.parentd_admin.name, resourcetype=10,
domainid=self.parent_domain.id) max=accountLimit,
account=self.parentd_admin.name,
domainid=self.parent_domain.id)
except Exception as e: except Exception as e:
return [FAIL, e] return [FAIL, e]
return [PASS, None] return [PASS, None]
@ -149,10 +167,13 @@ class TestResizeVolume(cloudstackTestCase):
def setupAccounts(self): def setupAccounts(self):
try: try:
self.parent_domain = Domain.create(self.apiclient, self.parent_domain = Domain.create(self.apiclient,
services=self.services["domain"], services=self.services[
parentdomainid=self.domain.id) "domain"],
self.parentd_admin = Account.create(self.apiclient, self.services["account"], parentdomainid=self.domain.id)
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 # Cleanup the resources created at end of test
self.cleanup.append(self.parentd_admin) self.cleanup.append(self.parentd_admin)
@ -163,24 +184,26 @@ class TestResizeVolume(cloudstackTestCase):
@attr(tags=["advanced"], required_hardware="true") @attr(tags=["advanced"], required_hardware="true")
def test_01_increase_volume_size_within_account_limit(self): 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 # Validate the following
# 1. Create a domain and its admin account # 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) # 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 # 4. Create a volume of 5 GB in the account and attach it to the VM
# 5. Increase (resize) the volume to 20 GB # 5. Increase (resize) the volume to 20 GB
# 6. Resize opearation should be successful and primary storage counnt for # 6. Resize operation should be successful and primary storage count
# account should be updated successfully""" # for account should be updated successfully"""
# Setting up account and domain hierarchy # Setting up account and domain hierarchy
result = self.setupAccounts() result = self.setupAccounts()
self.assertEqual(result[0], PASS, result[1]) self.assertEqual(result[0], PASS, result[1])
apiclient = self.testClient.getUserApiClient( apiclient = self.testClient.getUserApiClient(
UserName=self.parentd_admin.name, UserName=self.parentd_admin.name,
DomainName=self.parentd_admin.domain) DomainName=self.parentd_admin.domain)
self.assertNotEqual(apiclient, FAILED, "Failed to get api client\ self.assertNotEqual(apiclient, FAILED, "Failed to get api client\
of account: %s" % self.parentd_admin.name) of account: %s" % self.parentd_admin.name)
@ -190,35 +213,40 @@ class TestResizeVolume(cloudstackTestCase):
self.assertEqual(response[0], PASS, response[1]) self.assertEqual(response[0], PASS, response[1])
try: try:
virtualMachine = VirtualMachine.create( virtualMachine = VirtualMachine.create(
apiclient, self.services["virtual_machine"], apiclient, self.services["virtual_machine"],
accountid=self.parentd_admin.name, domainid=self.parent_domain.id, accountid=self.parentd_admin.name,
serviceofferingid=self.service_offering.id domainid=self.parent_domain.id,
) serviceofferingid=self.service_offering.id
)
volume = Volume.create( volume = Volume.create(
apiclient,self.services["volume"],zoneid=self.zone.id, apiclient, self.services["volume"],
account=self.parentd_admin.name,domainid=self.parent_domain.id, zoneid=self.zone.id,
diskofferingid=self.disk_offering_5_GB.id) account=self.parentd_admin.name,
domainid=self.parent_domain.id,
diskofferingid=self.disk_offering_5_GB.id)
virtualMachine.attach_volume(apiclient, volume=volume) virtualMachine.attach_volume(apiclient, volume=volume)
expectedCount = (templateSize + self.disk_offering_5_GB.disksize) expectedCount = (templateSize + self.disk_offering_5_GB.disksize)
response = matchResourceCount( response = matchResourceCount(
self.apiclient, expectedCount, self.apiclient, expectedCount,
RESOURCE_PRIMARY_STORAGE, RESOURCE_PRIMARY_STORAGE,
accountid=self.parentd_admin.id) accountid=self.parentd_admin.id)
if response[0] == FAIL: if response[0] == FAIL:
raise Exception(response[1]) raise Exception(response[1])
if self.hypervisor == str(XEN_SERVER).lower(): if self.hypervisor == str(XEN_SERVER).lower():
virtualMachine.stop(self.apiclient) 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) expectedCount = (templateSize + self.disk_offering_20_GB.disksize)
response = matchResourceCount( response = matchResourceCount(
self.apiclient, expectedCount, self.apiclient, expectedCount,
RESOURCE_PRIMARY_STORAGE, RESOURCE_PRIMARY_STORAGE,
accountid=self.parentd_admin.id) accountid=self.parentd_admin.id)
if response[0] == FAIL: if response[0] == FAIL:
raise Exception(response[1]) raise Exception(response[1])
except Exception as e: except Exception as e:
@ -227,12 +255,13 @@ class TestResizeVolume(cloudstackTestCase):
@attr(tags=["advanced"], required_hardware="true") @attr(tags=["advanced"], required_hardware="true")
def test_02_increase_volume_size_above_account_limit(self): def test_02_increase_volume_size_above_account_limit(self):
"""Test increasing volume size above the account limit """Test increasing volume size above the account limit
# Validate the following # Validate the following
# 1. Create a domain and its admin account # 1. Create a domain and its admin account
# 2. Set account primary storage limit more than (5 GB volume + template size of VM) # 2. Set account primary storage limit more than (5 GB volume +
# and less than (20 GB volume+ template size of VM) # 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) # 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 # 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 # 5. Try to (resize) the volume to 20 GB
@ -248,30 +277,33 @@ class TestResizeVolume(cloudstackTestCase):
self.assertEqual(response[0], PASS, response[1]) self.assertEqual(response[0], PASS, response[1])
apiclient = self.testClient.getUserApiClient( apiclient = self.testClient.getUserApiClient(
UserName=self.parentd_admin.name, UserName=self.parentd_admin.name,
DomainName=self.parentd_admin.domain) DomainName=self.parentd_admin.domain)
self.assertNotEqual(apiclient, FAILED, "Failed to get api client\ self.assertNotEqual(apiclient, FAILED, "Failed to get api client\
of account: %s" % self.parentd_admin.name) of account: %s" % self.parentd_admin.name)
try: try:
virtualMachine = VirtualMachine.create( virtualMachine = VirtualMachine.create(
apiclient, self.services["virtual_machine"], apiclient, self.services["virtual_machine"],
accountid=self.parentd_admin.name, domainid=self.parent_domain.id, accountid=self.parentd_admin.name,
serviceofferingid=self.service_offering.id domainid=self.parent_domain.id,
) serviceofferingid=self.service_offering.id
)
volume = Volume.create( volume = Volume.create(
apiclient,self.services["volume"],zoneid=self.zone.id, apiclient, self.services["volume"],
account=self.parentd_admin.name,domainid=self.parent_domain.id, zoneid=self.zone.id,
diskofferingid=self.disk_offering_5_GB.id) account=self.parentd_admin.name,
domainid=self.parent_domain.id,
diskofferingid=self.disk_offering_5_GB.id)
virtualMachine.attach_volume(apiclient, volume=volume) virtualMachine.attach_volume(apiclient, volume=volume)
expectedCount = (templateSize + self.disk_offering_5_GB.disksize) expectedCount = (templateSize + self.disk_offering_5_GB.disksize)
response = matchResourceCount( response = matchResourceCount(
self.apiclient, expectedCount, self.apiclient, expectedCount,
RESOURCE_PRIMARY_STORAGE, RESOURCE_PRIMARY_STORAGE,
accountid=self.parentd_admin.id) accountid=self.parentd_admin.id)
if response[0] == FAIL: if response[0] == FAIL:
raise Exception(response[1]) raise Exception(response[1])
except Exception as e: except Exception as e:
@ -280,17 +312,20 @@ class TestResizeVolume(cloudstackTestCase):
if self.hypervisor == str(XEN_SERVER).lower(): if self.hypervisor == str(XEN_SERVER).lower():
virtualMachine.stop(self.apiclient) virtualMachine.stop(self.apiclient)
with self.assertRaises(Exception): 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 return
@attr(tags=["advanced"], required_hardware="true") @attr(tags=["advanced"], required_hardware="true")
def test_03_increase_volume_size_above_domain_limit(self): def test_03_increase_volume_size_above_domain_limit(self):
"""Test increasing volume size above the domain limit """Test increasing volume size above the domain limit
# Validate the following # Validate the following
# 1. Create a domain and its admin account # 1. Create a domain and its admin account
# 2. Set domain primary storage limit more than (5 GB volume + template size of VM) # 2. Set domain primary storage limit more than (5 GB volume +
# and less than (20 GB volume+ template size of VM) # 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) # 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 # 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 # 5. Try to (resize) the volume to 20 GB
@ -306,29 +341,32 @@ class TestResizeVolume(cloudstackTestCase):
self.assertEqual(response[0], PASS, response[1]) self.assertEqual(response[0], PASS, response[1])
apiclient = self.testClient.getUserApiClient( apiclient = self.testClient.getUserApiClient(
UserName=self.parentd_admin.name, UserName=self.parentd_admin.name,
DomainName=self.parentd_admin.domain) DomainName=self.parentd_admin.domain)
self.assertNotEqual(apiclient, FAILED, "Failed to get api client\ self.assertNotEqual(apiclient, FAILED, "Failed to get api client\
of account: %s" % self.parentd_admin.name) of account: %s" % self.parentd_admin.name)
try: try:
virtualMachine = VirtualMachine.create( virtualMachine = VirtualMachine.create(
apiclient, self.services["virtual_machine"], apiclient, self.services["virtual_machine"],
accountid=self.parentd_admin.name, domainid=self.parent_domain.id, accountid=self.parentd_admin.name,
serviceofferingid=self.service_offering.id domainid=self.parent_domain.id,
) serviceofferingid=self.service_offering.id
)
volume = Volume.create( volume = Volume.create(
apiclient,self.services["volume"],zoneid=self.zone.id, apiclient, self.services["volume"],
account=self.parentd_admin.name,domainid=self.parent_domain.id, zoneid=self.zone.id,
diskofferingid=self.disk_offering_5_GB.id) account=self.parentd_admin.name,
domainid=self.parent_domain.id,
diskofferingid=self.disk_offering_5_GB.id)
virtualMachine.attach_volume(apiclient, volume=volume) virtualMachine.attach_volume(apiclient, volume=volume)
expectedCount = (templateSize + self.disk_offering_5_GB.disksize) expectedCount = (templateSize + self.disk_offering_5_GB.disksize)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.parent_domain.id, self.apiclient, self.parent_domain.id,
expectedCount, RESOURCE_PRIMARY_STORAGE) expectedCount, RESOURCE_PRIMARY_STORAGE)
self.assertFalse(result[0], result[1]) self.assertFalse(result[0], result[1])
self.assertTrue(result[2], "Resource count does not match") self.assertTrue(result[2], "Resource count does not match")
except Exception as e: except Exception as e:
@ -337,5 +375,7 @@ class TestResizeVolume(cloudstackTestCase):
if self.hypervisor == str(XEN_SERVER).lower(): if self.hypervisor == str(XEN_SERVER).lower():
virtualMachine.stop(self.apiclient) virtualMachine.stop(self.apiclient)
with self.assertRaises(Exception): 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 return