Regression Testing with Apache httpd

I wanted to jot down some notes on how to use the Apache httpd test suite, since people occasionally ask me how to test httpd.

The first step to using the test suite is to get a build of httpd with all the right modules enabled.  There a handful of extra modules which are useful in the test suite, but are not usually built with httpd .  If you are building httpd fresh from a source tarball this is as simple as getting the configure options correct.  Here’s what I use:

$ ./configure \
      "--enable-mods-shared=all ssl proxy rewrite dav reallyall bucketeer cache \
       disk_cache case_filter case_filter_in echo" \
      "--enable-load-all-modules"

The extra modules we’re after here are mod_case_filter, mod_case_filter_in, mod_bucketeer and mod_echo.  Those modules are virtually useless in a production server so you’ll never normally want to build them, but they provide some neat filters which are used in the test suite.   (With httpd 2.4.x it is only necessary to specific the  “reallyall” argument to –enable-mods-shared, but the above line does the right thing with all vintages of 2.x)

If you are trying to test a binary distribution of httpd (RPM, .deb etc) then you can grab the .c files for those modules from the Subversion repository and build them by hand.  For example:

$ wget http://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x/modules/echo/mod_echo.c
$ apxs -cia mod_echo.c

The extra modules must be built, installed and enabled in the httpd configuration, otherwise the Perl harness doesn’t know they exist.  If you want to test mod_ssl, you also need to make sure you have the right Perl modules to enable SSL support in LWP.  This means Crypt::SSLeay and with recent LWPs, LWP::Protocol::https.

Once you’re all set, you can grab the test suite from SVN and run it – note this must be done as a non-root user, since it’s a pain to get working as root:

$ svn co https://svn.apache.org/repos/asf/httpd/test/framework/trunk perl-harness
$ cd perl-harness
$ perl Makefile.PL -apxs /usr/bin/apxs
...
$ make
...
$ ./t/TEST

Use the appropriate apxs binary from the httpd install you wish to test.

The coverage of the test suite is not too bad; we have an ever-increasing number of regression tests for specific bugs and new features added during 2.2 and 2.4 development.   Adding new tests is easy, the test suite uses Apache::Test – I’ll do another post sometime showing how easy it is to create regression tests even if (like me) you are not particularly comfortable writing Perl.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s