Merge branch '2.2' into 2.3

This commit is contained in:
Johan Wikman
2018-10-11 11:12:31 +03:00
5 changed files with 117 additions and 3 deletions

View File

@ -35,14 +35,14 @@ also be embedded into SQL-queries, see
type=filter type=filter
module=namedserverfilter module=namedserverfilter
match01=^Select.*TableOne$ match01=^Select.*TableOne$
target01=SlaveServer1, SlaveServer2 target01=server2,server3
match22=^SELECT.*TableTwo$ match22=^SELECT.*TableTwo$
target22=->master target22=->master
[MyService] [MyService]
type=service type=service
router=readwritesplit router=readwritesplit
servers=server1,server2 servers=server1,server2,server3
user=myuser user=myuser
passwd=mypasswd passwd=mypasswd
filters=NamedServerFilter filters=NamedServerFilter

View File

@ -1081,4 +1081,7 @@ add_test_executable(mxs701_binlog_filter.cpp mxs701_binlog_filter mxs701_binlog_
# https://jira.mariadb.org/browse/MXS-2043 # https://jira.mariadb.org/browse/MXS-2043
add_test_executable(mxs2043_select_for_update.cpp mxs2043_select_for_update replication LABELS REPL_BACKEND) 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 ${CMAKE_CURRENT_BINARY_DIR}/templates.h @ONLY) configure_file(templates.h.in ${CMAKE_CURRENT_BINARY_DIR}/templates.h @ONLY)

View File

@ -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

View File

@ -23,7 +23,7 @@ void get_output(TestConnections& test)
test.tprintf("MaxScale output:"); test.tprintf("MaxScale output:");
} }
output = test.maxscales->ssh_node_output(0, 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", "sudo truncate -s 0 /var/log/maxscale/maxscale.log",
true, true,
&ec); &ec);

View File

@ -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;
}