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