From 19630581f1ac53918aa5cc15faca8b2f0d53c00e Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Mon, 19 Sep 2016 00:33:27 +0000 Subject: Change display way of reporting status, add last ten days score JIRA: YARDSTICK-350 Change-Id: Iea1d8a30cf3464c8b9a0b8b6ac2e0ce41adea00d Signed-off-by: chenjiankun --- utils/test/reporting/yardstick/reportingUtils.py | 48 ++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'utils/test/reporting/yardstick/reportingUtils.py') diff --git a/utils/test/reporting/yardstick/reportingUtils.py b/utils/test/reporting/yardstick/reportingUtils.py index 06bcd4926..71eb9196c 100644 --- a/utils/test/reporting/yardstick/reportingUtils.py +++ b/utils/test/reporting/yardstick/reportingUtils.py @@ -45,17 +45,59 @@ def getScenarioStatus(installer, version): print 'Got an error code:', e scenario_results = {} + result_dict = {} if test_results is not None: for r in test_results: - if r['stop_date'] != 'None': + if r['stop_date'] != 'None' and r['criteria'] is not None: if not r['scenario'] in scenario_results.keys(): scenario_results[r['scenario']] = [] scenario_results[r['scenario']].append(r) for k,v in scenario_results.items(): - scenario_results[k] = v[:conf.LASTEST_TESTS] + # scenario_results[k] = v[:conf.LASTEST_TESTS] + s_list = [] + for element in v: + if element['criteria'] == 'SUCCESS': + s_list.append(1) + else: + s_list.append(0) + result_dict[k] = s_list - return scenario_results + # return scenario_results + return result_dict + +def subfind(given_list, pattern_list): + for i in range(len(given_list)): + if given_list[i] == pattern_list[0] and given_list[i:i + conf.LASTEST_TESTS] == pattern_list: + return True + return False + +def get_percent(status): + + if status * 100 % 6: + return round(float(status) * 100 / 6, 1) + else: + return status * 100 / 6 + +def get_status(four_list, ten_list): + four_score = 0 + ten_score = 0 + + for v in four_list: + four_score += v + for v in ten_list: + ten_score += v + + if four_score == conf.LASTEST_TESTS: + status = 6 + elif subfind(ten_list, [1, 1, 1, 1]): + status = 5 + elif ten_score == 0: + status = 0 + else: + status = four_score + 1 + + return get_percent(status) def _test(): -- cgit 1.2.3-korg