3 # This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
16 import reportingUtils as utils
17 import reportingConf as conf
18 import scenarioResult as sr
19 from scenarios import config as cf
22 logger = utils.getLogger("Yardstick-Status")
24 logger.info("*******************************************")
25 logger.info("* Generating reporting scenario status *")
26 logger.info("* Data retention = %s days *" % conf.PERIOD)
28 logger.info("*******************************************")
31 # For all the versions
32 for version in conf.versions:
33 # For all the installers
34 for installer in conf.installers:
35 # get scenarios results data
36 scenario_results = utils.getScenarioStatus(installer, version)
37 if 'colorado' == version:
38 stable_result = utils.getScenarioStatus(installer, 'stable/colorado')
39 for k,v in stable_result.items():
40 if not scenario_results.has_key(k):
41 scenario_results[k] = []
42 scenario_results[k] += stable_result[k]
43 scenario_result_criteria = {}
45 for s in scenario_results.keys():
46 if cf.has_key(installer) and cf[installer].has_key(s):
47 scenario_results.pop(s)
49 # From each scenarios get results list
50 for s, s_result in scenario_results.items():
51 logger.info("---------------------------------")
52 logger.info("installer %s, version %s, scenario %s:" % (installer, version, s))
54 ten_criteria = len(s_result)
59 four_result = s_result[:conf.LASTEST_TESTS]
60 four_criteria = len(four_result)
65 s_status = str(utils.get_status(four_result, s_result))
66 s_four_score = str(four_score) + '/' + str(four_criteria)
67 s_ten_score = str(ten_score) + '/' + str(ten_criteria)
68 scenario_result_criteria[s] = sr.ScenarioResult(s_status, s_four_score, s_ten_score)
71 logger.info(">>>>> scenario OK, save the information")
73 logger.info(">>>> scenario not OK, last 4 iterations = %s, last 10 days = %s" % (s_four_score, s_ten_score))
74 logger.info("--------------------------")
76 templateLoader = jinja2.FileSystemLoader(conf.REPORTING_PATH)
77 templateEnv = jinja2.Environment(loader=templateLoader, autoescape=True)
79 TEMPLATE_FILE = "/template/index-status-tmpl.html"
80 template = templateEnv.get_template(TEMPLATE_FILE)
82 outputText = template.render(scenario_results=scenario_result_criteria,
87 with open(conf.REPORTING_PATH + "/release/" + version +
88 "/index-status-" + installer + ".html", "wb") as fh: