From ecc77fad440a63627755e7ff042a98f34f3e9b75 Mon Sep 17 00:00:00 2001 From: CNlukai Date: Wed, 27 Jan 2016 12:02:29 +0800 Subject: FUNCTEST-127 FIx the condition judgment of vping Change-Id: I58abace66fb73e0531affc651194473718dfacd5 Signed-off-by: CNlukai --- testcases/vPing/CI/libraries/vPing2.py | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'testcases/vPing/CI') diff --git a/testcases/vPing/CI/libraries/vPing2.py b/testcases/vPing/CI/libraries/vPing2.py index 912627b76..7714dfcb8 100644 --- a/testcases/vPing/CI/libraries/vPing2.py +++ b/testcases/vPing/CI/libraries/vPing2.py @@ -449,16 +449,16 @@ def main(): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - timeout = 20 + timeout = 50 while timeout > 0: try: - ssh.connect(floatip, username=username, password=password, timeout=10) + ssh.connect(floatip, username=username, password=password, timeout=2) logger.debug("SSH connection established to %s." % floatip) break except Exception, e: #print e logger.debug("Waiting for %s..." % floatip) - time.sleep(2) + time.sleep(6) timeout -= 1 if timeout == 0: # 300 sec timeout (5 min) @@ -496,6 +496,7 @@ def main(): duration = 0 cmd = '~/ping.sh ' + IP_1 + flag = False while True: time.sleep(1) # we do the SCP every time in the loop because while testing, I observed @@ -508,20 +509,24 @@ def main(): # print "--"+console_log # report if the test is failed - if "vPing OK" in output: - logger.info("vPing detected!") - - # we consider start time at VM1 booting - end_time_ts = time.time() - duration = round(end_time_ts - start_time_ts, 1) - logger.info("vPing duration:'%s'" % duration) - EXIT_CODE = 0 + for line in output: + if "vPing OK" in output: + logger.info("vPing detected!") + + # we consider start time at VM1 booting + end_time_ts = time.time() + duration = round(end_time_ts - start_time_ts, 1) + logger.info("vPing duration:'%s'" % duration) + EXIT_CODE = 0 + flag = True + break + elif sec == PING_TIMEOUT: + logger.info("Timeout reached.") + flag = True + break + if flag : break - elif sec == PING_TIMEOUT: - logger.info("Timeout reached.") - break - else: - logger.debug("Pinging %s. Waiting for response..." % IP_2) + logger.debug("Pinging %s. Waiting for response..." % IP_1) sec += 1 cleanup(nova_client, neutron_client, image_id, network_dic, -- cgit 1.2.3-korg