[Nagiosplug-checkins] nagiosplug/plugins/t check_mysql.t,1.4,1.5
Ton Voon
tonvoon at users.sourceforge.net
Thu Dec 15 09:08:01 CET 2005
Update of /cvsroot/nagiosplug/nagiosplug/plugins/t
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23109/plugins/t
Modified Files:
check_mysql.t
Log Message:
Display errors with slave queries correctly. Added extra tests for slaves
Index: check_mysql.t
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/t/check_mysql.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- check_mysql.t 9 Nov 2005 17:27:36 -0000 1.4
+++ check_mysql.t 15 Dec 2005 17:06:55 -0000 1.5
@@ -13,20 +13,49 @@
plan skip_all => "check_mysql not compiled" unless (-x "check_mysql");
-plan tests => 3;
+plan tests => 7;
-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");
+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 expected failure");
-like( $result->output, $failureOutput, "Error string as expected");
+ $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");
+}
+
+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" );
+}
More information about the Commits
mailing list