FUNCTEST-127 25/8125/1
authorCNlukai <lukai1@huawei.com>
Wed, 27 Jan 2016 04:02:29 +0000 (12:02 +0800)
committerJose Lausuch <jose.lausuch@ericsson.com>
Wed, 27 Jan 2016 09:53:58 +0000 (09:53 +0000)
FIx the condition judgment of vping

Change-Id: I58abace66fb73e0531affc651194473718dfacd5
Signed-off-by: CNlukai <lukai1@huawei.com>
(cherry picked from commit ecc77fad440a63627755e7ff042a98f34f3e9b75)

testcases/config_functest.yaml
testcases/vPing/CI/libraries/vPing2.py

index 7aa0be8..bab1a4b 100644 (file)
@@ -65,7 +65,7 @@ general:
         neutron_router_name: functest-router
 
 vping:
-    ping_timeout:   300
+    ping_timeout:   200
     vm_flavor: m1.small #adapt to your environment
     vm_name_1: opnfv-vping-1
     vm_name_2: opnfv-vping-2
index 912627b..7714dfc 100644 (file)
@@ -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,