Add test for MXS-1310
Added test that checks how the use of implicit databases is handled in schemarouter.
This commit is contained in:
@ -299,6 +299,9 @@ add_test_executable(longblob.cpp longblob longblob LABELS readwritesplit readcon
|
|||||||
# Test with extremely big blob inserting/selecting with > 16 mb data blocks
|
# Test with extremely big blob inserting/selecting with > 16 mb data blocks
|
||||||
add_test_executable(mxs1110_16mb.cpp mxs1110_16mb longblob_filters LABELS readwritesplit readconnroute HEAVY REPL_BACKEND)
|
add_test_executable(mxs1110_16mb.cpp mxs1110_16mb longblob_filters LABELS readwritesplit readconnroute HEAVY REPL_BACKEND)
|
||||||
|
|
||||||
|
# Schemarouter implicit database detection
|
||||||
|
add_test_executable(mxs1310_implicit_db.cpp mxs1310_implicit_db mxs1310_implicit_db LABELS schemarouter REPL_BACKEND)
|
||||||
|
|
||||||
# INSERT extremelly big number of rows
|
# INSERT extremelly big number of rows
|
||||||
add_test_executable(lots_of_rows.cpp lots_of_rows galera LABELS readwritesplit HEAVY GALERA_BACKEND)
|
add_test_executable(lots_of_rows.cpp lots_of_rows galera LABELS readwritesplit HEAVY GALERA_BACKEND)
|
||||||
|
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
[maxscale]
|
||||||
|
threads=###threads###
|
||||||
|
log_info=1
|
||||||
|
|
||||||
|
[MySQL Monitor]
|
||||||
|
type=monitor
|
||||||
|
module=mysqlmon
|
||||||
|
###repl51###
|
||||||
|
servers=server1,server2
|
||||||
|
user=maxskysql
|
||||||
|
passwd=skysql
|
||||||
|
|
||||||
|
[Sharding router]
|
||||||
|
type=service
|
||||||
|
router=schemarouter
|
||||||
|
servers=server1,server2
|
||||||
|
user=maxskysql
|
||||||
|
passwd=skysql
|
||||||
|
auth_all_servers=1
|
||||||
|
ignore_databases_regex=.*
|
||||||
|
|
||||||
|
[Sharding Listener]
|
||||||
|
type=listener
|
||||||
|
service=Sharding router
|
||||||
|
protocol=MySQLClient
|
||||||
|
port=4006
|
||||||
|
|
||||||
|
[CLI]
|
||||||
|
type=service
|
||||||
|
router=cli
|
||||||
|
|
||||||
|
[CLI Listener]
|
||||||
|
type=listener
|
||||||
|
service=CLI
|
||||||
|
protocol=maxscaled
|
||||||
|
socket=default
|
||||||
|
|
||||||
|
[server1]
|
||||||
|
type=server
|
||||||
|
address=###node_server_IP_1###
|
||||||
|
port=###node_server_port_1###
|
||||||
|
protocol=MySQLBackend
|
||||||
|
|
||||||
|
[server2]
|
||||||
|
type=server
|
||||||
|
address=###node_server_IP_2###
|
||||||
|
port=###node_server_port_2###
|
||||||
|
protocol=MySQLBackend
|
54
maxscale-system-test/mxs1310_implicit_db.cpp
Normal file
54
maxscale-system-test/mxs1310_implicit_db.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* Test for MXS-1310.
|
||||||
|
* - Only explicit databases used -> shard containing the explicit database
|
||||||
|
* - Only implicit databases used -> shard containing current database
|
||||||
|
* - Mix of explicit and implicit databases -> shard containing current database
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "testconnections.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
TestConnections test(argc, argv);
|
||||||
|
|
||||||
|
// Get the @@server_id value from both shards
|
||||||
|
char server_id[2][1024];
|
||||||
|
test.repl->connect();
|
||||||
|
sprintf(server_id[0], "%d", test.repl->get_server_id(0));
|
||||||
|
sprintf(server_id[1], "%d", test.repl->get_server_id(1));
|
||||||
|
execute_query(test.repl->nodes[0],
|
||||||
|
"CREATE DATABASE db1;"
|
||||||
|
"CREATE TABLE db1.t1(id int);"
|
||||||
|
"INSERT INTO db1.t1 VALUES (@@server_id)");
|
||||||
|
execute_query(test.repl->nodes[1],
|
||||||
|
"CREATE DATABASE db2;"
|
||||||
|
"CREATE TABLE db2.t2(id int);"
|
||||||
|
"INSERT INTO db2.t2 VALUES (@@server_id)");
|
||||||
|
test.repl->sync_slaves();
|
||||||
|
|
||||||
|
test.tprintf("Run test with sharded database as active database");
|
||||||
|
test.connect_rwsplit();
|
||||||
|
test.try_query(test.conn_rwsplit, "USE db2");
|
||||||
|
execute_query_check_one(test.conn_rwsplit, "SELECT @@server_id, id FROM t2", server_id[1]);
|
||||||
|
execute_query_check_one(test.conn_rwsplit, "SELECT @@server_id, id FROM db1.t1", server_id[0]);
|
||||||
|
execute_query_check_one(test.conn_rwsplit, "SELECT @@server_id, a.id FROM t2 as a JOIN db1.t1 as b",
|
||||||
|
server_id[1]);
|
||||||
|
test.close_rwsplit();
|
||||||
|
|
||||||
|
test.tprintf("Run test with a common database as active database");
|
||||||
|
test.connect_rwsplit();
|
||||||
|
test.try_query(test.conn_rwsplit, "USE db1");
|
||||||
|
execute_query_check_one(test.conn_rwsplit, "SELECT @@server_id, id FROM t1", server_id[0]);
|
||||||
|
execute_query_check_one(test.conn_rwsplit, "SELECT @@server_id, id FROM db2.t2", server_id[1]);
|
||||||
|
execute_query_check_one(test.conn_rwsplit, "SELECT @@server_id, a.id FROM t1 as a JOIN db1.t1 as b",
|
||||||
|
server_id[0]);
|
||||||
|
test.close_rwsplit();
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
execute_query(test.repl->nodes[0], "DROP DATABASE db1");
|
||||||
|
execute_query(test.repl->nodes[1], "DROP DATABASE db2");
|
||||||
|
|
||||||
|
test.repl->fix_replication();
|
||||||
|
|
||||||
|
return test.global_result;
|
||||||
|
}
|
Reference in New Issue
Block a user