From 08627aa75381cc5bb708b144ea1d62afd81e4c64 Mon Sep 17 00:00:00 2001 From: SrikanteswaraRao Talluri Date: Thu, 22 Aug 2013 16:09:22 +0530 Subject: [PATCH] CLOUDSTACK-4448: Fix test_03_RouterStartOnVmDeploy to stop all the pre-existing VMs before starting the test Signed-off-by: Prasanna Santhanam (cherry picked from commit 4a8119c8077ca15dfa42c11a425f3c5273f39f13) --- test/integration/component/test_routers.py | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/integration/component/test_routers.py b/test/integration/component/test_routers.py index a724a3fc3b7..396c54ee7bd 100644 --- a/test/integration/component/test_routers.py +++ b/test/integration/component/test_routers.py @@ -492,6 +492,35 @@ class TestRouterServices(cloudstackTestCase): # 4. listRouters should report router to have come back to "Running" state # 5. All other VMs in the account should remain in "Stopped" state + + #stop all pre-existing virtual machines if they are in 'Running' state + virtual_machines = list_virtual_machines( + self.apiclient, + account=self.account.name, + domainid=self.account.domainid, + ) + + self.assertEqual( + isinstance(virtual_machines, list), + True, + "Check for list virtual machines response return valid data" + ) + self.assertNotEqual( + len(virtual_machines), + 0, + "Check list virtual machines response" + ) + for virtual_machine in virtual_machines: + self.debug("VM ID: %s & VM state: %s" % ( + virtual_machine.id, + virtual_machine.state + )) + if virtual_machine.state == 'Running': + # Stop virtual machine + cmd = stopVirtualMachine.stopVirtualMachineCmd() + cmd.id = virtual_machine.id + self.apiclient.stopVirtualMachine(cmd) + vm = VirtualMachine.create( self.apiclient, self.services["virtual_machine"],