diff options
Diffstat (limited to 'plugins/t')
-rw-r--r-- | plugins/t/check_mysql.t | 32 | ||||
-rw-r--r-- | plugins/t/check_swap.t | 35 |
2 files changed, 30 insertions, 37 deletions
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index baf3acc6..a383bc99 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t | |||
@@ -21,11 +21,11 @@ plan skip_all => "check_mysql not compiled" unless (-x "check_mysql"); | |||
21 | plan tests => 15; | 21 | plan tests => 15; |
22 | 22 | ||
23 | my $bad_login_output = '/Access denied for user /'; | 23 | my $bad_login_output = '/Access denied for user /'; |
24 | my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup"); | 24 | my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no replica setup"); |
25 | my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup"); | 25 | my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no replica setup"); |
26 | my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest"); | 26 | my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest"); |
27 | my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup"); | 27 | my $with_replica = getTestParameter("NP_MYSQL_WITH_REPLICA", "MySQL server with replica setup"); |
28 | my $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"); | 28 | my $with_replica_login = getTestParameter("NP_MYSQL_WITH_REPLICA_LOGIN", "Login details for server with replica (requires REPLICATION CLIENT privileges)", $mysql_login_details || "-u test -ptest"); |
29 | 29 | ||
30 | my $result; | 30 | my $result; |
31 | 31 | ||
@@ -39,8 +39,8 @@ SKIP: { | |||
39 | like( $result->output, $bad_login_output, "Expected login failure message"); | 39 | like( $result->output, $bad_login_output, "Expected login failure message"); |
40 | 40 | ||
41 | $result = NPTest->testCmd("./check_mysql -S -H $mysqlserver $mysql_login_details"); | 41 | $result = NPTest->testCmd("./check_mysql -S -H $mysqlserver $mysql_login_details"); |
42 | cmp_ok( $result->return_code, "==", 1, "No slaves defined" ); | 42 | cmp_ok( $result->return_code, "==", 1, "No replicas defined" ); |
43 | like( $result->output, "/No slaves defined/", "Correct error message"); | 43 | like( $result->output, "/No replicas defined/", "Correct error message"); |
44 | } | 44 | } |
45 | 45 | ||
46 | SKIP: { | 46 | SKIP: { |
@@ -53,22 +53,22 @@ SKIP: { | |||
53 | like( $result->output, $bad_login_output, "Expected login failure message"); | 53 | like( $result->output, $bad_login_output, "Expected login failure message"); |
54 | 54 | ||
55 | $result = NPTest->testCmd("./check_mysql -S -s $mysqlsocket $mysql_login_details"); | 55 | $result = NPTest->testCmd("./check_mysql -S -s $mysqlsocket $mysql_login_details"); |
56 | cmp_ok( $result->return_code, "==", 1, "No slaves defined" ); | 56 | cmp_ok( $result->return_code, "==", 1, "No replicas defined" ); |
57 | like( $result->output, "/No slaves defined/", "Correct error message"); | 57 | like( $result->output, "/No replicas defined/", "Correct error message"); |
58 | } | 58 | } |
59 | 59 | ||
60 | SKIP: { | 60 | SKIP: { |
61 | skip "No mysql server with slaves defined", 5 unless $with_slave; | 61 | skip "No mysql server with replicas defined", 5 unless $with_replica; |
62 | $result = NPTest->testCmd("./check_mysql -H $with_slave $with_slave_login"); | 62 | $result = NPTest->testCmd("./check_mysql -H $with_replica $with_replica_login"); |
63 | cmp_ok( $result->return_code, '==', 0, "Login okay"); | 63 | cmp_ok( $result->return_code, '==', 0, "Login okay"); |
64 | 64 | ||
65 | $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login"); | 65 | $result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login"); |
66 | cmp_ok( $result->return_code, "==", 0, "Slaves okay" ); | 66 | cmp_ok( $result->return_code, "==", 0, "Replicas okay" ); |
67 | 67 | ||
68 | $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login -w 60"); | 68 | $result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login -w 60"); |
69 | cmp_ok( $result->return_code, '==', 0, 'Slaves are not > 60 seconds behind'); | 69 | cmp_ok( $result->return_code, '==', 0, 'Replicas are not > 60 seconds behind'); |
70 | 70 | ||
71 | $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login -w 60:"); | 71 | $result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login -w 60:"); |
72 | cmp_ok( $result->return_code, '==', 1, 'Alert warning if < 60 seconds behind'); | 72 | cmp_ok( $result->return_code, '==', 1, 'Alert warning if < 60 seconds behind'); |
73 | like( $result->output, "/^SLOW_SLAVE WARNING:/", "Output okay"); | 73 | like( $result->output, "/^SLOW_REPLICA WARNING:/", "Output okay"); |
74 | } | 74 | } |
diff --git a/plugins/t/check_swap.t b/plugins/t/check_swap.t index 7e61b766..68946f6d 100644 --- a/plugins/t/check_swap.t +++ b/plugins/t/check_swap.t | |||
@@ -17,42 +17,35 @@ my $message = '/^[0-9]+\% free \([0-9]+MiB out of [0-9]+MiB\)/'; | |||
17 | 17 | ||
18 | $result = NPTest->testCmd( "./check_swap $outputFormat" ); # Always OK | 18 | $result = NPTest->testCmd( "./check_swap $outputFormat" ); # Always OK |
19 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); | 19 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); |
20 | $output = decode_json($result->output); | 20 | is($result->{'mp_test_result'}->{'state'}, "OK", "State was correct"); |
21 | is($output->{'state'}, "OK", "State was correct"); | 21 | like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); |
22 | like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); | ||
23 | 22 | ||
24 | $result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576 $outputFormat" ); # 1 MB free | 23 | $result = NPTest->testCmd( "./check_swap -w 1048576 -c 1048576 $outputFormat" ); # 1 MB free |
25 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); | 24 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); |
26 | $output = decode_json($result->output); | 25 | is($result->{'mp_test_result'}->{'state'}, "OK", "State was correct"); |
27 | is($output->{'state'}, "OK", "State was correct"); | 26 | like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); |
28 | like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); | ||
29 | 27 | ||
30 | $result = NPTest->testCmd( "./check_swap -w 1% -c 1% $outputFormat" ); # 1% free | 28 | $result = NPTest->testCmd( "./check_swap -w 1% -c 1% $outputFormat" ); # 1% free |
31 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); | 29 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); |
32 | $output = decode_json($result->output); | 30 | is($result->{'mp_test_result'}->{'state'}, "OK", "State was correct"); |
33 | is($output->{'state'}, "OK", "State was correct"); | 31 | like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); |
34 | like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); | ||
35 | 32 | ||
36 | $result = NPTest->testCmd( "./check_swap -w 100% -c 100% $outputFormat" ); # 100% (always critical) | 33 | $result = NPTest->testCmd( "./check_swap -w 100% -c 100% $outputFormat" ); # 100% (always critical) |
37 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); | 34 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); |
38 | $output = decode_json($result->output); | 35 | is($result->{'mp_test_result'}->{'state'}, "CRITICAL", "State was correct"); |
39 | is($output->{'state'}, "CRITICAL", "State was correct"); | 36 | like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); |
40 | like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); | ||
41 | 37 | ||
42 | $result = NPTest->testCmd( "./check_swap -w 100% -c 1% $outputFormat" ); # 100% (always warn) | 38 | $result = NPTest->testCmd( "./check_swap -w 100% -c 1% $outputFormat" ); # 100% (always warn) |
43 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); | 39 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); |
44 | $output = decode_json($result->output); | 40 | is($result->{'mp_test_result'}->{'state'}, "WARNING", "State was correct"); |
45 | is($output->{'state'}, "WARNING", "State was correct"); | 41 | like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); |
46 | like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); | ||
47 | 42 | ||
48 | $result = NPTest->testCmd( "./check_swap -w 100% $outputFormat" ); # 100% (single threshold, always warn) | 43 | $result = NPTest->testCmd( "./check_swap -w 100% $outputFormat" ); # 100% (single threshold, always warn) |
49 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); | 44 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); |
50 | $output = decode_json($result->output); | 45 | is($result->{'mp_test_result'}->{'state'}, "WARNING", "State was correct"); |
51 | is($output->{'state'}, "WARNING", "State was correct"); | 46 | like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); |
52 | like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); | ||
53 | 47 | ||
54 | $result = NPTest->testCmd( "./check_swap -c 100% $outputFormat" ); # 100% (single threshold, always critical) | 48 | $result = NPTest->testCmd( "./check_swap -c 100% $outputFormat" ); # 100% (single threshold, always critical) |
55 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); | 49 | cmp_ok( $result->return_code, "==", 0, "Always OK" ); |
56 | $output = decode_json($result->output); | 50 | is($result->{'mp_test_result'}->{'state'}, "CRITICAL", "State was correct"); |
57 | is($output->{'state'}, "CRITICAL", "State was correct"); | 51 | like($result->{'mp_test_result'}->{'checks'}->[0]->{'output'}, $message, "Output was correct"); |
58 | like($output->{'checks'}->[0]->{'output'}, $message, "Output was correct"); | ||