diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/t/check_http.t | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index d979914..598a423 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -6,31 +6,43 @@ | |||
6 | # | 6 | # |
7 | 7 | ||
8 | use strict; | 8 | use strict; |
9 | use Test; | 9 | use Test::More; |
10 | use NPTest; | 10 | use NPTest; |
11 | 11 | ||
12 | use vars qw($tests); | 12 | my $successOutput = '/OK.*HTTP.*second/'; |
13 | BEGIN {$tests = 4; plan tests => $tests} | ||
14 | 13 | ||
15 | my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost", | 14 | my $res; |
16 | "A host providing the HTTP Service (a web server)" ); | ||
17 | 15 | ||
18 | my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", | 16 | my $host_tcp_http = getTestParameter( "NP_HOST_TCP_HTTP", |
19 | "The hostname of system not responsive to network requests" ); | 17 | "A host providing the HTTP Service (a web server)", |
18 | "localhost" ); | ||
20 | 19 | ||
21 | my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", | 20 | my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", |
22 | "An invalid (not known to DNS) hostname" ); | 21 | "The hostname of system not responsive to network requests", |
22 | "10.0.0.1" ); | ||
23 | 23 | ||
24 | my $successOutput = '/OK.*HTTP.*second/'; | 24 | my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", |
25 | "An invalid (not known to DNS) hostname", | ||
26 | "nosuchhost"); | ||
27 | |||
28 | plan tests => 6; | ||
25 | 29 | ||
26 | my %exceptions = ( 2 => "No Web Server present?" ); | ||
27 | 30 | ||
28 | my $t; | 31 | $res = NPTest->testCmd( |
32 | "./check_http $host_tcp_http -wt 300 -ct 600" | ||
33 | ); | ||
34 | cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); | ||
35 | like( $res->output, $successOutput, "Output OK" ); | ||
29 | 36 | ||
30 | $t += checkCmd( "./check_http $host_tcp_http -wt 300 -ct 600", { 0 => 'continue', 2 => 'skip' }, $successOutput, %exceptions ); | 37 | $res = NPTest->testCmd( |
31 | $t += checkCmd( "./check_http $host_nonresponsive -wt 1 -ct 2", 2 ); | 38 | "./check_http $host_nonresponsive -wt 1 -ct 2" |
32 | $t += checkCmd( "./check_http $hostname_invalid -wt 1 -ct 2", 2 ); | 39 | ); |
40 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); | ||
41 | cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 10 seconds", "Output OK"); | ||
33 | 42 | ||
34 | exit(0) if defined($Test::Harness::VERSION); | 43 | $res = NPTest->testCmd( |
35 | exit($tests - $t); | 44 | "./check_http $hostname_invalid -wt 1 -ct 2" |
45 | ); | ||
46 | cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); | ||
47 | like( $res->output, "/Name or service not known.*/", "Output OK"); | ||
36 | 48 | ||