summaryrefslogtreecommitdiffstats
path: root/testcases/features/sfc/sfc.py
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/features/sfc/sfc.py')
-rwxr-xr-xtestcases/features/sfc/sfc.py67
1 files changed, 45 insertions, 22 deletions
diff --git a/testcases/features/sfc/sfc.py b/testcases/features/sfc/sfc.py
index c84810efa..8aa7bb9a0 100755
--- a/testcases/features/sfc/sfc.py
+++ b/testcases/features/sfc/sfc.py
@@ -58,6 +58,11 @@ def main():
# Allow any port so that tacker commands reaches the server.
# This will be deleted when tacker is included in OPNFV installation
+ status = "PASS"
+ failures = 0
+ 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}'")
@@ -81,6 +86,10 @@ def main():
" ssh " + ip_server + " iptables -P INPUT ACCEPT ")
iptable_cmd2 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
" ssh " + ip_server + " iptables -t nat -P INPUT ACCEPT ")
+ iptable_cmd3 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
+ " ssh " + ssh_options + " " + ip_server +
+ " iptables -A INPUT -m state"
+ " --state NEW,ESTABLISHED,RELATED -j ACCEPT")
logger.info("Changing firewall policy in controller: '%s'" % iptable_cmd1)
subprocess.call(iptable_cmd1, shell=True, stderr=subprocess.PIPE)
@@ -88,6 +97,9 @@ def main():
logger.info("Changing firewall policy in controller: '%s'" % iptable_cmd2)
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)
+
# Getting the different clients
nova_client = os_utils.get_nova_client()
@@ -315,7 +327,7 @@ def main():
logger.info("Waiting for 60 seconds before TEST")
for j in range(0, 6):
- logger.info("Test starting in {0} seconds".format(str((6 - j)*10)))
+ logger.info("Test starting in {0} seconds".format(str((6 - j) * 10)))
time.sleep(10)
i = 0
@@ -333,10 +345,13 @@ def main():
logger.info('\033[92m' + "TEST 1 [PASSED] "
"==> SSH BLOCKED" + '\033[0m')
i = i + 1
+ json_results.update({"Test 1: SSH Blocked": "Passed"})
else:
logger.error('\033[91m' + "TEST 1 [FAILED] "
"==> SSH NOT BLOCKED" + '\033[0m')
- return
+ status = "FAIL"
+ json_results.update({"Test 1: SSH Blocked": "Failed"})
+ failures += 1
except:
logger.debug("Waiting for %s..." % floatip_client)
time.sleep(6)
@@ -353,10 +368,13 @@ def main():
logger.info('\033[92m' + "TEST 2 [PASSED] "
"==> HTTP WORKS" + '\033[0m')
i = i + 1
+ json_results.update({"Test 2: HTTP works": "Passed"})
else:
logger.error('\033[91m' + "TEST 2 [FAILED] "
"==> HTTP BLOCKED" + '\033[0m')
- return
+ status = "FAIL"
+ json_results.update({"Test 2: HTTP works": "Failed"})
+ failures += 1
except:
logger.debug("Waiting for %s..." % floatip_client)
time.sleep(6)
@@ -389,13 +407,16 @@ def main():
(stdin, stdout, stderr) = ssh.exec_command(command)
if "timed out" in stdout.readlines()[0]:
- logger.info('\033[92m' + "TEST 3 [WORKS] "
+ logger.info('\033[92m' + "TEST 3 [PASSED] "
"==> HTTP BLOCKED" + '\033[0m')
i = i + 1
+ json_results.update({"Test 3: HTTP Blocked": "Passed"})
else:
logger.error('\033[91m' + "TEST 3 [FAILED] "
"==> HTTP NOT BLOCKED" + '\033[0m')
- return
+ status = "FAIL"
+ json_results.update({"Test 3: HTTP Blocked": "Failed"})
+ failures += 1
except:
logger.debug("Waiting for %s..." % floatip_client)
time.sleep(6)
@@ -409,13 +430,16 @@ def main():
(stdin, stdout, stderr) = ssh.exec_command(command)
if "succeeded" in stdout.readlines()[0]:
- logger.info('\033[92m' + "TEST 4 [WORKS] "
+ logger.info('\033[92m' + "TEST 4 [PASSED] "
"==> SSH WORKS" + '\033[0m')
i = i + 1
+ json_results.update({"Test 4: SSH works": "Passed"})
else:
logger.error('\033[91m' + "TEST 4 [FAILED] "
"==> SSH BLOCKED" + '\033[0m')
- return
+ status = "FAIL"
+ json_results.update({"Test 4: SSH works": "Failed"})
+ failures += 1
except:
logger.debug("Waiting for %s..." % floatip_client)
time.sleep(6)
@@ -426,21 +450,20 @@ def main():
logger.info('\033[92m' + "SFC TEST WORKED"
" :) \n" + '\033[0m')
- # TODO report results to DB
- # functest_utils.logger_test_results("SFC",
- # "odl-sfc",
- # status, details)
- # see doctor, promise, domino, ...
- # if args.report:
- # logger.info("Pushing odl-SFC results")
- # functest_utils.push_results_to_db("functest",
- # "odl-sfc",
- # start_time,
- # stop_time,
- # status,
- # details)
-
- sys.exit(0)
+ if args.report:
+ stop_time = time.time()
+ json_results.update({"tests": "4", "failures": int(failures)})
+ logger.debug("Promise Results json: " + str(json_results))
+ ft_utils.push_results_to_db("sfc",
+ "functest-odl-sfc",
+ start_time,
+ stop_time,
+ status,
+ json_results)
+ if status == "PASS":
+ sys.exit(0)
+ else:
+ sys.exit(1)
if __name__ == '__main__':
main()