From knutroy at projects.linpro.no Mon Sep 3 10:12:29 2007 From: knutroy at projects.linpro.no (knutroy at projects.linpro.no) Date: Mon, 3 Sep 2007 12:12:29 +0200 (CEST) Subject: r1932 - in trunk/varnish-tools: autobuild regress regress/bin regress/lib/Varnish Message-ID: <20070903101229.DC4261EC21C@projects.linpro.no> Author: knutroy Date: 2007-09-03 12:12:29 +0200 (Mon, 03 Sep 2007) New Revision: 1932 Added: trunk/varnish-tools/regress/MANIFEST trunk/varnish-tools/regress/Makefile.PL trunk/varnish-tools/regress/bin/ trunk/varnish-tools/regress/bin/varnish-regress.pl Removed: trunk/varnish-tools/regress/varnish-regress.pl Modified: trunk/varnish-tools/autobuild/autobuild.sh trunk/varnish-tools/regress/lib/Varnish/Test.pm Log: * Added Makefile.PL to test framework. * Moved varnish-regress.pl to subdirectory "bin". * Minor POD additions. Modified: trunk/varnish-tools/autobuild/autobuild.sh =================================================================== --- trunk/varnish-tools/autobuild/autobuild.sh 2007-08-31 12:14:06 UTC (rev 1931) +++ trunk/varnish-tools/autobuild/autobuild.sh 2007-09-03 10:12:29 UTC (rev 1932) @@ -85,7 +85,7 @@ ) > 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 +PATH=/tmp/"$DIR"/sbin:"$PATH" trunk/varnish-tools/regress/bin/varnish-regress.pl > regress.html 2> regress.log # Update status file. grep -A 4 'Total' regress.html \ Added: trunk/varnish-tools/regress/MANIFEST =================================================================== --- trunk/varnish-tools/regress/MANIFEST (rev 0) +++ trunk/varnish-tools/regress/MANIFEST 2007-09-03 10:12:29 UTC (rev 1932) @@ -0,0 +1,23 @@ +bin/varnish-regress.pl +doc/README +doc/structure.dia +lib/Varnish/Test.pm +lib/Varnish/Test/Case.pm +lib/Varnish/Test/Case/LRU.pm +lib/Varnish/Test/Case/POST.pm +lib/Varnish/Test/Case/RePurge.pm +lib/Varnish/Test/Case/Ticket056.pm +lib/Varnish/Test/Case/Ticket102.pm +lib/Varnish/Test/Case/Ticket128.pm +lib/Varnish/Test/Case/Vary.pm +lib/Varnish/Test/Client.pm +lib/Varnish/Test/Engine.pm +lib/Varnish/Test/Report.pm +lib/Varnish/Test/Report/HTML.pm +lib/Varnish/Test/Report/report.html +lib/Varnish/Test/Server.pm +lib/Varnish/Test/Varnish.pm +Makefile.PL +MANIFEST +README +TODO Added: trunk/varnish-tools/regress/Makefile.PL =================================================================== --- trunk/varnish-tools/regress/Makefile.PL (rev 0) +++ trunk/varnish-tools/regress/Makefile.PL 2007-09-03 10:12:29 UTC (rev 1932) @@ -0,0 +1,6 @@ +# $Id$ + +use ExtUtils::MakeMaker; + +WriteMakefile(NAME => 'Varnish::Test', + EXE_FILES => ['bin/varnish-regress.pl']); Property changes on: trunk/varnish-tools/regress/Makefile.PL ___________________________________________________________________ Name: svn:keywords + Id Copied: trunk/varnish-tools/regress/bin/varnish-regress.pl (from rev 1931, trunk/varnish-tools/regress/varnish-regress.pl) =================================================================== --- trunk/varnish-tools/regress/bin/varnish-regress.pl (rev 0) +++ trunk/varnish-tools/regress/bin/varnish-regress.pl 2007-09-03 10:12:29 UTC (rev 1932) @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w +#- +# Copyright (c) 2006 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$ +# + +=head1 NAME + +varnish-regress.pl - run Varnish regression tests + +=cut + +use strict; + +eval { require Varnish::Test }; +if ($@) { + use FindBin; + use lib "$FindBin::Bin/../lib"; +} + +use Getopt::Long; +use Varnish::Test; +use Varnish::Test::Report::HTML; + +sub usage() { + print STDERR < \&usage) + or usage(); + + my $controller = new Varnish::Test; + my @all_cases = $controller->cases(); + + if (@ARGV == 1 && $ARGV[0] eq 'list') { + print join(' ', @all_cases), "\n"; + exit 0; + } + + if (!@ARGV) { + @ARGV = @all_cases; + } else { + map { s/^(\d+)$/sprintf('Ticket%03d', $1)/e } @ARGV; + } + + $controller->start_engine(); + foreach my $casename (@ARGV) { + $controller->run_case($casename); + } + $controller->stop_engine(); + + my $report = new Varnish::Test::Report::HTML; + $report->run($controller->results()); +} + +=head1 SEE ALSO + +L + +=cut Modified: trunk/varnish-tools/regress/lib/Varnish/Test.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test.pm 2007-08-31 12:14:06 UTC (rev 1931) +++ trunk/varnish-tools/regress/lib/Varnish/Test.pm 2007-09-03 10:12:29 UTC (rev 1932) @@ -173,3 +173,12 @@ } 1; + +=head1 SEE ALSO + +L +L +L +L + +=cut Deleted: trunk/varnish-tools/regress/varnish-regress.pl =================================================================== --- trunk/varnish-tools/regress/varnish-regress.pl 2007-08-31 12:14:06 UTC (rev 1931) +++ trunk/varnish-tools/regress/varnish-regress.pl 2007-09-03 10:12:29 UTC (rev 1932) @@ -1,86 +0,0 @@ -#!/usr/bin/perl -w -#- -# Copyright (c) 2006 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 FindBin; - -use lib "$FindBin::Bin/lib"; - -use Getopt::Long; -use Varnish::Test; -use Varnish::Test::Report::HTML; - -sub usage() { - print STDERR < \&usage) - or usage(); - - my $controller = new Varnish::Test; - my @all_cases = $controller->cases(); - - if (@ARGV == 1 && $ARGV[0] eq 'list') { - print join(' ', @all_cases), "\n"; - exit 0; - } - - if (!@ARGV) { - @ARGV = @all_cases; - } else { - map { s/^(\d+)$/sprintf('Ticket%03d', $1)/e } @ARGV; - } - - $controller->start_engine(); - foreach my $casename (@ARGV) { - $controller->run_case($casename); - } - $controller->stop_engine(); - - my $report = new Varnish::Test::Report::HTML; - $report->run($controller->results()); -} From cecilihf at projects.linpro.no Tue Sep 4 08:03:44 2007 From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no) Date: Tue, 4 Sep 2007 10:03:44 +0200 (CEST) Subject: r1933 - trunk/varnish-cache/bin/varnishd Message-ID: <20070904080344.CF0AD1EC3DD@projects.linpro.no> Author: cecilihf Date: 2007-09-04 10:03:43 +0200 (Tue, 04 Sep 2007) New Revision: 1933 Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c Log: Copy-paste error. Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-03 10:12:29 UTC (rev 1932) +++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-04 08:03:43 UTC (rev 1933) @@ -48,7 +48,7 @@ struct ber { unsigned magic; -#define BER_MAGIC 0x66f05894 +#define BER_MAGIC 0x645b3f4 struct brspec *blist; #if 0 /* Store a hash of the backend info given in @@ -61,7 +61,7 @@ struct brspec { unsigned magic; -#define BRSPEC_MAGIC 0x761d69c2 +#define BRSPEC_MAGIC 0x5aa072a7 struct brspec *next; double limit; char *hostname; From cecilihf at projects.linpro.no Tue Sep 4 08:04:49 2007 From: cecilihf at projects.linpro.no (cecilihf at projects.linpro.no) Date: Tue, 4 Sep 2007 10:04:49 +0200 (CEST) Subject: r1934 - trunk/varnish-cache/bin/varnishd Message-ID: <20070904080449.1A1941EC307@projects.linpro.no> Author: cecilihf Date: 2007-09-04 10:04:48 +0200 (Tue, 04 Sep 2007) New Revision: 1934 Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c Log: Missing 0 Modified: trunk/varnish-cache/bin/varnishd/cache_backend_random.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-04 08:03:43 UTC (rev 1933) +++ trunk/varnish-cache/bin/varnishd/cache_backend_random.c 2007-09-04 08:04:48 UTC (rev 1934) @@ -48,7 +48,7 @@ struct ber { unsigned magic; -#define BER_MAGIC 0x645b3f4 +#define BER_MAGIC 0x645b03f4 struct brspec *blist; #if 0 /* Store a hash of the backend info given in From ssm at projects.linpro.no Tue Sep 4 10:55:25 2007 From: ssm at projects.linpro.no (ssm at projects.linpro.no) Date: Tue, 4 Sep 2007 12:55:25 +0200 (CEST) Subject: r1935 - trunk/varnish-cache/debian Message-ID: <20070904105525.E1CB91EC3DD@projects.linpro.no> Author: ssm Date: 2007-09-04 12:55:25 +0200 (Tue, 04 Sep 2007) New Revision: 1935 Modified: trunk/varnish-cache/debian/changelog trunk/varnish-cache/debian/rules trunk/varnish-cache/debian/varnish.default trunk/varnish-cache/debian/varnish.varnishlog.init Log: * Set statedir to /var/lib, to conform to debian packaging standards. * Removed -n switch from varnish defaults file and varnishlog init script. Use the default instance name instead. This makes sure varnish utilities work without having to use the -n switch for the default instance. Modified: trunk/varnish-cache/debian/changelog =================================================================== --- trunk/varnish-cache/debian/changelog 2007-09-04 08:04:48 UTC (rev 1934) +++ trunk/varnish-cache/debian/changelog 2007-09-04 10:55:25 UTC (rev 1935) @@ -1,14 +1,20 @@ -varnish (1.1.1) unstable; urgency=low +varnish (1.1.1-1) unstable; urgency=low + [Lars Bahner] * New upstream release * User and Group id added to default DAEMON_OPTS * Added user and group creation to postinst * Added missing man pages - -- Lars Bahner Mon, 20 Aug 2007 11:29:33 +0200 + [Stig Sandbeck Mathisen] + * Set statedir to /var/lib + * Removed -n switch from varnish defaults file and varnishlog init script. + Use the default instance name instead. -varnish (1.1) unstable; urgency=low + -- Stig Sandbeck Mathisen Tue, 04 Sep 2007 12:27:09 +0200 +varnish (1.1-1) unstable; urgency=low + * New upstream release * Split package into varnish, libvarnish and libvarnish-dev Modified: trunk/varnish-cache/debian/rules =================================================================== --- trunk/varnish-cache/debian/rules 2007-09-04 08:04:48 UTC (rev 1934) +++ trunk/varnish-cache/debian/rules 2007-09-04 10:55:25 UTC (rev 1935) @@ -32,7 +32,7 @@ # The boilerplate linker flags won't allow varnish to compile :( # There are circular dependencies in the varnish libraries, but # the core developers have OK'ed that we don't check. - ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" --localstatedir=/var + ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" --localstatedir=/var/lib build: build-stamp Modified: trunk/varnish-cache/debian/varnish.default =================================================================== --- trunk/varnish-cache/debian/varnish.default 2007-09-04 08:04:48 UTC (rev 1934) +++ trunk/varnish-cache/debian/varnish.default 2007-09-04 10:55:25 UTC (rev 1935) @@ -7,6 +7,10 @@ # Maximum number of open files (for ulimit -n) NFILES=131072 +# Default varnish instance name is the local nodename. Can be overridden with +# the -n switch, to have more instances on a single server. +INSTANCE=$(uname -n) + # This file contains 4 alternatives, please use only one. ## Alternative 1, Minimal configuration, no VCL @@ -18,8 +22,7 @@ -T localhost:6082 \ -b localhost:8080 \ -u varnish -g varnish \ - -n /var/lib/varnish \ - -s file,/var/lib/varnish/varnish_storage.bin,1G" + -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G" ## Alternative 2, Configuration with VCL @@ -32,7 +35,7 @@ # -T localhost:6082 \ # -f /etc/varnish/default.vcl \ # -n /var/lib/varnish \ -# -s file,/var/lib/varnish/varnish_storage.bin,1G" +# -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G" ## Alternative 3, Advanced configuration @@ -65,7 +68,7 @@ # VARNISH_HOMEDIR=/var/lib/varnish # # # Cache file location -# VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin +# VARNISH_STORAGE_FILE=/var/lib/varnish/$INSTANCE/varnish_storage.bin # # # Cache file size: in bytes, optionally using k / M / G / T suffix, # # or in percentage of available disk space using the % suffix. @@ -84,7 +87,6 @@ # -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \ # -t ${VARNISH_TTL} \ # -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \ -# -n ${VARNISH_HOMEDIR} \ # -s ${VARNISH_STORAGE}" # Modified: trunk/varnish-cache/debian/varnish.varnishlog.init =================================================================== --- trunk/varnish-cache/debian/varnish.varnishlog.init 2007-09-04 08:04:48 UTC (rev 1934) +++ trunk/varnish-cache/debian/varnish.varnishlog.init 2007-09-04 10:55:25 UTC (rev 1935) @@ -24,7 +24,7 @@ test -x $DAEMON || exit 0 -DAEMON_OPTS="-a -n /var/lib/varnish -w ${LOGFILE} -D -P $PIDFILE" +DAEMON_OPTS="-a -w ${LOGFILE} -D -P $PIDFILE" case "$1" in start) From knutroy at projects.linpro.no Tue Sep 4 14:00:14 2007 From: knutroy at projects.linpro.no (knutroy at projects.linpro.no) Date: Tue, 4 Sep 2007 16:00:14 +0200 (CEST) Subject: r1936 - trunk/varnish-doc/en/inside-varnish Message-ID: <20070904140014.438161EC429@projects.linpro.no> Author: knutroy Date: 2007-09-04 16:00:13 +0200 (Tue, 04 Sep 2007) New Revision: 1936 Modified: trunk/varnish-doc/en/inside-varnish/article.xml Log: * Added information about test framework to "Inside Varnish". Modified: trunk/varnish-doc/en/inside-varnish/article.xml =================================================================== --- trunk/varnish-doc/en/inside-varnish/article.xml 2007-09-04 10:55:25 UTC (rev 1935) +++ trunk/varnish-doc/en/inside-varnish/article.xml 2007-09-04 14:00:13 UTC (rev 1936) @@ -335,7 +335,76 @@
The test framework - Lorem ipsum dolor sit amet + The test framework for Varnish consists of a library of Perl + modules organized under Varnish::Test. The + framework works by starting up a Varnish daemon process and + communicating with it while acting as both client and server. The + framework also operates the management command-line interface of + the Varnish daemon. This enables the framework to monitor all + external aspects of the daemon's behavior. + + The test framework contains a set of test-cases, each one + being a Perl module organized under + Varnish::Test::Case. The test-cases are run + sequentially, and each one typically focuses on a specific element + of Varnish's behavior or functionality. If the expectations of a + test-case is not fulfilled by the daemon being tested, the + test-case fails. Only when all test-cases succeeds, the Varnish + daemon may be considered healthy. + + Test-case development is an ongoing process, and anyone is + welcome to contribute test-cases which reveals erroneous behavior + in at least one revision of Varnish. + +
+ I/O-handling + + The test framework is based on a single + select(2)-driven loop, where all relevant + I/O channels are monitored. Activity on the I/O channels is + handled in an event-driven way, so the select loop also works as + an event loop. I/O-events are dispatched and optionally handled + by the running test-case which then decides what to do next. The + event loop may be paused, in order to drive the test processing + flow forward. +
+ +
+ Object structure + + The test framework employs an object-oriented approach and + uses (Perl) objects to represent instances of servers + (Varnish::Test::Server), clients + (Varnish::Test::Client), and HTTP messages + (HTTP::Message). + + Also, the Varnish daemon is represented by an object + (Varnish::Test::Varnish) taking care of the + daemon process which is spawned by the test framework process + before the tests start. + + Additionally, each test-case is represented by its own + object derived from the super-class + Varnish::Test::Case. + + In the center of all the objects stands the engine object + (Varnish::Test::Engine) which coordinates + the communication between the other objects by dispatching and + queuing events. The engine also sets up the + select(2)-loop, using an object instance of + the CPAN module IO::Multiplex. +
+ +
+ Further information + + Consult the POD-based in-source documentation for more + details if you like to get involved in developing test-cases or + improving the framework in general. In that case, prior + experience with Perl as well as a general understanding of + network programming using select(2), is + beneficial. +
From knutroy at projects.linpro.no Wed Sep 5 12:49:05 2007 From: knutroy at projects.linpro.no (knutroy at projects.linpro.no) Date: Wed, 5 Sep 2007 14:49:05 +0200 (CEST) Subject: r1937 - in trunk/varnish-tools/regress: . bin lib/Varnish lib/Varnish/Test lib/Varnish/Test/Server Message-ID: <20070905124905.B8A5A1EC3DD@projects.linpro.no> Author: knutroy Date: 2007-09-05 14:49:05 +0200 (Wed, 05 Sep 2007) New Revision: 1937 Added: trunk/varnish-tools/regress/lib/Varnish/Test/Server/ trunk/varnish-tools/regress/lib/Varnish/Test/Server/Connection.pm Removed: trunk/varnish-tools/regress/TODO Modified: trunk/varnish-tools/regress/ trunk/varnish-tools/regress/bin/varnish-regress.pl trunk/varnish-tools/regress/lib/Varnish/Test.pm trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm trunk/varnish-tools/regress/lib/Varnish/Test/Engine.pm trunk/varnish-tools/regress/lib/Varnish/Test/Report.pm trunk/varnish-tools/regress/lib/Varnish/Test/Server.pm trunk/varnish-tools/regress/lib/Varnish/Test/Varnish.pm Log: * Added POD. * Moved Varnish::Test::Server::Connection to its own module file. * Removed TODO which was not too exciting anyway. Property changes on: trunk/varnish-tools/regress ___________________________________________________________________ Name: svn:ignore + Makefile Deleted: trunk/varnish-tools/regress/TODO =================================================================== --- trunk/varnish-tools/regress/TODO 2007-09-04 14:00:13 UTC (rev 1936) +++ trunk/varnish-tools/regress/TODO 2007-09-05 12:49:05 UTC (rev 1937) @@ -1,2 +0,0 @@ -* Completely POD-ify Perl-code. -* Detect and act upon unexpected death of Varnish grandchild process. Modified: trunk/varnish-tools/regress/bin/varnish-regress.pl =================================================================== --- trunk/varnish-tools/regress/bin/varnish-regress.pl 2007-09-04 14:00:13 UTC (rev 1936) +++ trunk/varnish-tools/regress/bin/varnish-regress.pl 2007-09-05 12:49:05 UTC (rev 1937) @@ -32,6 +32,27 @@ varnish-regress.pl - run Varnish regression tests +=head1 DESCRIPTION + +This program is a thin wrapper around the L regression +test framework library. Using this library, regression tests are +performed on Varnish. + +The Varnish daemon (L) must be available in one of the +directories given by the "PATH" environment variable. + +By default, this program will run all test-cases available in the +regression test framework library, or the test-cases selected by name +as arguments on the command line. + +=head1 OUTPUT + +STDERR is used to continually report progress during testing. + +STDOUT is used to output a HTML-formatted report at the end of the +run, provided that execution does not abort prematurely for any +reason. + =cut use strict; @@ -96,5 +117,6 @@ =head1 SEE ALSO L +L =cut Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm 2007-09-04 14:00:13 UTC (rev 1936) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Case.pm 2007-09-05 12:49:05 UTC (rev 1937) @@ -34,14 +34,16 @@ =head1 DESCRIPTION -Varnish::Test::Case is meant to be the superclass of specific -test-case clases. It provides functionality to run a number of tests -defined in methods whose names start with "test", as well as keeping -track of the number of successful or failed tests. +Varnish::Test::Case is the superclass of test-case clases. It provides +functionality to run a number of tests defined in methods whose names +start with "test", as well as keeping track of the number of +successful or failed tests. It also provides default event handlers for "ev_client_response" and "ev_client_timeout", which are standard for most test-cases. +=head1 METHODS + =cut package Varnish::Test::Case; @@ -54,6 +56,12 @@ use POSIX qw(strftime); use Time::HiRes qw(gettimeofday tv_interval); +=head2 new + +Create a new Case object. + +=cut + sub new($$) { my ($this, $engine) = @_; my $class = ref($this) || $this; @@ -64,12 +72,25 @@ 'failed' => 0 }, $class); } +=head2 log + +Logging facility. + +=cut + sub log($$) { my ($self, $str) = @_; $self->{'engine'}->log($self, 'CAS: ', $str); } +=head2 init + +Test-case initialization which loads specified VCL into Varnish and +starts the Varnish daemon's child. + +=cut + sub init($) { my ($self) = @_; my ($code, $text); @@ -105,6 +126,13 @@ } } +=head2 fini + +Does the reverse of "init" by stopping the Varnish child and reverting +to a default VCL definition. + +=cut + sub fini($) { my ($self) = @_; @@ -127,6 +155,12 @@ } } +=head2 run + +Run test-case proper when everything is set up right. + +=cut + sub run($;@) { my ($self, @args) = @_; @@ -162,18 +196,37 @@ $self->{'stop'} = [gettimeofday()]; } +=head2 run_loop + +Proxy for Varnish::Test::Engine::run_loop. + +=cut + sub run_loop($@) { my ($self, @wait_for) = @_; return $self->{'engine'}->run_loop(@wait_for); } +=head2 new_client + +Creates a new Client object. + +=cut + sub new_client($) { my ($self) = @_; return Varnish::Test::Client->new($self->{'engine'}); } +=head2 results + +Report test-case results as a hashref suitable for Template +processing. + +=cut + sub results($) { my ($self) = @_; @@ -196,12 +249,22 @@ # Default event handlers # +=head1 DEFAULT EVENT HANDLER METHODS + +=head2 ev_client_response + +=cut + sub ev_client_response($$$) { my ($self, $client, $response) = @_; return $response; } +=head2 ev_client_timeout + +=cut + sub ev_client_timeout($$) { my ($self, $client) = @_; @@ -209,6 +272,10 @@ return $client; } +=head2 ev_server_request + +=cut + sub ev_server_request($$$$) { my ($self, $server, $connection, $request) = @_; @@ -237,6 +304,10 @@ $connection->send_response($response); } +=head2 ev_server_timeout + +=cut + sub ev_server_timeout($$) { my ($self, $srvconn) = @_; @@ -248,6 +319,16 @@ # Client utilities # +=head1 CLIENT UTILITY METHODS + +=head2 request + +Prepare and send an HTTP request using Client object given as +argument. Also, HTTP method, URI, HTTP headers and content are given +as argument. HTTP headers and content is optional. + +=cut + sub request($$$$;$$) { my ($self, $client, $method, $uri, $header, $content) = @_; @@ -279,18 +360,40 @@ return $self->{'cached_response'} = $resp; } +=head2 head + +Send "HEAD" request using "request" method above. Client object, URI, +and HTTP headers (optional) are given as arguments. + +=cut + sub head($$$;$) { my ($self, $client, $uri, $header) = @_; return $self->request($client, 'HEAD', $uri, $header); } +=head2 get + +Send "GET" request using "request" method above. Client object, URI, +and HTTP headers (optional) are given as arguments. + +=cut + sub get($$$;$) { my ($self, $client, $uri, $header) = @_; return $self->request($client, 'GET', $uri, $header); } +=head2 post + +Send "POST" request using "request" method above. Client object, URI, +and HTTP headers (optional) and body (optional) are given as +arguments. + +=cut + sub post($$$;$$) { my ($self, $client, $uri, $header, $body) = @_; @@ -299,6 +402,18 @@ return $self->request($client, 'POST', $uri, $header, $body); } +=head1 ASSERT METHODS + +The following assert methods take an optional response object is their +last argument. When this argument is not used, response object is +looked up in $self->{'cached_response'}. + +=head2 assert_code + +Assert a certain HTTP status code. + +=cut + sub assert_code($$;$) { my ($self, $code, $resp) = @_; @@ -308,6 +423,12 @@ unless $resp->code == $code; } +=head2 assert_ok + +Assert status "200 OK" using "assert_code" method above. + +=cut + sub assert_ok($;$) { my ($self, $resp) = @_; @@ -317,6 +438,12 @@ $self->assert_code(200, $resp); } +=head2 assert_xid + +Assert a certain XID in "X-Varnish" header. + +=cut + sub assert_xid($;$) { my ($self, $resp) = @_; @@ -329,6 +456,12 @@ unless ($resp->header('X-Varnish') =~ m/^\d+(?: \d+)?$/); } +=head2 assert_no_xid + +Assert absence of "X-Varnish" header. + +=cut + sub assert_no_xid($;$) { my ($self, $resp) = @_; @@ -339,6 +472,12 @@ if (defined($resp->header('X-Varnish'))); } +=head2 assert_cached + +Assert that "X-Varnish" header indicates that the response was cached. + +=cut + sub assert_cached($;$) { my ($self, $resp) = @_; @@ -350,6 +489,13 @@ unless $resp->header('X-Varnish') =~ /^\d+ \d+$/; } +=head2 assert_uncached + +Assert that "X-Varnish" header indicates that the response was NOT +cached. + +=cut + sub assert_uncached($;$) { my ($self, $resp) = @_; @@ -361,6 +507,13 @@ if $resp->header('X-Varnish') =~ /^\d+ \d+$/; } +=head2 assert_header + +Assert that a certain header (named by an argument) is present, and +optionally matches a given regular expression. + +=cut + sub assert_header($$;$$) { my ($self, $header, $re, $resp) = @_; @@ -375,6 +528,13 @@ } } +=head2 assert_body + +Assert presence of a HTTP body, optionally matching given regular +expression. + +=cut + sub assert_body($;$$) { my ($self, $re, $resp) = @_; @@ -389,6 +549,12 @@ } } +=head2 assert_no_body + +Assert absence of HTTP body. + +=cut + sub assert_no_body($;$) { my ($self, $resp) = @_; @@ -402,6 +568,14 @@ # Miscellaneous # +=head1 MISCELLANEOUS METHODS + +=head2 usleep + +Sleep for a given number of microseconds. + +=cut + sub usleep($$) { my ($self, $usec) = @_; @@ -409,3 +583,11 @@ } 1; + +=head1 SEE ALSO + +L +L +L + +=cut Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm 2007-09-04 14:00:13 UTC (rev 1936) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Client.pm 2007-09-05 12:49:05 UTC (rev 1937) @@ -44,9 +44,17 @@ use strict; use IO::Socket::INET; +use HTTP::Response; our $id_seq = 1; +=head2 new + +Called by test-cases to create a new Client object to be used to send +HTTP-requests. + +=cut + sub new($$) { my ($this, $engine, $attrs) = @_; my $class = ref($this) || $this; @@ -62,18 +70,36 @@ return $self; } +=head2 log + +Logging facility. + +=cut + sub log($$;$) { my ($self, $str, $extra_prefix) = @_; $self->{'engine'}->log($self, sprintf('CLI[%d]: ', $self->{'id'}) . ($extra_prefix || ''), $str); } +=head2 logf + +Logging facility using a formatting string as first argument. + +=cut + sub logf($$;@) { my ($self, $fmt, @args) = @_; $self->{'engine'}->log($self, sprintf('CLI[%d]: ', $self->{'id'}), sprintf($fmt, @args)); } +=head2 send_request + +Called by test-cases to send HTTP requests out on a connection. + +=cut + sub send_request($$;$) { my ($self, $request, $timeout) = @_; @@ -93,6 +119,13 @@ $self->logf("%s %s %s", $request->method(), $request->uri(), $request->protocol()); } +=head2 got_response + +Called by mux_input and mux_eof to dispatch event related to received +HTTP response. + +=cut + sub got_response($$) { my ($self, $response) = @_; @@ -101,6 +134,13 @@ $self->{'engine'}->ev_client_response($self, $response); } +=head2 shutdown + +Called by test-cases to shutdown client including termination of HTTP +connection. + +=cut + sub shutdown($) { my ($self) = @_; @@ -119,6 +159,17 @@ } } +=head1 IO::MULTIPLEX CALLBACKS + +=head2 mux_input + +Called by L when new input is received on an associated +file-handle. Complete HTTP messages are extracted from the input +buffer, while any incomplete message is left in the buffer, awaiting +more input (mux_input) or EOF (mux_eof). + +=cut + sub mux_input($$$$) { my ($self, $mux, $fh, $data) = @_; @@ -197,6 +248,13 @@ # nothing at all or a partial HTTP message. } +=head2 mux_eof + +Called by L when connection is being shutdown by +foreign host. + +=cut + sub mux_eof($$$$) { my ($self, $mux, $fh, $data) = @_; @@ -210,6 +268,13 @@ } } +=head2 mux_timeout + +Called by L when a specified timeout has been reached +on an associated file-handle. + +=cut + sub mux_timeout($$$) { my ($self, $mux, $fh) = @_; @@ -217,6 +282,13 @@ $self->{'engine'}->ev_client_timeout($self); } +=head2 mux_close + +Called by L when an associated file-handle has been +closed. + +=cut + sub mux_close($$) { my ($self, $mux, $fh) = @_; @@ -224,3 +296,10 @@ } 1; + +=head1 SEE ALSO + +L +L + +=cut Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Engine.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Engine.pm 2007-09-04 14:00:13 UTC (rev 1936) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Engine.pm 2007-09-05 12:49:05 UTC (rev 1937) @@ -34,15 +34,15 @@ =head1 DESCRIPTION -Varnish::Test::Engine is primarily a wrapper around a -IO::Multiplex-based select-loop which monitors activity on -client-side, server-side and Varnish's I/O-channels. On startup, it -automatically creates an associated Server object and a Varnish -objects whoses sockets/filehandles are registered in the -IO::Multiplex-object. +An L object is primarily a wrapper +around a L-based L object which monitors +activity on relevant sockets and file handles. -Additionally, event dispatching is performed by the AUTOLOAD method. +Additionally, an Engine object performs event dispatching and queuing, +which are handled by an AUTOLOAD method. +=head1 METHODS + =cut package Varnish::Test::Engine; @@ -53,6 +53,16 @@ use Varnish::Test::Varnish; use IO::Multiplex; +=head2 new + +Used by main program to create a new Varnish::Test::Engine object +which starts up a L and +L object, so test-cases are ready to be run. +Also an object is started to handle the central +select(2) mechanism. + +=cut + sub new($$;%) { my ($this, $controller, %config) = @_; my $class = ref($this) || $this; @@ -83,6 +93,12 @@ return $self; } +=head2 log + +Logging facility. + +=cut + sub log($$$) { my ($self, $object, $prefix, $str) = @_; @@ -92,6 +108,14 @@ print STDERR $str; } +=head2 run_loop + +Enter event loop based on IO::Multiplex::loop. Also, handles +dispatching of "wait-for" or "die" events which are returned to the +caller. + +=cut + sub run_loop($@) { my ($self, @wait_for) = @_; @@ -145,6 +169,13 @@ return undef; } +=head2 shutdown + +Shutdown Engine by shutting down Server, Varnish, and IO::Multiplex +objects. + +=cut + sub shutdown($) { my ($self) = @_; @@ -158,7 +189,17 @@ } } -sub AUTOLOAD ($;@) { +=head2 AUTOLOAD + +Event dispatch mechanism. When an I/O event occurs, it goes through +this method because $engine->ev_* resolves to this one. It will the +look for a method of the same name in the running test-case object. +Queuing and end-loop signaling is done when a "wait-for" or "die" +event occurs. + +=cut + +sub AUTOLOAD($;@) { my ($self, @args) = @_; (my $event = our $AUTOLOAD) =~ s/.*://; @@ -209,3 +250,11 @@ } 1; + +=head1 SEE ALSO + +L +L +L + +=cut Modified: trunk/varnish-tools/regress/lib/Varnish/Test/Report.pm =================================================================== --- trunk/varnish-tools/regress/lib/Varnish/Test/Report.pm 2007-09-04 14:00:13 UTC (rev 1936) +++ trunk/varnish-tools/regress/lib/Varnish/Test/Report.pm 2007-09-05 12:49:05 UTC (rev 1937) @@ -28,12 +28,32 @@ # $Id$ # +=head1 NAME + +Varnish::Test::Report + +=head1 DESCRIPTION + +Produce test result reports in different formats. Currently, HTML +format is supported via a subclass found in +Varnish::Test::Report::HTML. + +=head1 METHODS + +=cut + package Varnish::Test::Report; use strict; use Template; +=head2 new + +Create a new Report object. + +=cut + sub new($) { my ($this) = @_; my $class = ref($this) || $this; @@ -51,6 +71,12 @@ return $self; } +=head2 new + +Generate report. + +=cut + sub run($@) { my ($self, @cases) = @_; @@ -75,3 +101,9 @@ } 1; + +=head1 SEE ALSO + +L