Wait for a number of monitor intervals in tests
The tests can now wait for a number of monitor intervals. This removes the need to have hard-coded sleeps in the code and makes monitor tests more robust under heavier load.
This commit is contained in:
@ -40,7 +40,10 @@ int main(int argc, char** argv)
|
||||
const int old_master_id = get_master_server_id(test); // Read master id now before shutdown.
|
||||
const int master_index = test.repl->master;
|
||||
test.repl->stop_node(master_index);
|
||||
sleep(10);
|
||||
|
||||
// Wait until failover is performed
|
||||
test.maxscales->wait_for_monitor(3);
|
||||
|
||||
// Recreate maxscale session
|
||||
mysql_close(maxconn);
|
||||
maxconn = test.maxscales->open_rwsplit_connection(0);
|
||||
@ -54,20 +57,16 @@ int main(int argc, char** argv)
|
||||
{
|
||||
cout << "Sending more inserts." << endl;
|
||||
generate_traffic_and_check(test, maxconn, 5);
|
||||
if (find_field(maxconn, GTID_QUERY, GTID_FIELD, result_tmp) == 0)
|
||||
{
|
||||
gtid_final = result_tmp;
|
||||
}
|
||||
print_gtids(test);
|
||||
cout << "Bringing old master back online..." << endl;
|
||||
test.repl->start_node(master_index, (char*) "");
|
||||
sleep(10);
|
||||
test.maxscales->wait_for_monitor();
|
||||
test.repl->connect();
|
||||
get_output(test);
|
||||
test.tprintf("and manually rejoining it to cluster.");
|
||||
const char REJOIN_CMD[] = "maxadmin call command mariadbmon rejoin MySQL-Monitor server1";
|
||||
test.maxscales->ssh_node_output(0, REJOIN_CMD , true, &ec);
|
||||
sleep(10);
|
||||
test.maxscales->wait_for_monitor();
|
||||
get_output(test);
|
||||
|
||||
string gtid_old_master;
|
||||
@ -75,15 +74,20 @@ int main(int argc, char** argv)
|
||||
{
|
||||
gtid_old_master = result_tmp;
|
||||
}
|
||||
if (find_field(maxconn, GTID_QUERY, GTID_FIELD, result_tmp) == 0)
|
||||
{
|
||||
gtid_final = result_tmp;
|
||||
}
|
||||
|
||||
cout << LINE << "\n";
|
||||
print_gtids(test);
|
||||
cout << LINE << "\n";
|
||||
test.assert(gtid_final == gtid_old_master, "Old master did not successfully rejoin the cluster.");
|
||||
test.assert(gtid_final == gtid_old_master, "Old master did not successfully rejoin the cluster (%s != %s).", gtid_final.c_str(), gtid_old_master.c_str());
|
||||
// Switch master back to server1 so last check is faster
|
||||
int ec;
|
||||
test.maxscales->ssh_node_output(0, "maxadmin call command mysqlmon switchover "
|
||||
"MySQL-Monitor server1 server2" , true, &ec);
|
||||
sleep(10); // Wait for monitor to update status
|
||||
test.maxscales->wait_for_monitor(); // Wait for monitor to update status
|
||||
get_output(test);
|
||||
master_id = get_master_server_id(test);
|
||||
test.assert(master_id == old_master_id, "Switchover back to server1 failed.");
|
||||
@ -91,7 +95,7 @@ int main(int argc, char** argv)
|
||||
else
|
||||
{
|
||||
test.repl->start_node(master_index, (char*) "");
|
||||
sleep(10);
|
||||
test.maxscales->wait_for_monitor();
|
||||
}
|
||||
|
||||
test.repl->fix_replication();
|
||||
|
Reference in New Issue
Block a user