From: chenjiankun Date: Mon, 31 Jul 2017 03:33:00 +0000 (+0000) Subject: Bugfix: yardstick always report 'PASS' to DB X-Git-Tag: opnfv-5.0.RC1~319^2 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F97%2F38397%2F1;p=yardstick.git Bugfix: yardstick always report 'PASS' to DB JIRA: YARDSTICK-768 Now yardstick will not stop if test case failed, so that we can run the rest test case in the suite. CI judge task status by the cmd return code. In this way, the 'yardstick task start' cmd will always return 0. So we will always report 'PASS' to DB. In this patch I add a judgement in cmd, if the status is not 'PASS', we will raise a RuntimeError. Change-Id: I655424dd9cd3782869986963a17b24acfb340345 Signed-off-by: chenjiankun --- diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index 03f6b1b1e..8d8ea2b3c 100644 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py @@ -51,11 +51,17 @@ class TaskCommands(object): # pragma: no cover self.output_file = param.output_file try: - Task().start(param, **kwargs) + result = Task().start(param, **kwargs) except Exception as e: self._write_error_data(e) LOG.exception("") + if result.get('result', {}).get('criteria') == 'PASS': + LOG.info('Task Success') + else: + LOG.info('Task Failed') + raise RuntimeError('Task Failed') + def _write_error_data(self, error): data = {'status': 2, 'result': str(error)} write_json_to_file(self.output_file, data)