Encapsulate sleeps in function 45/24045/5
authorGeorge Paraskevopoulos <geopar@intracom-telecom.com>
Tue, 8 Nov 2016 08:15:01 +0000 (10:15 +0200)
committerGeorge Paraskevopoulos <geopar@intracom-telecom.com>
Thu, 10 Nov 2016 14:43:48 +0000 (16:43 +0200)
We have some sleeps into the testcase code. We can encapsulate them in a
utility function to refactor them out of the code until we figure out
the best way to remove them completely

Change-Id: I44c32d8329c2e319660518a8a46debc22f02c753
Signed-off-by: George Paraskevopoulos <geopar@intracom-telecom.com>
test/functest/testcase_1.py
test/functest/testcase_2.py
test/functest/testcase_4.py
test/functest/utils.py

index ad1e121..aa9bc92 100644 (file)
@@ -11,7 +11,6 @@
 import argparse
 import os
 from random import randint
-import time
 
 import functest.utils.functest_logger as ft_logger
 import functest.utils.functest_utils as ft_utils
@@ -251,7 +250,7 @@ def main():
 
     logger.info("Waiting for the VMs to connect to each other using the"
                 " updated network configuration")
-    time.sleep(30)
+    test_utils.wait_before_subtest()
 
     # Ping from VM4 to VM5 should work
     results.get_ping_status(vm_4, vm_4_ip, vm_5, vm_5_ip,
@@ -272,9 +271,10 @@ def main():
               "export_targets": TARGETS_1,
               "name": vpn_name}
     bgpvpn = os_utils.update_bgpvpn(neutron_client, bgpvpn_id, **kwargs)
+
     logger.info("Waiting for the VMs to connect to each other using the"
                 " updated network configuration")
-    time.sleep(30)
+    test_utils.wait_before_subtest()
 
     # Ping from VM1 to VM4 should work
     results.get_ping_status(vm_1, vm_1_ip, vm_4, vm_4_ip,
index f6296be..dee70b4 100644 (file)
@@ -12,7 +12,6 @@ import argparse
 import os
 from random import randint
 import sys
-import time
 
 import functest.utils.functest_logger as ft_logger
 import functest.utils.functest_utils as ft_utils
@@ -260,7 +259,7 @@ def main():
 
     logger.info("Waiting for the VMs to connect to each other using the"
                 " updated network configuration")
-    time.sleep(30)
+    test_utils.wait_before_subtest()
 
     # 10.10.10.12 should return sdnvpn-2 to sdnvpn-1
     results.check_ssh_output(
@@ -295,7 +294,7 @@ def main():
 
     logger.info("Waiting for the VMs to connect to each other using the"
                 " updated network configuration")
-    time.sleep(30)
+    test_utils.wait_before_subtest()
 
     # 10.10.11.13 should return sdnvpn-5 to sdnvpn-4
     results.check_ssh_output(
index 3811141..7aa0be2 100644 (file)
@@ -11,7 +11,6 @@
 import argparse
 import os
 from random import randint
-import time
 
 import functest.utils.functest_logger as ft_logger
 import functest.utils.functest_utils as ft_utils
@@ -243,7 +242,7 @@ def main():
 
     logger.info("Waiting for the VMs to connect to each other using the"
                 " updated network configuration")
-    time.sleep(30)
+    test_utils.wait_before_subtest()
 
     # Ping from VM4 to VM5 should work
     results.get_ping_status(vm_4, vm_4_ip, vm_5, vm_5_ip,
@@ -267,7 +266,7 @@ def main():
 
     logger.info("Waiting for the VMs to connect to each other using the"
                 " updated network configuration")
-    time.sleep(30)
+    test_utils.wait_before_subtest()
 
     # Ping from VM1 to VM4 should work
     results.get_ping_status(vm_1, vm_1_ip, vm_4, vm_4_ip,
index d416765..b75cb3b 100644 (file)
@@ -271,6 +271,12 @@ def wait_for_bgp_router_assocs(neutron_client, bgpvpn_id, *args):
     return all(check)
 
 
+def wait_before_subtest(*args, **kwargs):
+    ''' This is a placeholder.
+        TODO: Replace delay with polling logic. '''
+    time.sleep(30)
+
+
 def assert_and_get_compute_nodes(nova_client, required_node_number=2):
     """Get the compute nodes in the deployment