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
19 from functest.core import testcase
20 from sdnvpn.lib import config as sdnvpn_config
21 from sdnvpn.lib.gather_logs import gather_logs
23 COMMON_CONFIG = sdnvpn_config.CommonConfig()
26 class SdnvpnFunctest(testcase.TestCase):
28 __logger = logging.getLogger(__name__)
31 self.start_time = time.time()
33 cmd_line = "neutron quota-update --subnet -1 --network -1 --port -1"
34 self.__logger.info("Setting subnet/net quota to unlimited : %s"
36 cmd = os.popen(cmd_line)
38 self.__logger.debug(output)
41 # https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115
42 cmd_line = "nova quota-class-update --instances -1 default"
43 self.__logger.info("Setting instances quota to unlimited : %s"
45 cmd = os.popen(cmd_line)
47 self.__logger.debug(output)
49 with open(COMMON_CONFIG.config_file) as f:
50 config_yaml = yaml.safe_load(f)
52 testcases = config_yaml.get("testcases")
53 overall_status = "PASS"
55 if testcases[tc]['enabled']:
57 test_descr = testcases[tc]['description']
58 title = ("Running '%s - %s'" %
59 (test_name, test_descr))
60 self.__logger.info(title)
61 self.__logger.info("%s\n" % ("=" * len(title)))
62 t = importlib.import_module(test_name, package=None)
65 except Exception as ex:
67 self.__logger.info("Caught Exception in %s: %s Trace: %s"
69 traceback.format_exc()))
72 overall_status = "FAIL"
73 self.__logger.info("Testcase %s failed" % test_name)
75 status = result.get("status")
77 {test_name: {'status': status,
78 'details': result.get("details")}})
79 self.__logger.info("Results of test case '%s - %s':\n%s\n"
80 % (test_name, test_descr, result))
83 overall_status = "FAIL"
85 self.stop_time = time.time()
88 installer_type = str(os.environ['INSTALLER_TYPE'].lower())
89 if installer_type in ["fuel", "apex"]:
90 gather_logs('overall')
92 self.__logger.info("Skipping log gathering because installer"
93 "type %s is neither fuel nor apex" %
95 except Exception as ex:
96 self.__logger.error(('Something went wrong in the Log gathering.'
98 % (ex, traceback.format_exc()))
100 if overall_status == "PASS":
102 return testcase.TestCase.EX_OK
104 return testcase.TestCase.EX_RUN_ERROR
107 if __name__ == '__main__':
108 logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s'
109 '- %(levelname)s - %(message)s')
110 SDNVPN = SdnvpnFunctest()
111 sys.exit(SDNVPN.run())