diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 60fdd9a11..9d1bc4216 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -1027,6 +1027,10 @@ add_test_executable(mxs1949_warn_user_injection.cpp mxs1949_warn_user_injection # https://jira.mariadb.org/browse/MXS-1958 add_test_executable(mxs1958_insert_priv.cpp mxs1958_insert_priv replication LABELS REPL_BACKEND) +# MXS-1849: Table family sharding router +# https://jira.mariadb.org/browse/MXS-1849 +add_test_executable(mxs1849_table_sharding.cpp mxs1849_table_sharding mxs1849_table_sharding LABELS schemarouter BREAKS_REPL) + configure_file(templates.h.in templates.h @ONLY) include(CTest) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs1849_table_sharding b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1849_table_sharding new file mode 100755 index 000000000..30b9659ad --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1849_table_sharding @@ -0,0 +1,58 @@ +[maxscale] +threads=###threads### +log_warning=1 + +[MySQL Monitor] +type=monitor +module=mysqlmon +servers=server1,server2,server3,server4 +user=maxskysql +passwd=skysql + +[Sharding router] +type=service +router=schemarouter +servers=server1,server2,server3,server4 +user=maxskysql +passwd=skysql +auth_all_servers=1 + +[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 + +[server3] +type=server +address=###node_server_IP_3### +port=###node_server_port_3### +protocol=MySQLBackend + +[server4] +type=server +address=###node_server_IP_4### +port=###node_server_port_4### +protocol=MySQLBackend diff --git a/maxscale-system-test/mxs1849_table_sharding.cpp b/maxscale-system-test/mxs1849_table_sharding.cpp new file mode 100644 index 000000000..5a4992a0d --- /dev/null +++ b/maxscale-system-test/mxs1849_table_sharding.cpp @@ -0,0 +1,42 @@ +/** + * MXS-1849: Table family sharding router test + * + * https://jira.mariadb.org/browse/MXS-1849 + */ + + +#include +#include "testconnections.h" + +int main(int argc, char *argv[]) +{ + TestConnections test(argc, argv); + test.set_timeout(30); + test.repl->execute_query_all_nodes("STOP SLAVE"); + test.repl->execute_query_all_nodes("DROP DATABASE IF EXISTS shard_db"); + test.repl->execute_query_all_nodes("CREATE DATABASE shard_db"); + MYSQL* conn; + for (int i = 0; i < test.repl->N; i++) + { + conn = open_conn_db(test.repl->port[i], test.repl->IP[i], "shard_db", + test.repl->user_name, test.repl->password, test.ssl); + execute_query(conn, "CREATE TABLE table%d (x1 int, fl int)", i); + mysql_close(conn); + } + + conn = test.maxscales->open_rwsplit_connection(0); + // Check that queries are routed to the right shards + for (int i = 0; i < test.repl->N; i++) + { + test.add_result(execute_query(conn, "SELECT * FROM shard_db.table%d", i), "Query should succeed."); + } + + mysql_close(conn); + test.stop_timeout(); + // Cleanup + test.repl->execute_query_all_nodes("DROP DATABASE IF EXISTS shard_db"); + test.repl->execute_query_all_nodes("START SLAVE"); + sleep(1); + test.repl->fix_replication(); + return test.global_result; +}