summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVijayendra Radhakrishna <vradhakrishna@mvista.com>2016-12-07 16:22:28 +0530
committerVijayendra Radhakrishna <vradhakrishna@mvista.com>2016-12-07 18:04:47 +0530
commit12b658702a1db256fb9cf1e3fa7d055ac58b91af (patch)
tree213340894e4b9a492abfc1bf4108525e3987d55b /tests
parent7fddc131f4ed035397adf685df617d0df6cd8bf9 (diff)
odl-sfc refactor:run_tests.py integration
- JIRA:SFC-54 - This has not yet removed dependacy of prepare_odl_sfc.py Change-Id: Ie86eb167d49a16bbe4322978a907825829ac364d Signed-off-by: Vijayendra Radhakrishna <vradhakrishna@mvista.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/functest/odl-sfc/config.yaml6
-rw-r--r--tests/functest/odl-sfc/results.py7
-rw-r--r--tests/functest/odl-sfc/run_tests.py102
-rwxr-xr-xtests/functest/odl-sfc/sfc.py31
4 files changed, 114 insertions, 32 deletions
diff --git a/tests/functest/odl-sfc/config.yaml b/tests/functest/odl-sfc/config.yaml
index c6624af6..e99ea102 100644
--- a/tests/functest/odl-sfc/config.yaml
+++ b/tests/functest/odl-sfc/config.yaml
@@ -9,7 +9,11 @@ defaults:
url: "http://artifacts.opnfv.org/sfc/demo"
testcases:
- sfc_two_chains_SSH_and_HTTP:
+# this change requires sfc.py to be renamed as sfc_two_chains_SSH_and_HTTP
+# for run_tests.py integration. Rename of sfc.py will be submitted in
+# separate patch for better review clarity and name will be changed back to
+# sfc_two_chains_SSH_and_HTTP once sfc.py is renamed
+ sfc:
enabled: true
description: "ODL-SFC tests"
testname_db: "sfc_two_chains_SSH_and_HTTP"
diff --git a/tests/functest/odl-sfc/results.py b/tests/functest/odl-sfc/results.py
index 69e5523b..5fa9aa05 100644
--- a/tests/functest/odl-sfc/results.py
+++ b/tests/functest/odl-sfc/results.py
@@ -43,11 +43,10 @@ class Results(object):
self.add_to_summary(0, "=")
logger.info("\n%s" % self.summary)
- status = "FAILED"
- if self.test_result == "PASS":
- status = "PASS"
+ if self.num_tests_failed == 0:
+ self.test_result = "PASS"
logger.info(success_message)
else:
logger.info(failure_message)
- return {"status": status, "details": self.details}
+ return {"status": self.test_result, "details": self.details}
diff --git a/tests/functest/odl-sfc/run_tests.py b/tests/functest/odl-sfc/run_tests.py
new file mode 100644
index 00000000..96ed9a3f
--- /dev/null
+++ b/tests/functest/odl-sfc/run_tests.py
@@ -0,0 +1,102 @@
+#!/bin/python
+#
+# Copyright (c) 2015 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 argparse
+import config as sfc_config
+import importlib
+import os
+import sys
+import time
+import ovs_utils
+import functest.utils.functest_logger as ft_logger
+import functest.utils.functest_utils as ft_utils
+import yaml
+
+
+parser = argparse.ArgumentParser()
+parser.add_argument("-r", "--report",
+ help="Create json result file",
+ action="store_true")
+args = parser.parse_args()
+
+logger = ft_logger.Logger("sfc-run-tests").getLogger()
+COMMON_CONFIG = sfc_config.CommonConfig()
+
+
+def push_results(testname, start_time, end_time, criteria, details):
+ logger.info("Push testcase '%s' results into the DB...\n" % testname)
+ ft_utils.push_results_to_db("sfc",
+ testname,
+ start_time,
+ end_time,
+ criteria,
+ details)
+
+
+def main():
+ ovs_logger = ovs_utils.OVSLogger(
+ os.path.join(COMMON_CONFIG.sfc_test_dir, 'ovs-logs'),
+ COMMON_CONFIG.functest_results_dir)
+
+ config_file = os.path.join(COMMON_CONFIG.config_file)
+ with open(config_file) as f:
+ config_yaml = yaml.safe_load(f)
+
+ testcases = config_yaml.get("testcases")
+ overall_details = {}
+ overall_status = "FAIL"
+ overall_start_time = time.time()
+ for testcase in testcases:
+ if testcases[testcase]['enabled']:
+ test_name = testcase
+ test_descr = testcases[testcase]['description']
+ test_name_db = testcases[testcase]['testname_db']
+ title = ("Running '%s - %s'" %
+ (test_name, test_descr))
+ logger.info(title)
+ logger.info("%s\n" % ("=" * len(title)))
+ t = importlib.import_module(testcase, package=None)
+ start_time = time.time()
+ result = t.main()
+ end_time = time.time()
+ duration = end_time - start_time
+ status = "FAIL"
+ if result != 0:
+ overall_details.update({test_name_db: "execution error."})
+ else:
+ status = result.get("status")
+ if status == "FAIL":
+ overall_status = "FAIL"
+ ovs_logger.create_artifact_archive()
+
+ logger.info("Results of test case '%s - %s':\n%s\n" %
+ (test_name, test_descr, result))
+
+ dic = {"duration": duration, "status": overall_status}
+ overall_details.update({test_name_db: dic})
+ if args.report:
+ details = result.get("details")
+ push_results(
+ test_name_db, start_time, end_time, status, details)
+
+ overall_end_time = time.time()
+ if args.report:
+ push_results(
+ "odl-sfc", overall_start_time, overall_end_time,
+ overall_status, overall_details)
+
+ if overall_status == "FAIL":
+ sys.exit(-1)
+
+ sys.exit(0)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/functest/odl-sfc/sfc.py b/tests/functest/odl-sfc/sfc.py
index de233869..5c7a8522 100755
--- a/tests/functest/odl-sfc/sfc.py
+++ b/tests/functest/odl-sfc/sfc.py
@@ -1,9 +1,7 @@
import argparse
import os
import sys
-import time
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 functest.utils.openstack_tacker as os_tacker
import threading
@@ -27,7 +25,9 @@ logger = ft_logger.Logger("ODL_SFC").getLogger()
CLIENT = "client"
SERVER = "server"
COMMON_CONFIG = sfc_config.CommonConfig()
-TESTCASE_CONFIG = sfc_config.TestcaseConfig('sfc_two_chains_SSH_and_HTTP')
+# TestcaseConfig sfc name will be changed once
+# we rename sfc.py with appropriate name
+TESTCASE_CONFIG = sfc_config.TestcaseConfig('sfc')
PROXY = {
'ip': COMMON_CONFIG.fuel_master_ip,
@@ -56,8 +56,6 @@ def main():
'\033[91mexport INSTALLER_IP=<ip>\033[0m')
sys.exit(1)
- start_time = time.time()
- status = "PASS"
test_utils.configure_iptables()
test_utils.download_image(COMMON_CONFIG.url,
COMMON_CONFIG.image_path)
@@ -252,28 +250,7 @@ def main():
ovs_logger, controller_clients, compute_clients, error)
results.add_to_summary(2, "FAIL", "SSH works")
- if results.num_tests_failed > 0:
- status = "FAIL"
- logger.error('\033[91mSFC TESTS: %s :( FOUND %s FAIL \033[0m' % (
- status, results.num_tests_failed))
-
- if args.report:
- details = results["details"]
- stop_time = time.time()
- 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,
- details)
- ovs_logger.create_artifact_archive()
-
- if status == "PASS":
- logger.info('\033[92mSFC ALL TESTS: %s :)\033[0m' % status)
- sys.exit(0)
-
- sys.exit(1)
+ return results.compile_summary()
if __name__ == '__main__':