MXS-2146: Add csmon test case

Added a test case that does a set of sanity checks on the monitor. As the
monitor is very simple, there are not a lot of things to test without
access to the actual instances (e.g. ExeMgr failures need to be tested).

Currently the test always passes as ColumnStore clusters aren't
implemented for the test framework.
This commit is contained in:
Markus Mäkelä
2018-11-19 10:51:47 +02:00
parent da1772f8c9
commit 41670875fc
3 changed files with 100 additions and 0 deletions

View File

@ -9,6 +9,7 @@
# REPL_BACKEND
# GALERA_BACKEND
# EXTERN_BACKEND
# CS_BACKEND
# BREAKS_REPL
# BREAKS_GALERA
set(CTEST_BUILD_NAME "${BUILDNAME}")
@ -356,6 +357,18 @@ add_test_executable(mxs1980_blr_galera_server_ids.cpp mxs1980_blr_galera_server_
# END: Galera tests #
############################################
############################################
# BEGIN: ColumnStore tests #
############################################
# MXS-2146: Add test case for csmon
# https://jira.mariadb.org/browse/MXS-2146
add_test_executable(csmon_test.cpp csmon_test csmon_test LABELS csmon CS_BACKEND)
############################################
# END: ColumnStore tests #
############################################
# Test monitor state change events when manually clearing server bits
add_test_executable(false_monitor_state_change.cpp false_monitor_state_change replication LABELS mysqlmon REPL_BACKEND)

View File

@ -0,0 +1,48 @@
[maxscale]
threads=###threads###
[CS-Monitor]
type=monitor
module=csmon
servers=server1,server2,server3,server4
user=maxskysql
password=skysql
monitor_interval=1000
primary=server1
[RW-Split-Router]
type=service
router=readwritesplit
servers=server1,server2,server3,server4
user=maxskysql
password=skysql
[RW-Split-Listener]
type=listener
service=RW-Split-Router
protocol=MariaDBClient
port=4006
[server1]
type=server
address=###node_server_IP_1###
port=###node_server_port_1###
protocol=MariaDBBackend
[server2]
type=server
address=###node_server_IP_2###
port=###node_server_port_2###
protocol=MariaDBBackend
[server3]
type=server
address=###node_server_IP_3###
port=###node_server_port_3###
protocol=MariaDBBackend
[server4]
type=server
address=###node_server_IP_4###
port=###node_server_port_4###
protocol=MariaDBBackend

View File

@ -0,0 +1,39 @@
/**
* MXS-2146: Test case for csmon
*/
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections::require_columnstore(true);
TestConnections test(argc, argv);
// Simple check for correct routing behavior
test.maxscales->connect();
auto slave = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id");
test.try_query(test.maxscales->conn_rwsplit[0], "BEGIN");
auto master = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id");
test.try_query(test.maxscales->conn_rwsplit[0], "COMMIT");
test.expect(slave != master, "Master and slave server_id should be different");
test.maxscales->disconnect();
// Master failures are detected
test.maxscales->connect();
test.repl->block_node(0);
test.expect(execute_query_silent(test.maxscales->conn_rwsplit[0], "SELECT @@last_insert_id") != 0,
"Query should fail when the master is blocked");
test.repl->unblock_node(0);
test.maxscales->disconnect();
// Slave failures are detected
test.maxscales->connect();
test.repl->block_node(1);
test.maxscales->wait_for_monitor();
auto backup_slave = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id");
test.expect(backup_slave == master, "Query should go to the master when the slave is down");
test.repl->unblock_node(1);
test.maxscales->disconnect();
return test.global_result;
}