MXS-1295: Add test case

The test case checks that the strict_sp_calls parameter works as expected.
This commit is contained in:
Markus Mäkelä
2017-09-20 10:36:27 +03:00
parent 9046db06c5
commit 481ad080ef
3 changed files with 98 additions and 0 deletions

View File

@ -488,6 +488,12 @@ add_test_executable(mxs1319.cpp mxs1319 replication LABELS MySQLAuth REPL_BACKEN
# https://jira.mariadb.org/browse/MXS-1418
add_test_executable(mxs1418.cpp mxs1418 replication LABELS maxscale REPL_BACKEND)
# MXS-1295: MaxScale's readwritesplit router does not take into account the fact
# that stored procedure call may change the value of a user variable
#
# https://jira.mariadb.org/browse/MXS-1295
add_test_executable(mxs1295_sp_call.cpp mxs1295_sp_call mxs1295 LABELS maxscale REPL_BACKEND)
# 'namedserverfilter' test
add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND)

View File

@ -0,0 +1,48 @@
[maxscale]
threads=###threads###
[MySQL Monitor]
type=monitor
module=mysqlmon
###repl51###
servers=server1,server2
user=maxskysql
passwd=skysql
monitor_interval=1000
[RW Split Router]
type=service
router=readwritesplit
servers=server1,server2
user=maxskysql
passwd=skysql
strict_multi_stmt=false
strict_sp_calls=true
[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
[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

View File

@ -0,0 +1,44 @@
/**
* Test for MXS-1295: https://jira.mariadb.org/browse/MXS-1295
*/
#include "testconnections.h"
const char sp_sql[] =
"DROP PROCEDURE IF EXISTS multi;"
"CREATE PROCEDURE multi()"
"BEGIN"
" SELECT @@server_id;"
"END";
int get_server_id(MYSQL* conn)
{
char value[200] = "";
find_field(conn, "SELECT @@server_id", "@@server_id", value);
return atoi(value);
}
int main(int argc, char *argv[])
{
TestConnections test(argc, argv);
test.connect_maxscale();
test.repl->connect();
test.tprintf("Create the stored procedure and check that it works");
test.try_query(test.repl->nodes[0], sp_sql);
test.try_query(test.repl->nodes[0], "CALL multi()");
test.tprintf("Check that queries after a CALL command get routed to the master");
int master = get_server_id(test.repl->nodes[0]);
int slave = get_server_id(test.repl->nodes[1]);
int result = get_server_id(test.conn_rwsplit);
test.add_result(result != slave, "The query should be routed to a slave(%d): %d", slave, result);
test.try_query(test.conn_rwsplit, "USE test");
test.try_query(test.conn_rwsplit, "CALL multi()");
result = get_server_id(test.conn_rwsplit);
test.add_result(result != master, "The query should be routed to the master(%d): %d", master, result);
return test.global_result;
}