diff options
-rw-r--r-- | reporting/html/danube.html | 2 | ||||
-rw-r--r-- | reporting/html/euphrates.html | 2 | ||||
-rw-r--r-- | reporting/html/index.html | 2 | ||||
-rw-r--r-- | reporting/html/master.html | 2 | ||||
-rw-r--r-- | reporting/reporting/utils/reporting_utils.py | 4 | ||||
-rw-r--r-- | reporting/reporting/vsperf/reporting-status.py | 251 | ||||
-rw-r--r-- | reporting/reporting/vsperf/template/index-status-tmpl.html | 38 |
7 files changed, 144 insertions, 157 deletions
diff --git a/reporting/html/danube.html b/reporting/html/danube.html index 09de789..e06d6e5 100644 --- a/reporting/html/danube.html +++ b/reporting/html/danube.html @@ -91,7 +91,7 @@ <span class="image"> <img src="img/projectIcon_vsperf_250x250.png" alt="" /> </span> - <a href="danube/vsperf/status-apex.html"> + <a href="danube/vsperf/reporting.html"> <h2>Vsperf</h2> <div class="content"> <p>Virtual switch testing</p> diff --git a/reporting/html/euphrates.html b/reporting/html/euphrates.html index ff7061b..1828fc7 100644 --- a/reporting/html/euphrates.html +++ b/reporting/html/euphrates.html @@ -75,7 +75,7 @@ <span class="image"> <img src="img/projectIcon_vsperf_250x250.png" alt="" /> </span> - <a href="euphrates/vsperf/status-apex.html"> + <a href="euphrates/vsperf/reporting.html"> <h2>Vsperf</h2> <div class="content"> <p>Virtual switch testing</p> diff --git a/reporting/html/index.html b/reporting/html/index.html index 2789045..22d7078 100644 --- a/reporting/html/index.html +++ b/reporting/html/index.html @@ -72,7 +72,7 @@ <a href="euphrates.html"> <h2>Euphrates</h2> <div class="content"> - <p>Euphreates (ETA 10/2017)</p> + <p>Euphrates (ETA 10/2017)</p> </div> </a> </article> diff --git a/reporting/html/master.html b/reporting/html/master.html index 7805386..312e8e6 100644 --- a/reporting/html/master.html +++ b/reporting/html/master.html @@ -91,7 +91,7 @@ <span class="image"> <img src="img/projectIcon_vsperf_250x250.png" alt="" /> </span> - <a href="master/vsperf/status-apex.html"> + <a href="master/vsperf/reporting.html"> <h2>Vsperf</h2> <div class="content"> <p>Virtual switch testing</p> diff --git a/reporting/reporting/utils/reporting_utils.py b/reporting/reporting/utils/reporting_utils.py index 58a0c62..28499cd 100644 --- a/reporting/reporting/utils/reporting_utils.py +++ b/reporting/reporting/utils/reporting_utils.py @@ -110,13 +110,13 @@ def getApiResults(case, installer, scenario, version): return results -def getScenarios(project, case, installer, version): +def getScenarios(project, case, installer, version, **kwargs): """ Get the list of Scenarios """ test_results = None scenario_results = None - period = get_config('general.period') + period = kwargs.get('period', get_config('general.period')) url_base = get_config('testapi.url') url = ("http://" + url_base + diff --git a/reporting/reporting/vsperf/reporting-status.py b/reporting/reporting/vsperf/reporting-status.py index fc4cc67..b307ef0 100644 --- a/reporting/reporting/vsperf/reporting-status.py +++ b/reporting/reporting/vsperf/reporting-status.py @@ -6,133 +6,132 @@ # # http://www.apache.org/licenses/LICENSE-2.0 # -import datetime import os +import datetime +import logging +from itertools import ifilter import jinja2 -import reporting.utils.reporting_utils as rp_utils -import reporting.utils.scenarioResult as sr - -installers = rp_utils.get_config('general.installers') -PERIOD = rp_utils.get_config('general.period') - -# Logger -logger = rp_utils.getLogger("Storperf-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("*******************************************") - -# retrieve the list of storperf tests -versions = {'master'} - -# For all the versions -for version in versions: - # For all the installers - for installer in installers: - scenario_results = rp_utils.getScenarios("vsperf", - None, - installer, - None) - items = {} - scenario_result_criteria = {} - logger.info("installer %s, version %s, scenario ", installer, version) - - # 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: - if "PASS" in v['criteria']: - ten_score += 1 - - logger.info("ten_score: %s / %s" % (ten_score, ten_criteria)) - - four_score = 0 - try: - LASTEST_TESTS = rp_utils.get_config( - 'general.nb_iteration_tests_success_criteria') - s_result.sort(key=lambda x: x['start_date']) - four_result = s_result[-LASTEST_TESTS:] - logger.debug("four_result: {}".format(four_result)) - logger.debug("LASTEST_TESTS: {}".format(LASTEST_TESTS)) - # logger.debug("four_result: {}".format(four_result)) - four_criteria = len(four_result) - for v in four_result: - if "PASS" in v['criteria']: - four_score += 1 - logger.info("4 Score: %s / %s " % (four_score, - four_criteria)) - except Exception: - logger.error("Impossible to retrieve the four_score") - - try: - s_status = (four_score * 100) / four_criteria - except ZeroDivisionError: - s_status = 0 - logger.info("Score percent = %s" % str(s_status)) - s_four_score = str(four_score) + '/' + str(four_criteria) - s_ten_score = str(ten_score) + '/' + str(ten_criteria) - s_score_percent = str(s_status) - - logger.debug(" s_status: {}".format(s_status)) - if s_status == 100: - 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)) - - s_url = "" - if len(s_result) > 0: - build_tag = s_result[len(s_result)-1]['build_tag'] - logger.debug("Build tag: %s" % build_tag) - s_url = s_url = rp_utils.getJenkinsUrl(build_tag) - logger.info("last jenkins url: %s" % s_url) - - # Save daily results in a file - path_validation_file = ("./display/" + version + - "/vsperf/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, - s_url) - - logger.info("--------------------------") - - templateLoader = jinja2.FileSystemLoader(".") - templateEnv = jinja2.Environment(loader=templateLoader, - autoescape=True) - - TEMPLATE_FILE = "./reporting/vsperf/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 + - "/vsperf/status-" + installer + ".html", "wb") as fh: - fh.write(outputText) +from reporting.utils import reporting_utils +from reporting.utils.scenarioResult import ScenarioResult + +LOG = reporting_utils.getLogger("Vsperf-Status") +LOG.setLevel(logging.DEBUG) + +HISTORY_FILE = "./display/{}/vsperf/scenario_history.txt" +TEMPLATE_FILE = "./reporting/vsperf/template/index-status-tmpl.html" +TARGET_FILE = "./display/{}/vsperf/reporting.html" + + +def _get_version_data(data): + version_data = {} + for ele in data: + try: + version = ele['build_tag'].split('-')[-2] + except (KeyError, TypeError, IndexError): + continue + + if version not in version_data: + version_data[version] = [] + version_data[version].append(ele) + return version_data + + +def _get_case_data(data): + case_data = {} + for ele in data: + case_name = ele['case_name'] + if case_name not in case_data: + case_data[case_name] = [] + case_data[case_name].append(ele) + return case_data + + +def _get_score(data): + count = len(list(ifilter(lambda r: r['criteria'] == 'PASS', data))) + total = len(data) + return count, total + + +def _get_result_obj(version, case, data): + fifty_pass, fifty_total = _get_score(data) + four_pass, four_total = _get_score(data[:4]) + status = (four_pass * 100) / four_total + four_score = '{}/{}'.format(four_pass, four_total) + fifty_score = '{}/{}'.format(fifty_pass, fifty_total) + percent = str(status) + url = reporting_utils.getJenkinsUrl(data[-1]['build_tag']) + LOG.debug('Last four score: %s', four_score) + LOG.debug('Fifty days score: %s', fifty_score) + LOG.debug('Last Four percent: %s', percent) + + _write_history_file(version, case, fifty_score, percent) + + return ScenarioResult(status, four_score, fifty_score, percent, url) + + +def _write_history_file(version, case, fifty_score, percent): + file_path = HISTORY_FILE.format(version) + + if not os.path.exists(file_path): + with open(file_path, 'w') as f: + info = 'date,case,details,score\n' + f.write(info) + + date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") + + with open(file_path, "a") as f: + info = '{},{},{},{}\n'.format(date, case, fifty_score, percent) + f.write(info) + + +def _do_generate(version, case_result): + templateLoader = jinja2.FileSystemLoader(".") + templateEnv = jinja2.Environment(loader=templateLoader, + autoescape=True) + + template = templateEnv.get_template(TEMPLATE_FILE) + + date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") + + outputText = template.render(case_result=case_result, + period=50, + version=version, + date=date) + + with open(TARGET_FILE.format(version), 'wb') as f: + f.write(outputText) + + +def _generate_reporting(version, data): + case_result = {} + case_data = _get_case_data(data) + for case, value in case_data.items(): + LOG.debug('version: %s, case: %s', version, case) + case_result[case] = _get_result_obj(version, case, value) + _do_generate(version, case_result) + + +def main(): + LOG.info("*******************************************") + LOG.info("* Generating vsperf reporting status *") + LOG.info("* Data retention = 50 days *") + LOG.info("* *") + LOG.info("*******************************************") + + data = reporting_utils.getScenarios("vsperf", + None, + "fuel", + None, + period=50) + version_data = _get_version_data(data['vsperf']) + + for version in {'master', 'danube', 'euphrates'}: + _generate_reporting(version, version_data.get(version, [])) + + LOG.info("End") + + +if __name__ == '__main__': + main() diff --git a/reporting/reporting/vsperf/template/index-status-tmpl.html b/reporting/reporting/vsperf/template/index-status-tmpl.html index 7e06ef6..0b14798 100644 --- a/reporting/reporting/vsperf/template/index-status-tmpl.html +++ b/reporting/reporting/vsperf/template/index-status-tmpl.html @@ -12,13 +12,12 @@ <script> function onDocumentReady() { // Gauge management - {% for scenario in scenario_results.keys() -%} - var gaugeScenario{{loop.index}} = gauge('#gaugeScenario{{loop.index}}'); + {% for scenario in case_result.keys() -%} var gaugeScenario{{loop.index}} = gauge('#gaugeScenario{{loop.index}}'); {%- endfor %} // assign success rate to the gauge function updateReadings() { - {% for scenario in scenario_results.keys() -%} - gaugeScenario{{loop.index}}.update({{scenario_results[scenario].getScorePercent()}}); + {% for case in case_result.keys() -%} + gaugeScenario{{loop.index}}.update({{case_result[case].getScorePercent()}}); {%- endfor %} } updateReadings(); @@ -28,11 +27,11 @@ d3.csv("./scenario_history.txt", function(data) { // *************************************** // Create the trend line - {% for scenario in scenario_results.keys() -%} + {% for case in case_result.keys() -%} // for scenario {{scenario}} // Filter results var trend{{loop.index}} = data.filter(function(row) { - return row["scenario"]=="{{scenario}}" && row["installer"]=="{{installer}}"; + return row["case"]=="{{case}}"; }) // Parse the date trend{{loop.index}}.forEach(function(d) { @@ -68,41 +67,30 @@ <nav> <ul class="nav nav-justified"> <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-joid.html">Joid</a></li> + <li><a href="reporting.html">Baremetal</a></li> </ul> </nav> </div> <div class="row"> <div class="col-md-1"></div> <div class="col-md-10"> - <div class="page-header"> - <h2>{{installer}}</h2> - </div> - <div><h1>Reported values represent the percentage of completed - - CI tests during the reporting period, where results - - were communicated to the Test Database.</h1></div> <div class="scenario-overview"> - <div class="panel-heading"><h4><b>List of last scenarios ({{version}}) run over the last {{period}} days </b></h4></div> + <div class="panel-heading"><h4><b>List of last cases ({{version}}) run over the last {{period}} days </b></h4></div> <table class="table"> <tr> - <th width="40%">Scenario</th> + <th width="40%">Case</th> <th width="20%">Status</th> <th width="20%">Trend</th> <th width="10%">Last 4 Iterations</th> - <th width="10%">Last 10 Days</th> + <th width="10%">Last 50 Days</th> </tr> - {% for scenario,result in scenario_results.iteritems() -%} + {% for case,result in case_result.items() -%} <tr class="tr-ok"> - <td><a href="{{scenario_results[scenario].getLastUrl()}}">{{scenario}}</a></td> + <td><a href="{{case_result[case].getLastUrl()}}">{{case}}</a></td> <td><div id="gaugeScenario{{loop.index}}"></div></td> <td><div id="trend_svg{{loop.index}}"></div></td> - <td>{{scenario_results[scenario].getFourDaysScore()}}</td> - <td>{{scenario_results[scenario].getTenDaysScore()}}</td> + <td>{{case_result[case].getFourDaysScore()}}</td> + <td>{{case_result[case].getTenDaysScore()}}</td> </tr> {%- endfor %} </table> |