diff options
author | George Paraskevopoulos <geopar@intracom-telecom.com> | 2016-09-16 17:04:51 +0300 |
---|---|---|
committer | Jose Lausuch <jose.lausuch@ericsson.com> | 2016-09-21 15:02:52 +0000 |
commit | fac331621b6f74a5403f9715abbeb43ad7edafda (patch) | |
tree | ec57e047951ae152101cf1d9c443f6c1e893ec95 /testcases/features/sfc | |
parent | 42ad800660b47da787513294013e08f82a7d2516 (diff) |
Add SSH connectivity check
- Remove sleep after floating IP assignment
- Add ssh connection check
- Fix iptables instruction
Change-Id: I1a7aa7f928592f148ff4bcd20167e4684f7a7dbe
Signed-off-by: George Paraskevopoulos <geopar@intracom-telecom.com>
(cherry picked from commit b9e50a3e0869cef0ff6ac11355abc2387c86839c)
Diffstat (limited to 'testcases/features/sfc')
-rwxr-xr-x | testcases/features/sfc/sfc.py | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/testcases/features/sfc/sfc.py b/testcases/features/sfc/sfc.py index e0bf4e8d7..3f46026ad 100755 --- a/testcases/features/sfc/sfc.py +++ b/testcases/features/sfc/sfc.py @@ -52,6 +52,16 @@ TACKER_SCRIPT = 'sfc_tacker.bash' TEARDOWN_SCRIPT = "sfc_teardown.bash" TACKER_CHANGECLASSI = "sfc_change_classi.bash" +ssh_options = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' + + +def check_ssh(ip): + cmd = "sshpass -p opnfv ssh " + ssh_options + " -q " + ip + " exit" + success = subprocess.call(cmd, shell=True) == 0 + if not success: + logger.debug("Wating for SSH connectivity in SF with IP: %s" % ip) + return success + def main(): @@ -63,7 +73,6 @@ def main(): start_time = time.time() json_results = {} - ssh_options = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' contr_cmd = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2" " 'fuel node'|grep controller|awk '{print $10}'") logger.info("Executing script to get ip_server: '%s'" % contr_cmd) @@ -98,7 +107,7 @@ def main(): subprocess.call(iptable_cmd2, shell=True, stderr=subprocess.PIPE) logger.info("Changing firewall policy in controller: '%s'" % iptable_cmd3) - subprocess.call(iptable_cmd2, shell=True, stderr=subprocess.PIPE) + subprocess.call(iptable_cmd3, shell=True, stderr=subprocess.PIPE) # Getting the different clients @@ -263,13 +272,29 @@ def main(): logger.error('Failed to obtain IPs, cant continue, exiting') return - logger.info("Waiting 60 seconds for floating IP assignment") - for j in range(0, 6): - logger.debug("Test starting in {0} seconds".format(str((6 - j) * 10))) - time.sleep(10) - logger.debug("Floating IPs for SFs: %s..." % ips) + # Check SSH connectivity to VNFs + r = 0 + retries = 100 + check = [False, False] + + logger.info("Checking SSH connectivity to the SFs with ips %s" % str(ips)) + while r < retries and not all(check): + try: + check = [check_ssh(ips[0]), check_ssh(ips[1])] + except Exception: + logger.exception("SSH check failed") + check = [False, False] + time.sleep(3) + r += 1 + + logger.info("SSH connectivity to the SFs established") + + if not all(check): + logger.error("Cannot establish SSH connection to the SFs") + sys.exit(1) + # SSH TO START THE VXLAN_TOOL ON SF1 logger.info("Configuring the SFs") try: |