CLOUDSTACK-4757. Improvements to the marvin test.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/87d87a6f Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/87d87a6f Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/87d87a6f Branch: refs/heads/multiple-disk-ova Commit: 87d87a6f30c45125e5769f04e8d4260074c79f87 Parents: 30b8eba Author: Likitha Shetty <likitha.she...@citrix.com> Authored: Wed May 21 20:29:03 2014 +0530 Committer: Likitha Shetty <likitha.she...@citrix.com> Committed: Wed May 21 21:15:54 2014 +0530 ---------------------------------------------------------------------- server/src/com/cloud/vm/UserVmManagerImpl.java | 2 +- .../test_ova_templates_with_multiple_disks.py | 69 ++++++++++---------- tools/marvin/marvin/lib/base.py | 14 ++-- 3 files changed, 41 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/87d87a6f/server/src/com/cloud/vm/UserVmManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 8a719de..74bd6d02 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2610,7 +2610,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (dataDiskTemplate == null || (!dataDiskTemplate.getTemplateType().equals(TemplateType.DATADISK)) && (dataDiskTemplate.getState().equals(VirtualMachineTemplate.State.Active))) { - throw new InvalidParameterValueException("Invalid template id specified for Datadisk template" + datadiskTemplateToDiskOffering.getKey()); + throw new InvalidParameterValueException("Invalid template id specified for Datadisk template " + datadiskTemplateToDiskOffering.getKey()); } long dataDiskTemplateId = datadiskTemplateToDiskOffering.getKey(); if (!dataDiskTemplate.getParentTemplateId().equals(template.getId())) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/87d87a6f/test/integration/component/test_ova_templates_with_multiple_disks.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_ova_templates_with_multiple_disks.py b/test/integration/component/test_ova_templates_with_multiple_disks.py old mode 100644 new mode 100755 index adb948c..a4011f4 --- a/test/integration/component/test_ova_templates_with_multiple_disks.py +++ b/test/integration/component/test_ova_templates_with_multiple_disks.py @@ -20,13 +20,13 @@ import marvin from nose.plugins.attrib import attr from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * -from marvin.integration.lib.utils import * -from marvin.integration.lib.base import * -from marvin.integration.lib.common import * +from marvin.lib.utils import * +from marvin.lib.base import * +from marvin.lib.common import * import urllib from random import random import time - +from ddt import ddt class Services: """Test OVA template with mutiple disks @@ -51,7 +51,6 @@ class Services: "disk_offering": { "displaytext": "Small", "name": "Small", - "disksize": 1 }, "virtual_machine": { "displayname": "testVM", @@ -63,24 +62,19 @@ class Services: "privateport": 22, "publicport": 22, }, - "templates": { - 0: { + "template": { "displaytext": "Template with multiple disks", "name": "Template with multiple disks", - "ostype": 'CentOS 5.3 (64-bit)', - "url": "http://10.147.28.7/templates/multipledisk.ova", - "hypervisor": 'VMware', - "format": 'OVA', "isfeatured": True, "ispublic": True, "isextractable": False, - }, }, "sleep": 60, "timeout": 10, + "format": 'ova', } - +@ddt class TestOVATemplateWithMupltipleDisks(cloudstackTestCase): def setUp(self): @@ -101,20 +95,21 @@ class TestOVATemplateWithMupltipleDisks(cloudstackTestCase): @classmethod def setUpClass(cls): - cls.services = Services().services - cls.api_client = super(TestOVATemplateWithMupltipleDisks, cls).getClsTestClient().getApiClient() - cls.api_client.hypervisor = 'VMware' + cls.testClient = super(TestOVATemplateWithMupltipleDisks, cls).getClsTestClient() + cls.api_client = cls.testClient.getApiClient() + cls.services = cls.testClient.getParsedTestDataConfig() # Get Zone, Domain and templates - cls.zone = get_zone(cls.api_client, cls.services) - cls.domain = get_domain(cls.api_client, cls.services) - cls.services['mode'] = cls.zone.networktype + cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests()) + cls.domain = get_domain(cls.api_client) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.service_offering = ServiceOffering.create( cls.api_client, cls.services["service_offering"] ) + # Disk offering size should be greater than datadisk template size + cls.services["disk_offering"]["disksize"] = 10 cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] @@ -158,21 +153,25 @@ class TestOVATemplateWithMupltipleDisks(cloudstackTestCase): # 5. Verify an additional data disk attached to the VM # Register new template - template = Template.register( + self.services["template"]["url"] = 'http://10.147.28.7/templates/single-datadisk-template.ova' + self.services["template"]["format"] = 'OVA' + self.services["template"]["ostype"] = 'CentOS 5.3 (64-bit)' + registered_template = Template.register( self.apiclient, - self.services["templates"][0], + self.services["template"], zoneid=self.zone.id, account=self.account.name, - domainid=self.account.domainid + domainid=self.account.domainid, + hypervisor='VMware' ) self.debug( - "Registered a template of format: %s with ID: %s" % ( - self.services["templates"][0]["format"], - template.id + "Registered a template of format: %s with id: %s" % ( + self.services["template"]["format"], + registered_template.id )) # Wait for template to download - template.download(self.apiclient) - self.cleanup.append(template) + registered_template.download(self.apiclient) + self.cleanup.append(registered_template) # Wait for template status to be changed across time.sleep(self.services["sleep"]) @@ -181,7 +180,7 @@ class TestOVATemplateWithMupltipleDisks(cloudstackTestCase): list_template_response = list_templates( self.apiclient, templatefilter='all', - id=template.id, + id=registered_template.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid @@ -213,12 +212,11 @@ class TestOVATemplateWithMupltipleDisks(cloudstackTestCase): "Template state is not ready, it is %s" % template_response.isready ) - time.sleep(120) # Veriy 1 additonal Datadisk Templates got created list_datadisk_template_response = list_templates( self.apiclient, - templatefilter='all', - parenttemplateid=template.id, + templatefilter='self', + parenttemplateid=registered_template.id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid @@ -244,18 +242,17 @@ class TestOVATemplateWithMupltipleDisks(cloudstackTestCase): ) # Deploy new virtual machine using template + datadisktemplate_diskoffering_list = {datadisk_template_response.id: self.disk_offering.id} virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], - templateid=template.id, + templateid=registered_template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, - mode=self.services["mode"], - datadisktemplateid=datadisk_template_response.id, - datadiskofferingid=self.disk_offering.id + datadisktemplate_diskoffering_list=datadisktemplate_diskoffering_list ) - self.debug("Creating an instance with template ID: %s" % template.id) + self.debug("Creating an instance with template ID: %s" % registered_template.id) vm_response = list_virtual_machines( self.apiclient, id=virtual_machine.id, http://git-wip-us.apache.org/repos/asf/cloudstack/blob/87d87a6f/tools/marvin/marvin/lib/base.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 82e17b6..7cba55d 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -328,8 +328,8 @@ class VirtualMachine: securitygroupids=None, projectid=None, startvm=None, diskofferingid=None, affinitygroupnames=None, affinitygroupids=None, group=None, hostid=None, keypair=None, ipaddress=None, mode='default', method='GET',hypervisor=None, - customcpunumber=None, customcpuspeed=None, custommemory=None, rootdisksize=None): - datadisktemplateid=None, datadiskofferingid=None): + customcpunumber=None, customcpuspeed=None, custommemory=None, rootdisksize=None, + datadisktemplate_diskoffering_list={}): """Create the instance""" cmd = deployVirtualMachine.deployVirtualMachineCmd() @@ -434,12 +434,12 @@ class VirtualMachine: if group: cmd.group = group - if datadisktemplateid is not None and datadiskofferingid is not None: - cmd.datadisktemplatetodiskofferinglist = [] + cmd.datadisktemplatetodiskofferinglist = [] + for datadisktemplate, diskoffering in datadisktemplate_diskoffering_list.items(): cmd.datadisktemplatetodiskofferinglist.append({ - 'datadisktemplateid': datadisktemplateid, - 'diskofferingid': datadiskofferingid - }) + 'datadisktemplateid': datadisktemplate, + 'diskofferingid': diskoffering + }) #program default access to ssh if mode.lower() == 'basic':