CLOUDSTACK-8124: Skipping snapshot tests on hyperv hypervisor

Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
Gaurav Aradhye 2014-12-24 16:30:28 +05:30 committed by SrikanteswaraRao Talluri
parent 78b9be07d5
commit 762727439b
9 changed files with 3179 additions and 2956 deletions

View File

@ -18,7 +18,7 @@
""" """
#Import Local Modules #Import Local Modules
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackTestCase import cloudstackTestCase,unittest
#from marvin.cloudstackAPI import * #from marvin.cloudstackAPI import *
from marvin.lib.utils import (cleanup_resources, from marvin.lib.utils import (cleanup_resources,
validateList) validateList)
@ -522,7 +522,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
def setUpClass(cls): def setUpClass(cls):
cls.testClient = super(TestResourceLimitsProject, cls).getClsTestClient() cls.testClient = super(TestResourceLimitsProject, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient() cls.api_client = cls.testClient.getApiClient()
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services cls.services = Services().services
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype cls.services['mode'] = cls.zone.networktype
@ -758,6 +758,8 @@ class TestResourceLimitsProject(cloudstackTestCase):
# 5. Try to create another snapshot in this project. It should give # 5. Try to create another snapshot in this project. It should give
# user an appropriate error and an alert should be generated. # user an appropriate error and an alert should be generated.
if self.hypervisor.lower() in ['hyperv']:
raise self.skipTest("Snapshots feature is not supported on Hyper-V")
self.debug( self.debug(
"Updating snapshot resource limits for project: %s" % "Updating snapshot resource limits for project: %s" %
self.project.id) self.project.id)

View File

@ -46,25 +46,29 @@ from marvin.codes import (PASS,
FAILED, FAILED,
RESOURCE_PRIMARY_STORAGE) RESOURCE_PRIMARY_STORAGE)
class TestMultipleChildDomain(cloudstackTestCase): class TestMultipleChildDomain(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
cloudstackTestClient = super(TestMultipleChildDomain, cloudstackTestClient = super(TestMultipleChildDomain,
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.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
@ -72,8 +76,9 @@ class TestMultipleChildDomain(cloudstackTestCase):
cls._cleanup = [] cls._cleanup = []
try: try:
cls.service_offering = ServiceOffering.create(cls.api_client, cls.service_offering = ServiceOffering.create(
cls.services["service_offering"]) cls.api_client,
cls.services["service_offering"])
cls._cleanup.append(cls.service_offering) cls._cleanup.append(cls.service_offering)
except Exception as e: except Exception as e:
cls.tearDownClass() cls.tearDownClass()
@ -96,11 +101,11 @@ class TestMultipleChildDomain(cloudstackTestCase):
self.services["disk_offering"]["disksize"] = 5 self.services["disk_offering"]["disksize"] = 5
try: try:
self.disk_offering = DiskOffering.create( self.disk_offering = DiskOffering.create(
self.apiclient, self.apiclient,
self.services["disk_offering"] self.services["disk_offering"]
) )
self.assertNotEqual(self.disk_offering, None, \ self.assertNotEqual(self.disk_offering, None,
"Disk offering is None") "Disk offering is None")
self.cleanup.append(self.disk_offering) self.cleanup.append(self.disk_offering)
except Exception as e: except Exception as e:
self.tearDown() self.tearDown()
@ -121,44 +126,56 @@ class TestMultipleChildDomain(cloudstackTestCase):
child domains""" child domains"""
try: try:
#Update resource limit for domain # Update resource limit for domain
Resources.updateLimit(self.apiclient, resourcetype=10, Resources.updateLimit(self.apiclient, resourcetype=10,
max=parentdomainlimit, max=parentdomainlimit,
domainid=self.parent_domain.id) domainid=self.parent_domain.id)
# Update Resource limit for sub-domains # Update Resource limit for sub-domains
Resources.updateLimit(self.apiclient, resourcetype=10, Resources.updateLimit(self.apiclient, resourcetype=10,
max=subdomainlimit, max=subdomainlimit,
domainid=self.cadmin_1.domainid) domainid=self.cadmin_1.domainid)
Resources.updateLimit(self.apiclient, resourcetype=10, Resources.updateLimit(self.apiclient, resourcetype=10,
max=subdomainlimit, max=subdomainlimit,
domainid=self.cadmin_2.domainid) domainid=self.cadmin_2.domainid)
except Exception as e: except Exception as e:
return [FAIL, e] return [FAIL, e]
return [PASS, None] return [PASS, None]
def setupAccounts(self): def setupAccounts(self):
try: try:
self.parent_domain = Domain.create(self.apiclient, self.parent_domain = Domain.create(
services=self.services["domain"], self.apiclient,
parentdomainid=self.domain.id) services=self.services["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)
# Create sub-domains and their admin accounts # Create sub-domains and their admin accounts
self.cdomain_1 = Domain.create(self.apiclient, self.cdomain_1 = Domain.create(
services=self.services["domain"], self.apiclient,
parentdomainid=self.parent_domain.id) services=self.services["domain"],
self.cdomain_2 = Domain.create(self.apiclient, parentdomainid=self.parent_domain.id)
services=self.services["domain"], self.cdomain_2 = Domain.create(
parentdomainid=self.parent_domain.id) self.apiclient,
services=self.services["domain"],
parentdomainid=self.parent_domain.id)
self.cadmin_1 = Account.create(self.apiclient, self.services["account"], self.cadmin_1 = Account.create(
admin=True, domainid=self.cdomain_1.id) self.apiclient,
self.services["account"],
admin=True,
domainid=self.cdomain_1.id)
self.cadmin_2 = Account.create(self.apiclient, self.services["account"], self.cadmin_2 = Account.create(
admin=True, domainid=self.cdomain_2.id) self.apiclient,
self.services["account"],
admin=True,
domainid=self.cdomain_2.id)
# Cleanup the resources created at end of test # Cleanup the resources created at end of test
self.cleanup.append(self.cadmin_1) self.cleanup.append(self.cadmin_1)
@ -169,14 +186,14 @@ class TestMultipleChildDomain(cloudstackTestCase):
self.cleanup.append(self.parent_domain) self.cleanup.append(self.parent_domain)
users = { users = {
self.cdomain_1: self.cadmin_1, self.cdomain_1: self.cadmin_1,
self.cdomain_2: self.cadmin_2 self.cdomain_2: self.cadmin_2
} }
except Exception as e: except Exception as e:
return [FAIL, e, None] return [FAIL, e, None]
return [PASS, None, users] return [PASS, None, users]
@attr(tags=["advanced","selfservice"]) @attr(tags=["advanced", "selfservice"])
def test_01_multiple_domains_primary_storage_limits(self): def test_01_multiple_domains_primary_storage_limits(self):
"""Test primary storage limit of domain and its sub-domains """Test primary storage limit of domain and its sub-domains
@ -204,73 +221,97 @@ class TestMultipleChildDomain(cloudstackTestCase):
# Setting up account and domain hierarchy # Setting up account and domain hierarchy
result = self.setupAccounts() result = self.setupAccounts()
self.assertEqual(result[0], PASS,\ self.assertEqual(
"Failure while setting up accounts and domains: %s" % result[1]) result[0],
PASS,
"Failure while setting up accounts and domains: %s" %
result[1])
templatesize = (self.template.size / (1024**3)) templatesize = (self.template.size / (1024 ** 3))
disksize = 10 disksize = 10
subdomainlimit = (templatesize + disksize) subdomainlimit = (templatesize + disksize)
result = self.updateDomainResourceLimits(((subdomainlimit*3)- 1), subdomainlimit) result = self.updateDomainResourceLimits(
self.assertEqual(result[0], PASS,\ ((subdomainlimit * 3) - 1),
"Failure while updating resource limits: %s" % result[1]) subdomainlimit)
self.assertEqual(
result[0],
PASS,
"Failure while updating resource limits: %s" %
result[1])
try: try:
self.services["disk_offering"]["disksize"] = disksize self.services["disk_offering"]["disksize"] = disksize
disk_offering_custom = DiskOffering.create(self.apiclient, disk_offering_custom = DiskOffering.create(
services=self.services["disk_offering"]) self.apiclient,
services=self.services["disk_offering"])
self.cleanup.append(disk_offering_custom) self.cleanup.append(disk_offering_custom)
except Exception as e: except Exception as e:
self.fail("Failed to create disk offering") self.fail("Failed to create disk offering")
# Get API clients of parent and child domain admin accounts # Get API clients of parent and child domain admin accounts
api_client_admin = self.testClient.getUserApiClient( api_client_admin = 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(api_client_admin, FAILED,\ self.assertNotEqual(
"Failed to create api client for account: %s" % self.parentd_admin.name) api_client_admin,
FAILED,
"Failed to create api client for account: %s" %
self.parentd_admin.name)
api_client_cadmin_1 = self.testClient.getUserApiClient( api_client_cadmin_1 = self.testClient.getUserApiClient(
UserName=self.cadmin_1.name, UserName=self.cadmin_1.name,
DomainName=self.cadmin_1.domain) DomainName=self.cadmin_1.domain)
self.assertNotEqual(api_client_cadmin_1, FAILED,\ self.assertNotEqual(
"Failed to create api client for account: %s" % self.cadmin_1.name) api_client_cadmin_1,
FAILED,
"Failed to create api client for account: %s" %
self.cadmin_1.name)
api_client_cadmin_2 = self.testClient.getUserApiClient( api_client_cadmin_2 = self.testClient.getUserApiClient(
UserName=self.cadmin_2.name, UserName=self.cadmin_2.name,
DomainName=self.cadmin_2.domain) DomainName=self.cadmin_2.domain)
self.assertNotEqual(api_client_cadmin_2, FAILED,\ self.assertNotEqual(
"Failed to create api client for account: %s" % self.cadmin_2.name) api_client_cadmin_2,
FAILED,
"Failed to create api client for account: %s" %
self.cadmin_2.name)
VirtualMachine.create( VirtualMachine.create(
api_client_cadmin_1, self.services["virtual_machine"], api_client_cadmin_1,
accountid=self.cadmin_1.name, domainid=self.cadmin_1.domainid, self.services["virtual_machine"],
diskofferingid=disk_offering_custom.id, serviceofferingid=self.service_offering.id accountid=self.cadmin_1.name,
) domainid=self.cadmin_1.domainid,
diskofferingid=disk_offering_custom.id,
serviceofferingid=self.service_offering.id)
self.initialResourceCount = (templatesize + disksize) self.initialResourceCount = (templatesize + disksize)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.parent_domain.id, self.apiclient, self.parent_domain.id,
self.initialResourceCount, RESOURCE_PRIMARY_STORAGE) self.initialResourceCount, 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")
# Create VM in second child domain # Create VM in second child domain
vm_2 = VirtualMachine.create( vm_2 = VirtualMachine.create(
api_client_cadmin_2, self.services["virtual_machine"], api_client_cadmin_2,
accountid=self.cadmin_2.name, domainid=self.cadmin_2.domainid, self.services["virtual_machine"],
diskofferingid=disk_offering_custom.id, serviceofferingid=self.service_offering.id accountid=self.cadmin_2.name,
) domainid=self.cadmin_2.domainid,
diskofferingid=disk_offering_custom.id,
serviceofferingid=self.service_offering.id)
# Now the VMs in two child domains have exhausted the primary storage limit # Now the VMs in two child domains have exhausted the primary storage limit
# of parent domain, hence VM creation in parent domain with custom disk offering # of parent domain, hence VM creation in parent domain with custom disk offering
# should fail # should fail
with self.assertRaises(Exception): with self.assertRaises(Exception):
VirtualMachine.create( VirtualMachine.create(
api_client_admin, self.services["virtual_machine"], api_client_admin,
accountid=self.parentd_admin.name, domainid=self.parentd_admin.domainid, self.services["virtual_machine"],
diskofferingid=disk_offering_custom.id, serviceofferingid=self.service_offering.id accountid=self.parentd_admin.name,
) domainid=self.parentd_admin.domainid,
diskofferingid=disk_offering_custom.id,
serviceofferingid=self.service_offering.id)
# Deleting user account # Deleting user account
self.cadmin_1.delete(self.apiclient) self.cadmin_1.delete(self.apiclient)
@ -278,8 +319,8 @@ class TestMultipleChildDomain(cloudstackTestCase):
expectedCount = self.initialResourceCount expectedCount = self.initialResourceCount
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")
@ -293,8 +334,8 @@ class TestMultipleChildDomain(cloudstackTestCase):
expectedCount = 0 expectedCount = 0
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")
return return
@ -315,68 +356,79 @@ class TestMultipleChildDomain(cloudstackTestCase):
# Setting up account and domain hierarchy # Setting up account and domain hierarchy
result = self.setupAccounts() result = self.setupAccounts()
self.assertEqual(result[0], PASS,\ self.assertEqual(
"Failure while setting up accounts and domains: %s" % result[1]) result[0],
PASS,
"Failure while setting up accounts and domains: %s" %
result[1])
users = result[2] users = result[2]
templatesize = (self.template.size / (1024**3)) templatesize = (self.template.size / (1024 ** 3))
for domain, admin in users.items(): for domain, admin in users.items():
self.account = admin self.account = admin
self.domain = domain self.domain = domain
apiclient = self.testClient.getUserApiClient( apiclient = self.testClient.getUserApiClient(
UserName=self.account.name, UserName=self.account.name,
DomainName=self.account.domain) DomainName=self.account.domain)
self.assertNotEqual(apiclient, FAILED,\ self.assertNotEqual(
"Failed to create api client for account: %s" % self.account.name) apiclient,
FAILED,
"Failed to create api client for account: %s" %
self.account.name)
try: try:
vm = VirtualMachine.create( vm = VirtualMachine.create(
apiclient, self.services["virtual_machine"], apiclient,
accountid=self.account.name, domainid=self.account.domainid, self.services["virtual_machine"],
diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id accountid=self.account.name,
) domainid=self.account.domainid,
diskofferingid=self.disk_offering.id,
serviceofferingid=self.service_offering.id)
expectedCount = templatesize + self.disk_offering.disksize expectedCount = templatesize + self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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")
# Creating service offering with 10 GB volume # Creating service offering with 10 GB volume
self.services["disk_offering"]["disksize"] = 10 self.services["disk_offering"]["disksize"] = 10
disk_offering_10_GB = DiskOffering.create(self.apiclient, disk_offering_10_GB = DiskOffering.create(
services=self.services["disk_offering"]) self.apiclient,
services=self.services["disk_offering"])
self.cleanup.append(disk_offering_10_GB) self.cleanup.append(disk_offering_10_GB)
volume = Volume.create( volume = Volume.create(
apiclient, self.services["volume"], apiclient,
zoneid=self.zone.id, account=self.account.name, self.services["volume"],
domainid=self.account.domainid, diskofferingid=disk_offering_10_GB.id zoneid=self.zone.id,
) account=self.account.name,
domainid=self.account.domainid,
diskofferingid=disk_offering_10_GB.id)
volumeSize = (volume.size / (1024**3)) volumeSize = (volume.size / (1024 ** 3))
expectedCount += volumeSize expectedCount += volumeSize
vm.attach_volume(apiclient, volume=volume) vm.attach_volume(apiclient, volume=volume)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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")
expectedCount -= volumeSize expectedCount -= volumeSize
vm.detach_volume(apiclient, volume=volume) vm.detach_volume(apiclient, volume=volume)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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:
self.fail("Failure: %s" % e) self.fail("Failure: %s" % e)
return return
@attr(tags=["advanced"], required_hardware="false") @attr(tags=["advanced"], required_hardware="false")
def test_03_multiple_domains_multiple_volumes(self): def test_03_multiple_domains_multiple_volumes(self):
@ -397,67 +449,80 @@ class TestMultipleChildDomain(cloudstackTestCase):
# Setting up account and domain hierarchy # Setting up account and domain hierarchy
result = self.setupAccounts() result = self.setupAccounts()
if result[0] == FAIL: if result[0] == FAIL:
self.fail("Failure while setting up accounts and domains: %s" % result[1]) self.fail(
"Failure while setting up accounts and domains: %s" %
result[1])
else: else:
users = result[2] users = result[2]
templatesize = (self.template.size / (1024**3)) templatesize = (self.template.size / (1024 ** 3))
for domain, admin in users.items(): for domain, admin in users.items():
self.account = admin self.account = admin
self.domain = domain self.domain = domain
apiclient = self.testClient.getUserApiClient( apiclient = self.testClient.getUserApiClient(
UserName=self.account.name, UserName=self.account.name,
DomainName=self.account.domain) DomainName=self.account.domain)
self.assertNotEqual(apiclient, FAILED,\ self.assertNotEqual(
"Failed to create api client for account: %s" % self.account.name) apiclient,
FAILED,
"Failed to create api client for account: %s" %
self.account.name)
try: try:
vm = VirtualMachine.create( vm = VirtualMachine.create(
apiclient, self.services["virtual_machine"], apiclient,
accountid=self.account.name, domainid=self.account.domainid, self.services["virtual_machine"],
diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id accountid=self.account.name,
) domainid=self.account.domainid,
diskofferingid=self.disk_offering.id,
serviceofferingid=self.service_offering.id)
expectedCount = templatesize + self.disk_offering.disksize expectedCount = templatesize + self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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")
volume1size = self.services["disk_offering"]["disksize"] = 15 volume1size = self.services["disk_offering"]["disksize"] = 15
disk_offering_15_GB = DiskOffering.create(self.apiclient, disk_offering_15_GB = DiskOffering.create(
services=self.services["disk_offering"]) self.apiclient,
services=self.services["disk_offering"])
self.cleanup.append(disk_offering_15_GB) self.cleanup.append(disk_offering_15_GB)
volume2size = self.services["disk_offering"]["disksize"] = 20 volume2size = self.services["disk_offering"]["disksize"] = 20
disk_offering_20_GB = DiskOffering.create(self.apiclient, disk_offering_20_GB = DiskOffering.create(
services=self.services["disk_offering"]) self.apiclient,
services=self.services["disk_offering"])
self.cleanup.append(disk_offering_20_GB) self.cleanup.append(disk_offering_20_GB)
volume_1 = Volume.create( volume_1 = Volume.create(
apiclient, self.services["volume"], apiclient,
zoneid=self.zone.id, account=self.account.name, self.services["volume"],
domainid=self.account.domainid, diskofferingid=disk_offering_15_GB.id zoneid=self.zone.id,
) account=self.account.name,
domainid=self.account.domainid,
diskofferingid=disk_offering_15_GB.id)
volume_2 = Volume.create( volume_2 = Volume.create(
apiclient, self.services["volume"], apiclient,
zoneid=self.zone.id, account=self.account.name, self.services["volume"],
domainid=self.account.domainid, diskofferingid=disk_offering_20_GB.id zoneid=self.zone.id,
) account=self.account.name,
domainid=self.account.domainid,
diskofferingid=disk_offering_20_GB.id)
vm.attach_volume(apiclient, volume=volume_1) vm.attach_volume(apiclient, volume=volume_1)
vm.attach_volume(apiclient, volume=volume_2) vm.attach_volume(apiclient, volume=volume_2)
expectedCount += volume1size + volume2size expectedCount += volume1size + volume2size
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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")
@ -466,16 +531,16 @@ class TestMultipleChildDomain(cloudstackTestCase):
expectedCount -= volume1size expectedCount -= volume1size
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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")
expectedCount -= volume2size expectedCount -= volume2size
vm.detach_volume(apiclient, volume=volume_2) vm.detach_volume(apiclient, volume=volume_2)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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:
@ -498,9 +563,14 @@ class TestMultipleChildDomain(cloudstackTestCase):
# 5. Delete volume which was created from snapshot and verify primary storage # 5. Delete volume which was created from snapshot and verify primary storage
resource count""" resource count"""
if self.hypervisor.lower() in ['hyperv']:
self.skipTest("Snapshots feature is not supported on Hyper-V")
result = self.setupAccounts() result = self.setupAccounts()
if result[0] == FAIL: if result[0] == FAIL:
self.fail("Failure while setting up accounts and domains: %s" % result[1]) self.fail(
"Failure while setting up accounts and domains: %s" %
result[1])
users = result[2] users = result[2]
for domain, admin in users.items(): for domain, admin in users.items():
@ -509,62 +579,75 @@ class TestMultipleChildDomain(cloudstackTestCase):
try: try:
apiclient = self.testClient.getUserApiClient( apiclient = self.testClient.getUserApiClient(
UserName=self.account.name, UserName=self.account.name,
DomainName=self.account.domain) DomainName=self.account.domain)
self.assertNotEqual(apiclient, FAILED,\ self.assertNotEqual(
"Failed to create api client for account: %s" % self.account.name) apiclient,
FAILED,
"Failed to create api client for account: %s" %
self.account.name)
vm = VirtualMachine.create( vm = VirtualMachine.create(
apiclient, self.services["virtual_machine"], apiclient,
accountid=self.account.name, domainid=self.account.domainid, self.services["virtual_machine"],
diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id accountid=self.account.name,
) domainid=self.account.domainid,
diskofferingid=self.disk_offering.id,
serviceofferingid=self.service_offering.id)
templatesize = (self.template.size / (1024**3)) templatesize = (self.template.size / (1024 ** 3))
initialResourceCount = expectedCount = templatesize + self.disk_offering.disksize initialResourceCount = expectedCount = templatesize + \
self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.domain.id,
initialResourceCount, RESOURCE_PRIMARY_STORAGE) initialResourceCount, 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")
vm.stop(self.apiclient) vm.stop(self.apiclient)
response = createSnapshotFromVirtualMachineVolume(apiclient, self.account, vm.id) response = createSnapshotFromVirtualMachineVolume(
apiclient,
self.account,
vm.id)
self.assertEqual(response[0], PASS, response[1]) self.assertEqual(response[0], PASS, response[1])
snapshot = response[1] snapshot = response[1]
response = snapshot.validateState(apiclient, Snapshot.BACKED_UP) response = snapshot.validateState(
apiclient,
Snapshot.BACKED_UP)
self.assertEqual(response[0], PASS, response[1]) self.assertEqual(response[0], PASS, response[1])
self.services["volume"]["size"] = self.services["disk_offering"]["disksize"] self.services["volume"]["size"] = self.services[
volume = Volume.create_from_snapshot(apiclient, "disk_offering"]["disksize"]
snapshot_id=snapshot.id, volume = Volume.create_from_snapshot(
services=self.services["volume"], apiclient,
account=self.account.name, snapshot_id=snapshot.id,
domainid=self.account.domainid) services=self.services["volume"],
volumeSize = (volume.size / (1024**3)) account=self.account.name,
domainid=self.account.domainid)
volumeSize = (volume.size / (1024 ** 3))
vm.attach_volume(apiclient, volume) vm.attach_volume(apiclient, volume)
expectedCount = initialResourceCount + (volumeSize) expectedCount = initialResourceCount + (volumeSize)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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")
expectedCount -= volumeSize expectedCount -= volumeSize
vm.detach_volume(apiclient, volume) vm.detach_volume(apiclient, volume)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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")
volume.delete(apiclient) volume.delete(apiclient)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.domain.id, self.apiclient, self.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:
@ -573,7 +656,7 @@ class TestMultipleChildDomain(cloudstackTestCase):
@attr(tags=["advanced"], required_hardware="false") @attr(tags=["advanced"], required_hardware="false")
def test_05_assign_virtual_machine_different_domain(self): def test_05_assign_virtual_machine_different_domain(self):
"""Test assign virtual machine to account belonging to different domain """Test assign virtual machine to account belonging to different domain
# Steps # Steps
1. Create a parent domain and two sub-domains in it (also admin accounts 1. Create a parent domain and two sub-domains in it (also admin accounts
@ -590,41 +673,48 @@ class TestMultipleChildDomain(cloudstackTestCase):
self.assertEqual(result[0], PASS, result[1]) self.assertEqual(result[0], PASS, result[1])
apiclient = self.testClient.getUserApiClient( apiclient = self.testClient.getUserApiClient(
UserName=self.cadmin_1.name, UserName=self.cadmin_1.name,
DomainName=self.cadmin_1.domain) DomainName=self.cadmin_1.domain)
self.assertNotEqual(apiclient, FAILED,\ self.assertNotEqual(
"Failed to create api client for account: %s" % self.cadmin_1.name) apiclient,
FAILED,
"Failed to create api client for account: %s" %
self.cadmin_1.name)
try: try:
vm_1 = VirtualMachine.create( vm_1 = VirtualMachine.create(
apiclient, self.services["virtual_machine"], apiclient,
accountid=self.cadmin_1.name, domainid=self.cadmin_1.domainid, self.services["virtual_machine"],
diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id accountid=self.cadmin_1.name,
) domainid=self.cadmin_1.domainid,
diskofferingid=self.disk_offering.id,
serviceofferingid=self.service_offering.id)
templatesize = (self.template.size / (1024**3)) templatesize = (self.template.size / (1024 ** 3))
expectedCount = templatesize + self.disk_offering.disksize expectedCount = templatesize + self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.cadmin_1.domainid, self.apiclient, self.cadmin_1.domainid,
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")
vm_1.stop(apiclient) vm_1.stop(apiclient)
vm_1.assign_virtual_machine(self.apiclient, account=self.cadmin_2.name, vm_1.assign_virtual_machine(
domainid=self.cadmin_2.domainid) self.apiclient,
account=self.cadmin_2.name,
domainid=self.cadmin_2.domainid)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.cadmin_2.domainid, self.apiclient, self.cadmin_2.domainid,
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")
expectedCount = 0 expectedCount = 0
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.cadmin_1.domainid, self.apiclient, self.cadmin_1.domainid,
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:
@ -633,7 +723,7 @@ class TestMultipleChildDomain(cloudstackTestCase):
@attr(tags=["advanced"], required_hardware="false") @attr(tags=["advanced"], required_hardware="false")
def test_06_destroy_recover_vm(self): def test_06_destroy_recover_vm(self):
"""Test primary storage counts while destroying and recovering VM """Test primary storage counts while destroying and recovering VM
# Steps # Steps
1. Create a parent domain and two sub-domains in it (also admin accounts 1. Create a parent domain and two sub-domains in it (also admin accounts
of each domain) of each domain)
@ -656,33 +746,35 @@ class TestMultipleChildDomain(cloudstackTestCase):
self.domain = domain self.domain = domain
try: try:
vm_1 = VirtualMachine.create( vm_1 = VirtualMachine.create(
self.apiclient, self.services["virtual_machine"], self.apiclient,
accountid=self.account.name, domainid=self.account.domainid, self.services["virtual_machine"],
diskofferingid=self.disk_offering.id, serviceofferingid=self.service_offering.id accountid=self.account.name,
) domainid=self.account.domainid,
diskofferingid=self.disk_offering.id,
serviceofferingid=self.service_offering.id)
templatesize = (self.template.size / (1024**3)) templatesize = (self.template.size / (1024 ** 3))
expectedCount = templatesize + self.disk_offering.disksize expectedCount = templatesize + self.disk_offering.disksize
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.account.domainid, self.apiclient, self.account.domainid,
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")
vm_1.delete(self.apiclient, expunge=False) vm_1.delete(self.apiclient, expunge=False)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.account.domainid, self.apiclient, self.account.domainid,
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")
vm_1.recover(self.apiclient) vm_1.recover(self.apiclient)
result = isDomainResourceCountEqualToExpectedCount( result = isDomainResourceCountEqualToExpectedCount(
self.apiclient, self.account.domainid, self.apiclient, self.account.domainid,
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:

View File

@ -56,6 +56,7 @@ class TestVolumeLimits(cloudstackTestCase):
cloudstackTestClient = super(TestVolumeLimits, cloudstackTestClient = super(TestVolumeLimits,
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
@ -505,7 +506,8 @@ class TestVolumeLimits(cloudstackTestCase):
# 3. Create volume againt from this snapshto and attach to VM # 3. Create volume againt from this snapshto and attach to VM
# 4. Verify that primary storage count increases by the volume size # 4. Verify that primary storage count increases by the volume size
# 5. Detach and delete volume, verify primary storage count decreaes by volume size""" # 5. Detach and delete volume, verify primary storage count decreaes by volume size"""
if self.hypervisor.lower() in ['hyperv']:
self.skipTest("Snapshots feature is not supported on Hyper-V")
response = self.setupAccount(value) response = self.setupAccount(value)
self.debug(response[0]) self.debug(response[0])
self.debug(response[1]) self.debug(response[1])

View File

@ -18,7 +18,7 @@
""" """
#Import Local Modules #Import Local Modules
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase from marvin.cloudstackTestCase import cloudstackTestCase,unittest
from marvin.lib.base import (VirtualMachine, from marvin.lib.base import (VirtualMachine,
Snapshot, Snapshot,
Template, Template,
@ -129,7 +129,7 @@ class TestResourceLimitsAccount(cloudstackTestCase):
def setUpClass(cls): def setUpClass(cls):
cls.testClient = super(TestResourceLimitsAccount, cls).getClsTestClient() cls.testClient = super(TestResourceLimitsAccount, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient() cls.api_client = cls.testClient.getApiClient()
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services cls.services = Services().services
# Get Zone, Domain and templates # Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client) cls.domain = get_domain(cls.api_client)
@ -448,6 +448,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
# 5. Create 2 snapshot in account 2. Verify account 2 should be able to # 5. Create 2 snapshot in account 2. Verify account 2 should be able to
# create snapshots without any warning # create snapshots without any warning
if self.hypervisor.lower() in ['hyperv']:
self.skipTest("Snapshots feature is not supported on Hyper-V")
self.debug( self.debug(
"Updating public IP resource limit for account: %s" % "Updating public IP resource limit for account: %s" %
self.account_1.name) self.account_1.name)
@ -914,7 +916,7 @@ class TestResourceLimitsDomain(cloudstackTestCase):
def setUpClass(cls): def setUpClass(cls):
cls.testClient = super(TestResourceLimitsDomain, cls).getClsTestClient() cls.testClient = super(TestResourceLimitsDomain, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient() cls.api_client = cls.testClient.getApiClient()
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services cls.services = Services().services
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype cls.services['mode'] = cls.zone.networktype
@ -1132,7 +1134,8 @@ class TestResourceLimitsDomain(cloudstackTestCase):
# created # created
# 5. Try to create another snapshot in this domain. It should give the # 5. Try to create another snapshot in this domain. It should give the
# user an appropriate error and an alert should be generated. # user an appropriate error and an alert should be generated.
if self.hypervisor.lower() in ['hyperv']:
self.skipTest("Snapshots feature is not supported on Hyper-V")
self.debug( self.debug(
"Updating snapshot resource limits for domain: %s" % "Updating snapshot resource limits for domain: %s" %
self.account.domainid) self.account.domainid)

File diff suppressed because it is too large Load Diff

View File

@ -58,6 +58,7 @@ class TestSecondaryStorageLimits(cloudstackTestCase):
cloudstackTestClient = super(TestSecondaryStorageLimits, cloudstackTestClient = super(TestSecondaryStorageLimits,
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
@ -205,6 +206,9 @@ class TestSecondaryStorageLimits(cloudstackTestCase):
5. Verify that the secondary storage count of the account equals 5. Verify that the secondary storage count of the account equals
the size of the template""" the size of the template"""
if self.hypervisor.lower() in ['hyperv']:
self.skipTest("Snapshots feature is not supported on Hyper-V")
response = self.setupAccount(value) response = self.setupAccount(value)
self.assertEqual(response[0], PASS, response[1]) self.assertEqual(response[0], PASS, response[1])

File diff suppressed because it is too large Load Diff

View File

@ -284,7 +284,7 @@ class TestTemplates(cloudstackTestCase):
cls.testClient = super(TestTemplates, cls).getClsTestClient() cls.testClient = super(TestTemplates, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient() cls.api_client = cls.testClient.getApiClient()
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services cls.services = Services().services
# Get Zone, Domain and templates # Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client) cls.domain = get_domain(cls.api_client)
@ -495,6 +495,9 @@ class TestTemplates(cloudstackTestCase):
# 4. Deploy Virtual machine using this template # 4. Deploy Virtual machine using this template
# 5. VM should be in running state # 5. VM should be in running state
if self.hypervisor.lower() in ['hyperv']:
self.skipTest("Snapshots feature is not supported on Hyper-V")
userapiclient = self.testClient.getUserApiClient( userapiclient = self.testClient.getUserApiClient(
UserName=self.account.name, UserName=self.account.name,
DomainName=self.account.domain) DomainName=self.account.domain)

File diff suppressed because it is too large Load Diff