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))
66 LASTEST_TESTS = rp_utils.get_config(
67 'general.nb_iteration_tests_success_criteria')
68 four_result = s_result[:LASTEST_TESTS]
69 four_criteria = len(four_result)
72 if "PASS" in v['criteria']:
74 logger.info("four_score: %s / %s " % (four_score, four_criteria))
77 s_status = (four_score * 100) / four_criteria
80 logger.info("Score percent = %s" % str(s_status))
81 s_four_score = str(four_score) + '/' + str(four_criteria)
82 s_ten_score = str(ten_score) + '/' + str(ten_criteria)
83 s_score_percent = str(s_status)
86 logger.info(">>>>> scenario OK, save the information")
88 logger.info(">>>> scenario not OK, last 4 iterations = %s, \
89 last 10 days = %s" % (s_four_score, s_ten_score))
91 # Save daily results in a file
92 path_validation_file = ("./display/" + version +
93 "/storperf/scenario_history.txt")
95 if not os.path.exists(path_validation_file):
96 with open(path_validation_file, 'w') as f:
97 info = 'date,scenario,installer,details,score\n'
100 with open(path_validation_file, "a") as f:
101 info = (reportingDate + "," + s + "," + installer +
102 "," + s_ten_score + "," +
103 str(s_score_percent) + "\n")
106 scenario_result_criteria[s] = sr.ScenarioResult(s_status,
111 logger.info("--------------------------")
113 templateLoader = jinja2.FileSystemLoader(".")
114 templateEnv = jinja2.Environment(loader=templateLoader,
117 TEMPLATE_FILE = "./storperf/template/index-status-tmpl.html"
118 template = templateEnv.get_template(TEMPLATE_FILE)
120 outputText = template.render(scenario_results=scenario_result_criteria,
126 with open("./display/" + version +
127 "/storperf/status-" + installer + ".html", "wb") as fh: