From f53fc8221faf7718d1cf060038ad3a23463b8398 Mon Sep 17 00:00:00 2001 From: rexlee8776 Date: Sat, 27 Aug 2016 06:26:46 +0000 Subject: Add the function of yardstick testcase reporter JIRA: YARDSTICK-324 Change-Id: I58969265f88d5c20f46f0b1097f5b0ccb1d9a40d Signed-off-by: rexlee8776 --- utils/test/reporting/yardstick/reporting-status.py | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 utils/test/reporting/yardstick/reporting-status.py (limited to 'utils/test/reporting/yardstick/reporting-status.py') diff --git a/utils/test/reporting/yardstick/reporting-status.py b/utils/test/reporting/yardstick/reporting-status.py new file mode 100644 index 000000000..ed5dab044 --- /dev/null +++ b/utils/test/reporting/yardstick/reporting-status.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# +# 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 +# +import datetime +import jinja2 +import requests +import sys +import time +import yaml + +import reportingUtils as utils +import reportingConf as conf +import scenarioResult as sr + +# Logger +logger = utils.getLogger("Yardstick-Status") + +logger.info("*******************************************") +logger.info("* Generating reporting scenario status *") +logger.info("* Data retention = %s days *" % conf.PERIOD) +logger.info("* *") +logger.info("*******************************************") + +# For all the versions +for version in conf.versions: + # For all the installers + for installer in conf.installers: + # get scenarios results data + scenario_results = utils.getScenarioStatus(installer, version) + scenario_result_criteria = {} + + # From each scenarios get results list + for s, s_result in scenario_results.items(): + logger.info("---------------------------------") + logger.info("installer %s, version %s, scenario %s:" % (installer, version, s)) + + s_status = 'KO' + scenario_criteria = len(s_result) + scenario_score = 0 + + for v in s_result: + if v['details'] == 'SUCCESS': + scenario_score += 1 + + if scenario_score == scenario_criteria: + s_status = 'OK' + logger.info(">>>>> scenario OK, save the information") + else: + logger.info(">>>> scenario not OK, score = %s/%s" % (scenario_score, scenario_criteria)) + + s_score = str(scenario_score) + '/' + str(scenario_criteria) + scenario_result_criteria[s] = sr.ScenarioResult(s_status, s_score) + + logger.info("--------------------------") + + templateLoader = jinja2.FileSystemLoader(conf.REPORTING_PATH) + templateEnv = jinja2.Environment(loader=templateLoader) + + TEMPLATE_FILE = "/template/index-status-tmpl.html" + template = templateEnv.get_template(TEMPLATE_FILE) + + outputText = template.render(scenario_results=scenario_result_criteria, + installer=installer, + period=conf.PERIOD, + version=version) + + with open(conf.REPORTING_PATH + "/release/" + version + + "/index-status-" + installer + ".html", "wb") as fh: + fh.write(outputText) -- cgit 1.2.3-korg