aboutsummaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-07-31 22:15:44 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2016-07-31 22:15:44 +0200
commitbb3419f192cafe4090753e5568f1e14071069dd2 (patch)
tree89710d1cc142027f0ce3caca38b9674a14d55dad /ci
parent86ff7d4f2fbe563f4b6ca781909c7c9d8681f39a (diff)
Wrap call to the rest api with try-except while generating report
When the Rest api is not available for some reason (see associated JIRA), the script fails and it gives also a false output to Jenkins. JIRA: FUNCTEST-399 Change-Id: I81622a2e22661889afcf49526c2421af257920a4 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'ci')
-rw-r--r--ci/generate_report.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/ci/generate_report.py b/ci/generate_report.py
index 53aef0c9e..3ca2847bd 100644
--- a/ci/generate_report.py
+++ b/ci/generate_report.py
@@ -35,8 +35,12 @@ def get_results_from_db():
url = 'http://testresults.opnfv.org/test/api/v1/results?build_tag=' + \
BUILD_TAG
logger.debug("Query to rest api: %s" % url)
- data = json.load(urllib2.urlopen(url))
- return data['results']
+ try:
+ data = json.load(urllib2.urlopen(url))
+ return data['results']
+ except:
+ logger.error("Cannot read content from the url: %s" % url)
+ return None
def get_data(test, results):
@@ -90,10 +94,11 @@ def main(args):
if IS_CI_RUN:
results = get_results_from_db()
- for test in executed_test_cases:
- data = get_data(test, results)
- test.update({"url": data['url'],
- "result": data['result']})
+ if results is not None:
+ for test in executed_test_cases:
+ data = get_data(test, results)
+ test.update({"url": data['url'],
+ "result": data['result']})
TOTAL_LEN = COL_1_LEN + COL_2_LEN + COL_3_LEN + COL_4_LEN
if IS_CI_RUN: