diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2005-12-15 17:06:55 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2005-12-15 17:06:55 +0000 |
commit | 71ce143ab1cac10b974084a21653b71bee68fe55 (patch) | |
tree | 2d7f757c122e6caef0297173ee55d8a2048dc1cf /plugins/t/check_mysql.t | |
parent | e03d87d8aef6701e7245b98800e67b64319bf7b2 (diff) | |
download | monitoring-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/check_mysql.t')
-rw-r--r-- | plugins/t/check_mysql.t | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index b29c5c6a..764db72c 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t @@ -13,20 +13,49 @@ use vars qw($tests); plan skip_all => "check_mysql not compiled" unless (-x "check_mysql"); -plan tests => 3; - -my $failureOutput = '/Access denied for user /'; -my $mysqlserver = getTestParameter( "mysql_server", "NP_MYSQL_SERVER", undef, - "A MySQL Server"); -my $mysql_login_details = getTestParameter( "mysql_login_details", "MYSQL_LOGIN_DETAILS", undef, - "Command line parameters to specify login access"); +plan tests => 7; + +my $bad_login_output = '/Access denied for user /'; +my $mysqlserver = getTestParameter( + "NP_MYSQL_SERVER", + "A MySQL Server with no slaves setup" + ); +my $mysql_login_details = getTestParameter( + "MYSQL_LOGIN_DETAILS", + "Command line parameters to specify login access", + "-u user -ppw", + ); +my $with_slave = getTestParameter( + "NP_MYSQL_WITH_SLAVE", + "MySQL server with slaves setup" + ); +my $with_slave_login = getTestParameter( + "NP_MYSQL_WITH_SLAVE_LOGIN", + "Login details for server with slave", + "-uroot -ppw" + ); my $result; -$result = NPTest->testCmd("./check_mysql -H $mysqlserver $mysql_login_details"); -cmp_ok( $result->return_code, '==', 0, "Login okay"); +SKIP: { + skip "No mysql server defined", 5 unless $mysqlserver; + $result = NPTest->testCmd("./check_mysql -H $mysqlserver $mysql_login_details"); + cmp_ok( $result->return_code, '==', 0, "Login okay"); + + $result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy"); + cmp_ok( $result->return_code, '==', 2, "Login failure"); + like( $result->output, $bad_login_output, "Expected login failure message"); + + $result = NPTest->testCmd("./check_mysql -S -H $mysqlserver $mysql_login_details"); + cmp_ok( $result->return_code, "==", 1, "No slaves defined" ); + like( $result->output, "/No slaves defined/", "Correct error message"); +} -$result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy"); -cmp_ok( $result->return_code, '==', 2, "Login expected failure"); -like( $result->output, $failureOutput, "Error string as expected"); +SKIP: { + skip "No mysql server with slaves defined", 2 unless $with_slave; + $result = NPTest->testCmd("./check_mysql -H $with_slave $with_slave_login"); + cmp_ok( $result->return_code, '==', 0, "Login okay"); + $result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login"); + cmp_ok( $result->return_code, "==", 0, "Slaves okay" ); +} |