diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-01-31 22:50:54 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-01-31 22:50:54 +0000 |
commit | a48b7fd824730cd2766e9a6ebeb05245c43f116d (patch) | |
tree | 8a72809a44ed5cbff34c7ae0220c7c079b99a06e | |
parent | 1f7821a657f95398ff6533e7665cbeeab9ddd8a5 (diff) | |
download | monitoring-plugins-a48b7fd824730cd2766e9a6ebeb05245c43f116d.tar.gz |
Converted to new style object and Test::More testing. Skipped jabber server
tests if not defined
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1601 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | plugins/t/check_jabber.t | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/plugins/t/check_jabber.t b/plugins/t/check_jabber.t index be232f2c..07742214 100644 --- a/plugins/t/check_jabber.t +++ b/plugins/t/check_jabber.t | |||
@@ -6,11 +6,10 @@ | |||
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 | plan tests => 10; |
13 | BEGIN {$tests = 10; plan tests => $tests} | ||
14 | 13 | ||
15 | my $host_tcp_jabber = getTestParameter( | 14 | my $host_tcp_jabber = getTestParameter( |
16 | "NP_HOST_TCP_JABBER", | 15 | "NP_HOST_TCP_JABBER", |
@@ -30,7 +29,6 @@ my $hostname_invalid = getTestParameter( | |||
30 | "nosuchhost", | 29 | "nosuchhost", |
31 | ); | 30 | ); |
32 | 31 | ||
33 | my %exceptions = ( 2 => "No Jabber Server present?" ); | ||
34 | 32 | ||
35 | my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on port 5222/'; | 33 | my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on port 5222/'; |
36 | 34 | ||
@@ -38,18 +36,30 @@ my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/'; | |||
38 | 36 | ||
39 | my $jabberInvalid = '/check_JABBER: Invalid hostname, address or socket\s-\s.+/'; | 37 | my $jabberInvalid = '/check_JABBER: Invalid hostname, address or socket\s-\s.+/'; |
40 | 38 | ||
41 | my $t; | 39 | my $r; |
42 | 40 | ||
43 | $t += checkCmd( "./check_jabber $host_tcp_jabber", 0, $jabberOK ); | 41 | SKIP: { |
42 | skip "No jabber server defined", 6 unless $host_tcp_jabber; | ||
44 | 43 | ||
45 | $t += checkCmd( "./check_jabber -H $host_tcp_jabber -w 9 -c 9 -t 10", 0, $jabberOK ); | 44 | $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber" ); |
45 | is( $r->return_code, 0, "Connected okay"); | ||
46 | like( $r->output, $jabberOK, "Output as expected" ); | ||
46 | 47 | ||
47 | $t += checkCmd( "./check_jabber $host_tcp_jabber -wt 9 -ct 9 -to 10", 0, $jabberOK ); | 48 | $r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber -w 9 -c 9 -t 10" ); |
49 | is( $r->return_code, 0, "Connected okay, within limits" ); | ||
50 | like( $r->output, $jabberOK, "Output as expected" ); | ||
51 | |||
52 | $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber -wt 9 -ct 9 -to 10" ); | ||
53 | is( $r->return_code, 0, "Old syntax okay" ); | ||
54 | like( $r->output, $jabberOK, "Output as expected" ); | ||
48 | 55 | ||
49 | $t += checkCmd( "./check_jabber $host_nonresponsive", 2, $jabberUnresponsive ); | 56 | } |
50 | 57 | ||
51 | $t += checkCmd( "./check_jabber $hostname_invalid", 2, $jabberInvalid ); | 58 | $r = NPTest->testCmd( "./check_jabber $host_nonresponsive" ); |
59 | is( $r->return_code, 2, "Unresponsive host gives critical" ); | ||
60 | like( $r->output, $jabberUnresponsive ); | ||
52 | 61 | ||
53 | exit(0) if defined($Test::Harness::VERSION); | 62 | $r = NPTest->testCmd( "./check_jabber $hostname_invalid" ); |
54 | exit($tests - $t); | 63 | is( $r->return_code, 2, "Invalid hostname gives critical" ); |
64 | like( $r->output, $jabberInvalid ); | ||
55 | 65 | ||