From e01825bfeebed42af5fe08b2264e0d6413955e36 Mon Sep 17 00:00:00 2001 From: Erick Fejta Date: Fri, 15 Apr 2016 18:09:58 -0700 Subject: [PATCH] Add blocking suites to daily summary Add title and optional script to html header --- hack/jenkins/test-history/gen_history | 6 +- hack/jenkins/test-history/gen_html.py | 231 ++++++++++++++------- hack/jenkins/test-history/gen_html_test.py | 110 ++++++++-- hack/jenkins/test-history/gen_json.py | 70 +++++-- hack/jenkins/test-history/gen_json_test.py | 55 +++++ 5 files changed, 350 insertions(+), 122 deletions(-) create mode 100644 hack/jenkins/test-history/gen_json_test.py diff --git a/hack/jenkins/test-history/gen_history b/hack/jenkins/test-history/gen_history index 8694704d5ce..ad0efad73ab 100755 --- a/hack/jenkins/test-history/gen_history +++ b/hack/jenkins/test-history/gen_history @@ -24,10 +24,12 @@ readonly jenkins="$1" readonly datestr=$(date +"%Y-%m-%d") # Create JSON report -time python gen_json.py "${jenkins}" kubernetes +time python gen_json.py \ + "--server=${jenkins}" \ + "--match=^kubernetes|kubernetes-build|kubelet-gce-e2e-ci" # 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 +python gen_html.py --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 06f622b9d0c..0f94fa17b30 100755 --- a/hack/jenkins/test-history/gen_html.py +++ b/hack/jenkins/test-history/gen_html.py @@ -28,12 +28,23 @@ JSON. That would allow custom filtering and stuff like that. from __future__ import print_function import argparse +import cgi +import collections import json import os import string import sys import time + +TestMetadata = collections.namedtuple('TestMetadata', [ + 'okay', + 'unstable', + 'failed', + 'skipped', +]) + + def gen_tests(data, prefix, exact_match): """Creates the HTML for all test cases. @@ -43,14 +54,10 @@ def gen_tests(data, prefix, exact_match): exact_match: Only match Jenkins jobs with name equal to prefix. Returns: - The HTML as a list of elements along with a tuple of the number of - passing, unstable, failing, and skipped tests. + (html, TestMetadata) for matching tests """ html = ['') - return '\n'.join(html), (total_okay, total_unstable, total_failed, total_skipped) + return '\n'.join(html), TestMetadata( + totals['okay'], totals['unstable'], totals['failed'], totals['skipped']) -def html_header(): + +def html_header(title, script): + """Return html header items.""" html = ['', ''] html.append('') - html.append('') + if title: + html.append('%s' % cgi.escape(title)) + if script: + html.append('') html.append('') html.append('') return html + def gen_html(data, prefix, exact_match=False): """Creates the HTML for the entire page. - Args: Same as gen_tests. - Returns: Same as gen_tests. + Args: + Same as gen_tests. + Returns: + Same as gen_tests. """ - tests_html, (okay, unstable, failed, skipped) = gen_tests(data, prefix, exact_match) - html = html_header() + tests_html, meta = gen_tests(data, prefix, exact_match) if exact_match: - html.append('