diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/t/check_cluster.t | 83 |
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 | |||
8 | use strict; | ||
9 | use Test::More tests => 15; | ||
10 | use NPTest; | ||
11 | |||
12 | my $result; | ||
13 | |||
14 | $result = NPTest->testCmd( | ||
15 | "./check_cluster -s -w 0:0 -c 0:0 -d 0,0,0,0" | ||
16 | ); | ||
17 | cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning ranges" ); | ||
18 | like( $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 | ); | ||
23 | like( $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 | ); | ||
28 | cmp_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 | ); | ||
33 | cmp_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 | ); | ||
38 | cmp_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 | ); | ||
43 | cmp_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 | ); | ||
48 | cmp_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 | ); | ||
57 | cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning ranges" ); | ||
58 | like( $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 | ); | ||
63 | cmp_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 | ); | ||
68 | cmp_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 | ); | ||
73 | cmp_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 | ); | ||
78 | cmp_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 | ); | ||
83 | cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok hosts exceed critical warning (no ranges)" ); | ||