NAME

HTTP::WebTest::Plugin::Apache - Plugin for local web file tests

SYNOPSIS

Not Applicable

DESCRIPTION

This plugin adds support for local web file test mode to HTTP::WebTest. In this mode Apache is started on a private/dynamic port with a configuration file in a temporary directory and HTTP::WebTest runs its tests against local web files using this temporary local instance of Apache.

Data flow diagram for HTTP::WebTest using a local web file:

--------------           ---------------------
|            |           |                   |
| Input      |           |  Web page code    |
| parameters |           |  (Perl/HTML/etc.) |
|            |           |                   |
--------------           ---------------------
    |                              |
    |  -----------------------------
    |  |
    V  V                ------------------------
-------------           |                      |
|           |---------->| Temporary Apache     |
|  WebTest  |           | directories (htdocs, |
|           |<----------| conf, logs)          |
-------------           |                      |
    |  ^                ------------------------
    |  |                        |    ^
    V  |                        V    |
------------             ----------------------
|          |   request   |                    |
|   HTTP   |------------>| Temporary local    |
|   user   |             | instance of Apache |
|   agent  |<------------|                    |
|          |   response  ----------------------
------------

EXAMPLE

The parameters below specify a test of a local file containing Perl code using the Apache::ASP module. The includes.htm file requires five include files and two Perl modules, which are copied using the include_file_path parameter.

apache_exec = /usr/sbin/apache
ignore_case = yes
include_file_path = ( footer.inc => htdocs/apps/myapp/inc
                      header.inc => htdocs/apps/myapp/inc
                      head.inc   => htdocs/apps/myapp/inc
                      go.script  => htdocs/shared/includes
                      go.include => htdocs/shared/includes
                      ../utils/DBconn.pm  => lib/perl/utils
                      ../utils/Window.pm  => lib/perl/utils
                    )

test_name = includes.htm
    file_path = ( includes.htm => apps/myapp )
    min_bytes = 33000
    max_bytes = 35000
    text_require = ( input type=hidden name=control value= )
    text_forbid  = ( Premature end of script headers
                     an error occurred while processing this directive
                   )
end_test

APACHE DIRECTORY AND FILES

A tree of directories with templates of Apache config files is required to run local web file tests.

The apache_dir parameter must be set to the name of a directory that contains the subdirectories conf, logs and htdocs. The conf subdirectory must contain a file named httpd.conf-dist. The htdocs subdirectory must contain a subdirectory named webtest that contains a file named is_apache_responding.html. If your installation of Apache has the Perl module Apache::ASP configured, the apache_dir directory must also contain a subdirectory named asp_tmp.

The file httpd.conf-dist is used as template for the Apache config file. It contains tags which are replaced with the values needed by the Apache server that the program starts at runtime.

  • Please_do_not_modify_PORT

    To be replaced with port number on which Apache runs during tests.

  • Please_do_not_modify_HOST_NAME

    To be replace with Apache host name.

  • Please_do_not_modify_SERVER_ROOT

    To be replaced with Apache server root.

  • Please_do_not_modify_LOG_LEVEL

    To be replaced with Apache log level.

TEST PARAMETERS

apache_dir

GLOBAL PARAMETER

Absolute or relative path name of directory containing Apache files. See the APACHE DIRECTORY AND FILES section. This parameter is ignored unless the file_path parameter is specified.

Default value

/usr/local/etc/http-webtest

apache_exec

GLOBAL PARAMETER

Absolute or relative path name of Apache executable. This command can be in your $PATH. This parameter is ignored unless the file_path parameter is specified.

Default value

/usr/sbin/apache

apache_loglevel

GLOBAL PARAMETER

Apache logging level. If you use a level less than warn (i.e., debug, info, or notice), the program may generate irrelevant errors. This parameter is ignored unless the file_path parameter is specified. See also the ignore_error_log parameter.

Allowed values

debug, info, notice, warn, error, crit, alert, emerg

Default value

warn

apache_max_wait

GLOBAL PARAMETER

Maximum number of seconds to wait for Apache to start. This parameter is ignored unless the file_path parameter is specified.

Default value

60

apache_options

GLOBAL PARAMETER

Additional Apache command line options. Many of the options cause Apache to exit immediately after starting, so the web page tests will not run. This parameter is ignored unless the file_path parameter is specified.

Allowed values

See Apache documentation

error_log

GLOBAL PARAMETER

The pathname of a local web server error log. The module counts the number of lines in the error log before and after each request. If the number of lines increases, an error is counted and the additional lines are listed in the report. This argument should be used only when the local web server is running in single-process mode. Otherwise, requests generated by other processes/users may add lines to the error log that are not related to the requests generated by this module. See also parameter ignore_error_log.

file_path

If HTTP::WebTest encounters parameter file_path it switches in local web file test mode. In local web file test mode it launches an instance of Apache daemon, copies local test file(s) under DocumentRoot of this Apache and performs test checks against it.

Allowed values

Two-element list. First element is the file to test, either an absolute or a relative pathname. Second element is the subdirectory pathname, relative to the Apache htdocs directory, to copy the file to. The copied file will have the same basename as the first element and the relative pathname of the second element. To copy the file directly to the htdocs directory, use a pathname of . or ./..

ignore_error_log

Option to ignore any errors found in the Apache error log. The default behavior is to flag an error if the fetch causes any errors to be added to the error log and echo the errors to the program output. This check is available only if error_log parameter is specified. See also the apache_loglevel parameter.

Allowed values

yes, no

Default value

no

include_file_path

List with an even number of elements. Odd-numbered elements are files to copy to the the temporary Apache directory before running the tests. These files can be specified using either an absolute or a relative pathname. Even-numbered elements are the subdirectory pathname, relative to the Apache ServerRoot directory, to copy the corresponding file to. The copied file will have the same basename as the odd-numbered element and the relative pathname of the corresponding even-numbered element. To copy the file directly to the ServerRoot directory, use a pathname of . or ./..

For example:

include_file_path = (/home/tester/inc/header.inc => htdocs/includes)

will copy the file to htdocs/includes/header.inc.

This parameter is also useful for adding Perl modules that are needed by the web page specified by the file_path parameter. For example:

include_file_path = ( ../apps/myapp/DBconn.pm => lib/perl/apps )

will copy the Perl module DBconn.pm to a directory that is in the Perl @INC array.

RESTRICTIONS / BUGS

Local file test mode unlikely to work on Win32 systems (at least it have never been tested by authors there and nobody confirmed it to work).

AUTHORS

Richard Anderson <richard@richard-anderson.org> wrote HTTP::WebTest 1.xx, using some ideas from the CPAN Monkeywrench module.

Ilya Martynov <ilya@martynov.org> implemented the plug-in concept, the extended API and completely rewrote HTTP::WebTest.

Later this plugin module was removed from HTTP::WebTest distribution and released separately.

Please don't email authors directly. Use the SourceForge HTTP::WebTest mail list (see SUPPORT, next section).

SUPPORT

Please email bug reports, suggestions, questions, etc. to the SourceForge HTTP::WebTest maillist. You can sign up at http://lists.sourceforge.net/lists/listinfo/http-webtest-general . The email address is http-webtest-general@lists.sourceforge.net.

COPYRIGHT

Copyright (c) 2000-2001 Richard Anderson. All rights reserved.

Copyright (c) 2001-2002 Ilya Martynov. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

HTTP::WebTest

HTTP::WebTest::API

HTTP::WebTest::Plugin

HTTP::WebTest::Plugins