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
48 cmd_line = "neutron quota-update --subnet -1 --network -1 --port -1"
49 logger.info("Setting subnet/net quota to unlimited : %s" % cmd_line)
50 cmd = os.popen(cmd_line)
54 # Workaround for https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115
55 cmd_line = "nova quota-class-update --instances -1 default"
56 logger.info("Setting instances quota to unlimited : %s" % cmd_line)
57 cmd = os.popen(cmd_line)
61 with open(COMMON_CONFIG.config_file) as f:
62 config_yaml = yaml.safe_load(f)
64 testcases = config_yaml.get("testcases")
65 overall_status = "PASS"
66 for testcase in testcases:
67 if testcases[testcase]['enabled']:
69 test_descr = testcases[testcase]['description']
70 test_name_db = testcases[testcase]['testname_db']
71 title = ("Running '%s - %s'" %
72 (test_name, test_descr))
74 logger.info("%s\n" % ("=" * len(title)))
75 t = importlib.import_module(testcase, package=None)
76 start_time = time.time()
78 end_time = time.time()
81 overall_status = "FAIL"
83 status = result.get("status")
84 details = result.get("details")
85 logger.info("Results of test case '%s - %s':\n%s\n" %
86 (test_name, test_descr, result))
89 overall_status = "FAIL"
93 test_name_db, start_time, end_time, status, details)
95 if overall_status == "FAIL":
101 if __name__ == '__main__':