3 # Copyright (c) 2017 All rights reserved
4 # This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
17 import functest.utils.functest_logger as ft_logger
18 import functest.utils.functest_utils as ft_utils
19 from sdnvpn.lib import config as sdnvpn_config
22 parser = argparse.ArgumentParser()
23 parser.add_argument("-r", "--report",
24 help="Create json result file",
26 args = parser.parse_args()
28 logger = ft_logger.Logger("sdnvpn-run-tests").getLogger()
30 COMMON_CONFIG = sdnvpn_config.CommonConfig()
31 TEST_DB_URL = COMMON_CONFIG.test_db
34 def push_results(testname, start_time, end_time, criteria, details):
35 logger.info("Push testcase '%s' results into the DB...\n" % testname)
36 ft_utils.push_results_to_db("sdnvpn",
46 with open(COMMON_CONFIG.config_file) as f:
47 config_yaml = yaml.safe_load(f)
49 testcases = config_yaml.get("testcases")
50 overall_status = "PASS"
51 for testcase in testcases:
52 if testcases[testcase]['enabled']:
54 test_descr = testcases[testcase]['description']
55 test_name_db = testcases[testcase]['testname_db']
56 title = ("Running '%s - %s'" %
57 (test_name, test_descr))
59 logger.info("%s\n" % ("=" * len(title)))
60 t = importlib.import_module(testcase, package=None)
61 start_time = time.time()
63 end_time = time.time()
66 overall_status = "FAIL"
68 status = result.get("status")
69 details = result.get("details")
70 logger.info("Results of test case '%s - %s':\n%s\n" %
71 (test_name, test_descr, result))
74 overall_status = "FAIL"
78 test_name_db, start_time, end_time, status, details)
80 if overall_status == "FAIL":
86 if __name__ == '__main__':