diff options
Diffstat (limited to 'utils/test/reporting')
3 files changed, 166 insertions, 118 deletions
diff --git a/utils/test/reporting/reporting/utils/reporting_utils.py b/utils/test/reporting/reporting/utils/reporting_utils.py index 235bd6ef9..6c0d5a23f 100644 --- a/utils/test/reporting/reporting/utils/reporting_utils.py +++ b/utils/test/reporting/reporting/utils/reporting_utils.py @@ -205,25 +205,34 @@ def getScenarioStatus(installer, version): except URLError: print "GetScenarioStatus: error when calling the API" - scenario_results = {} - result_dict = {} + x86 = 'x86' + aarch64 = 'aarch64' + scenario_results = {x86: {}, aarch64: {}} + result_dict = {x86: {}, aarch64: {}} if test_results is not None: for test_r in test_results: if (test_r['stop_date'] != 'None' and test_r['criteria'] is not None): - if not test_r['scenario'] in scenario_results.keys(): - scenario_results[test_r['scenario']] = [] - scenario_results[test_r['scenario']].append(test_r) - - for scen_k, scen_v in scenario_results.items(): - # scenario_results[k] = v[:LASTEST_TESTS] - s_list = [] - for element in scen_v: - if element['criteria'] == 'SUCCESS': - s_list.append(1) + scenario_name = test_r['scenario'] + if 'arm' in test_r['pod_name']: + if not test_r['scenario'] in scenario_results[aarch64]: + scenario_results[aarch64][scenario_name] = [] + scenario_results[aarch64][scenario_name].append(test_r) else: - s_list.append(0) - result_dict[scen_k] = s_list + if not test_r['scenario'] in scenario_results[x86]: + scenario_results[x86][scenario_name] = [] + scenario_results[x86][scenario_name].append(test_r) + + for key in scenario_results: + for scen_k, scen_v in scenario_results[key].items(): + # scenario_results[k] = v[:LASTEST_TESTS] + s_list = [] + for element in scen_v: + if element['criteria'] == 'SUCCESS': + s_list.append(1) + else: + s_list.append(0) + result_dict[key][scen_k] = s_list # return scenario_results return result_dict diff --git a/utils/test/reporting/reporting/yardstick/reporting-status.py b/utils/test/reporting/reporting/yardstick/reporting-status.py index 6584f4e8d..77e260412 100644 --- a/utils/test/reporting/reporting/yardstick/reporting-status.py +++ b/utils/test/reporting/reporting/yardstick/reporting-status.py @@ -11,109 +11,147 @@ import os import jinja2 -import reporting.utils.scenarioResult as sr -import reporting.utils.reporting_utils as rp_utils -from scenarios import config as cf +from reporting.utils.scenarioResult import ScenarioResult +from reporting.utils import reporting_utils as utils +from scenarios import config as blacklist -installers = rp_utils.get_config('general.installers') -versions = rp_utils.get_config('general.versions') -PERIOD = rp_utils.get_config('general.period') # Logger -logger = rp_utils.getLogger("Yardstick-Status") -reportingDate = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") - -logger.info("*******************************************") -logger.info("* Generating reporting scenario status *") -logger.info("* Data retention = %s days *" % PERIOD) -logger.info("* *") -logger.info("*******************************************") - - -# For all the versions -for version in versions: - # For all the installers - for installer in installers: - # get scenarios results data - scenario_results = rp_utils.getScenarioStatus(installer, version) - if 'colorado' == version: - stable_result = rp_utils.getScenarioStatus(installer, - 'stable/colorado') - for k, v in stable_result.items(): - if k not in scenario_results.keys(): - scenario_results[k] = [] - scenario_results[k] += stable_result[k] - scenario_result_criteria = {} - - for s in scenario_results.keys(): - if installer in cf.keys() and s in cf[installer].keys(): - scenario_results.pop(s) - - # From each scenarios get results list - for s, s_result in scenario_results.items(): - logger.info("---------------------------------") - logger.info("installer %s, version %s, scenario %s", installer, - version, s) - - ten_criteria = len(s_result) - ten_score = 0 - for v in s_result: - ten_score += v - - LASTEST_TESTS = rp_utils.get_config( - 'general.nb_iteration_tests_success_criteria') - four_result = s_result[:LASTEST_TESTS] - four_criteria = len(four_result) - four_score = 0 - for v in four_result: - four_score += v - - s_status = str(rp_utils.get_percent(four_result, s_result)) - s_four_score = str(four_score) + '/' + str(four_criteria) - s_ten_score = str(ten_score) + '/' + str(ten_criteria) - s_score_percent = rp_utils.get_percent(four_result, s_result) - - if '100' == s_status: - logger.info(">>>>> scenario OK, save the information") - else: - logger.info(">>>> scenario not OK, last 4 iterations = %s, \ - last 10 days = %s" % (s_four_score, s_ten_score)) - - # Save daily results in a file - path_validation_file = ("./display/" + version + - "/yardstick/scenario_history.txt") - - if not os.path.exists(path_validation_file): - with open(path_validation_file, 'w') as f: - info = 'date,scenario,installer,details,score\n' - f.write(info) - - with open(path_validation_file, "a") as f: - info = (reportingDate + "," + s + "," + installer + - "," + s_ten_score + "," + - str(s_score_percent) + "\n") - f.write(info) - - scenario_result_criteria[s] = sr.ScenarioResult(s_status, - s_four_score, - s_ten_score, - s_score_percent) - - logger.info("--------------------------") - - templateLoader = jinja2.FileSystemLoader(".") - templateEnv = jinja2.Environment(loader=templateLoader, - autoescape=True) - - TEMPLATE_FILE = "./reporting/yardstick/template/index-status-tmpl.html" - template = templateEnv.get_template(TEMPLATE_FILE) - - outputText = template.render(scenario_results=scenario_result_criteria, - installer=installer, - period=PERIOD, - version=version, - date=reportingDate) - - with open("./display/" + version + - "/yardstick/status-" + installer + ".html", "wb") as fh: - fh.write(outputText) +LOG = utils.getLogger("Yardstick-Status") + + +def get_scenario_data(version, installer): + scenarios = utils.getScenarioStatus(installer, version) + + if 'colorado' == version: + data = utils.getScenarioStatus(installer, 'stable/colorado') + for archi, value in data.items(): + for k, v in value.items(): + if k not in scenarios[archi]: + scenarios[archi][k] = [] + scenarios[archi][k].extend(data[archi][k]) + + for archi, value in scenarios.items(): + for scenario in value: + if installer in blacklist and scenario in blacklist[installer]: + scenarios[archi].pop(scenario) + + return scenarios + + +def write_history_data(version, scenario, installer, ten_score, percent): + # Save daily results in a file + history_file = './display/{}/yardstick/scenario_history.txt'.format( + version) + + if not os.path.exists(history_file): + with open(history_file, 'w') as f: + f.write('date,scenario,installer,details,score\n') + + date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") + with open(history_file, "a") as f: + info = '{},{},{},{},{}\n'.format(date, + scenario, + installer, + ten_score, + percent) + f.write(info) + + +def generate_page(scenario_data, installer, period, version, architecture): + date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") + + templateLoader = jinja2.FileSystemLoader(".") + template_env = jinja2.Environment(loader=templateLoader, + autoescape=True) + + template_file = "./reporting/yardstick/template/index-status-tmpl.html" + template = template_env.get_template(template_file) + + if installer == 'fuel': + installer = '{}@{}'.format(installer, architecture) + + output_text = template.render(scenario_results=scenario_data, + installer=installer, + period=period, + version=version, + date=date) + + page_file = './display/{}/yardstick/status-{}.html'.format(version, + installer) + with open(page_file, 'wb') as f: + f.write(output_text) + + +def do_statistic(data): + ten_score = 0 + for v in data: + ten_score += v + + last_count = utils.get_config( + 'general.nb_iteration_tests_success_criteria') + last_data = data[:last_count] + last_score = 0 + for v in last_data: + last_score += v + + percent = utils.get_percent(last_data, data) + status = str(percent) + last_score = '{}/{}'.format(last_score, len(last_data)) + ten_score = '{}/{}'.format(ten_score, len(data)) + + if '100' == status: + LOG.info(">>>>> scenario OK, save the information") + else: + LOG.info(">>>> scenario not OK, last 4 iterations = %s, \ + last 10 days = %s" % (last_score, ten_score)) + + return last_score, ten_score, percent, status + + +def generate_reporting_page(version, installer, archi, scenarios, period): + scenario_data = {} + + # From each scenarios get results list + for scenario, data in scenarios.items(): + LOG.info("---------------------------------") + + LOG.info("installer %s, version %s, scenario %s", + installer, + version, + scenario) + last_score, ten_score, percent, status = do_statistic(data) + write_history_data(version, scenario, installer, ten_score, percent) + scenario_data[scenario] = ScenarioResult(status, + last_score, + ten_score, + percent) + + LOG.info("--------------------------") + if scenario_data: + generate_page(scenario_data, installer, period, version, archi) + + +def main(): + installers = utils.get_config('general.installers') + versions = utils.get_config('general.versions') + period = utils.get_config('general.period') + + LOG.info("*******************************************") + LOG.info("* Generating reporting scenario status *") + LOG.info("* Data retention = %s days *" % period) + LOG.info("* *") + LOG.info("*******************************************") + + # For all the versions + for version in versions: + # For all the installers + for installer in installers: + # get scenarios results data + scenarios = get_scenario_data(version, installer) + for k, v in scenarios.items(): + generate_reporting_page(version, installer, k, v, period) + + +if __name__ == '__main__': + main() diff --git a/utils/test/reporting/reporting/yardstick/template/index-status-tmpl.html b/utils/test/reporting/reporting/yardstick/template/index-status-tmpl.html index f9b852490..3db32e531 100644 --- a/utils/test/reporting/reporting/yardstick/template/index-status-tmpl.html +++ b/utils/test/reporting/reporting/yardstick/template/index-status-tmpl.html @@ -70,7 +70,8 @@ <li class="active"><a href="http://testresults.opnfv.org/reporting/index.html">Home</a></li> <li><a href="status-apex.html">Apex</a></li> <li><a href="status-compass.html">Compass</a></li> - <li><a href="status-fuel.html">Fuel</a></li> + <li><a href="status-fuel@x86.html">Fuel@x86</a></li> + <li><a href="status-fuel@aarch64.html">Fuel@aarch64</a></li> <li><a href="status-joid.html">Joid</a></li> </ul> </nav> |