From 36e64aefe862d65784522406b6e262ac89507890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 13 Feb 2019 08:54:17 +0200 Subject: [PATCH] MXS-2326: Add hint cloning test case The test checks that the steps taken to reproduce the bug no longer result in a failure to route the query correctly. --- maxscale-system-test/CMakeLists.txt | 5 +- .../maxscale.cnf.template.mxs2326_hint_clone | 53 +++++++++++++++++++ maxscale-system-test/mxs2326_hint_clone.cpp | 29 ++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100755 maxscale-system-test/cnf/maxscale.cnf.template.mxs2326_hint_clone create mode 100644 maxscale-system-test/mxs2326_hint_clone.cpp diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 3de14a9c3..4b4c33699 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -919,7 +919,10 @@ add_test_executable(mxs2115_version_string.cpp mxs2115_version_string replicatio add_test_executable(mxs2295_change_user_loop.cpp mxs2295_change_user_loop mxs2295_change_user_loop LABELS REPL_BACKEND) # MXS-2300: Prune session command history -add_test_executable(mxs2300_history_pruning.cpp mxs2300_history_pruning mxs2300_history_pruning LABELS REPL_BACKEND) +add_test_executable(mxs2300_history_pruning.cpp mxs2300_history_pruning mxs2300_history_pruning LABELS readwritesplit REPL_BACKEND) + +# MXS-2326: Routing hints aren't cloned in gwbuf_clone +add_test_executable(mxs2326_hint_clone.cpp mxs2326_hint_clone mxs2326_hint_clone LABELS readwritesplit REPL_BACKEND) ############################################ # BEGIN: binlogrouter and avrorouter tests # diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs2326_hint_clone b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2326_hint_clone new file mode 100755 index 000000000..292912ad1 --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2326_hint_clone @@ -0,0 +1,53 @@ +[maxscale] +threads=###threads### +log_info=1 + +[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 + +[MySQL Monitor] +type=monitor +module=mysqlmon +servers=server1,server2,server3,server4 +user=maxskysql +password=skysql +monitor_interval=1000 + +[hint] +type=filter +module=hintfilter + +[RW Split Router] +type=service +router=readwritesplit +servers=server1,server2,server3,server4 +user=maxskysql +password=skysql +filters=hint + +[RW Split Listener] +type=listener +service=RW Split Router +protocol=MySQLClient +port=4006 diff --git a/maxscale-system-test/mxs2326_hint_clone.cpp b/maxscale-system-test/mxs2326_hint_clone.cpp new file mode 100644 index 000000000..3224a31dd --- /dev/null +++ b/maxscale-system-test/mxs2326_hint_clone.cpp @@ -0,0 +1,29 @@ +/** + * MXS-2326: Routing hints aren't cloned in gwbuf_clone + */ + +#include "testconnections.h" + +int main(int argc, char** argv) +{ + TestConnections test(argc, argv); + Connection c = test.maxscales->rwsplit(); + test.expect(c.connect(), "Connection should work: %s", c.error()); + + std::string correct_id = c.field("SELECT @@server_id -- maxscale route to server server4"); + + test.tprintf("Executing session command"); + test.expect(c.query("SET @a = 1"), "SET should work: %s", c.error()); + + test.tprintf("Forcing a reconnection to occur on the next query by blocking the server"); + test.repl->block_node(3); + test.maxscales->wait_for_monitor(); + test.repl->unblock_node(3); + test.maxscales->wait_for_monitor(); + + test.tprintf("Executing a query with a routing hint to a server that the session is not connected to"); + test.expect(c.check("SELECT @@server_id -- maxscale route to server server4", + correct_id), "Hint should be routed to the same server"); + + return test.global_result; +}