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:
Markus Mäkelä
2018-04-11 10:17:23 +03:00
parent dc3c848df8
commit 553e159182
5 changed files with 144 additions and 0 deletions

View 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;
}