MXS-2158 Add test case for rejoining a server with no gtid
This commit is contained in:
parent
48eb57bdc5
commit
45eee098d1
@ -32,6 +32,7 @@ int main(int argc, char** argv)
|
||||
char result_tmp[bufsize];
|
||||
// Advance gtid:s a bit to so gtid variables are updated.
|
||||
generate_traffic_and_check(test, maxconn, 10);
|
||||
mysql_close(maxconn);
|
||||
test.tprintf(LINE);
|
||||
print_gtids(test);
|
||||
get_input();
|
||||
@ -42,19 +43,18 @@ int main(int argc, char** argv)
|
||||
test.repl->stop_node(master_index);
|
||||
|
||||
// Wait until failover is performed
|
||||
test.maxscales->wait_for_monitor(3);
|
||||
|
||||
// Recreate maxscale session
|
||||
mysql_close(maxconn);
|
||||
maxconn = test.maxscales->open_rwsplit_connection(0);
|
||||
test.maxscales->wait_for_monitor(2);
|
||||
get_output(test);
|
||||
|
||||
int master_id = get_master_server_id(test);
|
||||
cout << "Master server id is " << master_id << endl;
|
||||
const bool failover_ok = (master_id > 0 && master_id != old_master_id);
|
||||
test.expect(failover_ok, "Master did not change or no master detected.");
|
||||
string gtid_final;
|
||||
if (failover_ok)
|
||||
|
||||
if (test.ok())
|
||||
{
|
||||
// Recreate maxscale session
|
||||
maxconn = test.maxscales->open_rwsplit_connection(0);
|
||||
cout << "Sending more inserts." << endl;
|
||||
generate_traffic_and_check(test, maxconn, 5);
|
||||
print_gtids(test);
|
||||
@ -74,6 +74,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
gtid_old_master = result_tmp;
|
||||
}
|
||||
string gtid_final;
|
||||
if (find_field(maxconn, GTID_QUERY, GTID_FIELD, result_tmp) == 0)
|
||||
{
|
||||
gtid_final = result_tmp;
|
||||
@ -84,19 +85,54 @@ int main(int argc, char** argv)
|
||||
cout << LINE << "\n";
|
||||
test.expect(gtid_final == gtid_old_master,
|
||||
"Old master did not successfully rejoin the cluster (%s != %s).",
|
||||
gtid_final.c_str(),
|
||||
gtid_old_master.c_str());
|
||||
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);
|
||||
test.maxscales->wait_for_monitor(); // Wait for monitor to update status
|
||||
test.maxscales->ssh_node_output(0, "maxadmin call command mysqlmon switchover "
|
||||
"MySQL-Monitor server1 server2", true, &ec);
|
||||
test.maxscales->wait_for_monitor();
|
||||
get_output(test);
|
||||
master_id = get_master_server_id(test);
|
||||
test.expect(master_id == old_master_id, "Switchover back to server1 failed.");
|
||||
|
||||
// STOP and RESET SLAVE on a server, then remove binlogs. Check that a server with empty binlogs
|
||||
// can be rejoined.
|
||||
if (test.ok())
|
||||
{
|
||||
cout << "Removing slave connection and deleting binlogs on server3 to get empty gtid.\n";
|
||||
int slave_to_reset = 2;
|
||||
test.repl->connect();
|
||||
auto conn = test.repl->nodes[slave_to_reset];
|
||||
string sstatus_query = "SHOW ALL SLAVES STATUS;";
|
||||
test.try_query(conn,
|
||||
"STOP SLAVE; RESET SLAVE ALL; RESET MASTER; SET GLOBAL gtid_slave_pos='';");
|
||||
test.maxscales->wait_for_monitor();
|
||||
get_output(test);
|
||||
auto row = get_row(conn, sstatus_query.c_str());
|
||||
test.expect(row.empty(), "server3 is still replicating.");
|
||||
row = get_row(conn, "SELECT @@gtid_current_pos;");
|
||||
test.expect(row.empty() || row[0].empty(),
|
||||
"server3 gtid is not empty as it should (%s).", row[0].c_str());
|
||||
cout << "Rejoining server3.\n";
|
||||
test.maxscales->ssh_node_output(0, "maxadmin call command mysqlmon rejoin "
|
||||
"MySQL-Monitor server3", true, &ec);
|
||||
test.maxscales->wait_for_monitor();
|
||||
get_output(test);
|
||||
char result[100];
|
||||
if (find_field(conn, sstatus_query.c_str(), "Master_Host", result) == 0)
|
||||
{
|
||||
test.expect(strcmp(result, test.repl->IP[0]) == 0,
|
||||
"server3 did not rejoin the cluster (%s != %s).", result, test.repl->IP[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
test.expect(false, "Could not query slave status.");
|
||||
}
|
||||
if (test.ok())
|
||||
{
|
||||
cout << "server3 joined succesfully, test complete.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -104,6 +140,5 @@ int main(int argc, char** argv)
|
||||
test.maxscales->wait_for_monitor();
|
||||
}
|
||||
|
||||
test.repl->fix_replication();
|
||||
return test.global_result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user