From 41670875fc8227de13f5022fe22c9f11fd3b40ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 19 Nov 2018 10:51:47 +0200 Subject: [PATCH] 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. --- maxscale-system-test/CMakeLists.txt | 13 +++++ .../cnf/maxscale.cnf.template.csmon_test | 48 +++++++++++++++++++ maxscale-system-test/csmon_test.cpp | 39 +++++++++++++++ 3 files changed, 100 insertions(+) create mode 100755 maxscale-system-test/cnf/maxscale.cnf.template.csmon_test create mode 100644 maxscale-system-test/csmon_test.cpp diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 115d30abb..0d18c6813 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -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) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.csmon_test b/maxscale-system-test/cnf/maxscale.cnf.template.csmon_test new file mode 100755 index 000000000..d6d4a5abc --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.csmon_test @@ -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 diff --git a/maxscale-system-test/csmon_test.cpp b/maxscale-system-test/csmon_test.cpp new file mode 100644 index 000000000..6560901cd --- /dev/null +++ b/maxscale-system-test/csmon_test.cpp @@ -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; +}