From 29547a92197f88a732420761ee72d92dcc4b9972 Mon Sep 17 00:00:00 2001 From: grakiss Date: Fri, 17 Nov 2017 06:34:15 +0000 Subject: [cvp-web] Bugfix:return 500 when upload a tarball file with no results.json JIRA: DOVETAIL-558 The Web portal will return 500 code when upload a tarball file with no results.json When all test cases failed or report with wrong DB url, there may be no results.json. Check this and alert users instead of returning 500 status code. Change-Id: Ie13d9c3c62044c525f5dbb3fca9b6123d0b5acce Signed-off-by: grakiss --- cvp/opnfv_testapi/resources/result_handlers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cvp/opnfv_testapi') diff --git a/cvp/opnfv_testapi/resources/result_handlers.py b/cvp/opnfv_testapi/resources/result_handlers.py index 8cb9a347..2e65ba44 100644 --- a/cvp/opnfv_testapi/resources/result_handlers.py +++ b/cvp/opnfv_testapi/resources/result_handlers.py @@ -248,7 +248,12 @@ class ResultsUploadHandler(ResultsCLHandler): fileinfo = self.request.files['file'][0] tar_in = tarfile.open(fileobj=io.BytesIO(fileinfo['body']), mode="r:gz") - results = tar_in.extractfile('results/results.json').read() + try: + results = tar_in.extractfile('results/results.json').read() + except KeyError: + msg = 'Uploaded results must contain at least one passing test.' + self.finish_request({'code': 403, 'msg': msg}) + return results = results.split('\n') result_ids = [] for result in results: -- cgit 1.2.3-korg