summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_mysql.t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t/check_mysql.t')
-rw-r--r--plugins/t/check_mysql.t33
1 files changed, 17 insertions, 16 deletions
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t
index baf3acc6..9114cccc 100644
--- a/plugins/t/check_mysql.t
+++ b/plugins/t/check_mysql.t
@@ -11,6 +11,7 @@
11# mysql -u$user -p$password -h$host $db 11# mysql -u$user -p$password -h$host $db
12 12
13use strict; 13use strict;
14use warnings;
14use Test::More; 15use Test::More;
15use NPTest; 16use NPTest;
16 17
@@ -21,11 +22,11 @@ plan skip_all => "check_mysql not compiled" unless (-x "check_mysql");
21plan tests => 15; 22plan tests => 15;
22 23
23my $bad_login_output = '/Access denied for user /'; 24my $bad_login_output = '/Access denied for user /';
24my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup"); 25my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no replica setup");
25my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup"); 26my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no replica setup");
26my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest"); 27my $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"); 28my $with_replica = getTestParameter("NP_MYSQL_WITH_REPLICA", "MySQL server with replica setup");
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"); 29my $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 30
30my $result; 31my $result;
31 32
@@ -39,8 +40,8 @@ SKIP: {
39 like( $result->output, $bad_login_output, "Expected login failure message"); 40 like( $result->output, $bad_login_output, "Expected login failure message");
40 41
41 $result = NPTest->testCmd("./check_mysql -S -H $mysqlserver $mysql_login_details"); 42 $result = NPTest->testCmd("./check_mysql -S -H $mysqlserver $mysql_login_details");
42 cmp_ok( $result->return_code, "==", 1, "No slaves defined" ); 43 cmp_ok( $result->return_code, "==", 1, "No replicas defined" );
43 like( $result->output, "/No slaves defined/", "Correct error message"); 44 like( $result->output, "/no replicas defined/", "Correct error message");
44} 45}
45 46
46SKIP: { 47SKIP: {
@@ -53,22 +54,22 @@ SKIP: {
53 like( $result->output, $bad_login_output, "Expected login failure message"); 54 like( $result->output, $bad_login_output, "Expected login failure message");
54 55
55 $result = NPTest->testCmd("./check_mysql -S -s $mysqlsocket $mysql_login_details"); 56 $result = NPTest->testCmd("./check_mysql -S -s $mysqlsocket $mysql_login_details");
56 cmp_ok( $result->return_code, "==", 1, "No slaves defined" ); 57 cmp_ok( $result->return_code, "==", 1, "No replicas defined" );
57 like( $result->output, "/No slaves defined/", "Correct error message"); 58 like( $result->output, "/no replicas defined/", "Correct error message");
58} 59}
59 60
60SKIP: { 61SKIP: {
61 skip "No mysql server with slaves defined", 5 unless $with_slave; 62 skip "No mysql server with replicas defined", 5 unless $with_replica;
62 $result = NPTest->testCmd("./check_mysql -H $with_slave $with_slave_login"); 63 $result = NPTest->testCmd("./check_mysql -H $with_replica $with_replica_login");
63 cmp_ok( $result->return_code, '==', 0, "Login okay"); 64 cmp_ok( $result->return_code, '==', 0, "Login okay");
64 65
65 $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login"); 66 $result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login");
66 cmp_ok( $result->return_code, "==", 0, "Slaves okay" ); 67 cmp_ok( $result->return_code, "==", 0, "Replicas okay" );
67 68
68 $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login -w 60"); 69 $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'); 70 cmp_ok( $result->return_code, '==', 0, 'Replicas are not > 60 seconds behind');
70 71
71 $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login -w 60:"); 72 $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'); 73 cmp_ok( $result->return_code, '==', 1, 'Alert warning if < 60 seconds behind');
73 like( $result->output, "/^SLOW_SLAVE WARNING:/", "Output okay"); 74 like( $result->output, "/^slow_replica/", "Output okay");
74} 75}