aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Paraskevopoulos <geopar@intracom-telecom.com>2016-09-16 17:04:51 +0300
committerGeorge Paraskevopoulos <geopar@intracom-telecom.com>2016-09-21 17:57:54 +0300
commitb9e50a3e0869cef0ff6ac11355abc2387c86839c (patch)
tree70bbf08c93d1b0ea5b6b1583a235eff112b3547e
parent7217cec00b68062206b39804a042543dcb31ce21 (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>
-rwxr-xr-xtestcases/features/sfc/sfc.py39
1 files changed, 32 insertions, 7 deletions
diff --git a/testcases/features/sfc/sfc.py b/testcases/features/sfc/sfc.py
index e0bf4e8d..3f46026a 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: