diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-11-22 15:55:30 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-11-25 17:51:06 +0800 |
commit | 96aef41089d2c62913320028dd9618197d0e75c5 (patch) | |
tree | 9a7c1b03340108e08d494d3c7e34fe678f2b31b2 /functest/opnfv_tests/vnf/vRNC | |
parent | e2de95f657cdeabd5c6aa4decaaee39e69f0ca32 (diff) |
Adapt Parser test case to the new template
JIRA: FUNCTEST-565
Change-Id: If702831438fac97c28a1a35b1a91b81feb8397bd
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'functest/opnfv_tests/vnf/vRNC')
-rw-r--r-- | functest/opnfv_tests/vnf/vRNC/__init__.py | 0 | ||||
-rwxr-xr-x | functest/opnfv_tests/vnf/vRNC/parser.py | 87 |
2 files changed, 47 insertions, 40 deletions
diff --git a/functest/opnfv_tests/vnf/vRNC/__init__.py b/functest/opnfv_tests/vnf/vRNC/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/functest/opnfv_tests/vnf/vRNC/__init__.py diff --git a/functest/opnfv_tests/vnf/vRNC/parser.py b/functest/opnfv_tests/vnf/vRNC/parser.py index 33d4d50c..c8d82bf7 100755 --- a/functest/opnfv_tests/vnf/vRNC/parser.py +++ b/functest/opnfv_tests/vnf/vRNC/parser.py @@ -14,57 +14,64 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import argparse +import sys import time -import functest.utils.functest_logger as ft_logger -import functest.utils.functest_utils as functest_utils -import functest.utils.functest_constants as ft_constants +import argparse -parser = argparse.ArgumentParser() -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") -args = parser.parse_args() +import functest.core.TestCasesBase as base +import functest.utils.functest_logger as ft_logger +import functest.utils.functest_utils as ft_utils -PARSER_REPO = ft_constants.PARSER_REPO -RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR -logger = ft_logger.Logger("parser").getLogger() +class Parser(base.TestCasesBase): + def __init__(self): + super(Parser, self).__init__() + self.project_name = "parser" + self.case_name = "parser-basics" + self.parser_repo = self.get_conf('general.directories.dir_repo_parser') + self.results_dir = self.get_conf('general.directories.dir_results') + self.logger = ft_logger.Logger("parser").getLogger() + self.log_file = self.results_dir + '/parser.log' + def run(self, **kwargs): + cmd = 'cd %s/tests && ./functest_run.sh' % self.parser_repo -def main(): - project = 'parser' - case_name = 'parser-basics' - cmd = 'cd %s/tests && ./functest_run.sh' % PARSER_REPO + self.start_time = time.time() + ret = ft_utils.execute_command(cmd, + info=True, + output_file=self.log_file) + self.stop_time = time.time() - start_time = time.time() - log_file = RESULTS_DIR + "/parser.log" - ret = functest_utils.execute_command(cmd, - info=True, - output_file=log_file) - stop_time = time.time() + self.criteria, details = ft_utils.check_test_result(self.project_name, + ret, + self.start_time, + self.stop_time) - status, details = functest_utils.check_test_result(project, - ret, - start_time, - stop_time) + ft_utils.logger_test_results(self.project_name, + self.case_name, + self.criteria, + details) - functest_utils.logger_test_results(project, - case_name, - status, - details) + return ret - if args.report: - logger.debug("Report Parser Results to DB......") - functest_utils.push_results_to_db(project, - case_name, - start_time, - stop_time, - status, - details) - exit(ret) + @staticmethod + def get_conf(parameter): + return ft_utils.get_functest_config(parameter) if __name__ == '__main__': - main() + args_parser = argparse.ArgumentParser() + args_parser.add_argument("-r", "--report", + help="Create json result file", + action="store_true") + args = vars(args_parser.parse_args()) + parser = Parser() + try: + result = parser.run(**args) + if result != base.TestCasesBase.EX_OK: + sys.exit(result) + if args['report']: + sys.exit(parser.push_to_db()) + except Exception: + sys.exit(base.TestCasesBase.EX_RUN_ERROR) |