diff options
Diffstat (limited to 'utils/test/reporting/yardstick')
-rw-r--r-- | utils/test/reporting/yardstick/reporting-status.py | 52 | ||||
-rw-r--r-- | utils/test/reporting/yardstick/reportingConf.py | 29 | ||||
-rw-r--r-- | utils/test/reporting/yardstick/reportingUtils.py | 115 | ||||
-rw-r--r-- | utils/test/reporting/yardstick/scenarios.py | 19 | ||||
-rw-r--r-- | utils/test/reporting/yardstick/template/index-status-tmpl.html | 9 |
5 files changed, 46 insertions, 178 deletions
diff --git a/utils/test/reporting/yardstick/reporting-status.py b/utils/test/reporting/yardstick/reporting-status.py index 49809e9d8..338154987 100644 --- a/utils/test/reporting/yardstick/reporting-status.py +++ b/utils/test/reporting/yardstick/reporting-status.py @@ -10,31 +10,36 @@ import datetime import jinja2 import os -import reportingUtils as utils -import reportingConf as conf import scenarioResult as sr from scenarios import config as cf +# manage conf +import utils.reporting_utils as rp_utils + +installers = rp_utils.get_config('general.installers') +versions = rp_utils.get_config('general.versions') +PERIOD = rp_utils.get_config('general.period') + # Logger -logger = utils.getLogger("Yardstick-Status") +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 *" % conf.PERIOD) +logger.info("* Data retention = %s days *" % PERIOD) logger.info("* *") logger.info("*******************************************") # For all the versions -for version in conf.versions: +for version in versions: # For all the installers - for installer in conf.installers: + for installer in installers: # get scenarios results data - scenario_results = utils.getScenarioStatus(installer, version) + scenario_results = rp_utils.getScenarioStatus(installer, version) if 'colorado' == version: - stable_result = utils.getScenarioStatus(installer, - 'stable/colorado') + 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] = [] @@ -48,24 +53,25 @@ for version in conf.versions: # 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)) + 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 - four_result = s_result[:conf.LASTEST_TESTS] + 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(utils.get_percent(four_result, s_result)) + 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 = utils.get_percent(four_result, s_result) + s_score_percent = rp_utils.get_percent(four_result, s_result) if '100' == s_status: logger.info(">>>>> scenario OK, save the information") @@ -74,9 +80,8 @@ for version in conf.versions: last 10 days = %s" % (s_four_score, s_ten_score)) # Save daily results in a file - path_validation_file = (conf.REPORTING_PATH + - "/release/" + version + - "/scenario_history.txt") + 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: @@ -96,18 +101,19 @@ for version in conf.versions: logger.info("--------------------------") - templateLoader = jinja2.FileSystemLoader(conf.REPORTING_PATH) - templateEnv = jinja2.Environment(loader=templateLoader, autoescape=True) + templateLoader = jinja2.FileSystemLoader(".") + templateEnv = jinja2.Environment(loader=templateLoader, + autoescape=True) - TEMPLATE_FILE = "/template/index-status-tmpl.html" + TEMPLATE_FILE = "./yardstick/template/index-status-tmpl.html" template = templateEnv.get_template(TEMPLATE_FILE) outputText = template.render(scenario_results=scenario_result_criteria, installer=installer, - period=conf.PERIOD, + period=PERIOD, version=version, date=reportingDate) - with open(conf.REPORTING_PATH + "/release/" + version + - "/index-status-" + installer + ".html", "wb") as fh: + with open("./display/" + version + + "/yardstick/status-" + installer + ".html", "wb") as fh: fh.write(outputText) diff --git a/utils/test/reporting/yardstick/reportingConf.py b/utils/test/reporting/yardstick/reportingConf.py deleted file mode 100644 index 2db41f0e1..000000000 --- a/utils/test/reporting/yardstick/reportingConf.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python -# -# This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Reporting: Declaration of the variables -# -# **************************************************** -installers = ["apex", "compass", "fuel", "joid"] - -versions = ["master", "colorado"] - -# get data in the past 10 days -PERIOD = 10 - -# get the lastest 4 test results to determinate the success criteria -LASTEST_TESTS = 4 - -REPORTING_PATH = "." - -URL_BASE = 'http://testresults.opnfv.org/test/api/v1/results' -TEST_CONF = "https://git.opnfv.org/cgit/yardstick/plain/tests/ci/report_config.yaml" - -# LOG_LEVEL = "ERROR" -LOG_LEVEL = "INFO" -LOG_FILE = REPORTING_PATH + "/reporting.log" diff --git a/utils/test/reporting/yardstick/reportingUtils.py b/utils/test/reporting/yardstick/reportingUtils.py deleted file mode 100644 index ec9ed76dc..000000000 --- a/utils/test/reporting/yardstick/reportingUtils.py +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/python -# -# This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -from urllib2 import Request, urlopen, URLError -import logging -import json -import reportingConf as conf - - -def getLogger(module): - logFormatter = logging.Formatter("%(asctime)s [" + - module + - "] [%(levelname)-5.5s] %(message)s") - logger = logging.getLogger() - - fileHandler = logging.FileHandler("{0}/{1}".format('.', conf.LOG_FILE)) - fileHandler.setFormatter(logFormatter) - logger.addHandler(fileHandler) - - consoleHandler = logging.StreamHandler() - consoleHandler.setFormatter(logFormatter) - logger.addHandler(consoleHandler) - logger.setLevel(conf.LOG_LEVEL) - return logger - - -def getScenarioStatus(installer, version): - url = (conf.URL_BASE + "?case=" + "scenario_status" + - "&installer=" + installer + - "&version=" + version + "&period=" + str(conf.PERIOD)) - request = Request(url) - - try: - response = urlopen(request) - k = response.read() - response.close() - results = json.loads(k) - test_results = results['results'] - except URLError, e: - print 'Got an error code:', e - - scenario_results = {} - result_dict = {} - if test_results is not None: - for r in test_results: - if r['stop_date'] != 'None' and r['criteria'] is not None: - if not r['scenario'] in scenario_results.keys(): - scenario_results[r['scenario']] = [] - scenario_results[r['scenario']].append(r) - - for k, v in scenario_results.items(): - # scenario_results[k] = v[:conf.LASTEST_TESTS] - s_list = [] - for element in v: - if element['criteria'] == 'SUCCESS': - s_list.append(1) - else: - s_list.append(0) - result_dict[k] = s_list - - # return scenario_results - return result_dict - - -def subfind(given_list, pattern_list): - - for i in range(len(given_list)): - if given_list[i] == pattern_list[0] and \ - given_list[i:i + conf.LASTEST_TESTS] == pattern_list: - return True - return False - - -def _get_percent(status): - - if status * 100 % 6: - return round(float(status) * 100 / 6, 1) - else: - return status * 100 / 6 - - -def get_percent(four_list, ten_list): - four_score = 0 - ten_score = 0 - - for v in four_list: - four_score += v - for v in ten_list: - ten_score += v - - if four_score == conf.LASTEST_TESTS: - status = 6 - elif subfind(ten_list, [1, 1, 1, 1]): - status = 5 - elif ten_score == 0: - status = 0 - else: - status = four_score + 1 - - return _get_percent(status) - - -def _test(): - status = getScenarioStatus("compass", "master") - print "status:++++++++++++++++++++++++" - print json.dumps(status, indent=4) - - -if __name__ == '__main__': # pragma: no cover - _test() diff --git a/utils/test/reporting/yardstick/scenarios.py b/utils/test/reporting/yardstick/scenarios.py index 590fea2a4..26e8c8bb0 100644 --- a/utils/test/reporting/yardstick/scenarios.py +++ b/utils/test/reporting/yardstick/scenarios.py @@ -1,11 +1,18 @@ -import yaml -import os +#!/usr/bin/python +# +# This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# import requests +import yaml -import reportingConf as conf - +import utils.reporting_utils as rp_utils -response = requests.get(conf.TEST_CONF) +yardstick_conf = rp_utils.get_config('yardstick.test_conf') +response = requests.get(yardstick_conf) yaml_file = yaml.safe_load(response.text) reporting = yaml_file.get('reporting') @@ -15,6 +22,6 @@ for element in reporting: name = element['name'] scenarios = element['scenario'] for s in scenarios: - if not config.has_key(name): + if name not in config: config[name] = {} config[name][s] = True diff --git a/utils/test/reporting/yardstick/template/index-status-tmpl.html b/utils/test/reporting/yardstick/template/index-status-tmpl.html index 5a4dc347c..b6f237a1a 100644 --- a/utils/test/reporting/yardstick/template/index-status-tmpl.html +++ b/utils/test/reporting/yardstick/template/index-status-tmpl.html @@ -3,12 +3,12 @@ <meta charset="utf-8"> <!-- Bootstrap core CSS --> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"> - <link href="../../../css/default.css" rel="stylesheet"> + <link href="../../css/default.css" rel="stylesheet"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <script type="text/javascript" src="http://d3js.org/d3.v2.min.js"></script> - <script type="text/javascript" src="../../../js/gauge.js"></script> - <script type="text/javascript" src="../../../js/trend.js"></script> + <script type="text/javascript" src="../../js/gauge.js"></script> + <script type="text/javascript" src="../../js/trend.js"></script> <script> function onDocumentReady() { // Gauge management @@ -25,8 +25,7 @@ } // trend line management - //d3.csv("./scenario_history.txt", function(data) { - d3.csv("./scenario_history.txt", function(data) { + d3.csv("./scenario_history.csv", function(data) { // *************************************** // Create the trend line {% for scenario in scenario_results.keys() -%} |