From 10791f49e46fb4885d8d21ad2494431aee7c2ace Mon Sep 17 00:00:00 2001 From: knutroy Date: Fri, 24 Aug 2007 13:45:11 +0000 Subject: [PATCH] Added first release of automatic build and test utility. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1920 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-tools/autobuild/README | 70 +++++++++++++++++++ varnish-tools/autobuild/autobuild.sh | 101 +++++++++++++++++++++++++++ varnish-tools/autobuild/mksummary.pl | 58 +++++++++++++++ varnish-tools/autobuild/summary.html | 48 +++++++++++++ 4 files changed, 277 insertions(+) create mode 100644 varnish-tools/autobuild/README create mode 100755 varnish-tools/autobuild/autobuild.sh create mode 100755 varnish-tools/autobuild/mksummary.pl create mode 100644 varnish-tools/autobuild/summary.html diff --git a/varnish-tools/autobuild/README b/varnish-tools/autobuild/README new file mode 100644 index 00000000..44968f3b --- /dev/null +++ b/varnish-tools/autobuild/README @@ -0,0 +1,70 @@ +Automatic Build and Test Utility +================================ + +The tools found in this directory may be used to automate periodic +building and regression testing of Varnish. + + +Cron-based Invocation +--------------------- + +Start by installing autobuild.sh, mksummary.pl, and summary.html into +an empty directory and configure cron(8) to run this new copy of +autobuild.sh periodically. + +autobuild.sh will start by looking up the most recent revision number +on the Subversion server and compare this number to the revision +number of the last autobuild, which is kept in a file called +LAST_TESTED_REVISION. + +If the numbers are identical, autobuild.sh will exit and be done. + +If not, the new revision is checked out, configured, built, installed +into a directory tree under /tmp, and finally, tested using the +regression test framework. + +The test result is extracted and the summary file, index.html is +updated with the new result. + +A web-server may be used to make index.html and the sub-directories +(which are the working directories of the individual autobuild runs) +available to the world. + + +Manual Invocation +----------------- + +autobuild.sh may also be invoked manually and takes an optional +argument which will be interpreted as a Subversion revision number. +This revision will then be processed in the same way as described +above. + + +Working Directories +------------------- + +Each time autobuild.sh builds and tests a revision, a working +directory is created inside the directory where autobuild.sh is +located. This working directory is used to hold the checked-out +revision as well as log files generated during building and testing. +The name of the working directory indicates the time (UTC) of its +creation. + +In addition to the checked-out revision residing in the sub-directory +"trunk", the following files are stored in a working directory: + + svn.log - output to STDOUT and STDERR during Subversion checkout + build.log - output to STDOUT and STDERR during configure, build, and install + regress.log - output to STDOUT and STDERR during regression testing + regress.bin - Varnish's storage cache file during regression testing + regress.html - HTML-formatted result of regression testing + regress.status - summary of regress.html, used by mksummary.pl + + +Summary file +------------ + +Currently, the overall summary file, index.html, is generated from +scratch based on the currently present working directories, every time +autobuild.sh completes successfully. The summary file is generated by +the Perl script called mksummary.pl, using summary.html as template. diff --git a/varnish-tools/autobuild/autobuild.sh b/varnish-tools/autobuild/autobuild.sh new file mode 100755 index 00000000..2c62d0e7 --- /dev/null +++ b/varnish-tools/autobuild/autobuild.sh @@ -0,0 +1,101 @@ +#!/bin/sh -e + +# Copyright (c) 2007 Linpro AS +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer +# in this position and unchanged. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $Id$ +# + +# Change to same directory as this script is located. +cd "`dirname "$0"`" + +if [ "$1" != "" ]; then + # Make and change to working directory. + DIR="`date -u +varnish-%Y%m%d-%H%M%SZ`" + mkdir "$DIR" + cd "$DIR" + + # Check out from Subversion. + svn co -r "$1" http://varnish.projects.linpro.no/svn/trunk > svn.log 2>&1 + + # Use most recent revision of regression test framework. + svn update trunk/varnish-tools/regress >> svn.log 2>&1 + + # Make status file. + echo "revision: $1" > regress.status +else + # What is the current revision? + CURR="`svn info http://varnish.projects.linpro.no/svn/trunk | grep 'Revision: ' | sed 's/Revision: //'`" + + # Compare to last tested revision and exit if we already tested + # this revision. + if [ -e LAST_TESTED_REVISION ]; then + LAST="`cat LAST_TESTED_REVISION`" + if [ "$CURR" = "$LAST" ]; then + exit 0; + fi + fi + + # Okay, new revision. Here we go... + + # Make and change to working directory. + DIR="`date -u +varnish-%Y%m%d-%H%M%SZ`" + mkdir "$DIR" + cd "$DIR" + + # Check out from Subversion. + svn co -r "$CURR" http://varnish.projects.linpro.no/svn/trunk > svn.log 2>&1 + + # Make status file. + echo "revision: $CURR" > regress.status + + # Update last revision status file. + echo "$CURR" > ../LAST_TESTED_REVISION +fi + +# Build. +( + cd trunk/varnish-cache + ./autogen.sh + ./configure --enable-debugging-symbols --enable-developer-warnings --enable-dependency-tracking --prefix=/tmp/"$DIR" + make + make install +) > build.log 2>&1 + +# Run regression test framework. +PATH=/tmp/"$DIR"/sbin:"$PATH" trunk/varnish-tools/regress/varnish-regress.pl > regress.html 2> regress.log + +# Update status file. +grep -A 4 'Total' regress.html \ + | sed 's/.*class="\([^"]*\)">\([^<]*\)<.*/\1: \2/' \ + | tail -n +2 >> regress.status + +cd .. + +# Make summary file. +./mksummary.pl varnish-*Z > index.html.new +mv -f index.html.new index.html + +exit 0 diff --git a/varnish-tools/autobuild/mksummary.pl b/varnish-tools/autobuild/mksummary.pl new file mode 100755 index 00000000..893871cd --- /dev/null +++ b/varnish-tools/autobuild/mksummary.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl -w +#- +# Copyright (c) 2007 Linpro AS +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer +# in this position and unchanged. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $Id$ +# + +use strict; + +use Template; + +my %cache = (); + +foreach my $dir (@ARGV) { + open(STATUS, $dir . '/regress.status') or next; + while () { + my ($name, $value) = split(/: /); + chomp($value) if defined($value); + $cache{$dir}{$name} = $value; + } + close(STATUS); +} + +my @tests = (); + +foreach my $dir (sort({ $b cmp $a } keys(%cache))) { + if ($dir =~ /^varnish-(\d\d\d\d)(\d\d)(\d\d)-(\d\d)(\d\d)(\d\d)Z$/) { + $cache{$dir}{'title'} = "$1-$2-$3 $4:$5:$6 UTC"; + $cache{$dir}{'link'} = $dir; + push(@tests, $cache{$dir}); + } +} + +my $template = new Template('TAG_STYLE' => 'html'); +$template->process('summary.html', { 'tests' => \@tests }); diff --git a/varnish-tools/autobuild/summary.html b/varnish-tools/autobuild/summary.html new file mode 100644 index 00000000..ece620a5 --- /dev/null +++ b/varnish-tools/autobuild/summary.html @@ -0,0 +1,48 @@ + + + + + Varnish automatic build and test summary + + + + +

Varnish automatic build and test summary

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Build and test timeRevisionTestsPassFailTest duration
working directory
+ + -- 2.39.5