summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2015-05-20 22:27:12 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2015-05-20 22:30:35 +0200
commite5bd917a64e7f0305c254f10ac168a714ce04456 (patch)
treee66949503d0319c0f2b5564d1f3dea26e0202341
parentd74d213c312e8d2b53fbda507fd33cbbaff46c9e (diff)
vPing.py: added timeout when building the VMs
JIRA: FUNCTEST-3 Change-Id: I5dfc80bb7a42d92a684d57f30abbe837518422df Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
-rw-r--r--testcases/vPing/CI/libraries/vPing.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py
index 3836a1a4c..1eb219dfb 100644
--- a/testcases/vPing/CI/libraries/vPing.py
+++ b/testcases/vPing/CI/libraries/vPing.py
@@ -24,6 +24,7 @@ with open(HOME+'.functest/functest.yaml') as f:
functest_yaml = yaml.safe_load(f)
f.close()
+VM_BOOT_TIMEOUT = 180
PING_TIMEOUT = functest_yaml.get("vping").get("ping_timeout")
NAME_VM_1 = functest_yaml.get("vping").get("vm_name_1")
NAME_VM_2 = functest_yaml.get("vping").get("vm_name_2")
@@ -98,10 +99,18 @@ def get_server(creds, servername):
def waitVmActive(nova,vm):
# sleep and wait for VM status change
- while get_status(nova,vm) != "ACTIVE":
- time.sleep(3)
- logger.debug("Status: %s" % vm.status)
- logger.debug("Status: %s" % vm.status)
+ sleep_time = 3
+ count = VM_BOOT_TIMEOUT / sleep_time
+ while True:
+ status = get_status(nova,vm)
+ logger.debug("Status: %s" % status)
+ if status == "ACTIVE":
+ return True
+ if status == "ERROR" or count == 0:
+ return False
+ count-=1
+ time.sleep(sleep_time)
+ return False
def get_status(nova,vm):
vm = nova.servers.get(vm.id)
@@ -172,7 +181,11 @@ def main():
#wait until VM status is active
- waitVmActive(nova,vm1)
+ if not waitVmActive(nova,vm1):
+ logger.error("Instance '%s' cannot be booted. Status is '%s'" % (NAME_VM_1,get_status(nova,vm1)))
+ return (EXIT_CODE)
+ else:
+ logger.info("Instance '%s' is ACTIVE." % NAME_VM_1)
#retrieve IP of first VM
logger.debug("Fetching IP...")
@@ -199,7 +212,11 @@ def main():
userdata = u,
)
- waitVmActive(nova,vm2)
+ if not waitVmActive(nova,vm2):
+ logger.error("Instance '%s' cannot be booted. Status is '%s'" % (NAME_VM_2,get_status(nova,vm2)))
+ return (EXIT_CODE)
+ else:
+ logger.info("Instance '%s' is ACTIVE." % NAME_VM_2)
sec = 0
console_log = vm2.get_console_output()