From 54fa6609530eb80db64583937e60970c3e301e92 Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Tue, 10 Oct 2017 08:08:37 +0000 Subject: Add fuel@x86 and fuel@arm support Since scenario data do not have a field named architecture, So I choose pod_name for now. For example: pod_name: arm-pod5 I assume that it is based arm architecture Change-Id: I92159a5e08b1ed80701494483fd9922dbd459193 Signed-off-by: chenjiankun --- reporting/reporting/utils/reporting_utils.py | 37 ++-- reporting/reporting/yardstick/reporting-status.py | 244 ++++++++++++--------- .../yardstick/template/index-status-tmpl.html | 3 +- 3 files changed, 166 insertions(+), 118 deletions(-) diff --git a/reporting/reporting/utils/reporting_utils.py b/reporting/reporting/utils/reporting_utils.py index 235bd6e..6c0d5a2 100644 --- a/reporting/reporting/utils/reporting_utils.py +++ b/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/reporting/reporting/yardstick/reporting-status.py b/reporting/reporting/yardstick/reporting-status.py index 6584f4e..77e2604 100644 --- a/reporting/reporting/yardstick/reporting-status.py +++ b/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/reporting/reporting/yardstick/template/index-status-tmpl.html b/reporting/reporting/yardstick/template/index-status-tmpl.html index f9b8524..3db32e5 100644 --- a/reporting/reporting/yardstick/template/index-status-tmpl.html +++ b/reporting/reporting/yardstick/template/index-status-tmpl.html @@ -70,7 +70,8 @@
  • Home
  • Apex
  • Compass
  • -
  • Fuel
  • +
  • Fuel@x86
  • +
  • Fuel@aarch64
  • Joid
  • -- cgit 1.2.3-korg