TAP::Harness::Remote - Run tests on a remote server farm
prove -l --state=save,slow --harness TAP::Harness::Remote t/*.t
Sometimes you want to run tests on a remote testing machine, rather than your local development box.
TAP::Harness::Remote allows you so reproduce entire directory trees on a remote server via
rsync, and spawn the tests remotely. It also supports round-robin distribution of tests across multiple remote testing machines.
TAP::Harness::Remote synchronizes local directories to the remote testing server. All tests that you wish to run remotely must be somewhere within these "local testing directories." You should configure this set by creating or editing your ~/.remote_test file:
--- ssh: /usr/bin/ssh local: - /path/to/local/testing/root/ - /path/to/another/testing/root/ user: username host: remote.testing.host.example.com root: /where/to/place/local/root/on/remote/ perl: /usr/bin/perl master: 1 ssh_args: - -x - -S - '~/.ssh/master-%r@%h:%p' rsync_args: - -C - --exclude - blib env: FOO: bar
See "CONFIGURATION AND ENVIRONMENT" for more details on the individual configuration options.
Once your ~/.remote_test is configured, you can run your tests remotely, using:
prove -l --harness TAP::Harness::Remote t/*.t
Any paths in
@INC which point inside your local testing roots are rewritten to point to the equivilent path on the remote host. This is especially useful if you are testing a number of inter-related modules; by placing all of them all as local testing roots, and adding all of their
lib/ paths to your
PERL5LIB, you can ensure that the remote machine always tests your combination of the modules, not whichever versions are installed on the remote host.
If you have a farm of remote hosts, you may change the
host configuration variable to be an array reference of hostnames. Tests will be distributed in a round-robin manner across the hosts. Each host will run as many tests in parallel as you specified with
Especially when running tests in parallel, it is highly suggested that you use the standard TAP::Harness
--state=save,slow option, as this ensures that the slowest tests will run first, reducing your overall test run time.
Overrides "new" in TAP::Harness to load the local configuration, and add the necessary hooks for when tests are actually run.
Returns the path to the configuration file; this is usually
Returns, as a hashref, the default configuration. See "CONFIGURATION".
Loads and canonicalizes the configuration. Writes and uses the default configuration ("default_config") if the file does not exist.
Returns the configuration value set fo the given
Returns a valid
user@host string; host is taken to be the first known host, unless provided.
Starts the ssh master connections, if support for them is enabled. Otherwise, does nothing. See the man page for
ssh -M for more information about master connections.
Starts the openssh master connections if need be (see "start_masters"), then "rsync"'s over the local roots. Additionally, stores a rewritten PERL5LIB path such that any directories which point into the local root are included in the remote PERL5LIB as well.
Sends all local roots to the remote hosts, one at a time, using
Rewrites the given local
PATH into the remote path on the testing server. Returns undef if the
PATH isn't inside any of the configured local paths.
Tears down the ssh master connections, if they were started.
Changes the switches around, such that the remote perl is called, via ssh. This code is called once per test file.
Configuration is done via the file
~/.remote_test, which is a YAML file. Valid keys are:
The username to use on the remote connection.
The host to connect to. If this is an array reference, tests will be distributed, round-robin fashion, across all of the hosts. This does also incur the overhead of rsync'ing to each host.
The remote testing root. This is the place where the local roots will be
The local testing roots. This can be either an array reference of multiple roots, or a single string. Files under each of these directories will be
rsync'd to the remote server. All tests to be run remotely must be within these roots.
The path to the
perl binary on the remote host.
The path to the local
Either a string or an array reference of arguments to pass to ssh. Suggested defaults include
If a true value is given for this, will attempt to use OpenSSH master connections to reduce the overhead of making repeated connections to the remote host.
Either a string or an array reference of arguments to pass to rsync. You can use this, for say
--exclude blib. The arguments
-avz --delete are fixed, and then any
rsync_args are appended.
-C is generally a useful and correct option, and is the default when creating new .remote_test files. See rsync(1) for more details.
A hash reference of environment variable names and values, to be used on the remote host.
A recent enough TAP::Harness build; 3.03 or later should suffice. Working copies of OpenSSH and rsync.
Aborting tests using
^C may leave dangling processes on the remote host.
Please report any bugs or feature requests to
firstname.lastname@example.org, or through the web interface at http://rt.cpan.org.
Copyright (c) 2007-2008, Best Practical Solutions, LLC. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.