From aca1e6a6cec40754c67d3cf229db2660c4685202 Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Wed, 30 Apr 2008 12:50:52 +0000 Subject: Add socket support to check_mysql* Also clears the password from check_mysql command-line options git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1988 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/t/check_mysql.t | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'plugins/t/check_mysql.t') diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index 852926a7..e8bccf1c 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t @@ -19,12 +19,16 @@ use vars qw($tests); plan skip_all => "check_mysql not compiled" unless (-x "check_mysql"); -plan tests => 10; +plan tests => 15; my $bad_login_output = '/Access denied for user /'; my $mysqlserver = getTestParameter( "NP_MYSQL_SERVER", - "A MySQL Server with no slaves setup" + "A MySQL Server hostname or IP with no slaves setup" + ); +my $mysqlsocket = getTestParameter( + "NP_MYSQL_SOCKET", + "A MySQL Server socket with no slaves setup" ); my $mysql_login_details = getTestParameter( "MYSQL_LOGIN_DETAILS", @@ -57,6 +61,20 @@ SKIP: { like( $result->output, "/No slaves defined/", "Correct error message"); } +SKIP: { + skip "No mysql socket defined", 5 unless $mysqlsocket; + $result = NPTest->testCmd("./check_mysql -s $mysqlsocket $mysql_login_details"); + cmp_ok( $result->return_code, '==', 0, "Login okay"); + + $result = NPTest->testCmd("./check_mysql -s $mysqlsocket -u dummy -pdummy"); + cmp_ok( $result->return_code, '==', 2, "Login failure"); + like( $result->output, $bad_login_output, "Expected login failure message"); + + $result = NPTest->testCmd("./check_mysql -S -s $mysqlsocket $mysql_login_details"); + cmp_ok( $result->return_code, "==", 1, "No slaves defined" ); + like( $result->output, "/No slaves defined/", "Correct error message"); +} + SKIP: { skip "No mysql server with slaves defined", 5 unless $with_slave; $result = NPTest->testCmd("./check_mysql -H $with_slave $with_slave_login"); -- cgit v1.2.3