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 from functest.core import feature as base
19 from sdnvpn.lib import config as sdnvpn_config
20 from sdnvpn.lib.gather_logs import gather_logs
22 COMMON_CONFIG = sdnvpn_config.CommonConfig()
25 class SdnvpnFunctest(base.Feature):
27 __logger = logging.getLogger(__name__)
31 cmd_line = "neutron quota-update --subnet -1 --network -1 --port -1"
32 self.__logger.info("Setting subnet/net quota to unlimited : %s"
34 cmd = os.popen(cmd_line)
36 self.__logger.debug(output)
39 # https://jira.opnfv.org/projects/SDNVPN/issues/SDNVPN-115
40 cmd_line = "nova quota-class-update --instances -1 default"
41 self.__logger.info("Setting instances quota to unlimited : %s"
43 cmd = os.popen(cmd_line)
45 self.__logger.debug(output)
47 with open(COMMON_CONFIG.config_file) as f:
48 config_yaml = yaml.safe_load(f)
50 testcases = config_yaml.get("testcases")
51 overall_status = "PASS"
53 if testcases[tc]['enabled']:
55 test_descr = testcases[tc]['description']
56 title = ("Running '%s - %s'" %
57 (test_name, test_descr))
58 self.__logger.info(title)
59 self.__logger.info("%s\n" % ("=" * len(title)))
60 t = importlib.import_module(test_name, package=None)
63 except Exception as ex:
65 self.__logger.info("Caught Exception in %s: %s Trace: %s"
67 traceback.format_exc()))
70 overall_status = "FAIL"
71 self.__logger.info("Testcase %s failed" % test_name)
73 status = result.get("status")
75 {test_name: {'status': status,
76 'details': result.get("details")}})
77 self.__logger.info("Results of test case '%s - %s':\n%s\n"
78 % (test_name, test_descr, result))
81 overall_status = "FAIL"
84 installer_type = str(os.environ['INSTALLER_TYPE'].lower())
85 if installer_type in ["fuel", "apex"]:
86 gather_logs('overall')
88 self.__logger.info("Skipping log gathering because installer"
89 "type %s is neither fuel nor apex" %
91 except Exception as ex:
92 self.__logger.error(('Something went wrong in the Log gathering.'
94 % (ex, traceback.format_exc()))
96 if overall_status == "PASS":
98 return base.Feature.EX_OK
100 return base.Feature.EX_RUN_ERROR
103 if __name__ == '__main__':
104 logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s'
105 '- %(levelname)s - %(message)s')
106 SDNVPN = SdnvpnFunctest()
107 sys.exit(SDNVPN.execute())