diff --git a/hack/jenkins/job-configs/kubernetes-test-history.yaml b/hack/jenkins/job-configs/kubernetes-test-history.yaml new file mode 100644 index 00000000000..628ce355d1a --- /dev/null +++ b/hack/jenkins/job-configs/kubernetes-test-history.yaml @@ -0,0 +1,21 @@ +- job: + name: kubernetes-test-summary + description: 'Create a daily test summary and upload to GCS. Test owner: spxtr.' + triggers: + # Run every night at midnight at a random minute. + - timed: 'H 0 * * *' + scm: + - git: + url: https://www.github.com/kubernetes/kubernetes + branches: + - master + browser: githubweb + browser-url: https://github.com/kubernetes/kubernetes + skip-tag: true + builders: + - shell: | + cd hack/jenkins/test-history + ./gen_history http://jenkins-master:8080/ + publishers: + - email-ext: + recipients: spxtr@google.com diff --git a/hack/jenkins/test-history/gen_history b/hack/jenkins/test-history/gen_history new file mode 100755 index 00000000000..cccaa6c7f34 --- /dev/null +++ b/hack/jenkins/test-history/gen_history @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright 2016 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Compiles a static HTML site containing the last day's worth of test results. +# Pass the URL of Jenkins into $1 + +set -o errexit +set -o nounset + +readonly jenkins="$1" +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 + +# Upload to GCS +readonly bucket="kubernetes-test-history" +readonly gcs_acl="public-read" +gsutil -q cp -az "${gcs_acl}" "tests.json" "gs://${bucket}/logs/${datestr}.json" +gsutil -q cp -ra "${gcs_acl}" "static" "gs://${bucket}/" diff --git a/hack/jenkins/test-history/gen_html.py b/hack/jenkins/test-history/gen_html.py new file mode 100755 index 00000000000..a4610951944 --- /dev/null +++ b/hack/jenkins/test-history/gen_html.py @@ -0,0 +1,135 @@ +#!/usr/bin/env python + +# Copyright 2016 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Creates an HTML report for all jobs starting with a given prefix. + +Reads the JSON from tests.json, and prints the HTML to stdout. + +This code is pretty nasty, but gets the job done. + +It would be really spiffy if this used an HTML template system, but for now +we're old-fashioned. We could also generate these with JS, directly from the +JSON. That would allow custom filtering and stuff like that. +""" + +from __future__ import print_function + +import json +import string +import sys + +def gen_tests(data, prefix): + """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. + + Returns: + The HTML as a list of elements along with the number of passing, + unstable, failing, and skipped tests. + """ + html = ['