MXS-2054: Add test case

Add test case that emulates a hybrid cluster of MariaDB and ColumnStore
instances.
This commit is contained in:
Markus Mäkelä 2018-10-01 13:46:26 +03:00
parent 321435b80e
commit 74effa6e7f
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 114 additions and 0 deletions

View File

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

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

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