summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2005-12-15 17:06:55 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2005-12-15 17:06:55 (GMT)
commit71ce143ab1cac10b974084a21653b71bee68fe55 (patch)
tree2d7f757c122e6caef0297173ee55d8a2048dc1cf /plugins/t
parente03d87d8aef6701e7245b98800e67b64319bf7b2 (diff)
downloadmonitoring-plugins-71ce143ab1cac10b974084a21653b71bee68fe55.tar.gz
Display errors with slave queries correctly. Added extra tests for slaves
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1299 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/check_mysql.t53
1 files changed, 41 insertions, 12 deletions
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t
index b29c5c6..764db72 100644
--- a/plugins/t/check_mysql.t
+++ b/plugins/t/check_mysql.t
@@ -13,20 +13,49 @@ use vars qw($tests);
13 13
14plan skip_all => "check_mysql not compiled" unless (-x "check_mysql"); 14plan skip_all => "check_mysql not compiled" unless (-x "check_mysql");
15 15
16plan tests => 3; 16plan tests => 7;
17 17
18my $failureOutput = '/Access denied for user /'; 18my $bad_login_output = '/Access denied for user /';
19my $mysqlserver = getTestParameter( "mysql_server", "NP_MYSQL_SERVER", undef, 19my $mysqlserver = getTestParameter(
20 "A MySQL Server"); 20 "NP_MYSQL_SERVER",
21my $mysql_login_details = getTestParameter( "mysql_login_details", "MYSQL_LOGIN_DETAILS", undef, 21 "A MySQL Server with no slaves setup"
22 "Command line parameters to specify login access"); 22 );
23my $mysql_login_details = getTestParameter(
24 "MYSQL_LOGIN_DETAILS",
25 "Command line parameters to specify login access",
26 "-u user -ppw",
27 );
28my $with_slave = getTestParameter(
29 "NP_MYSQL_WITH_SLAVE",
30 "MySQL server with slaves setup"
31 );
32my $with_slave_login = getTestParameter(
33 "NP_MYSQL_WITH_SLAVE_LOGIN",
34 "Login details for server with slave",
35 "-uroot -ppw"
36 );
23 37
24my $result; 38my $result;
25 39
26$result = NPTest->testCmd("./check_mysql -H $mysqlserver $mysql_login_details"); 40SKIP: {
27cmp_ok( $result->return_code, '==', 0, "Login okay"); 41 skip "No mysql server defined", 5 unless $mysqlserver;
42 $result = NPTest->testCmd("./check_mysql -H $mysqlserver $mysql_login_details");
43 cmp_ok( $result->return_code, '==', 0, "Login okay");
44
45 $result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy");
46 cmp_ok( $result->return_code, '==', 2, "Login failure");
47 like( $result->output, $bad_login_output, "Expected login failure message");
48
49 $result = NPTest->testCmd("./check_mysql -S -H $mysqlserver $mysql_login_details");
50 cmp_ok( $result->return_code, "==", 1, "No slaves defined" );
51 like( $result->output, "/No slaves defined/", "Correct error message");
52}
28 53
29$result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy"); 54SKIP: {
30cmp_ok( $result->return_code, '==', 2, "Login expected failure"); 55 skip "No mysql server with slaves defined", 2 unless $with_slave;
31like( $result->output, $failureOutput, "Error string as expected"); 56 $result = NPTest->testCmd("./check_mysql -H $with_slave $with_slave_login");
57 cmp_ok( $result->return_code, '==', 0, "Login okay");
32 58
59 $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login");
60 cmp_ok( $result->return_code, "==", 0, "Slaves okay" );
61}