summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-03-04 22:30:34 -0500
committerGeorg Kunz <georg.kunz@ericsson.com>2018-03-06 10:28:38 +0000
commited4e729d8e61b8bbfad51f294dd170c6c680dc43 (patch)
tree4127f8ff6ea33004f3327dbf0cd054aab9704a4d
parentead4a2bee15cf8c5891497c23592f8fa4fc2dc91 (diff)
Bugfix: it crashes when check_tc_result returns None
The function 'check_tc_result' may return 'None'. In this case it will throw an exception because of https://github.com/opnfv/dovetail/blob/master/dovetail/run.py#L65 The exception is like Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/dovetail/run.py", line 339, in <module> main() File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in _call_ return self.main(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main rv = self.invoke(ctx) File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/dovetail/run.py", line 304, in main duration = run_test(testsuite_yaml, testarea, logger, kwargs) File "/usr/local/lib/python2.7/dist-packages/dovetail/run.py", line 65, in run_test if stop_on_fail['criteria'] == "FAIL" and kwargs['stop']: TypeError: 'NoneType' object has no attribute '_getitem_' JIRA: DOVETAIL-622 Change-Id: I9e612b380c3dfb148692074a3bf8eb31875213ac Signed-off-by: xudan <xudan16@huawei.com>
-rwxr-xr-xdovetail/run.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/dovetail/run.py b/dovetail/run.py
index e43c126a..b2ba91d8 100755
--- a/dovetail/run.py
+++ b/dovetail/run.py
@@ -63,8 +63,12 @@ def run_test(testsuite, testarea, logger, kwargs):
testcase.run()
stop_on_fail = check_tc_result(testcase, logger)
- if stop_on_fail['criteria'] == "FAIL" and kwargs['stop']:
- return "stop_on_fail"
+ try:
+ if (not stop_on_fail or stop_on_fail['criteria'] == "FAIL") \
+ and kwargs['stop']:
+ return "stop_on_fail"
+ except KeyError as e:
+ logger.error("There is no key {}.".format(e))
end_time = time.time()
duration = end_time - start_time