Revision: 2175
http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2175&view=rev
Author: dermoth
Date: 2009-03-20 05:22:16 +0000 (Fri, 20 Mar 2009)
Log Message:
-----------
tests/check_http.t: Add various timeout-related tests
From: Thomas Guyot-Sionnest <[email protected]>
Modified Paths:
--------------
nagiosplug/trunk/plugins/tests/check_http.t
Modified: nagiosplug/trunk/plugins/tests/check_http.t
===================================================================
--- nagiosplug/trunk/plugins/tests/check_http.t 2009-03-19 21:06:14 UTC (rev 2174)
+++ nagiosplug/trunk/plugins/tests/check_http.t 2009-03-20 05:22:16 UTC (rev 2175)
@@ -37,6 +37,9 @@
my $port_https = $port_http + 1;
my $port_https_expired = $port_http + 2;
+# This array keeps sockets around for implementing timeouts
+my @persist;
+
# Start up all servers
my @pids;
my $pid = fork();
@@ -93,7 +96,7 @@
# Run the same server on http and https
sub run_server {
my $d = shift;
- while (my $c = $d->accept ) {
+ MAINLOOP: while (my $c = $d->accept ) {
while (my $r = $c->get_request) {
if ($r->method eq "GET" and $r->url->path =~ m^/statuscode/(\d+)^) {
$c->send_basic_header($1);
@@ -121,10 +124,19 @@
$c->send_response($r->method.":".$r->content);
} elsif ($r->url->path eq "/redirect") {
$c->send_redirect( "/redirect2" );
+ } elsif ($r->url->path eq "/redir_external") {
+ $c->send_redirect( "http://169.254.169.254/redirect2" );
} elsif ($r->url->path eq "/redirect2") {
$c->send_basic_header;
$c->send_crlf;
$c->send_response("redirected");
+ } elsif ($r->url->path eq "/redir_timeout") {
+ $c->send_redirect( "/timeout" );
+ } elsif ($r->url->path eq "/timeout") {
+ # Keep $c from being destroyed, but prevent severe leaks
+ unshift @persist, $c;
+ delete($persist[1000]);
+ next MAINLOOP;
} else {
$c->send_error(RC_FORBIDDEN);
}
@@ -141,11 +153,11 @@
if ($ARGV[0] && $ARGV[0] eq "-d") {
while (1) {
- `sleep 100`
+ sleep 100;
}
}
-my $common_tests = 51;
+my $common_tests = 55;
my $ssl_only_tests = 6;
if (-x "./check_http") {
plan tests => $common_tests * 2 + $ssl_only_tests;
@@ -315,4 +327,40 @@
is( $result->return_code, 0, $cmd);
like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
+ # These tests may block
+ print "ALRM\n";
+
+ $cmd = "$command -f sticky -u /redir_external -t 5";
+ eval {
+ local $SIG{ALRM} = sub { die "alarm\n" };
+ alarm(2);
+ $result = NPTest->testCmd( $cmd );
+ alarm(0); };
+ isnt( $@, "alarm\n", $cmd);
+
+ # Will this one work everywhere???
+ $cmd = "$command -f follow -u /redir_external -t 5";
+ eval {
+ local $SIG{ALRM} = sub { die "alarm\n" };
+ alarm(2);
+ $result = NPTest->testCmd( $cmd );
+ alarm(0); };
+ is( $@, "alarm\n", $cmd);
+
+ $cmd = "$command -u /timeout -t 5";
+ eval {
+ local $SIG{ALRM} = sub { die "alarm\n" };
+ alarm(2);
+ $result = NPTest->testCmd( $cmd );
+ alarm(0); };
+ is( $@, "alarm\n", $cmd);
+
+ $cmd = "$command -f follow -u /redir_timeout -t 2";
+ eval {
+ local $SIG{ALRM} = sub { die "alarm\n" };
+ alarm(5);
+ $result = NPTest->testCmd( $cmd );
+ alarm(0); };
+ isnt( $@, "alarm\n", $cmd);
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.