From 321435b80e85fef1f8b1cec13d7b6104ebe03eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 3 Oct 2018 12:46:54 +0300 Subject: [PATCH 1/3] Fix mysqlmon log copying The backup file required superuser permissions. --- maxscale-system-test/fail_switch_rejoin_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maxscale-system-test/fail_switch_rejoin_common.cpp b/maxscale-system-test/fail_switch_rejoin_common.cpp index cd03dbbe1..57be96381 100644 --- a/maxscale-system-test/fail_switch_rejoin_common.cpp +++ b/maxscale-system-test/fail_switch_rejoin_common.cpp @@ -23,7 +23,7 @@ void get_output(TestConnections& test) test.tprintf("MaxScale output:"); } output = test.maxscales->ssh_node_output(0, - "cat /var/log/maxscale/maxscale.log | tee -a /var/log/maxscale/maxscale_backup.log && " + "cat /var/log/maxscale/maxscale.log | sudo tee -a /var/log/maxscale/maxscale_backup.log && " "sudo truncate -s 0 /var/log/maxscale/maxscale.log", true, &ec); if (test.verbose) From 74effa6e7fbf770a4cff1aba626fa38b1849acef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 1 Oct 2018 13:46:26 +0300 Subject: [PATCH 2/3] MXS-2054: Add test case Add test case that emulates a hybrid cluster of MariaDB and ColumnStore instances. --- maxscale-system-test/CMakeLists.txt | 3 + ...xscale.cnf.template.mxs2054_hybrid_cluster | 72 +++++++++++++++++++ .../mxs2054_hybrid_cluster.cpp | 39 ++++++++++ 3 files changed, 114 insertions(+) create mode 100644 maxscale-system-test/cnf/maxscale.cnf.template.mxs2054_hybrid_cluster create mode 100644 maxscale-system-test/mxs2054_hybrid_cluster.cpp diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index b1a571d15..994fa48e2 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -978,6 +978,9 @@ add_test_executable(mxs2037_namedserver_wildcards.cpp mxs2037_namedserver_wildca # https://jira.mariadb.org/browse/MXS-2043 add_test_executable(mxs2043_select_for_update.cpp mxs2043_select_for_update replication LABELS REPL_BACKEND) +# MXS-2054: Hybrid clusters +add_test_executable(mxs2054_hybrid_cluster.cpp mxs2054_hybrid_cluster mxs2054_hybrid_cluster LABELS REPL_BACKEND) + configure_file(templates.h.in templates.h @ONLY) include(CTest) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs2054_hybrid_cluster b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2054_hybrid_cluster new file mode 100644 index 000000000..8a9e942b1 --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2054_hybrid_cluster @@ -0,0 +1,72 @@ +[maxscale] +threads=###threads### + +[server1] +type=server +address=###node_server_IP_1### +port=###node_server_port_1### +protocol=MySQLBackend +weight=1 + +[server2] +type=server +address=###node_server_IP_2### +port=###node_server_port_2### +protocol=MySQLBackend +weight=1 + +[server3] +type=server +address=###node_server_IP_3### +port=###node_server_port_3### +protocol=MySQLBackend +weight=0 + +[server4] +type=server +address=###node_server_IP_4### +port=###node_server_port_4### +protocol=MySQLBackend +weight=0 + +[MySQL Monitor] +type=monitor +module=mysqlmon +# Note that server3 and server4 are not monitored +servers=server1,server2 +user=maxskysql +password=skysql +monitor_interval=1000 + +[hybridizer] +type=filter +module=namedserverfilter +match03=test[.]t3 +target03=server3 +match04=test[.]t4 +target04=server4 + +[RW Split Router] +type=service +router=readwritesplit +servers=server1,server2,server3,server4 +user=maxskysql +password=skysql +filters=hybridizer +weightby=weight + +[RW Split Listener] +type=listener +service=RW Split Router +protocol=MySQLClient +port=4006 + +[CLI] +type=service +router=cli + +[CLI Listener] +type=listener +service=CLI +protocol=maxscaled +socket=default diff --git a/maxscale-system-test/mxs2054_hybrid_cluster.cpp b/maxscale-system-test/mxs2054_hybrid_cluster.cpp new file mode 100644 index 000000000..f414839e1 --- /dev/null +++ b/maxscale-system-test/mxs2054_hybrid_cluster.cpp @@ -0,0 +1,39 @@ +/** + * MXS-2054: Test "hybrid" clusters with namedserverfilter + */ + +#include "testconnections.h" + +int main(int argc, char** argv) +{ + TestConnections test(argc, argv); + + test.maxscales->ssh_node_f(0, true, "maxctrl set server server3 slave"); + test.maxscales->ssh_node_f(0, true, "maxctrl set server server4 slave"); + + test.repl->connect(); + execute_query(test.repl->nodes[0], "CREATE OR REPLACE TABLE test.t1 AS SELECT 1 AS id"); + execute_query(test.repl->nodes[0], "CREATE OR REPLACE TABLE test.t2 AS SELECT 2 AS id"); + execute_query(test.repl->nodes[0], "CREATE OR REPLACE TABLE test.t3 AS SELECT 3 AS id"); + execute_query(test.repl->nodes[0], "CREATE OR REPLACE TABLE test.t4 AS SELECT 4 AS id"); + test.repl->sync_slaves(); + test.repl->disconnect(); + + test.maxscales->connect(); + + Row server1 = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id, @@last_insert_id, id FROM test.t1"); + Row server2 = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id, id FROM test.t2"); + Row server3 = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id, id FROM test.t3"); + Row server4 = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id, id FROM test.t4"); + + test.maxscales->disconnect(); + + test.repl->connect(); + test.expect(server1[0] == test.repl->get_server_id_str(0), "First query without hint should go to server1, the master"); + test.expect(server2[0] == test.repl->get_server_id_str(1), "Second query without hint should go to server2, the slave"); + test.expect(server3[0] == test.repl->get_server_id_str(2), "First query with hint should go to server3, the first unmonitored server"); + test.expect(server4[0] == test.repl->get_server_id_str(3), "Second query with hint should go to server4, the second unmonitored server"); + test.repl->disconnect(); + + return test.global_result; +} From 0a04cb2d48a6c2964e4dc69e3c564bd5ca3d6a7d Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Tue, 9 Oct 2018 13:42:56 +0300 Subject: [PATCH 3/3] Clarify namedserverfilter documentation The example configuration had wrong server names. --- Documentation/Filters/Named-Server-Filter.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Filters/Named-Server-Filter.md b/Documentation/Filters/Named-Server-Filter.md index 068182406..2548e5c1e 100644 --- a/Documentation/Filters/Named-Server-Filter.md +++ b/Documentation/Filters/Named-Server-Filter.md @@ -35,14 +35,14 @@ also be embedded into SQL-queries, see type=filter module=namedserverfilter match01=^Select.*TableOne$ -target01=SlaveServer1, SlaveServer2 +target01=server2,server3 match22=^SELECT.*TableTwo$ target22=->master [MyService] type=service router=readwritesplit -servers=server1,server2 +servers=server1,server2,server3 user=myuser passwd=mypasswd filters=NamedServerFilter