From 099c2f87bc3fccd2ea0665fa14f2c70497c86af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 27 Sep 2017 19:08:09 +0300 Subject: [PATCH] MXS-1457: Add test case Added a test that reproduces the problem. --- maxscale-system-test/CMakeLists.txt | 4 ++ ...xscale.cnf.template.mxs1457_ignore_deleted | 60 +++++++++++++++++++ .../mxs1457_ignore_deleted.cpp | 46 ++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 maxscale-system-test/cnf/maxscale.cnf.template.mxs1457_ignore_deleted create mode 100644 maxscale-system-test/mxs1457_ignore_deleted.cpp diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 66b2315e2..90d31c0ff 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -498,6 +498,10 @@ add_test_executable(mxs1295_sp_call.cpp mxs1295_sp_call mxs1295 LABELS maxscale # https://jira.mariadb.org/browse/MXS-1451 add_test_executable(mxs1451_skip_auth.cpp mxs1451_skip_auth mxs1451_skip_auth LABELS maxscale REPL_BACKEND) +# MXS-1457: Deleted servers are not ignored when users are loaded +# https://jira.mariadb.org/browse/MXS-1457 +add_test_executable(mxs1457_ignore_deleted.cpp mxs1457_ignore_deleted mxs1457_ignore_deleted LABELS REPL_BACKEND) + # 'namedserverfilter' test add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs1457_ignore_deleted b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1457_ignore_deleted new file mode 100644 index 000000000..14b88472a --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1457_ignore_deleted @@ -0,0 +1,60 @@ +[maxscale] +threads=###threads### +log_info=1 + +[MySQL Monitor] +type=monitor +module=mysqlmon +###repl51### +servers=server1,server2,server3,server4 +user=maxskysql +passwd=skysql +monitor_interval=1000 + +[RW Split Router] +type=service +router=readwritesplit +servers=server1,server2,server3,server4 +user=maxskysql +passwd=skysql +router_options=master_failure_mode=error_on_write + +[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 + +[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/mxs1457_ignore_deleted.cpp b/maxscale-system-test/mxs1457_ignore_deleted.cpp new file mode 100644 index 000000000..753ea5d07 --- /dev/null +++ b/maxscale-system-test/mxs1457_ignore_deleted.cpp @@ -0,0 +1,46 @@ +/** + * MXS-1457: Deleted servers are not ignored when users are loaded + * + * Check that a corrupt and deleted server is not used to load users + */ + +#include "testconnections.h" + +int main(int argc, char *argv[]) +{ + TestConnections test(argc, argv); + + test.set_timeout(60); + test.repl->connect(); + execute_query(test.repl->nodes[0], "CREATE USER 'auth_test'@'%%' IDENTIFIED BY 'test'"); + execute_query(test.repl->nodes[0], "GRANT ALL ON *.* to 'auth_test'@'%%'"); + test.repl->sync_slaves(); + test.repl->close_connections(); + + // Stop slaves and drop the user on the master + test.repl->stop_slaves(); + test.repl->connect(); + execute_query(test.repl->nodes[0], "DROP USER 'auth_test'@'%%'"); + test.repl->close_connections(); + + test.set_timeout(60); + MYSQL* conn = open_conn_db(test.rwsplit_port, test.maxscale_ip(), "test", "auth_test", "test", false); + test.add_result(mysql_errno(conn) == 0, "Connection with users from master should fail"); + mysql_close(conn); + + test.ssh_maxscale(true, "maxadmin remove server server1 \"RW Split Router\""); + conn = open_conn_db(test.rwsplit_port, test.maxscale_ip(), "test", "auth_test", "test", false); + test.add_result(mysql_errno(conn), "Connection should be OK: %s", mysql_error(conn)); + test.try_query(conn, "SELECT 1"); + mysql_close(conn); + + test.set_timeout(60); + test.repl->connect(); + execute_query(test.repl->nodes[1], "START SLAVE"); + execute_query(test.repl->nodes[2], "START SLAVE"); + execute_query(test.repl->nodes[3], "START SLAVE"); + test.repl->sync_slaves(); + test.repl->close_connections(); + + return test.global_result; +}