[monitoring-plugins] check_mysql tests: Also exchange slave for replica

Lorenz Kästle git at monitoring-plugins.org
Fri Mar 7 17:10:11 CET 2025


 Module: monitoring-plugins
 Branch: master
 Commit: 3ed6b7cd3e99e328b9f34bfc4af8b2f8bd3b5231
 Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
   Date: Mon Feb 24 20:55:18 2025 +0100
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=3ed6b7cd

check_mysql tests: Also exchange slave for replica

---

 .github/NPTest.cache    |  4 ++--
 plugins/t/check_mysql.t | 32 ++++++++++++++++----------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/.github/NPTest.cache b/.github/NPTest.cache
index d488d1b9..6b463e74 100644
--- a/.github/NPTest.cache
+++ b/.github/NPTest.cache
@@ -38,8 +38,8 @@
   'NP_MYSQL_LOGIN_DETAILS' => '-u root -d test',
   'NP_MYSQL_SERVER' => 'localhost',
   'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock',
-  'NP_MYSQL_WITH_SLAVE' => '',
-  'NP_MYSQL_WITH_SLAVE_LOGIN' => '',
+  'NP_MYSQL_WITH_REPLICA' => '',
+  'NP_MYSQL_WITH_REPLICA_LOGIN' => '',
   'NP_NO_NTP_SERVICE' => 'localhost',
   'NP_PORT_TCP_PROXY' => '3128',
   'NP_SMB_SHARE' => '',
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t
index baf3acc6..a383bc99 100644
--- a/plugins/t/check_mysql.t
+++ b/plugins/t/check_mysql.t
@@ -21,11 +21,11 @@ plan skip_all => "check_mysql not compiled" unless (-x "check_mysql");
 plan tests => 15;
 
 my $bad_login_output = '/Access denied for user /';
-my $mysqlserver         = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup");
-my $mysqlsocket         = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup");
+my $mysqlserver         = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no replica setup");
+my $mysqlsocket         = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no replica setup");
 my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest");
-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 (requires REPLICATION CLIENT privileges)", $mysql_login_details || "-u test -ptest");
+my $with_replica          = getTestParameter("NP_MYSQL_WITH_REPLICA", "MySQL server with replica setup");
+my $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");
 
 my $result;
 
@@ -39,8 +39,8 @@ SKIP: {
 	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");
+	cmp_ok( $result->return_code, "==", 1, "No replicas defined" );
+	like( $result->output, "/No replicas defined/", "Correct error message");
 }
 
 SKIP: {
@@ -53,22 +53,22 @@ SKIP: {
 	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");
+	cmp_ok( $result->return_code, "==", 1, "No replicas defined" );
+	like( $result->output, "/No replicas 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");
+	skip "No mysql server with replicas defined", 5 unless $with_replica;
+	$result = NPTest->testCmd("./check_mysql -H $with_replica $with_replica_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" );
+	$result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login");
+	cmp_ok( $result->return_code, "==", 0, "Replicas okay" );
 
-	$result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login -w 60");
-	cmp_ok( $result->return_code, '==', 0, 'Slaves are not > 60 seconds behind');
+	$result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login -w 60");
+	cmp_ok( $result->return_code, '==', 0, 'Replicas are not > 60 seconds behind');
 
-	$result = NPTest->testCmd("./check_mysql -S -H $with_slave $with_slave_login -w 60:");
+	$result = NPTest->testCmd("./check_mysql -S -H $with_replica $with_replica_login -w 60:");
 	cmp_ok( $result->return_code, '==', 1, 'Alert warning if < 60 seconds behind');
-	like( $result->output, "/^SLOW_SLAVE WARNING:/", "Output okay");
+	like( $result->output, "/^SLOW_REPLICA WARNING:/", "Output okay");
 }



More information about the Commits mailing list