X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=sdnvpn%2Ftest%2Ffunctest%2Frun_tests.py;h=1bffe67a7ec0e540865d4368b524813b89132a80;hb=45df38fe0cd7a604827a5cde6ad6480971b0456b;hp=924a0e5163fafbf840ac7b193cd0dc4f6de6ec77;hpb=9d112e4b1a00063f79b088dab93d1700bfb9c0dd;p=sdnvpn.git diff --git a/sdnvpn/test/functest/run_tests.py b/sdnvpn/test/functest/run_tests.py index 924a0e5..1bffe67 100644 --- a/sdnvpn/test/functest/run_tests.py +++ b/sdnvpn/test/functest/run_tests.py @@ -1,6 +1,6 @@ #!/bin/python # -# Copyright (c) 2015 All rights reserved +# Copyright (c) 2017 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 @@ -10,22 +10,18 @@ import argparse import importlib +import logging +import os import sys import time +import traceback import yaml -import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils from sdnvpn.lib import config as sdnvpn_config +from sdnvpn.lib.gather_logs import gather_logs - -parser = argparse.ArgumentParser() -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") -args = parser.parse_args() - -logger = ft_logger.Logger("sdnvpn-run-tests").getLogger() +logger = logging.getLogger('sdnvpn-run-tests') COMMON_CONFIG = sdnvpn_config.CommonConfig() TEST_DB_URL = COMMON_CONFIG.test_db @@ -41,7 +37,21 @@ def push_results(testname, start_time, end_time, criteria, details): details) -def main(): +def main(report=False): + # Workaround for https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-100 + # and SDNVPN-126 + cmd_line = "neutron quota-update --subnet -1 --network -1 --port -1" + logger.info("Setting subnet/net quota to unlimited : %s" % cmd_line) + cmd = os.popen(cmd_line) + output = cmd.read() + logger.debug(output) + + # Workaround for https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115 + cmd_line = "nova quota-class-update --instances -1 default" + logger.info("Setting instances quota to unlimited : %s" % cmd_line) + cmd = os.popen(cmd_line) + output = cmd.read() + logger.debug(output) with open(COMMON_CONFIG.config_file) as f: config_yaml = yaml.safe_load(f) @@ -59,11 +69,17 @@ def main(): logger.info("%s\n" % ("=" * len(title))) t = importlib.import_module(testcase, package=None) start_time = time.time() - result = t.main() + try: + result = t.main() + except Exception as ex: + result = -1 + logger.info("Caught Exception in %s: %s Trace: %s" % + (test_name, ex, traceback.format_exc())) end_time = time.time() if result < 0: status = "FAIL" overall_status = "FAIL" + logger.info("Testcase %s failed" % test_name) else: status = result.get("status") details = result.get("details") @@ -73,10 +89,16 @@ def main(): if status == "FAIL": overall_status = "FAIL" - if args.report: + if report: push_results( test_name_db, start_time, end_time, status, details) + try: + gather_logs('overall') + except Exception as ex: + logger.error(('Something went wrong in the Log gathering.' + 'Ex: Trace: %s') + % ex, traceback.format_exc()) if overall_status == "FAIL": sys.exit(-1) @@ -84,4 +106,10 @@ def main(): if __name__ == '__main__': - main() + logging.basicConfig(level=logging.INFO) + parser = argparse.ArgumentParser() + parser.add_argument("-r", "--report", + help="Create json result file", + action="store_true") + args = parser.parse_args() + main(report=args.report)