diff options
author | Moshe <moshehoa@amdocs.com> | 2019-01-29 08:33:17 +0200 |
---|---|---|
committer | Moshe <moshehoa@amdocs.com> | 2019-01-29 08:33:56 +0200 |
commit | 50102ad9b8545ec7b3258025b0f6c0ef6cd0d223 (patch) | |
tree | b2d0e110b7ddbf6fe90b16db8ed1b02cbc029540 /vnftest/core/task.py | |
parent | 05837c6b540be12f8786edd8edc3a19c51466865 (diff) |
refactor error handling
Issue-ID: VNFSDK-350
Change-Id: I1486907e291539e3e59c5be03cc0955159613f84
Signed-off-by: Moshe <moshehoa@amdocs.com>
Diffstat (limited to 'vnftest/core/task.py')
-rw-r--r-- | vnftest/core/task.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/vnftest/core/task.py b/vnftest/core/task.py index 724f153..d464d12 100644 --- a/vnftest/core/task.py +++ b/vnftest/core/task.py @@ -272,6 +272,9 @@ class Task(object): # pragma: no cover runner = runner_item[1] self.finalize_step(step, runner, result) return result + except Exception as e: + LOG.error("Case fatal error", e) + self.task_info.testcase_fatal(case_name) finally: self.task_info.testcase_end(case_name) @@ -491,7 +494,7 @@ class TaskInfo(object): if self.info_dict['criteria'] == 'N/A': criteria = 'PASS' for testcase in self.info_dict['testcases']: - if testcase['criteria'] == 'FAIL': + if testcase['criteria'] == 'FAIL' or testcase['criteria'] == 'FATAL': criteria = 'FAIL' break self.info_dict['criteria'] = criteria @@ -501,6 +504,11 @@ class TaskInfo(object): self.info_dict['criteria'] = 'FATAL' self.info_dict['status'] = 'FINISHED' + def testcase_fatal(self, testcase_name): + testcase_dict = self.helper_test_cases_dict[testcase_name] + testcase_dict['criteria'] = 'FATAL' + testcase_dict['status'] = 'FINISHED' + def testcase_start(self, testcase_name): testcase_dict = {'name': testcase_name, 'criteria': 'N/A', 'status': 'IN_PROGRESS', 'steps': []} self.test_cases_list.append(testcase_dict) @@ -508,13 +516,14 @@ class TaskInfo(object): def testcase_end(self, testcase_name): testcase_dict = self.helper_test_cases_dict[testcase_name] - criteria = 'PASS' - for step in testcase_dict['steps']: - if step['criteria'] == 'FAIL': - criteria = 'FAIL' - break - testcase_dict['criteria'] = criteria - testcase_dict['status'] = 'FINISHED' + if testcase_dict['criteria'] == 'N/A': + criteria = 'PASS' + for step in testcase_dict['steps']: + if step['criteria'] == 'FAIL': + criteria = 'FAIL' + break + testcase_dict['criteria'] = criteria + testcase_dict['status'] = 'FINISHED' def step_add(self, testcase_name, step_name): step_dict = {'name': step_name, 'criteria': 'N/A', 'status': 'NOT_STARTED', 'results': []} |