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
14 import reporting.utils.scenarioResult as sr
15 import reporting.utils.reporting_utils as rp_utils
16 from scenarios import config as cf
18 installers = rp_utils.get_config('general.installers')
19 versions = rp_utils.get_config('general.versions')
20 PERIOD = rp_utils.get_config('general.period')
23 logger = rp_utils.getLogger("Yardstick-Status")
24 reportingDate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
26 logger.info("*******************************************")
27 logger.info("* Generating reporting scenario status *")
28 logger.info("* Data retention = %s days *" % PERIOD)
30 logger.info("*******************************************")
33 # For all the versions
34 for version in versions:
35 # For all the installers
36 for installer in installers:
37 # get scenarios results data
38 scenario_results = rp_utils.getScenarioStatus(installer, version)
39 if 'colorado' == version:
40 stable_result = rp_utils.getScenarioStatus(installer,
42 for k, v in stable_result.items():
43 if k not in scenario_results.keys():
44 scenario_results[k] = []
45 scenario_results[k] += stable_result[k]
46 scenario_result_criteria = {}
48 for s in scenario_results.keys():
49 if installer in cf.keys() and s in cf[installer].keys():
50 scenario_results.pop(s)
52 # From each scenarios get results list
53 for s, s_result in scenario_results.items():
54 logger.info("---------------------------------")
55 logger.info("installer %s, version %s, scenario %s", installer,
58 ten_criteria = len(s_result)
63 LASTEST_TESTS = rp_utils.get_config(
64 'general.nb_iteration_tests_success_criteria')
65 four_result = s_result[:LASTEST_TESTS]
66 four_criteria = len(four_result)
71 s_status = str(rp_utils.get_percent(four_result, s_result))
72 s_four_score = str(four_score) + '/' + str(four_criteria)
73 s_ten_score = str(ten_score) + '/' + str(ten_criteria)
74 s_score_percent = rp_utils.get_percent(four_result, s_result)
77 logger.info(">>>>> scenario OK, save the information")
79 logger.info(">>>> scenario not OK, last 4 iterations = %s, \
80 last 10 days = %s" % (s_four_score, s_ten_score))
82 # Save daily results in a file
83 path_validation_file = ("./display/" + version +
84 "/yardstick/scenario_history.txt")
86 if not os.path.exists(path_validation_file):
87 with open(path_validation_file, 'w') as f:
88 info = 'date,scenario,installer,details,score\n'
91 with open(path_validation_file, "a") as f:
92 info = (reportingDate + "," + s + "," + installer +
93 "," + s_ten_score + "," +
94 str(s_score_percent) + "\n")
97 scenario_result_criteria[s] = sr.ScenarioResult(s_status,
102 logger.info("--------------------------")
104 templateLoader = jinja2.FileSystemLoader(".")
105 templateEnv = jinja2.Environment(loader=templateLoader,
108 TEMPLATE_FILE = "./reporting/yardstick/template/index-status-tmpl.html"
109 template = templateEnv.get_template(TEMPLATE_FILE)
111 outputText = template.render(scenario_results=scenario_result_criteria,
117 with open("./display/" + version +
118 "/yardstick/status-" + installer + ".html", "wb") as fh: