diff --git a/maxscale-system-test/.gitignore b/maxscale-system-test/.gitignore index 5e5cfd663..a54ba1c74 100644 --- a/maxscale-system-test/.gitignore +++ b/maxscale-system-test/.gitignore @@ -160,6 +160,7 @@ mxs1643_extra_events mxs1653_ps_hang mxs1677_temp_table mxs1678_relay_master +mxs1719 mxs244_prepared_stmt_loop mxs280_select_outfile mxs314 diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 0a3660366..d8e30187e 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -829,6 +829,9 @@ add_test_executable(mxs781_binlog_wrong_passwrd.cpp mxs781_binlog_wrong_passwrd # Regression case for crash if long host name is used for binlog router (in 'change master to ...') add_test_executable(mxs813_long_hostname.cpp mxs813_long_hostname setup_binlog LABELS binlogrouter BREAKS_REPL) +# Test that masking filter can handle multi-statements. +add_test_executable(mxs1719.cpp mxs1719 mxs1719 LABELS masking REPL_BACKEND) + # configure binlog router setup, execute queries and transactions, check data; add_test_executable(setup_binlog.cpp setup_binlog setup_binlog LABELS binlogrouter BREAKS_REPL) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs1719 b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1719 new file mode 100644 index 000000000..3c528532f --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1719 @@ -0,0 +1,48 @@ +[maxscale] +threads=###threads### +maxlog=1 +log_info=1 + +[server1] +type=server +address=###node_server_IP_1### +port=###node_server_port_1### +protocol=MySQLBackend + +[TheMonitor] +type=monitor +module=mysqlmon +servers=server1 +user=maxskysql +passwd=skysql + +[Masking] +type=filter +module=masking +rules=/home/vagrant/mxs1719.json +warn_type_mismatch=always +large_payload=ignore + +[RWS] +type=service +router=readwritesplit +servers=server1 +user=maxskysql +passwd=skysql +filters=Masking + +[RWS-Listener] +type=listener +service=RWS +protocol=MySQLClient +port=4006 + +[CLI] +type=service +router=cli + +[CLI-Listener] +type=listener +service=CLI +protocol=maxscaled +socket=default diff --git a/maxscale-system-test/mxs1719.cpp b/maxscale-system-test/mxs1719.cpp new file mode 100644 index 000000000..e7be1d92e --- /dev/null +++ b/maxscale-system-test/mxs1719.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2020-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include +#include "testconnections.h" + +using namespace std; + +namespace +{ + +void init(TestConnections& test) +{ + MYSQL* pMysql = test.maxscales->conn_rwsplit[0]; + + test.try_query(pMysql, "DROP TABLE IF EXISTS MXS_1719"); + test.try_query(pMysql, "CREATE TABLE MXS_1719 (a TEXT, b TEXT)"); + test.try_query(pMysql, "INSERT INTO MXS_1719 VALUES (1, 1)"); +} + +void run(TestConnections& test) +{ + init(test); + + MYSQL* pMysql = mysql_init(NULL); + test.assert(pMysql, "Could not create MYSQL handle."); + + const char* zHost = test.maxscales->IP[0]; + const char* zUser = test.maxscales->user_name; + const char* zPassword = test.maxscales->password; + int port = test.maxscales->rwsplit_port[0]; + + if (mysql_real_connect(pMysql, test.maxscales->IP[0], zUser, zPassword, "test", port, NULL, + CLIENT_MULTI_STATEMENTS)) + { + // One multi-statement with two UPDATEs. + test.try_query(pMysql, "UPDATE MXS_1719 SET a=1; UPDATE MXS_1719 SET a=1;"); + // This will hang immediately, so we can shorten the timeout. + test.set_timeout(5); + test.try_query(pMysql, "SELECT * FROM MXS_1719"); + } + else + { + test.assert(false, "Could not connect to MaxScale."); + } +} + +} + +int main(int argc, char* argv[]) +{ + TestConnections::skip_maxscale_start(true); + + TestConnections test(argc, argv); + + if (test.maxscales->copy_to_node(0, "./mxs1719.json", "/home/vagrant/mxs1719.json") == 0) + { + if (test.maxscales->start() == 0) + { + if (test.maxscales->connect_rwsplit() == 0) + { + run(test); + } + else + { + test.assert(false, "Could not connect to RWS."); + } + } + else + { + test.assert(false, "Could not start MaxScale."); + } + } + else + { + test.assert(false, "Could not copy masking file to MaxScale node."); + } + + return test.global_result; +} diff --git a/maxscale-system-test/mxs1719.json b/maxscale-system-test/mxs1719.json new file mode 100644 index 000000000..74869426c --- /dev/null +++ b/maxscale-system-test/mxs1719.json @@ -0,0 +1,12 @@ +{ + "rules": [ + { + "replace": { + "column": "a" + }, + "with": { + "fill": "X" + } + } + ] +}