MXS-2167: Add test case

Added a test case that reproduces the problem.
This commit is contained in:
Markus Mäkelä
2018-11-15 12:46:10 +02:00
parent 396da06eb8
commit 598edea203
3 changed files with 159 additions and 0 deletions

View File

@ -196,6 +196,12 @@ add_test_executable(encrypted_passwords.cpp encrypted_passwords replication LABE
# Basic MaxCtrl test
add_test_executable(maxctrl_basic.cpp maxctrl_basic replication LABELS maxctrl REPL_BACKEND)
# MXS-2167: Monitors should be able to use extra_port
add_test_executable(mxs2167_extra_port.cpp mxs2167_extra_port mxs2167_extra_port LABELS REPL_BACKEND)
# TODO: Remove this once MXS-2167 is fixed
set_tests_properties(mxs2167_extra_port PROPERTIES WILL_FAIL TRUE)
############################################
# BEGIN: Tests that require GTID #
############################################

View File

@ -0,0 +1,63 @@
[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
[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
extra_port=33066
[server2]
type=server
address=###node_server_IP_2###
port=###node_server_port_2###
protocol=MySQLBackend
extra_port=33066
[server3]
type=server
address=###node_server_IP_3###
port=###node_server_port_3###
protocol=MySQLBackend
extra_port=33066
[server4]
type=server
address=###node_server_IP_4###
port=###node_server_port_4###
protocol=MySQLBackend
extra_port=33066

View File

@ -0,0 +1,90 @@
/**
* MXS-2167: Monitors should be able to use extra_port
*/
#include "testconnections.h"
#include <iostream>
using std::cout;
using std::endl;
int main(int argc, char** argv)
{
TestConnections test(argc, argv);
cout << "Stopping MaxScale" << endl;
test.maxscales->stop();
cout << "Configuring servers" << endl;
// Add the extra_port parameter to all servers
for (int i = 0; i < test.repl->N; i++)
{
test.repl->stash_server_settings(i);
test.repl->add_server_setting(i, "extra_port=33066");
test.repl->ssh_node_f(i, true, "service mysql restart");
}
test.repl->connect();
test.try_query(test.repl->nodes[0], "%s", "CREATE USER 'monitor'@'%' IDENTIFIED BY 'monitor'");
test.try_query(test.repl->nodes[0], "%s", "GRANT ALL ON *.* TO 'monitor'@'%'");
test.repl->disconnect();
cout << "Starting MaxScale" << endl;
test.maxscales->start();
// Stop the monitor to force the connections to be closed
test.maxctrl("stop monitor MySQL-Monitor");
// Limit the connections to 20 (is erased on restart)
test.repl->connect();
test.try_query(test.repl->nodes[0], "SET GLOBAL max_connections=20");
test.repl->disconnect();
std::vector<MYSQL*> connections;
// Open connections until we hit the limit
for (int i = 0; i < 40; i++)
{
cout << "Opening connection " << i << endl;
MYSQL* conn = test.maxscales->open_rwsplit_connection();
if (execute_query_silent(conn, "SELECT 1") == 0)
{
connections.push_back(conn);
}
else
{
mysql_close(conn);
break;
}
}
// Start the monitor to force it to reconnect
test.maxctrl("start monitor MySQL-Monitor");
test.maxscales->wait_for_monitor();
// Make sure the old connections still work
for (auto a : connections)
{
test.try_query(a, "SELECT 2");
mysql_close(a);
}
cout << "Stopping MaxScale" << endl;
test.maxscales->stop();
// Remove extra_port
for (int i = 0; i < test.repl->N; i++)
{
test.repl->restore_server_settings(i);
test.repl->ssh_node_f(i, true, "service mysql restart");
}
test.repl->connect();
test.try_query(test.repl->nodes[0], "%s", "DROP USER 'monitor'@'%'");
test.repl->disconnect();
return test.global_result;
}