aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/functest/odl-sfc/results.py53
-rwxr-xr-xtests/functest/odl-sfc/sfc.py44
2 files changed, 72 insertions, 25 deletions
diff --git a/tests/functest/odl-sfc/results.py b/tests/functest/odl-sfc/results.py
new file mode 100644
index 00000000..69e5523b
--- /dev/null
+++ b/tests/functest/odl-sfc/results.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2016 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
+#
+
+import functest.utils.functest_logger as ft_logger
+
+logger = ft_logger.Logger("sfc-results").getLogger()
+
+
+class Results(object):
+
+ def __init__(self, line_length):
+ self.line_length = line_length
+ self.test_result = "FAIL"
+ self.summary = ""
+ self.details = []
+ self.num_tests = 0
+ self.num_tests_failed = 0
+
+ def add_to_summary(self, num_cols, col1, col2=""):
+ if num_cols == 0:
+ self.summary += ("+%s+\n" % (col1 * (self.line_length - 2)))
+ elif num_cols == 1:
+ self.summary += ("| " + col1.ljust(self.line_length - 3) + "|\n")
+ elif num_cols == 2:
+ self.summary += ("| %s" % col1.ljust(7) + "| ")
+ self.summary += (col2.ljust(self.line_length - 12) + "|\n")
+ if col1 in ("FAIL", "PASS"):
+ self.details.append({col2: col1})
+ self.num_tests += 1
+ if col1 == "FAIL":
+ self.num_tests_failed += 1
+
+ def compile_summary(self):
+ success_message = "All the subtests have passed."
+ failure_message = "One or more subtests have failed."
+
+ self.add_to_summary(0, "=")
+ logger.info("\n%s" % self.summary)
+ status = "FAILED"
+ if self.test_result == "PASS":
+ status = "PASS"
+ logger.info(success_message)
+ else:
+ logger.info(failure_message)
+
+ return {"status": status, "details": self.details}
diff --git a/tests/functest/odl-sfc/sfc.py b/tests/functest/odl-sfc/sfc.py
index 12227698..de233869 100755
--- a/tests/functest/odl-sfc/sfc.py
+++ b/tests/functest/odl-sfc/sfc.py
@@ -10,6 +10,7 @@ import threading
import ovs_utils
import utils as test_utils
import config as sfc_config
+from results import Results
parser = argparse.ArgumentParser()
@@ -25,7 +26,6 @@ logger = ft_logger.Logger("ODL_SFC").getLogger()
CLIENT = "client"
SERVER = "server"
-json_results = {"tests": 4, "failures": 0}
COMMON_CONFIG = sfc_config.CommonConfig()
TESTCASE_CONFIG = sfc_config.TestcaseConfig('sfc_two_chains_SSH_and_HTTP')
@@ -36,15 +36,12 @@ PROXY = {
}
-def update_json_results(name, result):
- json_results.update({name: result})
- if result is not "Passed":
- json_results["failures"] += 1
-
- return
-
-
def main():
+ results = Results(COMMON_CONFIG.line_length)
+ results.add_to_summary(0, "=")
+ results.add_to_summary(2, "STATUS", "SUBTEST")
+ results.add_to_summary(0, "=")
+
installer_type = os.environ.get("INSTALLER_TYPE")
if installer_type != "fuel":
logger.error(
@@ -184,25 +181,23 @@ def main():
logger.info("Test SSH")
if test_utils.is_ssh_blocked(srv_prv_ip, client_ip):
- logger.info('\033[92mTEST 1 [PASSED] ==> SSH BLOCKED\033[0m')
- update_json_results("Test 1: SSH Blocked", "Passed")
+ results.add_to_summary(2, "PASS", "SSH Blocked")
else:
error = ('\033[91mTEST 1 [FAILED] ==> SSH NOT BLOCKED\033[0m')
logger.error(error)
test_utils.capture_err_logs(
ovs_logger, controller_clients, compute_clients, error)
- update_json_results("Test 1: SSH Blocked", "Failed")
+ results.add_to_summary(2, "FAIL", "SSH Blocked")
logger.info("Test HTTP")
if not test_utils.is_http_blocked(srv_prv_ip, client_ip):
- logger.info('\033[92mTEST 2 [PASSED] ==> HTTP WORKS\033[0m')
- update_json_results("Test 2: HTTP works", "Passed")
+ results.add_to_summary(2, "PASS", "HTTP works")
else:
error = ('\033[91mTEST 2 [FAILED] ==> HTTP BLOCKED\033[0m')
logger.error(error)
test_utils.capture_err_logs(
ovs_logger, controller_clients, compute_clients, error)
- update_json_results("Test 2: HTTP works", "Failed")
+ results.add_to_summary(2, "FAIL", "HTTP works")
logger.info("Changing the classification")
os_tacker.delete_sfc_classifier(tacker_client, sfc_clf_name='red_http')
@@ -239,40 +234,39 @@ def main():
logger.info("Test HTTP")
if test_utils.is_http_blocked(srv_prv_ip, client_ip):
- logger.info('\033[92mTEST 3 [PASSED] ==> HTTP Blocked\033[0m')
- update_json_results("Test 3: HTTP Blocked", "Passed")
+ results.add_to_summary(2, "PASS", "HTTP Blocked")
else:
error = ('\033[91mTEST 3 [FAILED] ==> HTTP WORKS\033[0m')
logger.error(error)
test_utils.capture_err_logs(
ovs_logger, controller_clients, compute_clients, error)
- update_json_results("Test 3: HTTP Blocked", "Failed")
+ results.add_to_summary(2, "FAIL", "HTTP Blocked")
logger.info("Test SSH")
if not test_utils.is_ssh_blocked(srv_prv_ip, client_ip):
- logger.info('\033[92mTEST 4 [PASSED] ==> SSH Works\033[0m')
- update_json_results("Test 4: SSH Works", "Passed")
+ results.add_to_summary(2, "PASS", "SSH works")
else:
error = ('\033[91mTEST 4 [FAILED] ==> SSH BLOCKED\033[0m')
logger.error(error)
test_utils.capture_err_logs(
ovs_logger, controller_clients, compute_clients, error)
- update_json_results("Test 4: SSH Works", "Failed")
+ results.add_to_summary(2, "FAIL", "SSH works")
- if json_results["failures"]:
+ if results.num_tests_failed > 0:
status = "FAIL"
logger.error('\033[91mSFC TESTS: %s :( FOUND %s FAIL \033[0m' % (
- status, json_results["failures"]))
+ status, results.num_tests_failed))
if args.report:
+ details = results["details"]
stop_time = time.time()
- logger.debug("Promise Results json: " + str(json_results))
+ logger.debug("Promise Results json: " + str(details))
ft_utils.push_results_to_db("sfc",
"sfc_two_chains_SSH_and_HTTP",
start_time,
stop_time,
status,
- json_results)
+ details)
ovs_logger.create_artifact_archive()
if status == "PASS":