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 utils.reporting_utils as rp_utils
16 import utils.scenarioResult as sr
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("Storperf-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("*******************************************")
32 # retrieve the list of storperf tests
33 storperf_tests = rp_utils.get_config('storperf.test_list')
34 logger.info("Storperf tests: %s" % storperf_tests)
36 # For all the versions
37 for version in versions:
38 # For all the installers
39 for installer in installers:
40 # get scenarios results data
41 # for the moment we consider only 1 case snia_steady_state
42 scenario_results = rp_utils.getScenarios("snia_steady_state",
45 # logger.info("scenario_results: %s" % scenario_results)
47 scenario_stats = rp_utils.getScenarioStats(scenario_results)
48 logger.info("scenario_stats: %s" % scenario_stats)
50 scenario_result_criteria = {}
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,
57 ten_criteria = len(s_result)
61 if "PASS" in v['criteria']:
64 logger.info("ten_score: %s / %s" % (ten_score, ten_criteria))
68 LASTEST_TESTS = rp_utils.get_config(
69 'general.nb_iteration_tests_success_criteria')
70 s_result.sort(key=lambda x: x['start_date'])
71 four_result = s_result[-LASTEST_TESTS:]
72 logger.debug("four_result: {}".format(four_result))
73 logger.debug("LASTEST_TESTS: {}".format(LASTEST_TESTS))
74 # logger.debug("four_result: {}".format(four_result))
75 four_criteria = len(four_result)
77 if "PASS" in v['criteria']:
79 logger.info("4 Score: %s / %s " % (four_score,
82 logger.error("Impossible to retrieve the four_score")
85 s_status = (four_score * 100) / four_criteria
88 logger.info("Score percent = %s" % str(s_status))
89 s_four_score = str(four_score) + '/' + str(four_criteria)
90 s_ten_score = str(ten_score) + '/' + str(ten_criteria)
91 s_score_percent = str(s_status)
93 logger.debug(" s_status: {}".format(s_status))
95 logger.info(">>>>> scenario OK, save the information")
97 logger.info(">>>> scenario not OK, last 4 iterations = %s, \
98 last 10 days = %s" % (s_four_score, s_ten_score))
101 if len(s_result) > 0:
102 build_tag = s_result[len(s_result)-1]['build_tag']
103 logger.debug("Build tag: %s" % build_tag)
104 s_url = s_url = rp_utils.getJenkinsUrl(build_tag)
105 logger.info("last jenkins url: %s" % s_url)
107 # Save daily results in a file
108 path_validation_file = ("./display/" + version +
109 "/storperf/scenario_history.txt")
111 if not os.path.exists(path_validation_file):
112 with open(path_validation_file, 'w') as f:
113 info = 'date,scenario,installer,details,score\n'
116 with open(path_validation_file, "a") as f:
117 info = (reportingDate + "," + s + "," + installer +
118 "," + s_ten_score + "," +
119 str(s_score_percent) + "\n")
122 scenario_result_criteria[s] = sr.ScenarioResult(s_status,
128 logger.info("--------------------------")
130 templateLoader = jinja2.FileSystemLoader(".")
131 templateEnv = jinja2.Environment(loader=templateLoader,
134 TEMPLATE_FILE = "./storperf/template/index-status-tmpl.html"
135 template = templateEnv.get_template(TEMPLATE_FILE)
137 outputText = template.render(scenario_results=scenario_result_criteria,
143 with open("./display/" + version +
144 "/storperf/status-" + installer + ".html", "wb") as fh: