From 5683c0b087653e53c18f41c6afe2d6d6a4a71d9c Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Mon, 11 Apr 2016 15:31:25 -0700 Subject: [PATCH] Make test-history generator create pages for individual suites This makes it easier to determine which tests cause particular suites to fail. All static HTML pages are now generated by one invocation of gen_html.py. - make index include good/flake/fail numbers for each link - consistently use % for string interpolation --- hack/jenkins/test-history/gen_history | 12 +- hack/jenkins/test-history/gen_html.py | 143 ++++++++++++++---- hack/jenkins/test-history/gen_html_test.py | 73 +++++++++ hack/jenkins/test-history/index_template.html | 15 -- hack/jenkins/test-history/static/style.css | 22 ++- 5 files changed, 202 insertions(+), 63 deletions(-) create mode 100755 hack/jenkins/test-history/gen_html_test.py delete mode 100644 hack/jenkins/test-history/index_template.html diff --git a/hack/jenkins/test-history/gen_history b/hack/jenkins/test-history/gen_history index fb5cd4bd2a..8694704d5c 100755 --- a/hack/jenkins/test-history/gen_history +++ b/hack/jenkins/test-history/gen_history @@ -26,16 +26,8 @@ readonly datestr=$(date +"%Y-%m-%d") # Create JSON report time python gen_json.py "${jenkins}" kubernetes -# Create static HTML report out of the JSON -python gen_html.py > static/tests.html -python gen_html.py kubernetes-e2e > static/tests-e2e.html -python gen_html.py kubernetes-soak > static/tests-soak.html -python gen_html.py kubernetes-e2e-gce > static/tests-e2e-gce.html -python gen_html.py kubernetes-e2e-gke > static/tests-e2e-gke.html -python gen_html.py kubernetes-upgrade > static/tests-upgrade.html - -# Fill in the last updated time into the template. -cat index_template.html | sed -e "s/TIME/Last updated: ${datestr}/" > static/index.html +# Create static HTML reports out of the JSON +python gen_html.py --suites --prefixes ,e2e,soak,e2e-gce,e2e-gke,upgrade --output-dir static --input tests.json # Upload to GCS readonly bucket="kubernetes-test-history" diff --git a/hack/jenkins/test-history/gen_html.py b/hack/jenkins/test-history/gen_html.py index a461095194..06f622b9d0 100755 --- a/hack/jenkins/test-history/gen_html.py +++ b/hack/jenkins/test-history/gen_html.py @@ -27,20 +27,24 @@ JSON. That would allow custom filtering and stuff like that. from __future__ import print_function +import argparse import json +import os import string import sys +import time -def gen_tests(data, prefix): +def gen_tests(data, prefix, exact_match): """Creates the HTML for all test cases. Args: data: Parsed JSON data that was created by gen_json.py. prefix: Considers Jenkins jobs that start with this. + exact_match: Only match Jenkins jobs with name equal to prefix. Returns: - The HTML as a list of elements along with the number of passing, - unstable, failing, and skipped tests. + The HTML as a list of elements along with a tuple of the number of + passing, unstable, failing, and skipped tests. """ html = ['') if has_failed: status = 'failed' total_failed += 1 @@ -94,42 +101,112 @@ def gen_tests(data, prefix): else: status = 'skipped' total_skipped += 1 - html.append('
  • {}'.format(status, test)) - html.extend(test_html) - html.append('') + html.append('
  • ' % status) + if exact_match and len(test_html) > 2: + if not (test_html[2].startswith('') html.append('') - return html, total_okay, total_unstable, total_failed, total_skipped + return '\n'.join(html), (total_okay, total_unstable, total_failed, total_skipped) -def gen_html(data, prefix): - """Creates the HTML for the entire page. - - Args: Same as gen_tests. - Returns: Just the list of HTML elements. - """ - tests_html, okay, unstable, failed, skipped = gen_tests(data, prefix) +def html_header(): html = ['', ''] html.append('') html.append('') html.append('') html.append('') - if len(prefix) > 0: - html.append('