Updated Branches: refs/heads/4.2 ed01a02c9 -> c8ad4e5ce
CLOUDSTACK-3354: Fix scalevm test After you scale the vm, user is expected (oddly) to update the virtual machine to signal that the PV tools are installed. This tells cloudstack that the VM has been successfully scaled up/down. Signed-off-by: Prasanna Santhanam <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c8ad4e5c Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c8ad4e5c Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c8ad4e5c Branch: refs/heads/4.2 Commit: c8ad4e5ced323d27862b7197a05f022f1a6efd4f Parents: ed01a02 Author: Prasanna Santhanam <[email protected]> Authored: Thu Jul 4 13:50:54 2013 +0530 Committer: Prasanna Santhanam <[email protected]> Committed: Thu Jul 4 13:50:54 2013 +0530 ---------------------------------------------------------------------- test/integration/smoke/test_scale_vm.py | 215 ++++++++++++++------------- 1 file changed, 108 insertions(+), 107 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c8ad4e5c/test/integration/smoke/test_scale_vm.py ---------------------------------------------------------------------- diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py index fd8d61e..1d1726d 100644 --- a/test/integration/smoke/test_scale_vm.py +++ b/test/integration/smoke/test_scale_vm.py @@ -20,15 +20,13 @@ import marvin from marvin.cloudstackTestCase import * from marvin.cloudstackAPI import * -from marvin.remoteSSHClient import remoteSSHClient from marvin.integration.lib.utils import * from marvin.integration.lib.base import * from marvin.integration.lib.common import * from nose.plugins.attrib import attr -#Import System modules -import time _multiprocess_shared_ = True + class Services: """Test VM Life Cycle Services """ @@ -36,17 +34,17 @@ class Services: def __init__(self): self.services = { - "account": { - "email": "[email protected]", - "firstname": "Test", - "lastname": "User", - "username": "test", - # Random characters are appended in create account to - # ensure unique username generated each time - "password": "password", - }, - "small": - # Create a small virtual machine instance with disk offering + "account": { + "email": "[email protected]", + "firstname": "Test", + "lastname": "User", + "username": "test", + # Random characters are appended in create account to + # ensure unique username generated each time + "password": "password", + }, + "small": + # Create a small virtual machine instance with disk offering { "displayname": "testserver", "username": "root", # VM creds for SSH @@ -57,34 +55,34 @@ class Services: "publicport": 22, "protocol": 'TCP', }, - "service_offerings": + "service_offerings": { - "small": - { - # Small service offering ID to for change VM - # service offering from medium to small - "name": "SmallInstance", - "displaytext": "SmallInstance", - "cpunumber": 1, - "cpuspeed": 100, - "memory": 256, - }, - "big": - { - # Big service offering ID to for change VM - "name": "BigInstance", - "displaytext": "BigInstance", - "cpunumber": 1, - "cpuspeed": 100, - "memory": 512, - } - }, - #Change this - "template": { - "displaytext": "xs", - "name": "xs", - "passwordenabled": False, + "small": + { + # Small service offering ID to for change VM + # service offering from medium to small + "name": "SmallInstance", + "displaytext": "SmallInstance", + "cpunumber": 1, + "cpuspeed": 100, + "memory": 256, + }, + "big": + { + # Big service offering ID to for change VM + "name": "BigInstance", + "displaytext": "BigInstance", + "cpunumber": 1, + "cpuspeed": 100, + "memory": 512, + } }, + #Change this + "template": { + "displaytext": "xs", + "name": "xs", + "passwordenabled": False, + }, "sleep": 60, "timeout": 10, #Migrate VM to hostid @@ -92,8 +90,8 @@ class Services: # CentOS 5.3 (64-bit) } -class TestScaleVm(cloudstackTestCase): +class TestScaleVm(cloudstackTestCase): @classmethod def setUpClass(cls): cls.api_client = super(TestScaleVm, cls).getClsTestClient().getApiClient() @@ -105,45 +103,44 @@ class TestScaleVm(cloudstackTestCase): cls.services['mode'] = zone.networktype template = get_template( - cls.api_client, - zone.id, - cls.services["ostype"] - ) + cls.api_client, + zone.id, + cls.services["ostype"] + ) # Set Zones and disk offerings ?? cls.services["small"]["zoneid"] = zone.id cls.services["small"]["template"] = template.id # Create account, service offerings, vm. cls.account = Account.create( - cls.api_client, - cls.services["account"], - domainid=domain.id - ) + cls.api_client, + cls.services["account"], + domainid=domain.id + ) cls.small_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offerings"]["small"] - ) - + cls.api_client, + cls.services["service_offerings"]["small"] + ) + cls.big_offering = ServiceOffering.create( - cls.api_client, - cls.services["service_offerings"]["big"] - ) + cls.api_client, + cls.services["service_offerings"]["big"] + ) #create a virtual machine cls.virtual_machine = VirtualMachine.create( - cls.api_client, - cls.services["small"], - accountid=cls.account.name, - domainid=cls.account.domainid, - serviceofferingid=cls.small_offering.id, - mode=cls.services["mode"] - ) - #how does it work ?? + cls.api_client, + cls.services["small"], + accountid=cls.account.name, + domainid=cls.account.domainid, + serviceofferingid=cls.small_offering.id, + mode=cls.services["mode"] + ) cls._cleanup = [ - cls.small_offering, - #cls.account - ] + cls.small_offering, + cls.account + ] @classmethod def tearDownClass(cls): @@ -161,65 +158,69 @@ class TestScaleVm(cloudstackTestCase): cleanup_resources(self.apiclient, self.cleanup) return - @attr(tags = ["xenserver", "advanced", "basic"]) + @attr(hypervisor="xenserver") + @attr(tags=["advanced", "basic"]) def test_01_scale_vm(self): """Test scale virtual machine """ # Validate the following # Scale up the vm and see if it scales to the new svc offering and is finally in running state - - - + self.debug("Scaling VM-ID: %s to service offering: %s and state %s" % ( - self.virtual_machine.id, - self.big_offering.id, - self.virtual_machine.state - )) - + self.virtual_machine.id, + self.big_offering.id, + self.virtual_machine.state + )) + cmd = scaleVirtualMachine.scaleVirtualMachineCmd() cmd.serviceofferingid = self.big_offering.id cmd.id = self.virtual_machine.id - self.apiclient.scaleVirtualMachine(cmd) + self.apiclient.scaleVirtualMachine(cmd) - list_vm_response = list_virtual_machines( - self.apiclient, - id=self.virtual_machine.id - ) + list_vm_response = VirtualMachine.list( + self.apiclient, + id=self.virtual_machine.id + ) self.assertEqual( - isinstance(list_vm_response, list), - True, - "Check list response returns a valid list" - ) + isinstance(list_vm_response, list), + True, + "Check list response returns a valid list" + ) self.assertNotEqual( - list_vm_response, - None, - "Check virtual machine is listVirtualMachines" - ) + list_vm_response, + None, + "Check virtual machine is listVirtualMachines" + ) vm_response = list_vm_response[0] - self.assertEqual( - vm_response.id, - self.virtual_machine.id, - "Check virtual machine ID of scaled VM" - ) + vm_response.id, + self.virtual_machine.id, + "Check virtual machine ID of scaled VM" + ) + + # VirtualMachine should be updated to tell cloudstack it has PV tools + # available and successfully scaled. We will only mock that behaviour + # here but it is not expected in production since the VM scaling is not + # guaranteed until tools are installed, vm rebooted + self.virtual_machine.update(self.apiclient, isdynamicallyscalable='true') self.debug("Scaling VM-ID: %s from service offering: %s to new service offering %s and the response says %s" % ( - self.virtual_machine.id, - self.virtual_machine.serviceofferingid, - self.big_offering.id, - vm_response.serviceofferingid - )) + self.virtual_machine.id, + self.virtual_machine.serviceofferingid, + self.big_offering.id, + vm_response.serviceofferingid + )) self.assertEqual( - vm_response.serviceofferingid, - self.big_offering.id, - "Check service offering of the VM" - ) + vm_response.serviceofferingid, + self.big_offering.id, + "Check service offering of the VM" + ) self.assertEqual( - vm_response.state, - 'Running', - "Check the state of VM" - ) + vm_response.state, + 'Running', + "Check the state of VM" + ) return
