Fix mysqlmon_rejoin_bad2
The test didn't work correctly with the failover/switchover changes. Also cleaned up the test a bit.
This commit is contained in:
@ -28,13 +28,11 @@ static void expect(TestConnections& test, const char* zServer, const StringSet&
|
|||||||
|
|
||||||
std::ostream_iterator<string> oi(cout, ", ");
|
std::ostream_iterator<string> oi(cout, ", ");
|
||||||
|
|
||||||
cout << zServer
|
cout << zServer << ", expected states: ";
|
||||||
<< ", expected states: ";
|
|
||||||
std::copy(expected.begin(), expected.end(), oi);
|
std::copy(expected.begin(), expected.end(), oi);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
cout << zServer
|
cout << zServer << ", found states : ";
|
||||||
<< ", found states : ";
|
|
||||||
std::copy(found.begin(), found.end(), oi);
|
std::copy(found.begin(), found.end(), oi);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
@ -51,7 +49,6 @@ static void expect(TestConnections& test, const char* zServer, const char* zStat
|
|||||||
{
|
{
|
||||||
StringSet s;
|
StringSet s;
|
||||||
s.insert(zState);
|
s.insert(zState);
|
||||||
|
|
||||||
expect(test, zServer, s);
|
expect(test, zServer, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +57,6 @@ static void expect(TestConnections& test, const char* zServer, const char* zStat
|
|||||||
StringSet s;
|
StringSet s;
|
||||||
s.insert(zState1);
|
s.insert(zState1);
|
||||||
s.insert(zState2);
|
s.insert(zState2);
|
||||||
|
|
||||||
expect(test, zServer, s);
|
expect(test, zServer, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,12 +65,14 @@ int main(int argc, char** argv)
|
|||||||
interactive = strcmp(argv[argc - 1], "interactive") == 0;
|
interactive = strcmp(argv[argc - 1], "interactive") == 0;
|
||||||
Mariadb_nodes::require_gtid(true);
|
Mariadb_nodes::require_gtid(true);
|
||||||
TestConnections test(argc, argv);
|
TestConnections test(argc, argv);
|
||||||
MYSQL* maxconn = test.maxscales->open_rwsplit_connection(0);
|
test.repl->connect();
|
||||||
|
|
||||||
// Set up test table
|
|
||||||
basic_test(test);
|
|
||||||
// Delete binlogs to sync gtid:s
|
// Delete binlogs to sync gtid:s
|
||||||
delete_slave_binlogs(test);
|
delete_slave_binlogs(test);
|
||||||
|
// Set up test table
|
||||||
|
basic_test(test);
|
||||||
|
|
||||||
|
MYSQL* maxconn = test.maxscales->open_rwsplit_connection(0);
|
||||||
// Advance gtid:s a bit to so gtid variables are updated.
|
// Advance gtid:s a bit to so gtid variables are updated.
|
||||||
generate_traffic_and_check(test, maxconn, 5);
|
generate_traffic_and_check(test, maxconn, 5);
|
||||||
test.repl->sync_slaves(0);
|
test.repl->sync_slaves(0);
|
||||||
@ -88,7 +86,7 @@ int main(int argc, char** argv)
|
|||||||
cout << "Stopping master, should auto-failover." << endl;
|
cout << "Stopping master, should auto-failover." << endl;
|
||||||
int master_id_old = get_master_server_id(test);
|
int master_id_old = get_master_server_id(test);
|
||||||
test.repl->stop_node(0);
|
test.repl->stop_node(0);
|
||||||
test.maxscales->wait_for_monitor();
|
test.maxscales->wait_for_monitor(2);
|
||||||
get_output(test);
|
get_output(test);
|
||||||
int master_id_new = get_master_server_id(test);
|
int master_id_new = get_master_server_id(test);
|
||||||
cout << "Master server id is " << master_id_new << endl;
|
cout << "Master server id is " << master_id_new << endl;
|
||||||
@ -99,52 +97,56 @@ int main(int argc, char** argv)
|
|||||||
return test.global_result;
|
return test.global_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << "Stopping MaxScale for a moment.\n";
|
||||||
// Stop maxscale to prevent an unintended rejoin.
|
// Stop maxscale to prevent an unintended rejoin.
|
||||||
if (test.stop_maxscale(0))
|
if (test.stop_maxscale(0))
|
||||||
{
|
{
|
||||||
test.expect(false, "Could not stop MaxScale.");
|
test.expect(false, "Could not stop MaxScale.");
|
||||||
return test.global_result;
|
return test.global_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart old master. Then add some events to it.
|
// Restart old master. Then add some events to it.
|
||||||
test.repl->start_node(0, (char*)"");
|
test.repl->start_node(0, (char*)"");
|
||||||
test.maxscales->wait_for_monitor();
|
|
||||||
test.repl->connect();
|
test.repl->connect();
|
||||||
cout << "Adding more events to node 0. It should not join the cluster." << endl;
|
cout << "Adding more events to node 0.\n";
|
||||||
generate_traffic_and_check(test, test.repl->nodes[0], 5);
|
generate_traffic_and_check(test, test.repl->nodes[0], 5);
|
||||||
print_gtids(test);
|
print_gtids(test);
|
||||||
|
|
||||||
|
cout << "Starting MaxScale, node 0 should not be able to join because it has extra events.\n";
|
||||||
// Restart maxscale. Should not rejoin old master.
|
// Restart maxscale. Should not rejoin old master.
|
||||||
if (test.start_maxscale(0))
|
if (test.start_maxscale(0))
|
||||||
{
|
{
|
||||||
test.expect(false, "Could not start MaxScale.");
|
test.expect(false, "Could not start MaxScale.");
|
||||||
return test.global_result;
|
return test.global_result;
|
||||||
}
|
}
|
||||||
test.maxscales->wait_for_monitor();
|
test.maxscales->wait_for_monitor(2);
|
||||||
get_output(test);
|
get_output(test);
|
||||||
|
|
||||||
expect(test, "server1", "Running");
|
expect(test, "server1", "Running");
|
||||||
if (test.global_result != 0)
|
if (test.global_result != 0)
|
||||||
{
|
{
|
||||||
cout << "Old master is a member or the cluster when it should not be." << endl;
|
cout << "Old master is a member of the cluster when it should not be. \n";
|
||||||
return test.global_result;
|
return test.global_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current master to replicate from the old master. The old master should remain as the current
|
// Set current master to replicate from the old master. The new master should lose its Master status
|
||||||
// master.
|
// and auto_rejoin will redirect servers 3 and 4 so that all replicate from server 1.
|
||||||
cout << "Setting server " << master_id_new << " to replicate from server 1. Server " << master_id_new
|
cout << "Setting server " << master_id_new << " to replicate from server 1. Server " << master_id_new
|
||||||
<< " should remain as the master because server 1 doesn't have the latest event it has." << endl;
|
<< " should lose its master status and other servers should be redirected to server 1.\n";
|
||||||
const char CHANGE_CMD_FMT[] = "CHANGE MASTER TO MASTER_HOST = '%s', MASTER_PORT = %d, "
|
const char CHANGE_CMD_FMT[] = "CHANGE MASTER TO MASTER_HOST = '%s', MASTER_PORT = %d, "
|
||||||
"MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';";
|
"MASTER_USE_GTID = current_pos, "
|
||||||
|
"MASTER_USER='repl', MASTER_PASSWORD = 'repl';";
|
||||||
char cmd[256];
|
char cmd[256];
|
||||||
int ind = master_id_new - 1;
|
int ind = master_id_new - 1;
|
||||||
snprintf(cmd, sizeof(cmd), CHANGE_CMD_FMT, test.repl->IP[0], test.repl->port[0]);
|
snprintf(cmd, sizeof(cmd), CHANGE_CMD_FMT, test.repl->IP[0], test.repl->port[0]);
|
||||||
MYSQL** nodes = test.repl->nodes;
|
MYSQL** nodes = test.repl->nodes;
|
||||||
mysql_query(nodes[ind], cmd);
|
mysql_query(nodes[ind], cmd);
|
||||||
mysql_query(nodes[ind], "START SLAVE;");
|
mysql_query(nodes[ind], "START SLAVE;");
|
||||||
test.maxscales->wait_for_monitor();
|
test.maxscales->wait_for_monitor(2);
|
||||||
get_output(test);
|
get_output(test);
|
||||||
|
|
||||||
expect(test, "server1", "Running");
|
expect(test, "server1", "Master", "Running");
|
||||||
expect(test, "server2", "Master", "Running");
|
expect(test, "server2", "Slave", "Running");
|
||||||
expect(test, "server3", "Slave", "Running");
|
expect(test, "server3", "Slave", "Running");
|
||||||
expect(test, "server4", "Slave", "Running");
|
expect(test, "server4", "Slave", "Running");
|
||||||
test.repl->fix_replication();
|
test.repl->fix_replication();
|
||||||
|
|||||||
Reference in New Issue
Block a user