X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Ftest%2Freporting%2Ffunctest%2Freporting-tempest.py;h=0304298b432a955f13354dda65f2dce923b65ad9;hb=e8d521f3fcfd0f6e4b982dc82049adcd86865a13;hp=5d6bcc06262e33de8f8a76c21ca05609a259c5ea;hpb=4b7eec61896662e456bc185852c0fdcf961e04c8;p=releng.git diff --git a/utils/test/reporting/functest/reporting-tempest.py b/utils/test/reporting/functest/reporting-tempest.py index 5d6bcc062..0304298b4 100755 --- a/utils/test/reporting/functest/reporting-tempest.py +++ b/utils/test/reporting/functest/reporting-tempest.py @@ -1,4 +1,15 @@ +#!/usr/bin/env python + +# Copyright (c) 2017 Orange and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +# SPDX-license-identifier: Apache-2.0 + from urllib2 import Request, urlopen, URLError +from datetime import datetime import json import jinja2 import os @@ -44,7 +55,7 @@ for version in rp_utils.get_config('general.versions'): response = urlopen(request) k = response.read() results = json.loads(k) - except URLError, e: + except URLError as e: logger.error("Error code: %s" % e) test_results = results['results'] @@ -73,9 +84,9 @@ for version in rp_utils.get_config('general.versions'): nb_tests_run = result['details']['tests'] nb_tests_failed = result['details']['failures'] if nb_tests_run != 0: - success_rate = 100*((int(nb_tests_run) - - int(nb_tests_failed)) / - int(nb_tests_run)) + success_rate = 100 * ((int(nb_tests_run) - + int(nb_tests_failed)) / + int(nb_tests_run)) else: success_rate = 0 @@ -97,7 +108,13 @@ for version in rp_utils.get_config('general.versions'): crit_rate = True # Expect that the suite duration is inferior to 30m - if result['details']['duration'] < criteria_duration: + stop_date = datetime.strptime(result['stop_date'], + '%Y-%m-%d %H:%M:%S') + start_date = datetime.strptime(result['start_date'], + '%Y-%m-%d %H:%M:%S') + + delta = stop_date - start_date + if (delta.total_seconds() < criteria_duration): crit_time = True result['criteria'] = {'tests': crit_tests,