Apache-Test
view release on metacpan or search on metacpan
turn on -v and LWP trace (1 is the default) mode in Apache::TestRequest
% t/TEST -d lwp t/modules/access.t
turn on -v and LWP trace mode (level 2) in Apache::TestRequest
% t/TEST -d lwp=2 t/modules/access.t
run all tests through mod_ssl
% t/TEST -ssl
run all tests with HTTP/1.1 (keep alive) requests
% t/TEST -http11 -ssl
run all tests with HTTP/1.1 (keep alive) requests through mod_ssl
% t/TEST -http11
run all tests through mod_proxy
% t/TEST -proxy
##################
# Stress testing #
##################
lib/Apache/TestClient.pm view on Meta::CPAN
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package Apache::TestClient;
#this module provides some fallback for when libwww-perl is not installed
#it is by no means an LWP replacement, just enough for very simple requests
#this module does not and will never support certain features such as:
#file upload, http/1.1 (byteranges, keepalive, etc.), following redirects,
#authentication, GET body callbacks, SSL, etc.
use strict;
use warnings FATAL => 'all';
use Apache::TestRequest ();
my $CRLF = "\015\012";
sub request {
lib/Apache/TestConfig.pm view on Meta::CPAN
if ($vars->{proxy} =~ /^on$/i) {
unless ($vars->{maxclients_preset}) {
$vars->{minclients}++;
$vars->{maxclients}++;
$vars->{maxspare}++;
$vars->{startserversthreadedmpm} ++;
$vars->{minclientsthreadedmpm} += $vars->{threadsperchild};
$vars->{maxclientsthreadedmpm} += $vars->{threadsperchild};
$vars->{maxsparethreadedmpm} += $vars->{threadsperchild};
#In addition allow for some backend processes
#in keep-alive state. For threaded MPMs we
#already should be fine.
$vars->{maxclients} += 3;
}
$vars->{proxy} = $self->{vhosts}->{'mod_proxy'}->{hostport};
return $vars->{proxy};
}
return undef;
}
lib/Apache/TestConfig.pm view on Meta::CPAN
if ($vars->{proxyssl_url}) {
unless ($vars->{maxclients_preset}) {
$vars->{minclients}++;
$vars->{maxclients}++;
$vars->{maxspare}++;
$vars->{startserversthreadedmpm} ++;
$vars->{minclientsthreadedmpm} += $vars->{threadsperchild};
$vars->{maxclientsthreadedmpm} += $vars->{threadsperchild};
$vars->{maxsparethreadedmpm} += $vars->{threadsperchild};
#In addition allow for some backend processes
#in keep-alive state. For threaded MPMs we
#already should be fine.
$vars->{maxclients} += 3;
}
}
}
}
sub extra_conf_files_needing_update {
my $self = shift;
lib/Apache/TestRequest.pm view on Meta::CPAN
} else {
# Set our internal flag.
$REDIR = 1;
}
} else {
# Make sure our internal flag is false if there's no LWP.
$REDIR = $have_lwp ? undef : 0;
}
}
$args->{keep_alive} ||= $ENV{APACHE_TEST_HTTP11};
if ($args->{keep_alive}) {
install_http11();
eval {
require LWP::Protocol::https; #https10 is the default
LWP::Protocol::implementor('https', 'LWP::Protocol::https');
};
}
# in LWP 6, verify_hostname defaults to on, so SSL_ca_file
# needs to be set accordingly
if ($have_lwp and $LWP::VERSION >= 6.0 and not exists $args->{ssl_opts}->{SSL_ca_file}) {
lib/Apache/TestRequest.pm view on Meta::CPAN
eval { $UA ||= __PACKAGE__->new(%$args); };
}
sub user_agent_request_num {
my $res = shift;
$res->header('Client-Request-Num') || #lwp 5.60
$res->header('Client-Response-Num'); #lwp 5.62+
}
sub user_agent_keepalive {
$ENV{APACHE_TEST_HTTP11} = shift;
}
sub do_request {
my($ua, $method, $url, $callback) = @_;
my $r = HTTP::Request->new($method, resolve_url($url));
my $response = $ua->request($r, $callback);
lwp_trace($response);
}
lib/Apache/TestRequest.pm view on Meta::CPAN
$conn_opts->{SSL_ca_file} = $cafile;
}
#want news: urls to work with the LWP shortcuts
#but cant find a clean way to override the default nntp port
#by brute force we trick Net::NTTP into calling FixupNNTP::new
#instead of IO::Socket::INET::new, we fixup the args then forward
#to IO::Socket::INET::new
#also want KeepAlive on for Net::HTTP
#XXX libwww-perl 5.53_xx has: LWP::UserAgent->new(keep_alive => 1);
sub install_net_socket_new {
my($module, $code) = @_;
return unless Apache::Test::have_module($module);
no strict 'refs';
my $new;
my $isa = \@{"$module\::ISA"};
lib/Apache/TestRequest.pm view on Meta::CPAN
The C<user_agent()> function only creates the internal
C<LWP::UserAgent> object the first time it is called. Since this
function is called internally by C<Apache::TestRequest>, you should
always use the C<reset> parameter to force it to create a new global
C<LWP::UserAgent> Object:
Apache::TestRequest::user_agent(reset => 1, %params);
C<user_agent()> differs from C<< LWP::UserAgent->new >> in two
additional ways. First, it supports an additional parameter,
C<keep_alive>, which enables connection persistence, where the same
connection is used to process multiple requests (and, according to the
C<L<LWP::UserAgent|LWP::UserAgent>> documentation, has the effect of
loading and enabling the new experimental HTTP/1.1 protocol module).
And finally, the semantics of the C<requests_redirectable> parameter is
different than for C<LWP::UserAgent> in that you can pass it a boolean
value as well as an array for C<LWP::UserAgent>. To force
C<Apache::TestRequest> not to follow redirects in any of its convenience
functions, pass a false value to C<requests_redirectable>:
lib/Apache/TestRun.pm view on Meta::CPAN
'clean' => 'remove all generated test files',
'help' => 'display this message',
'bugreport' => 'print the hint how to report problems',
'preamble' => 'config to add at the beginning of httpd.conf',
'postamble' => 'config to add at the end of httpd.conf',
'ping[=block]' => 'test if server is running or port in use',
'debug[=name]' => 'start server under debugger name (gdb, ddd, etc.)',
'breakpoint=bp' => 'set breakpoints (multiply bp can be set)',
'header' => "add headers to (" .
join('|', @request_opts) . ") request",
'http11' => 'run all tests with HTTP/1.1 (keep alive) requests',
'ssl' => 'run tests through ssl',
'proxy' => 'proxy requests (default proxy is localhost)',
'trace=T' => 'change tracing default to: warning, notice, ' .
'info, debug, ...',
'one-process' => 'run the server in single process mode',
(map { $_, "\U$_\E url" } @request_opts),
);
sub fixup {
#make sure we use an absolute path to perl
( run in 1.410 second using v1.01-cache-2.11-cpan-df04353d9ac )