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 logger = ft_logger.Logger(__name__).getLogger()
25 COMMON_CONFIG = sdnvpn_config.CommonConfig()
26 TEST_DB_URL = COMMON_CONFIG.test_db
29 def push_results(testname, start_time, end_time, criteria, details):
30 logger.info("Push testcase '%s' results into the DB...\n" % testname)
31 ft_utils.push_results_to_db("sdnvpn",
39 def main(report=False):
40 # Workaround for https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-100
42 cmd_line = "neutron quota-update --subnet -1 --network -1 --port -1"
43 logger.info("Setting subnet/net quota to unlimited : %s" % cmd_line)
44 cmd = os.popen(cmd_line)
48 # Workaround for https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115
49 cmd_line = "nova quota-class-update --instances -1 default"
50 logger.info("Setting instances quota to unlimited : %s" % cmd_line)
51 cmd = os.popen(cmd_line)
55 with open(COMMON_CONFIG.config_file) as f:
56 config_yaml = yaml.safe_load(f)
58 testcases = config_yaml.get("testcases")
59 overall_status = "PASS"
60 for testcase in testcases:
61 if testcases[testcase]['enabled']:
63 test_descr = testcases[testcase]['description']
64 test_name_db = testcases[testcase]['testname_db']
65 title = ("Running '%s - %s'" %
66 (test_name, test_descr))
68 logger.info("%s\n" % ("=" * len(title)))
69 t = importlib.import_module(testcase, package=None)
70 start_time = time.time()
72 end_time = time.time()
75 overall_status = "FAIL"
77 status = result.get("status")
78 details = result.get("details")
79 logger.info("Results of test case '%s - %s':\n%s\n" %
80 (test_name, test_descr, result))
83 overall_status = "FAIL"
87 test_name_db, start_time, end_time, status, details)
89 if overall_status == "FAIL":
95 if __name__ == '__main__':
96 parser = argparse.ArgumentParser()
97 parser.add_argument("-r", "--report",
98 help="Create json result file",
100 args = parser.parse_args()
101 main(report=args.report)