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.reporting_utils as rp_utils
15 import reporting.utils.scenarioResult as sr
17 installers = rp_utils.get_config('general.installers')
18 PERIOD = rp_utils.get_config('general.period')
21 logger = rp_utils.getLogger("Storperf-Status")
22 reportingDate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
24 logger.info("*******************************************")
25 logger.info("* Generating reporting scenario status *")
26 logger.info("* Data retention = %s days *" % PERIOD)
28 logger.info("*******************************************")
30 # retrieve the list of storperf tests
33 # For all the versions
34 for version in versions:
35 # For all the installers
36 for installer in installers:
37 scenario_results = rp_utils.getScenarios("vsperf",
42 scenario_result_criteria = {}
43 logger.info("installer %s, version %s, scenario ", installer, version)
45 # From each scenarios get results list
46 for s, s_result in scenario_results.items():
47 logger.info("---------------------------------")
48 logger.info("installer %s, version %s, scenario %s", installer,
50 ten_criteria = len(s_result)
54 if "PASS" in v['criteria']:
57 logger.info("ten_score: %s / %s" % (ten_score, ten_criteria))
61 LASTEST_TESTS = rp_utils.get_config(
62 'general.nb_iteration_tests_success_criteria')
63 s_result.sort(key=lambda x: x['start_date'])
64 four_result = s_result[-LASTEST_TESTS:]
65 logger.debug("four_result: {}".format(four_result))
66 logger.debug("LASTEST_TESTS: {}".format(LASTEST_TESTS))
67 # logger.debug("four_result: {}".format(four_result))
68 four_criteria = len(four_result)
70 if "PASS" in v['criteria']:
72 logger.info("4 Score: %s / %s " % (four_score,
75 logger.error("Impossible to retrieve the four_score")
78 s_status = (four_score * 100) / four_criteria
79 except ZeroDivisionError:
81 logger.info("Score percent = %s" % str(s_status))
82 s_four_score = str(four_score) + '/' + str(four_criteria)
83 s_ten_score = str(ten_score) + '/' + str(ten_criteria)
84 s_score_percent = str(s_status)
86 logger.debug(" s_status: {}".format(s_status))
88 logger.info(">>>>> scenario OK, save the information")
90 logger.info(">>>> scenario not OK, last 4 iterations = %s, \
91 last 10 days = %s" % (s_four_score, s_ten_score))
95 build_tag = s_result[len(s_result)-1]['build_tag']
96 logger.debug("Build tag: %s" % build_tag)
97 s_url = s_url = rp_utils.getJenkinsUrl(build_tag)
98 logger.info("last jenkins url: %s" % s_url)
100 # Save daily results in a file
101 path_validation_file = ("./display/" + version +
102 "/vsperf/scenario_history.txt")
104 if not os.path.exists(path_validation_file):
105 with open(path_validation_file, 'w') as f:
106 info = 'date,scenario,installer,details,score\n'
109 with open(path_validation_file, "a") as f:
110 info = (reportingDate + "," + s + "," + installer +
111 "," + s_ten_score + "," +
112 str(s_score_percent) + "\n")
115 scenario_result_criteria[s] = sr.ScenarioResult(s_status,
121 logger.info("--------------------------")
123 templateLoader = jinja2.FileSystemLoader(".")
124 templateEnv = jinja2.Environment(loader=templateLoader,
127 TEMPLATE_FILE = "./reporting/vsperf/template/index-status-tmpl.html"
128 template = templateEnv.get_template(TEMPLATE_FILE)
130 outputText = template.render(scenario_results=scenario_result_criteria,
136 with open("./display/" + version +
137 "/vsperf/status-" + installer + ".html", "wb") as fh: