CLOUDSTACK-4448: Fix test_03_RouterStartOnVmDeploy to stop all the pre-existing VMs before starting the test
Signed-off-by: Prasanna Santhanam <[email protected]> (cherry picked from commit 4a8119c8077ca15dfa42c11a425f3c5273f39f13) Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/08627aa7 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/08627aa7 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/08627aa7 Branch: refs/heads/master Commit: 08627aa75381cc5bb708b144ea1d62afd81e4c64 Parents: c516564 Author: SrikanteswaraRao Talluri <[email protected]> Authored: Thu Aug 22 16:09:22 2013 +0530 Committer: Prasanna Santhanam <[email protected]> Committed: Fri Aug 23 12:39:49 2013 +0530 ---------------------------------------------------------------------- test/integration/component/test_routers.py | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/08627aa7/test/integration/component/test_routers.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_routers.py b/test/integration/component/test_routers.py index a724a3f..396c54e 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"],
