aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/features/sfc
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/features/sfc')
-rwxr-xr-xtestcases/features/sfc/prepare_odl_sfc.bash38
-rwxr-xr-xtestcases/features/sfc/sfc.py86
2 files changed, 96 insertions, 28 deletions
diff --git a/testcases/features/sfc/prepare_odl_sfc.bash b/testcases/features/sfc/prepare_odl_sfc.bash
new file mode 100755
index 000000000..80ed9bd92
--- /dev/null
+++ b/testcases/features/sfc/prepare_odl_sfc.bash
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+#
+# Author: George Paraskevopoulos (geopar@intracom-telecom.com)
+# Manuel Buil (manuel.buil@ericsson.com)
+# Prepares the controller and the compute nodes for the odl-sfc testcase
+#
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+ODL_SFC_LOG=/home/opnfv/functest/results/odl-sfc.log
+ODL_SFC_DIR=${FUNCTEST_REPO_DIR}/testcases/features/sfc
+
+# Split the output to the log file and redirect STDOUT and STDERR to /dev/null
+bash ${ODL_SFC_DIR}/server_presetup_CI.bash |& \
+ tee -a ${ODL_SFC_LOG} 1>/dev/null 2>&1
+
+# Get return value from PIPESTATUS array (bash specific feature)
+ret_val=${PIPESTATUS[0]}
+if [ $ret_val != 0 ]; then
+ echo "The tacker server deployment failed"
+ exit $ret_val
+fi
+echo "The tacker server was deployed successfully"
+
+bash ${ODL_SFC_DIR}/compute_presetup_CI.bash |& \
+ tee -a ${ODL_SFC_LOG} 1>/dev/null 2>&1
+
+ret_val=${PIPESTATUS[0]}
+if [ $ret_val != 0 ]; then
+ exit $ret_val
+fi
+
+exit 0
diff --git a/testcases/features/sfc/sfc.py b/testcases/features/sfc/sfc.py
index a228ed298..8aa7bb9a0 100755
--- a/testcases/features/sfc/sfc.py
+++ b/testcases/features/sfc/sfc.py
@@ -4,11 +4,11 @@ import sys
import time
import argparse
+import paramiko
+
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
-import paramiko
-from functest.utils.functest_utils import FUNCTEST_REPO as FUNCTEST_REPO
parser = argparse.ArgumentParser()
@@ -21,6 +21,8 @@ args = parser.parse_args()
""" logging configuration """
logger = ft_logger.Logger("ODL_SFC").getLogger()
+FUNCTEST_REPO = ft_utils.FUNCTEST_REPO
+
HOME = os.environ['HOME'] + "/"
VM_BOOT_TIMEOUT = 180
@@ -56,13 +58,19 @@ 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}'")
logger.info("Executing script to get ip_server: '%s'" % contr_cmd)
process = subprocess.Popen(contr_cmd,
shell=True,
- stdout=subprocess.PIPE)
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
ip_server = process.stdout.readline().rstrip()
contr_cmd2 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
@@ -70,16 +78,27 @@ def main():
logger.info("Executing script to get ip_compute: '%s'" % contr_cmd2)
process = subprocess.Popen(contr_cmd2,
shell=True,
- stdout=subprocess.PIPE)
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
ip_compute = process.stdout.readline().rstrip()
iptable_cmd1 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
" 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)
- subprocess.call(iptable_cmd1, shell=True)
- subprocess.call(iptable_cmd2, shell=True)
+ 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
@@ -308,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
@@ -326,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)
@@ -346,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)
@@ -382,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)
@@ -402,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)
@@ -419,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()