MXS-3410 Add Mariadb_nodes::prepare_for_test(MYSQL*)

Needs to be a member function as the dropping of anonymous
users must be done differently for Xpand. With current code,
no anonymous users in Xpand will be dropped, and there will
always be an error (so, should someone care about the return
code, this would not work).
This commit is contained in:
Johan Wikman 2021-02-19 12:50:43 +02:00
parent c0abec4e5b
commit f782a538cc
2 changed files with 6 additions and 3 deletions

View File

@ -355,8 +355,10 @@ public:
/**
* @brief Flush hosts, adjust settings, remove anonymous users, etc.
* @param conn Valid handle to some node.
* @return True in case of success, false otherwise.
*/
bool prepare_for_test(MYSQL* conn);
bool prepare_for_test();
/**

View File

@ -1028,7 +1028,7 @@ std::vector<int> Mariadb_nodes::get_all_server_ids()
return rval;
}
bool do_prepare_for_test(MYSQL* conn)
bool Mariadb_nodes::prepare_for_test(MYSQL* conn)
{
int local_result = 0;
@ -1100,9 +1100,10 @@ bool Mariadb_nodes::prepare_for_test()
for (int i = 0; i < N; i++)
{
std::packaged_task<bool(MYSQL*)> task(do_prepare_for_test);
bool (Mariadb_nodes::*function)(MYSQL*) = &Mariadb_nodes::prepare_for_test;
std::packaged_task<bool(Mariadb_nodes*, MYSQL*)> task(function);
futures.push_back(task.get_future());
std::thread(std::move(task), nodes[i]).detach();
std::thread(std::move(task), this, nodes[i]).detach();
}
for (auto& f : futures)