summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 43c2e6e)
raw | patch | inline | side by side (parent: 43c2e6e)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Tue, 7 Mar 2006 10:23:31 +0000 (10:23 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Tue, 7 Mar 2006 10:23:31 +0000 (10:23 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1320 f882894a-f735-0410-b71e-b25c423dba1c
plugins/t/check_http.t | patch | blob | history |
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index d97991419960097ef1efb0807ffe018c0dc7ddc2..598a423f67458446a9e6412270cabe6a1e69ad17 100644 (file)
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
#
use strict;
-use Test;
+use Test::More;
use NPTest;
-use vars qw($tests);
-BEGIN {$tests = 4; plan tests => $tests}
+my $successOutput = '/OK.*HTTP.*second/';
-my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost",
- "A host providing the HTTP Service (a web server)" );
+my $res;
-my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
- "The hostname of system not responsive to network requests" );
+my $host_tcp_http = getTestParameter( "NP_HOST_TCP_HTTP",
+ "A host providing the HTTP Service (a web server)",
+ "localhost" );
-my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
- "An invalid (not known to DNS) hostname" );
+my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
+ "The hostname of system not responsive to network requests",
+ "10.0.0.1" );
-my $successOutput = '/OK.*HTTP.*second/';
+my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
+ "An invalid (not known to DNS) hostname",
+ "nosuchhost");
+
+plan tests => 6;
-my %exceptions = ( 2 => "No Web Server present?" );
-my $t;
+$res = NPTest->testCmd(
+ "./check_http $host_tcp_http -wt 300 -ct 600"
+ );
+cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
+like( $res->output, $successOutput, "Output OK" );
-$t += checkCmd( "./check_http $host_tcp_http -wt 300 -ct 600", { 0 => 'continue', 2 => 'skip' }, $successOutput, %exceptions );
-$t += checkCmd( "./check_http $host_nonresponsive -wt 1 -ct 2", 2 );
-$t += checkCmd( "./check_http $hostname_invalid -wt 1 -ct 2", 2 );
+$res = NPTest->testCmd(
+ "./check_http $host_nonresponsive -wt 1 -ct 2"
+ );
+cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
+cmp_ok( $res->output, 'eq', "CRITICAL - Socket timeout after 10 seconds", "Output OK");
-exit(0) if defined($Test::Harness::VERSION);
-exit($tests - $t);
+$res = NPTest->testCmd(
+ "./check_http $hostname_invalid -wt 1 -ct 2"
+ );
+cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
+like( $res->output, "/Name or service not known.*/", "Output OK");