Updated Branches: refs/heads/master afaf6370d -> 23499efe4
CLOUDSTACK-4995: Fixed test_reset_ssh_keypair which checks the state of the VM Signed-off-by: Girish Shilamkar <gir...@clogeny.com> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/23499efe Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/23499efe Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/23499efe Branch: refs/heads/master Commit: 23499efe42da721dd8123ab27e19531493318af4 Parents: afaf637 Author: Gaurav Aradhye <gaurav.arad...@clogeny.com> Authored: Thu Oct 31 21:55:32 2013 +0530 Committer: Girish Shilamkar <gir...@clogeny.com> Committed: Thu Oct 31 21:57:57 2013 +0530 ---------------------------------------------------------------------- .../component/test_reset_ssh_keypair.py | 48 ++++++++++++-------- tools/marvin/marvin/codes.py | 1 + 2 files changed, 30 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/23499efe/test/integration/component/test_reset_ssh_keypair.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_reset_ssh_keypair.py b/test/integration/component/test_reset_ssh_keypair.py index 4d0c45e..7530335 100644 --- a/test/integration/component/test_reset_ssh_keypair.py +++ b/test/integration/component/test_reset_ssh_keypair.py @@ -19,13 +19,28 @@ """ #Import Local Modules -from marvin.cloudstackTestCase import * -from marvin.integration.lib.base import * -from marvin.integration.lib.common import * +from marvin.integration.lib.base import (VirtualMachine, + SSHKeyPair, + Account, + Template, + ServiceOffering, + EgressFireWallRule) +from marvin.integration.lib.common import (get_domain, + get_zone, + get_template, + list_virtual_machines, + list_volumes) +from marvin.integration.lib.utils import (cleanup_resources, + random_gen, + validateList) +from marvin.cloudstackTestCase import cloudstackTestCase, unittest +from marvin.codes import PASS, RUNNING + #Import System modules import tempfile import os from nose.plugins.attrib import attr +import time class Services: @@ -82,17 +97,12 @@ class Services: "mode": 'advanced', } -def wait_vm_start(apiclient, account, timeout, sleep): +def wait_vm_start(apiclient, vmid, timeout, sleep): while timeout: - vms = VirtualMachine.list( - apiclient, - account=account.name, - domainid=account.domainid, - listall=True - ) - if vms and vms[0].state == "Running": + vms = VirtualMachine.list(apiclient, id=vmid) + vm_list_validation_result = validateList(vms) + if vm_list_validation_result[0] == PASS and vm_list_validation_result[1].state == RUNNING: return timeout - time.sleep(sleep) timeout = timeout - 1 @@ -363,7 +373,7 @@ class TestResetSSHKeypair(cloudstackTestCase): self.fail("Failed to start virtual machine: %s, %s" % (virtual_machine.name, e)) - timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"], + timeout = wait_vm_start(self.apiclient, virtual_machine.id, self.services["timeout"], self.services["sleep"]) if timeout == 0: @@ -473,7 +483,7 @@ class TestResetSSHKeypair(cloudstackTestCase): self.fail("Failed to start virtual machine: %s, %s" % (virtual_machine.name, e)) - timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"], + timeout = wait_vm_start(self.apiclient, virtual_machine.id, self.services["timeout"], self.services["sleep"]) if timeout == 0: @@ -583,7 +593,7 @@ class TestResetSSHKeypair(cloudstackTestCase): self.fail("Failed to start virtual machine: %s, %s" % (virtual_machine.name, e)) - timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"], + timeout = wait_vm_start(self.apiclient, virtual_machine.id, self.services["timeout"], self.services["sleep"]) if timeout == 0: @@ -694,7 +704,7 @@ class TestResetSSHKeypair(cloudstackTestCase): self.fail("Failed to start virtual machine: %s, %s" % (virtual_machine.name, e)) - timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"], + timeout = wait_vm_start(self.apiclient, virtual_machine.id, self.services["timeout"], self.services["sleep"]) if timeout == 0: @@ -1207,7 +1217,7 @@ class TestResetSSHKeyUserRights(cloudstackTestCase): self.fail("Failed to start virtual machine: %s, %s" % (virtual_machine.name, e)) - timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"], + timeout = wait_vm_start(self.apiclient, virtual_machine.id, self.services["timeout"], self.services["sleep"]) if timeout == 0: @@ -1346,7 +1356,7 @@ class TestResetSSHKeyUserRights(cloudstackTestCase): self.fail("Failed to start virtual machine: %s, %s" % (virtual_machine.name, e)) - timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"], + timeout = wait_vm_start(self.apiclient, virtual_machine.id, self.services["timeout"], self.services["sleep"]) if timeout == 0: @@ -1486,7 +1496,7 @@ class TestResetSSHKeyUserRights(cloudstackTestCase): self.fail("Failed to start virtual machine: %s, %s" % (virtual_machine.name, e)) - timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"], + timeout = wait_vm_start(self.apiclient, virtual_machine.id, self.services["timeout"], self.services["sleep"]) if timeout == 0: http://git-wip-us.apache.org/repos/asf/cloudstack/blob/23499efe/tools/marvin/marvin/codes.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py index 124abb3..bd01ad3 100644 --- a/tools/marvin/marvin/codes.py +++ b/tools/marvin/marvin/codes.py @@ -30,6 +30,7 @@ @DateAdded: 20th October 2013 """ +RUNNING = "Running" RECURRING = "RECURRING" ENABLED = "Enabled" NETWORK_OFFERING = "network_offering"