From 64e3074c7ea74afa3f48c21949335bb9208aca40 Mon Sep 17 00:00:00 2001 From: sanjeevneelarapu Date: Fri, 21 Jun 2013 16:00:42 +0530 Subject: [PATCH] Test Volumes: do not assume max.volumes attachable to guest 1.Current Implementation assumes 6 as the max volumes that can be attached to disk. Actually it depends on the hypervisor capabilities. 2.Modified the script to get the max limit from hypervsior capabilities. Signed-off-by: sanjeevneelarapu Signed-off-by: Prasanna Santhanam --- test/integration/component/test_volumes.py | 65 ++++++++++++++++++++-- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py index 369cefcaf34..e06bac9f543 100644 --- a/test/integration/component/test_volumes.py +++ b/test/integration/component/test_volumes.py @@ -58,7 +58,6 @@ class Services: }, "volume": { "diskname": "TestDiskServ", - "max": 6, }, "virtual_machine": { "displayname": "testVM", @@ -97,6 +96,7 @@ class TestAttachVolume(cloudstackTestCase): # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) + cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services) cls.services['mode'] = cls.zone.networktype cls.disk_offering = DiskOffering.create( cls.api_client, @@ -110,7 +110,25 @@ class TestAttachVolume(cloudstackTestCase): cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id - + #get max data volumes limit based on the hypervisor type and version + listHost = Host.list( + cls.api_client, + hypervisor = cls.services["virtual_machine"]["hypervisor"], + type ='Routing', + zoneid = cls.zone.id, + podid = cls.pod.id, + ) + ver = listHost[0].hypervisorversion + cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd() + cmd.hypervisor = cls.services["virtual_machine"]["hypervisor"] + res = cls.api_client.listHypervisorCapabilities(cmd) + cls.debug('Hypervisor Capabilities: {}'.format(res)) + for i in range(len(res)): + if res[i].hypervisorversion == ver: + break + max_data_volumes = int(res[i].maxdatavolumeslimit) + cls.debug('max data volumes:{}'.format(max_data_volumes)) + cls.services["volume"]["max"] = max_data_volumes # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, @@ -368,6 +386,7 @@ class TestAttachDetachVolume(cloudstackTestCase): # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) + cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services) cls.services['mode'] = cls.zone.networktype cls.disk_offering = DiskOffering.create( cls.api_client, @@ -381,7 +400,25 @@ class TestAttachDetachVolume(cloudstackTestCase): cls.services["zoneid"] = cls.zone.id cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id - + #get max data volumes limit based on the hypervisor type and version + listHost = Host.list( + cls.api_client, + hypervisor = cls.services["virtual_machine"]["hypervisor"], + type ='Routing', + zoneid = cls.zone.id, + podid = cls.pod.id, + ) + ver = listHost[0].hypervisorversion + cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd() + cmd.hypervisor = cls.services["virtual_machine"]["hypervisor"] + res = cls.api_client.listHypervisorCapabilities(cmd) + cls.debug('Hypervisor Capabilities: {}'.format(res)) + for i in range(len(res)): + if res[i].hypervisorversion == ver: + break + max_data_volumes = int(res[i].maxdatavolumeslimit) + cls.debug('max data volumes:{}'.format(max_data_volumes)) + cls.services["volume"]["max"] = max_data_volumes # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, @@ -614,6 +651,7 @@ class TestAttachVolumeISO(cloudstackTestCase): # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) + cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services) cls.services['mode'] = cls.zone.networktype cls.disk_offering = DiskOffering.create( cls.api_client, @@ -628,14 +666,31 @@ class TestAttachVolumeISO(cloudstackTestCase): cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["iso"]["zoneid"] = cls.zone.id cls.services["virtual_machine"]["template"] = template.id - + #get max data volumes limit based on the hypervisor type and version + listHost = Host.list( + cls.api_client, + hypervisor = cls.services["virtual_machine"]["hypervisor"], + type ='Routing', + zoneid = cls.zone.id, + podid = cls.pod.id, + ) + ver = listHost[0].hypervisorversion + cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd() + cmd.hypervisor = cls.services["virtual_machine"]["hypervisor"] + res = cls.api_client.listHypervisorCapabilities(cmd) + cls.debug('Hypervisor Capabilities: {}'.format(res)) + for i in range(len(res)): + if res[i].hypervisorversion == ver: + break + max_data_volumes = int(res[i].maxdatavolumeslimit) + cls.debug('max data volumes:{}'.format(max_data_volumes)) + cls.services["volume"]["max"] = max_data_volumes # Create VMs, NAT Rules etc cls.account = Account.create( cls.api_client, cls.services["account"], domainid=cls.domain.id ) - cls.services["account"] = cls.account.name cls.service_offering = ServiceOffering.create( cls.api_client,