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
13 import reportingUtils as utils
14 import reportingConf as conf
15 import scenarioResult as sr
16 from scenarios import config as cf
19 logger = utils.getLogger("Yardstick-Status")
20 reportingDate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
22 logger.info("*******************************************")
23 logger.info("* Generating reporting scenario status *")
24 logger.info("* Data retention = %s days *" % conf.PERIOD)
26 logger.info("*******************************************")
29 # For all the versions
30 for version in conf.versions:
31 # For all the installers
32 for installer in conf.installers:
33 # get scenarios results data
34 scenario_results = utils.getScenarioStatus(installer, version)
35 if 'colorado' == version:
36 stable_result = utils.getScenarioStatus(installer,
38 for k, v in stable_result.items():
39 if k not in scenario_results.keys():
40 scenario_results[k] = []
41 scenario_results[k] += stable_result[k]
42 scenario_result_criteria = {}
44 for s in scenario_results.keys():
45 if installer in cf.keys() and s in cf[installer].keys():
46 scenario_results.pop(s)
48 # From each scenarios get results list
49 for s, s_result in scenario_results.items():
50 logger.info("---------------------------------")
51 logger.info("installer %s, version %s, scenario %s:" % (installer,
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_percent(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 s_score_percent = utils.get_percent(four_result, s_result)
71 logger.info(">>>>> scenario OK, save the information")
73 logger.info(">>>> scenario not OK, last 4 iterations = %s, \
74 last 10 days = %s" % (s_four_score, s_ten_score))
76 # Save daily results in a file
77 path_validation_file = (conf.REPORTING_PATH +
78 "/release/" + version +
79 "/scenario_history.txt")
81 if not os.path.exists(path_validation_file):
82 with open(path_validation_file, 'w') as f:
83 info = 'date,scenario,installer,details,score\n'
86 with open(path_validation_file, "a") as f:
87 info = (reportingDate + "," + s + "," + installer +
88 "," + s_ten_score + "," +
89 str(s_score_percent) + "\n")
92 scenario_result_criteria[s] = sr.ScenarioResult(s_status,
97 logger.info("--------------------------")
99 templateLoader = jinja2.FileSystemLoader(conf.REPORTING_PATH)
100 templateEnv = jinja2.Environment(loader=templateLoader, autoescape=True)
102 TEMPLATE_FILE = "/template/index-status-tmpl.html"
103 template = templateEnv.get_template(TEMPLATE_FILE)
105 outputText = template.render(scenario_results=scenario_result_criteria,
111 with open(conf.REPORTING_PATH + "/release/" + version +
112 "/index-status-" + installer + ".html", "wb") as fh: