Code

Removing CVS/SVN tags and replacing with git-based versioning
[nagiosplug.git] / plugins / t / check_cluster.t
1 #! /usr/bin/perl -w -I ..
2 #
3 # check_cluster tests
4 #
5 #
7 use strict;
8 use Test::More tests => 15;
9 use NPTest;
11 my $result;
13 $result = NPTest->testCmd(
14         "./check_cluster -s -w 0:0 -c 0:0 -d 0,0,0,0"
15         );
16 cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning ranges" );
17 like( $result->output, qr/service/i, "Output contains the word 'service' (case insensitive)");
19 $result = NPTest->testCmd(
20         "./check_cluster -l LABEL -s -w 0:0 -c 0:0 -d 0,0,0,0"
21         );
22 like( $result->output, qr/LABEL/, "Output contains the defined label 'LABEL' (case sensitive)");
24 $result = NPTest->testCmd(
25         "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,0,1"
26         );
27 cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok services are inside critical and outside warning ranges" );
29 $result = NPTest->testCmd(
30         "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,1,1"
31         );
32 cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok services are inside critical and outside warning ranges" );
34 $result = NPTest->testCmd(
35         "./check_cluster -s -w 0 -c 0 -d 0,0,0,0"
36         );
37 cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning (no ranges)" );
39 $result = NPTest->testCmd(
40         "./check_cluster -s -w 0 -c 1 -d 0,0,1,0"
41         );
42 cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok services exceed warning (no ranges)" );
44 $result = NPTest->testCmd(
45         "./check_cluster -s -w 0 -c 1 -d 0,0,1,1"
46         );
47 cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok services exceed critical warning (no ranges)" );
50 #
51 # And for hosts..
52 #
53 $result = NPTest->testCmd(
54         "./check_cluster -h -w 0:0 -c 0:0 -d 0,0,0,0"
55         );
56 cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning ranges" );
57 like( $result->output, qr/host/i, "Output contains the word 'host' (case insensitive)");
59 $result = NPTest->testCmd(
60         "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,0,1"
61         );
62 cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok hosts are inside critical and outside warning ranges" );
64 $result = NPTest->testCmd(
65         "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,1,1"
66         );
67 cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok hosts are inside critical and outside warning ranges" );
69 $result = NPTest->testCmd(
70         "./check_cluster -h -w 0 -c 0 -d 0,0,0,0"
71         );
72 cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning (no ranges)" );
74 $result = NPTest->testCmd(
75         "./check_cluster -h -w 0 -c 1 -d 0,0,1,0"
76         );
77 cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok hosts exceed warning (no ranges)" );
79 $result = NPTest->testCmd(
80         "./check_cluster -h -w 0 -c 1 -d 0,0,1,1"
81         );
82 cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok hosts exceed critical warning (no ranges)" );