MXS-1849 Add basic test case

This commit is contained in:
Marko 2018-07-09 11:55:54 +03:00
parent 293279366f
commit 89e83fab4b
3 changed files with 104 additions and 0 deletions

View File

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

View File

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

View File

@ -0,0 +1,42 @@
/**
* MXS-1849: Table family sharding router test
*
* https://jira.mariadb.org/browse/MXS-1849
*/
#include <iostream>
#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;
}