summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/check_by_ssh.t18
-rw-r--r--plugins/t/check_disk.t12
-rw-r--r--plugins/t/check_http.t6
-rw-r--r--plugins/t/check_mysql.t6
-rw-r--r--plugins/t/check_mysql_query.t2
-rw-r--r--plugins/t/check_nagios.t2
-rw-r--r--plugins/t/negate.t2
7 files changed, 24 insertions, 24 deletions
diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t
index 1d2939e..b6479f1 100644
--- a/plugins/t/check_by_ssh.t
+++ b/plugins/t/check_by_ssh.t
@@ -19,19 +19,19 @@ plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_servic
19plan tests => 42; 19plan tests => 42;
20 20
21# Some random check strings/response 21# Some random check strings/response
22my @responce = ('OK: Everything is fine', 22my @response = ('OK: Everything is fine',
23 'WARNING: Hey, pick me, pick me', 23 'WARNING: Hey, pick me, pick me',
24 'CRITICAL: Shit happens', 24 'CRITICAL: Shit happens',
25 'UNKNOWN: What can I do for ya', 25 'UNKNOWN: What can I do for ya',
26 'WOOPS: What did I smoke', 26 'WOOPS: What did I smoke',
27); 27);
28my @responce_re; 28my @response_re;
29my @check; 29my @check;
30for (@responce) { 30for (@response) {
31 push(@check, "echo $_"); 31 push(@check, "echo $_");
32 my $re_str = $_; 32 my $re_str = $_;
33 $re_str =~ s{(.)} { "\Q$1" }ge; 33 $re_str =~ s{(.)} { "\Q$1" }ge;
34 push(@responce_re, $re_str); 34 push(@response_re, $re_str);
35} 35}
36 36
37my $result; 37my $result;
@@ -47,7 +47,7 @@ for (my $i=0; $i<4; $i++) {
47 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'" 47 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'"
48 ); 48 );
49 cmp_ok($result->return_code, '==', $i, "Exit with return code $i"); 49 cmp_ok($result->return_code, '==', $i, "Exit with return code $i");
50 is($result->output, $responce[$i], "Status text is correct for check $i"); 50 is($result->output, $response[$i], "Status text is correct for check $i");
51} 51}
52 52
53$result = NPTest->testCmd( 53$result = NPTest->testCmd(
@@ -84,7 +84,7 @@ $result = NPTest->testCmd(
84 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'" 84 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'"
85 ); 85 );
86cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); 86cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)");
87is($result->output, $responce[4], "Return proper status text even with unknown status codes"); 87is($result->output, $response[4], "Return proper status text even with unknown status codes");
88 88
89$result = NPTest->testCmd( 89$result = NPTest->testCmd(
90 "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" 90 "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'"
@@ -108,7 +108,7 @@ my %linemap = (
108foreach my $line (0, 2, 4, 6) { 108foreach my $line (0, 2, 4, 6) {
109 my $code = $linemap{$line}; 109 my $code = $linemap{$line};
110 my $statline = $line+1; 110 my $statline = $line+1;
111 is($lines[$line], "$responce[$code]", "multiple checks status text is correct for line $line"); 111 is($lines[$line], "$response[$code]", "multiple checks status text is correct for line $line");
112 is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line"); 112 is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line");
113} 113}
114 114
@@ -124,7 +124,7 @@ close(PASV) or die("Unable to close '/tmp/check_by_ssh.$$': $!");
124cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed'); 124cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed');
125for (0) { 125for (0) {
126 if ($pasv[$_]) { 126 if ($pasv[$_]) {
127 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $responce_re[2] . '$/', 'proper result for passive check'); 127 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $response_re[2] . '$/', 'proper result for passive check');
128 } else { 128 } else {
129 fail('proper result for passive check'); 129 fail('proper result for passive check');
130 } 130 }
@@ -144,7 +144,7 @@ for (0, 1, 2, 3, 4) {
144 if ($pasv[$_]) { 144 if ($pasv[$_]) {
145 my $ret = $_; 145 my $ret = $_;
146 $ret = 9 if ($_ == 4); 146 $ret = 9 if ($_ == 4);
147 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $responce_re[$_] . '$/', "proper result for passive check $_"); 147 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $response_re[$_] . '$/', "proper result for passive check $_");
148 } else { 148 } else {
149 fail("proper result for passive check $_"); 149 fail("proper result for passive check $_");
150 } 150 }
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index c8f08f5..ca035ce 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -326,19 +326,19 @@ cmp_ok( $result->return_code, '==', 0, "grouping: exit ok if the sum of free meg
326$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" ); 326$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" );
327cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname"); 327cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname");
328 328
329# regex: exit unknown if given regex is not compileable 329# regex: exit unknown if given regex is not compilable
330$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" ); 330$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" );
331cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable"); 331cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compilable");
332 332
333# ignore: exit unknown, if all pathes are deselected using -i 333# ignore: exit unknown, if all paths are deselected using -i
334$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" ); 334$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" );
335cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)"); 335cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)");
336 336
337# ignore: exit unknown, if all pathes are deselected using -I 337# ignore: exit unknown, if all paths are deselected using -I
338$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" ); 338$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" );
339cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)"); 339cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)");
340 340
341# ignore: exit unknown, if all pathes are deselected using -i 341# ignore: exit unknown, if all paths are deselected using -i
342$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" ); 342$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" );
343cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'"); 343cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'");
344 344
@@ -347,7 +347,7 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mo
347like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it"); 347like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it");
348unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it"); 348unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it");
349 349
350# ignore: test if all pathes are listed when ignore regex doesn't match 350# ignore: test if all paths are listed when ignore regex doesn't match
351$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'"); 351$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'");
352like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match"); 352like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match");
353like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match"); 353like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match");
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index 1ca52f6..1f2fbdf 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -178,13 +178,13 @@ SKIP: {
178 178
179 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302"); 179 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302");
180 is( $res->return_code, 0, "Proxy HTTP works"); 180 is( $res->return_code, 0, "Proxy HTTP works");
181 like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficent"); 181 like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficient");
182 182
183 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT"); 183 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT");
184 is( $res->return_code, 0, "Proxy HTTP CONNECT works"); 184 is( $res->return_code, 0, "Proxy HTTP CONNECT works");
185 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); 185 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient");
186 186
187 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD"); 187 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD");
188 is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method"); 188 is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method");
189 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); 189 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient");
190} 190}
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t
index e426bf5..baf3acc 100644
--- a/plugins/t/check_mysql.t
+++ b/plugins/t/check_mysql.t
@@ -5,7 +5,7 @@
5# 5#
6# 6#
7# These are the database permissions required for this test: 7# These are the database permissions required for this test:
8# GRANT SELECT ON $db.* TO $user@$host INDENTIFIED BY '$password'; 8# GRANT SELECT ON $db.* TO $user@$host IDENTIFIED BY '$password';
9# GRANT SUPER, REPLICATION CLIENT ON *.* TO $user@$host; 9# GRANT SUPER, REPLICATION CLIENT ON *.* TO $user@$host;
10# Check with: 10# Check with:
11# mysql -u$user -p$password -h$host $db 11# mysql -u$user -p$password -h$host $db
@@ -23,9 +23,9 @@ plan tests => 15;
23my $bad_login_output = '/Access denied for user /'; 23my $bad_login_output = '/Access denied for user /';
24my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup"); 24my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup");
25my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup"); 25my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup");
26my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privleges)", "-u test -ptest"); 26my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest");
27my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup"); 27my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup");
28my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privleges)", $mysql_login_details || "-u test -ptest"); 28my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privileges)", $mysql_login_details || "-u test -ptest");
29 29
30my $result; 30my $result;
31 31
diff --git a/plugins/t/check_mysql_query.t b/plugins/t/check_mysql_query.t
index 96899ac..c30245b 100644
--- a/plugins/t/check_mysql_query.t
+++ b/plugins/t/check_mysql_query.t
@@ -31,7 +31,7 @@ $result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver $
31cmp_ok( $result->return_code, '==', 0, "Can run query"); 31cmp_ok( $result->return_code, '==', 0, "Can run query");
32 32
33$result = NPTest->testCmd("./check_mysql_query -H $mysqlserver $mysql_login_details"); 33$result = NPTest->testCmd("./check_mysql_query -H $mysqlserver $mysql_login_details");
34cmp_ok( $result->return_code, '==', 3, "Missing query parmeter"); 34cmp_ok( $result->return_code, '==', 3, "Missing query parameter");
35like( $result->output, "/Must specify a SQL query to run/", "Missing query error message"); 35like( $result->output, "/Must specify a SQL query to run/", "Missing query error message");
36 36
37$result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver -u dummy -d mysql"); 37$result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver -u dummy -d mysql");
diff --git a/plugins/t/check_nagios.t b/plugins/t/check_nagios.t
index 81fc24d..f38f5e9 100644
--- a/plugins/t/check_nagios.t
+++ b/plugins/t/check_nagios.t
@@ -36,7 +36,7 @@ cmp_ok( $result->return_code, '==', 1, "Log over 5 minutes old" );
36like ( $result->output, $warningOutput, "Output for warning correct" ); 36like ( $result->output, $warningOutput, "Output for warning correct" );
37 37
38my $now = time; 38my $now = time;
39# This substitution is dependant on the testcase 39# This substitution is dependent on the testcase
40system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1"; 40system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1";
41 41
42$result = NPTest->testCmd( 42$result = NPTest->testCmd(
diff --git a/plugins/t/negate.t b/plugins/t/negate.t
index d96a109..5ec1c84 100644
--- a/plugins/t/negate.t
+++ b/plugins/t/negate.t
@@ -84,7 +84,7 @@ foreach my $current_state (keys(%state)) {
84 foreach my $new_state (keys(%state)) { 84 foreach my $new_state (keys(%state)) {
85 $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" ); 85 $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" );
86 is( $res->return_code, $state{$new_state}, "Got fake $new_state (with substitute)" ); 86 is( $res->return_code, $state{$new_state}, "Got fake $new_state (with substitute)" );
87 is( $res->output, uc($new_state).": Fake $new_state", "Substitued fake $new_state output"); 87 is( $res->output, uc($new_state).": Fake $new_state", "Substituted fake $new_state output");
88 } 88 }
89} 89}
90 90