aboutsummaryrefslogtreecommitdiff
path: root/plugins/t/check_cluster.t
diff options
context:
space:
mode:
authorGravatar Matthias Eble <psychotrahe@users.sourceforge.net> 2007-04-28 21:57:17 +0000
committerGravatar Matthias Eble <psychotrahe@users.sourceforge.net> 2007-04-28 21:57:17 +0000
commit14dd02c058bc34b7b47c31556b7cacaa4ea0942b (patch)
tree273dee934748a53fcf5950a729bb4fbc4b57cd84 /plugins/t/check_cluster.t
parentb9b27ab2552b5a236b4b422ad686388d8b31c54b (diff)
downloadmonitoring-plugins-14dd02c058bc34b7b47c31556b7cacaa4ea0942b.tar.gz
added test cases for check_cluster
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1702 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t/check_cluster.t')
-rw-r--r--plugins/t/check_cluster.t83
1 files changed, 83 insertions, 0 deletions
diff --git a/plugins/t/check_cluster.t b/plugins/t/check_cluster.t
new file mode 100644
index 00000000..f3e78b83
--- /dev/null
+++ b/plugins/t/check_cluster.t
@@ -0,0 +1,83 @@
+#! /usr/bin/perl -w -I ..
+#
+# check_cluster tests
+#
+# $Id$
+#
+
+use strict;
+use Test::More tests => 15;
+use NPTest;
+
+my $result;
+
+$result = NPTest->testCmd(
+ "./check_cluster -s -w 0:0 -c 0:0 -d 0,0,0,0"
+ );
+cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning ranges" );
+like( $result->output, qr/service/i, "Output contains the word 'service' (case insensitive)");
+
+$result = NPTest->testCmd(
+ "./check_cluster -l LABEL -s -w 0:0 -c 0:0 -d 0,0,0,0"
+ );
+like( $result->output, qr/LABEL/, "Output contains the defined label 'LABEL' (case sensitive)");
+
+$result = NPTest->testCmd(
+ "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,0,1"
+ );
+cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok services are inside critical and outside warning ranges" );
+
+$result = NPTest->testCmd(
+ "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,1,1"
+ );
+cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok services are inside critical and outside warning ranges" );
+
+$result = NPTest->testCmd(
+ "./check_cluster -s -w 0 -c 0 -d 0,0,0,0"
+ );
+cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning (no ranges)" );
+
+$result = NPTest->testCmd(
+ "./check_cluster -s -w 0 -c 1 -d 0,0,1,0"
+ );
+cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok services exceed warning (no ranges)" );
+
+$result = NPTest->testCmd(
+ "./check_cluster -s -w 0 -c 1 -d 0,0,1,1"
+ );
+cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok services exceed critical warning (no ranges)" );
+
+
+#
+# And for hosts..
+#
+$result = NPTest->testCmd(
+ "./check_cluster -h -w 0:0 -c 0:0 -d 0,0,0,0"
+ );
+cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning ranges" );
+like( $result->output, qr/host/i, "Output contains the word 'host' (case insensitive)");
+
+$result = NPTest->testCmd(
+ "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,0,1"
+ );
+cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok hosts are inside critical and outside warning ranges" );
+
+$result = NPTest->testCmd(
+ "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,1,1"
+ );
+cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok hosts are inside critical and outside warning ranges" );
+
+$result = NPTest->testCmd(
+ "./check_cluster -h -w 0 -c 0 -d 0,0,0,0"
+ );
+cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning (no ranges)" );
+
+$result = NPTest->testCmd(
+ "./check_cluster -h -w 0 -c 1 -d 0,0,1,0"
+ );
+cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok hosts exceed warning (no ranges)" );
+
+$result = NPTest->testCmd(
+ "./check_cluster -h -w 0 -c 1 -d 0,0,1,1"
+ );
+cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok hosts exceed critical warning (no ranges)" );