MXS-3410 Rename Mariadb_nodes::flush_hosts() to prepare_for_test()

The function does more than simply executes "FLUSH HOSTS". Also
change return type to bool as that is what it has returned.
This commit is contained in:
Johan Wikman
2021-02-19 12:36:16 +02:00
parent 3fefe557c0
commit c0abec4e5b
8 changed files with 19 additions and 15 deletions

View File

@ -109,7 +109,8 @@ int main(int argc, char* argv[])
pthread_join(parall_traffic1[j], NULL); pthread_join(parall_traffic1[j], NULL);
} }
Test->tprintf("All threads are finished"); Test->tprintf("All threads are finished");
Test->repl->flush_hosts(); // TODO: Just a simple flush_hosts() may be sufficient.
Test->repl->prepare_for_test();
Test->tprintf("Change user to '%s' in order to be able to DROP user", Test->maxscales->user_name); Test->tprintf("Change user to '%s' in order to be able to DROP user", Test->maxscales->user_name);
Test->set_timeout(30); Test->set_timeout(30);

View File

@ -354,10 +354,10 @@ public:
std::vector<std::string> get_all_server_ids_str(); std::vector<std::string> get_all_server_ids_str();
/** /**
* @brief Execute 'mysqladmin flush-hosts' on all nodes * @brief Flush hosts, adjust settings, remove anonymous users, etc.
* @return 0 in case of success * @return True in case of success, false otherwise.
*/ */
int flush_hosts(); bool prepare_for_test();
/** /**
* @brief Execute query on all nodes * @brief Execute query on all nodes

View File

@ -82,7 +82,7 @@ bool Mariadb_nodes::setup()
{ {
read_env(); read_env();
truncate_mariadb_logs(); truncate_mariadb_logs();
flush_hosts(); prepare_for_test();
close_active_connections(); close_active_connections();
return true; return true;
@ -874,7 +874,7 @@ bool Mariadb_nodes::fix_replication()
if (check_replication() == 0) if (check_replication() == 0)
{ {
cout << "Replication is fixed" << endl; cout << "Replication is fixed" << endl;
rval = flush_hosts(); rval = prepare_for_test();
} }
else else
{ {
@ -1028,7 +1028,7 @@ std::vector<int> Mariadb_nodes::get_all_server_ids()
return rval; return rval;
} }
bool do_flush_hosts(MYSQL* conn) bool do_prepare_for_test(MYSQL* conn)
{ {
int local_result = 0; int local_result = 0;
@ -1088,11 +1088,11 @@ bool do_flush_hosts(MYSQL* conn)
return local_result == 0; return local_result == 0;
} }
int Mariadb_nodes::flush_hosts() bool Mariadb_nodes::prepare_for_test()
{ {
if (this->nodes[0] == NULL && (this->connect() != 0)) if (this->nodes[0] == NULL && (this->connect() != 0))
{ {
return 1; return false;
} }
bool all_ok = true; bool all_ok = true;
@ -1100,7 +1100,7 @@ int Mariadb_nodes::flush_hosts()
for (int i = 0; i < N; i++) for (int i = 0; i < N; i++)
{ {
std::packaged_task<bool(MYSQL*)> task(do_flush_hosts); std::packaged_task<bool(MYSQL*)> task(do_prepare_for_test);
futures.push_back(task.get_future()); futures.push_back(task.get_future());
std::thread(std::move(task), nodes[i]).detach(); std::thread(std::move(task), nodes[i]).detach();
} }

View File

@ -107,7 +107,8 @@ int main(int argc, char* argv[])
/** Create connections to readconnroute slave */ /** Create connections to readconnroute slave */
create_and_check_connections(Test, 3); create_and_check_connections(Test, 3);
Test->repl->flush_hosts(); // TODO: Just a simple flush_hosts() may be sufficient.
Test->repl->prepare_for_test();
int rval = Test->global_result; int rval = Test->global_result;
delete Test; delete Test;

View File

@ -83,7 +83,8 @@ int main(int argc, char** argv)
test.tprintf("Flushing backend hosts"); test.tprintf("Flushing backend hosts");
test.set_timeout(60); test.set_timeout(60);
test.repl->flush_hosts(); // TODO: Just a simple flush_hosts() may be sufficient.
test.repl->prepare_for_test();
test.tprintf("Dropping tables and users"); test.tprintf("Dropping tables and users");
test.set_timeout(60); test.set_timeout(60);

View File

@ -87,7 +87,8 @@ int main(int argc, char* argv[])
test.stop_timeout(); test.stop_timeout();
test.tprintf("Make sure that replication works"); test.tprintf("Make sure that replication works");
test.repl->flush_hosts(); // TODO: Just a simple flush_hosts() may be sufficient.
test.repl->prepare_for_test();
if (!test.repl->fix_replication()) if (!test.repl->fix_replication())
{ {
test.tprintf("Replication is broken!"); test.tprintf("Replication is broken!");

View File

@ -278,7 +278,7 @@ int main(int argc, char* argv[])
Test->repl->disconnect(); Test->repl->disconnect();
/** Clean up test environment */ /** Clean up test environment */
Test->repl->flush_hosts(); Test->repl->prepare_for_test();
int rval = Test->global_result; int rval = Test->global_result;
delete Test; delete Test;
return rval; return rval;

View File

@ -112,7 +112,7 @@ int main(int argc, char* argv[])
} }
/** Clean up test environment */ /** Clean up test environment */
Test->repl->flush_hosts(); Test->repl->prepare_for_test();
int rval = Test->global_result; int rval = Test->global_result;
delete Test; delete Test;
return rval; return rval;