From a362e1e7beef9c3c9921b8f755d37dd60761c226 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Mon, 25 Sep 2017 17:46:24 +0200 Subject: Bug fix: Do not start testing before checking JIRA:SFC-113 We used to check that the ACL and RSP flows were implemented because it took a lot of time. However, the new ODL Nitrogen reduced this time a lot and thus we must check that the vxlan_tool is up and the HTTP port is up in the server before doing any test Change-Id: I70219071c7965781b17e80631bf3e2efbfcfe4cd Signed-off-by: Manuel Buil --- sfc/lib/utils.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py index e406568f..65b491be 100644 --- a/sfc/lib/utils.py +++ b/sfc/lib/utils.py @@ -282,18 +282,34 @@ def assign_floating_ip(nova_client, neutron_client, instance_id): return floating_ip -def start_http_server(ip): - """Start http server on a given machine, Can be VM""" +def start_http_server(ip, iterations_check=5): + """ + Start http server on a given machine. Wait until the process exists + and until the port is up + """ cmd = "\'python -m SimpleHTTPServer 80" cmd = cmd + " > /dev/null 2>&1 &\'" run_cmd_remote(ip, cmd) + + # Wait for the process to start before checking + time.sleep(3) _, output, _ = run_cmd_remote(ip, "ps aux | grep SimpleHTTPServer") if not output: logger.error("Failed to start http server") return False - logger.info(output) - return True + + while iterations_check > 0: + _, output, _ = run_cmd_remote(ip, "ss -na | grep *:80") + if output: + return True + else: + logger.debug("Port 80 is not up yet") + iterations_check -= 1 + time.sleep(5) + + logger.error("Failed to start http server") + return False def start_vxlan_tool(remote_ip, interface="eth0", block=None): @@ -315,7 +331,16 @@ def start_vxlan_tool(remote_ip, interface="eth0", block=None): options=options, output_redirection=output_redirection) - return run_cmd_remote(remote_ip, full_command) + output_execution = run_cmd_remote(remote_ip, full_command) + + # Wait for the process to start before checking + time.sleep(3) + _, output, _ = run_cmd_remote(remote_ip, "ps aux | grep vxlan_tool") + if not output: + logger.error("Failed to start the vxlan tool") + return False + + return output_execution def stop_vxlan_tool(remote_ip): -- cgit 1.2.3-korg