You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sw...@apache.org on 2013/10/17 13:38:17 UTC
git commit: updated refs/heads/master to 9cc5575
Updated Branches:
refs/heads/master 9fc471ddd -> 9cc557509
CLOUDSTACK-4766: Add timeout if vm does not reach running state
The tests use to wait for ever for the vm to attain Running state.
Added a timeout so it does not get into infinite loop.
Signed-off-by: venkataswamybabu budumuru <ve...@citrix.com>
(cherry picked from commit e3bcdc16a11d7452b5bf6ce5e5993dcd008526a6)
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9cc55750
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9cc55750
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9cc55750
Branch: refs/heads/master
Commit: 9cc557509265d8faacca134e8bfeb3a31ddbeb31
Parents: 9fc471d
Author: Girish Shilamkar <gi...@clogeny.com>
Authored: Tue Oct 8 22:53:00 2013 -0400
Committer: venkataswamybabu budumuru <ve...@citrix.com>
Committed: Thu Oct 17 17:07:58 2013 +0530
----------------------------------------------------------------------
.../component/test_reset_ssh_keypair.py | 145 +++++++++----------
1 file changed, 66 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cc55750/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 ace4499..4d0c45e 100644
--- a/test/integration/component/test_reset_ssh_keypair.py
+++ b/test/integration/component/test_reset_ssh_keypair.py
@@ -82,6 +82,23 @@ class Services:
"mode": 'advanced',
}
+def wait_vm_start(apiclient, account, timeout, sleep):
+ while timeout:
+ vms = VirtualMachine.list(
+ apiclient,
+ account=account.name,
+ domainid=account.domainid,
+ listall=True
+ )
+ if vms and vms[0].state == "Running":
+ return timeout
+
+ time.sleep(sleep)
+ timeout = timeout - 1
+
+ return timeout
+
+
class TestResetSSHKeypair(cloudstackTestCase):
@classmethod
@@ -339,7 +356,6 @@ class TestResetSSHKeypair(cloudstackTestCase):
except Exception as e:
self.fail("Failed to reset SSH key: %s, %s" %
(virtual_machine.name, e))
- return
self.debug("Starting the virtual machine after resetting the keypair")
try:
virtual_machine.start(self.apiclient)
@@ -347,17 +363,13 @@ class TestResetSSHKeypair(cloudstackTestCase):
self.fail("Failed to start virtual machine: %s, %s" %
(virtual_machine.name, e))
- while True:
- vms = VirtualMachine.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- if vms[0].state == "Running":
- break
- self.debug("Vm not in Running state sleep 60s")
- time.sleep(60)
+ timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"],
+ self.services["sleep"])
+
+ if timeout == 0:
+ self.fail("The virtual machine %s failed to start even after %s minutes"
+ % (virtual_machine.name, self.services["timeout"]))
+
self.debug("SSH key path: %s" % str(keyPairFilePath))
try:
virtual_machine.get_ssh_client(keyPairFileLocation=str(keyPairFilePath))
@@ -461,17 +473,12 @@ class TestResetSSHKeypair(cloudstackTestCase):
self.fail("Failed to start virtual machine: %s, %s" %
(virtual_machine.name, e))
- while True:
- vms = VirtualMachine.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- if vms[0].state == "Running":
- break
- self.debug("Vm not in Running state sleep 60s")
- time.sleep(60)
+ timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"],
+ self.services["sleep"])
+
+ if timeout == 0:
+ self.fail("The virtual machine %s failed to start even after %s minutes"
+ % (virtual_machine.name, self.services["timeout"]))
self.debug("SSHing with new keypair")
try:
@@ -575,17 +582,13 @@ class TestResetSSHKeypair(cloudstackTestCase):
except Exception as e:
self.fail("Failed to start virtual machine: %s, %s" %
(virtual_machine.name, e))
- while True:
- vms = VirtualMachine.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- if vms[0].state == "Running":
- break
- self.debug("Vm not in Running state sleep 60s")
- time.sleep(60)
+
+ timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"],
+ self.services["sleep"])
+
+ if timeout == 0:
+ self.fail("The virtual machine %s failed to start even after %s minutes"
+ % (virtual_machine.name, self.services["timeout"]))
self.debug("SSHing with new keypair")
try:
@@ -690,17 +693,13 @@ class TestResetSSHKeypair(cloudstackTestCase):
except Exception as e:
self.fail("Failed to start virtual machine: %s, %s" %
(virtual_machine.name, e))
- while True:
- vms = VirtualMachine.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- if vms[0].state == "Running":
- break
- self.debug("Vm not in Running state sleep 60s")
- time.sleep(60)
+
+ timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"],
+ self.services["sleep"])
+
+ if timeout == 0:
+ self.fail("The virtual machine %s failed to start even after %s minutes"
+ % (virtual_machine.name, self.services["timeout"]))
self.debug("SSHing with new keypair")
try:
@@ -1206,18 +1205,14 @@ class TestResetSSHKeyUserRights(cloudstackTestCase):
virtual_machine.start(self.apiclient)
except Exception as e:
self.fail("Failed to start virtual machine: %s, %s" %
- (virtual_machine.name, e))
- while True:
- vms = VirtualMachine.list(
- self.apiclient,
- account=self.user_account.name,
- domainid=self.user_account.domainid,
- listall=True
- )
- if vms[0].state == "Running":
- break
- self.debug("Vm not in Running state sleep 60s")
- time.sleep(60)
+ (virtual_machine.name, e))
+
+ timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"],
+ self.services["sleep"])
+
+ if timeout == 0:
+ self.fail("The virtual machine %s failed to start even after %s minutes"
+ % (vms[0].name, self.services["timeout"]))
self.debug("SSHing with new keypair")
try:
@@ -1350,17 +1345,13 @@ class TestResetSSHKeyUserRights(cloudstackTestCase):
except Exception as e:
self.fail("Failed to start virtual machine: %s, %s" %
(virtual_machine.name, e))
- while True:
- vms = VirtualMachine.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- if vms[0].state == "Running":
- break
- self.debug("Vm not in Running state sleep 60s")
- time.sleep(60)
+
+ timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"],
+ self.services["sleep"])
+
+ if timeout == 0:
+ self.fail("The virtual machine %s failed to start even after %s minutes"
+ % (virtual_machine.name, self.services["timeout"]))
self.debug("SSHing with new keypair")
try:
@@ -1494,17 +1485,13 @@ class TestResetSSHKeyUserRights(cloudstackTestCase):
except Exception as e:
self.fail("Failed to start virtual machine: %s, %s" %
(virtual_machine.name, e))
- while True:
- vms = VirtualMachine.list(
- self.apiclient,
- account=self.account.name,
- domainid=self.account.domainid,
- listall=True
- )
- if vms[0].state == "Running":
- break
- self.debug("Vm not in Running state sleep 60s")
- time.sleep(60)
+
+ timeout = wait_vm_start(self.apiclient, self.account, self.services["timeout"],
+ self.services["sleep"])
+
+ if timeout == 0:
+ self.fail("The virtual machine %s failed to start even after %s minutes"
+ % (virtual_machine.name, self.services["timeout"]))
self.debug("SSHing with new keypair")
try: