summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/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 @@
1#! /usr/bin/perl -w -I ..
2#
3# check_cluster tests
4#
5# $Id$
6#
7
8use strict;
9use Test::More tests => 15;
10use NPTest;
11
12my $result;
13
14$result = NPTest->testCmd(
15 "./check_cluster -s -w 0:0 -c 0:0 -d 0,0,0,0"
16 );
17cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning ranges" );
18like( $result->output, qr/service/i, "Output contains the word 'service' (case insensitive)");
19
20$result = NPTest->testCmd(
21 "./check_cluster -l LABEL -s -w 0:0 -c 0:0 -d 0,0,0,0"
22 );
23like( $result->output, qr/LABEL/, "Output contains the defined label 'LABEL' (case sensitive)");
24
25$result = NPTest->testCmd(
26 "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,0,1"
27 );
28cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok services are inside critical and outside warning ranges" );
29
30$result = NPTest->testCmd(
31 "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,1,1"
32 );
33cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok services are inside critical and outside warning ranges" );
34
35$result = NPTest->testCmd(
36 "./check_cluster -s -w 0 -c 0 -d 0,0,0,0"
37 );
38cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning (no ranges)" );
39
40$result = NPTest->testCmd(
41 "./check_cluster -s -w 0 -c 1 -d 0,0,1,0"
42 );
43cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok services exceed warning (no ranges)" );
44
45$result = NPTest->testCmd(
46 "./check_cluster -s -w 0 -c 1 -d 0,0,1,1"
47 );
48cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok services exceed critical warning (no ranges)" );
49
50
51#
52# And for hosts..
53#
54$result = NPTest->testCmd(
55 "./check_cluster -h -w 0:0 -c 0:0 -d 0,0,0,0"
56 );
57cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning ranges" );
58like( $result->output, qr/host/i, "Output contains the word 'host' (case insensitive)");
59
60$result = NPTest->testCmd(
61 "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,0,1"
62 );
63cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok hosts are inside critical and outside warning ranges" );
64
65$result = NPTest->testCmd(
66 "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,1,1"
67 );
68cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok hosts are inside critical and outside warning ranges" );
69
70$result = NPTest->testCmd(
71 "./check_cluster -h -w 0 -c 0 -d 0,0,0,0"
72 );
73cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning (no ranges)" );
74
75$result = NPTest->testCmd(
76 "./check_cluster -h -w 0 -c 1 -d 0,0,1,0"
77 );
78cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok hosts exceed warning (no ranges)" );
79
80$result = NPTest->testCmd(
81 "./check_cluster -h -w 0 -c 1 -d 0,0,1,1"
82 );
83cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok hosts exceed critical warning (no ranges)" );