MXS-1503: Test that no extra slaves are taken into use
Added a test that verifies that the slave connection count restrictions work.
This commit is contained in:
@ -599,6 +599,9 @@ add_test_executable(mxs1503_master_reconnection.cpp mxs1503_master_reconnection
|
||||
# Master reconnection with session commands
|
||||
add_test_executable(mxs1503_queued_sescmd.cpp mxs1503_queued_sescmd mxs1503_master_reconnection LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# Check that no extra slaves are taken into use
|
||||
add_test_executable(mxs1503_extra_slaves.cpp mxs1503_extra_slaves mxs1503_extra_slaves LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# MXS-1506: Delayed query retry
|
||||
# https://jira.mariadb.org/browse/MXS-1506
|
||||
add_test_executable(mxs1506_delayed_retry.cpp mxs1506_delayed_retry mxs1506_delayed_retry LABELS readwritesplit REPL_BACKEND)
|
||||
|
@ -0,0 +1,59 @@
|
||||
[maxscale]
|
||||
threads=###threads###
|
||||
|
||||
[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
|
||||
max_slave_connections=1
|
||||
|
||||
[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
|
@ -525,6 +525,32 @@ int find_field(MYSQL* conn, const char* sql, const char* field_name, char* value
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<std::string> get_row(MYSQL* conn, std::string sql)
|
||||
{
|
||||
std::vector<std::string> rval;
|
||||
MYSQL_RES* res;
|
||||
|
||||
if (mysql_query(conn, sql.c_str()) == 0 && (res = mysql_store_result(conn)))
|
||||
{
|
||||
MYSQL_ROW row = mysql_fetch_row(res);
|
||||
|
||||
if (row)
|
||||
{
|
||||
for (int i = 0; i < mysql_num_fields(res); i++)
|
||||
{
|
||||
rval.push_back(row[i]);
|
||||
}
|
||||
}
|
||||
mysql_free_result(res);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Query failed: %s\n", mysql_error(conn));
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
int get_int_version(std::string version)
|
||||
{
|
||||
std::istringstream str(version);
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* Opens connection to DB: wropper over mysql_real_connect
|
||||
@ -204,6 +205,16 @@ int get_conn_num(MYSQL* conn, std::string ip, std::string hostname, std::string
|
||||
*/
|
||||
int find_field(MYSQL* conn, const char* sql, const char* field_name, char* value);
|
||||
|
||||
/**
|
||||
* Execute a query and return the first row
|
||||
*
|
||||
* @param conn The connection to use
|
||||
* @param sql The query to execute
|
||||
*
|
||||
* @return The first row as a list of strings
|
||||
*/
|
||||
std::vector<std::string> get_row(MYSQL* conn, std::string sql);
|
||||
|
||||
int get_int_version(std::string version);
|
||||
|
||||
#endif // MARIADB_FUNC_H
|
||||
|
45
maxscale-system-test/mxs1503_extra_slaves.cpp
Normal file
45
maxscale-system-test/mxs1503_extra_slaves.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* MXS-1503: Make sure no extra slaves are taken into use
|
||||
*
|
||||
* https://jira.mariadb.org/browse/MXS-1503
|
||||
*/
|
||||
#include "testconnections.h"
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
|
||||
void query(MYSQL* conn, std::string q)
|
||||
{
|
||||
execute_query(conn, "%s", q.c_str());
|
||||
mysql_close(conn);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
std::vector<std::thread> connections;
|
||||
|
||||
test.maxscales->connect();
|
||||
|
||||
auto original_row = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id");
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
connections.emplace_back(query, test.maxscales->open_rwsplit_connection(), "SELECT SLEEP(10)");
|
||||
sleep(1);
|
||||
auto row = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id");
|
||||
test.assert(row == original_row, "Value of @@server_id should not change: %s", row.at(0).c_str());
|
||||
}
|
||||
|
||||
for (auto& a: connections)
|
||||
{
|
||||
a.join();
|
||||
auto row = get_row(test.maxscales->conn_rwsplit[0], "SELECT @@server_id");
|
||||
test.assert(row == original_row, "Value of @@server_id should not change: %s", row.at(0).c_str());
|
||||
}
|
||||
|
||||
|
||||
test.maxscales->disconnect();
|
||||
|
||||
return test.global_result;
|
||||
}
|
Reference in New Issue
Block a user