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
18 import functest.utils.functest_logger as ft_logger
19 import functest.utils.functest_utils as ft_utils
20 from sdnvpn.lib import config as sdnvpn_config
23 parser = argparse.ArgumentParser()
24 parser.add_argument("-r", "--report",
25 help="Create json result file",
27 args = parser.parse_args()
29 logger = ft_logger.Logger("sdnvpn-run-tests").getLogger()
31 COMMON_CONFIG = sdnvpn_config.CommonConfig()
32 TEST_DB_URL = COMMON_CONFIG.test_db
35 def push_results(testname, start_time, end_time, criteria, details):
36 logger.info("Push testcase '%s' results into the DB...\n" % testname)
37 ft_utils.push_results_to_db("sdnvpn",
46 # Workaround for https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-100
47 cmd_line = "neutron quota-update --subnet -1 --network -1"
48 logger.info("Setting subnet/net quota to unlimited : %s" % cmd_line)
49 cmd = os.popen(cmd_line)
53 # Workaround for https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115
54 cmd_line = "nova quota-class-update --instances -1 default"
55 logger.info("Setting instances quota to unlimited : %s" % cmd_line)
56 cmd = os.popen(cmd_line)
60 with open(COMMON_CONFIG.config_file) as f:
61 config_yaml = yaml.safe_load(f)
63 testcases = config_yaml.get("testcases")
64 overall_status = "PASS"
65 for testcase in testcases:
66 if testcases[testcase]['enabled']:
68 test_descr = testcases[testcase]['description']
69 test_name_db = testcases[testcase]['testname_db']
70 title = ("Running '%s - %s'" %
71 (test_name, test_descr))
73 logger.info("%s\n" % ("=" * len(title)))
74 t = importlib.import_module(testcase, package=None)
75 start_time = time.time()
77 end_time = time.time()
80 overall_status = "FAIL"
82 status = result.get("status")
83 details = result.get("details")
84 logger.info("Results of test case '%s - %s':\n%s\n" %
85 (test_name, test_descr, result))
88 overall_status = "FAIL"
92 test_name_db, start_time, end_time, status, details)
94 if overall_status == "FAIL":
100 if __name__ == '__main__':