diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-03-21 02:32:50 -0400 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-03-21 02:32:50 -0400 |
commit | e7cdcfee2a6025b41f67ead5020df3965ef05a98 (patch) | |
tree | aa9e7122e32e952379fac068e773d29941db21d3 /plugins/tests/check_http.t | |
parent | 3fa3707b5752adfe348e101a194635cc11ace2af (diff) | |
download | monitoring-plugins-e7cdcfee2a6025b41f67ead5020df3965ef05a98.tar.gz |
check_http: add --onredirect=stickyport - also follow the same port
Diffstat (limited to 'plugins/tests/check_http.t')
-rwxr-xr-x | plugins/tests/check_http.t | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index b0df960c..88b77d3b 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
@@ -125,11 +125,11 @@ sub run_server { | |||
125 | } elsif ($r->url->path eq "/redirect") { | 125 | } elsif ($r->url->path eq "/redirect") { |
126 | $c->send_redirect( "/redirect2" ); | 126 | $c->send_redirect( "/redirect2" ); |
127 | } elsif ($r->url->path eq "/redir_external") { | 127 | } elsif ($r->url->path eq "/redir_external") { |
128 | $c->send_redirect( "http://169.254.169.254/redirect2" ); | 128 | $c->send_redirect(($d->isa('HTTP::Daemon::SSL') ? "https" : "http") . "://169.254.169.254/redirect2" ); |
129 | } elsif ($r->url->path eq "/redirect2") { | 129 | } elsif ($r->url->path eq "/redirect2") { |
130 | $c->send_basic_header; | 130 | $c->send_basic_header; |
131 | $c->send_crlf; | 131 | $c->send_crlf; |
132 | $c->send_response("redirected"); | 132 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' )); |
133 | } elsif ($r->url->path eq "/redir_timeout") { | 133 | } elsif ($r->url->path eq "/redir_timeout") { |
134 | $c->send_redirect( "/timeout" ); | 134 | $c->send_redirect( "/timeout" ); |
135 | } elsif ($r->url->path eq "/timeout") { | 135 | } elsif ($r->url->path eq "/timeout") { |
@@ -157,7 +157,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | my $common_tests = 55; | 160 | my $common_tests = 62; |
161 | my $ssl_only_tests = 6; | 161 | my $ssl_only_tests = 6; |
162 | if (-x "./check_http") { | 162 | if (-x "./check_http") { |
163 | plan tests => $common_tests * 2 + $ssl_only_tests; | 163 | plan tests => $common_tests * 2 + $ssl_only_tests; |
@@ -181,7 +181,6 @@ SKIP: { | |||
181 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); | 181 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); |
182 | like( $result->output, '/WARNING - Certificate expires in \d+ day\(s\) \(03/03/2019 21:41\)./', "output ok" ); | 182 | like( $result->output, '/WARNING - Certificate expires in \d+ day\(s\) \(03/03/2019 21:41\)./', "output ok" ); |
183 | 183 | ||
184 | |||
185 | # Expired cert tests | 184 | # Expired cert tests |
186 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); | 185 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); |
187 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); | 186 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); |
@@ -316,7 +315,6 @@ sub run_common_tests { | |||
316 | is( $result->return_code, 0, $cmd); | 315 | is( $result->return_code, 0, $cmd); |
317 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | 316 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); |
318 | 317 | ||
319 | |||
320 | $cmd = "$command -u /redirect -k 'follow: me'"; | 318 | $cmd = "$command -u /redirect -k 'follow: me'"; |
321 | $result = NPTest->testCmd( $cmd ); | 319 | $result = NPTest->testCmd( $cmd ); |
322 | is( $result->return_code, 0, $cmd); | 320 | is( $result->return_code, 0, $cmd); |
@@ -327,25 +325,50 @@ sub run_common_tests { | |||
327 | is( $result->return_code, 0, $cmd); | 325 | is( $result->return_code, 0, $cmd); |
328 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | 326 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); |
329 | 327 | ||
328 | $cmd = "$command -f sticky -u /redirect -k 'follow: me'"; | ||
329 | $result = NPTest->testCmd( $cmd ); | ||
330 | is( $result->return_code, 0, $cmd); | ||
331 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
332 | |||
333 | $cmd = "$command -f stickyport -u /redirect -k 'follow: me'"; | ||
334 | $result = NPTest->testCmd( $cmd ); | ||
335 | is( $result->return_code, 0, $cmd); | ||
336 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
337 | |||
330 | # These tests may block | 338 | # These tests may block |
331 | print "ALRM\n"; | 339 | print "ALRM\n"; |
332 | 340 | ||
333 | $cmd = "$command -f sticky -u /redir_external -t 5"; | 341 | # stickyport - on full urlS port is set back to 80 otherwise |
342 | $cmd = "$command -f stickyport -u /redir_external -t 5 -s redirected"; | ||
334 | eval { | 343 | eval { |
335 | local $SIG{ALRM} = sub { die "alarm\n" }; | 344 | local $SIG{ALRM} = sub { die "alarm\n" }; |
336 | alarm(2); | 345 | alarm(2); |
337 | $result = NPTest->testCmd( $cmd ); | 346 | $result = NPTest->testCmd( $cmd ); |
338 | alarm(0); }; | 347 | alarm(0); }; |
339 | isnt( $@, "alarm\n", $cmd); | 348 | isnt( $@, "alarm\n", $cmd ); |
349 | is( $result->return_code, 0, $cmd ); | ||
340 | 350 | ||
341 | # Will this one work everywhere??? | 351 | # Let's hope there won't be any web server on :80 returning "redirected"! |
342 | $cmd = "$command -f follow -u /redir_external -t 5"; | 352 | $cmd = "$command -f sticky -u /redir_external -t 5 -s redirected"; |
343 | eval { | 353 | eval { |
344 | local $SIG{ALRM} = sub { die "alarm\n" }; | 354 | local $SIG{ALRM} = sub { die "alarm\n" }; |
345 | alarm(2); | 355 | alarm(2); |
346 | $result = NPTest->testCmd( $cmd ); | 356 | $result = NPTest->testCmd( $cmd ); |
347 | alarm(0); }; | 357 | alarm(0); }; |
348 | is( $@, "alarm\n", $cmd); | 358 | isnt( $@, "alarm\n", $cmd ); |
359 | isnt( $result->return_code, 0, $cmd ); | ||
360 | |||
361 | # Test an external address - timeout | ||
362 | SKIP: { | ||
363 | skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); | ||
364 | $cmd = "$command -f follow -u /redir_external -t 5"; | ||
365 | eval { | ||
366 | local $SIG{ALRM} = sub { die "alarm\n" }; | ||
367 | alarm(2); | ||
368 | $result = NPTest->testCmd( $cmd ); | ||
369 | alarm(0); }; | ||
370 | is( $@, "alarm\n", $cmd ); | ||
371 | } | ||
349 | 372 | ||
350 | $cmd = "$command -u /timeout -t 5"; | 373 | $cmd = "$command -u /timeout -t 5"; |
351 | eval { | 374 | eval { |
@@ -353,7 +376,7 @@ sub run_common_tests { | |||
353 | alarm(2); | 376 | alarm(2); |
354 | $result = NPTest->testCmd( $cmd ); | 377 | $result = NPTest->testCmd( $cmd ); |
355 | alarm(0); }; | 378 | alarm(0); }; |
356 | is( $@, "alarm\n", $cmd); | 379 | is( $@, "alarm\n", $cmd ); |
357 | 380 | ||
358 | $cmd = "$command -f follow -u /redir_timeout -t 2"; | 381 | $cmd = "$command -f follow -u /redir_timeout -t 2"; |
359 | eval { | 382 | eval { |
@@ -361,6 +384,7 @@ sub run_common_tests { | |||
361 | alarm(5); | 384 | alarm(5); |
362 | $result = NPTest->testCmd( $cmd ); | 385 | $result = NPTest->testCmd( $cmd ); |
363 | alarm(0); }; | 386 | alarm(0); }; |
364 | isnt( $@, "alarm\n", $cmd); | 387 | isnt( $@, "alarm\n", $cmd ); |
365 | 388 | ||
366 | } | 389 | } |
390 | |||