Remove hard-coded server_id from mysqlmon_failover_stress

Dynamically probing the server_id prevents the test from failing if the
server configuration is changed.
This commit is contained in:
Markus Mäkelä 2018-11-19 12:22:42 +02:00
parent 41670875fc
commit 87e350f171
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -501,6 +501,20 @@ void check_server_statuses(TestConnections& test)
}
}
bool is_valid_server_id(TestConnections& test, int id)
{
std::set<int> ids;
test.repl->connect();
for (int i = 0; i < test.repl->N; i++)
{
ids.insert(test.repl->get_server_id(i));
}
test.repl->disconnect();
return ids.count(id);
}
void run(TestConnections& test)
{
cout << "\nConnecting to MaxScale." << endl;
@ -528,7 +542,7 @@ void run(TestConnections& test)
int master_id = get_master_server_id(test);
if (master_id > 0 && master_id <= 4)
if (is_valid_server_id(test, master_id))
{
test.set_timeout(20);
cout << "\nStopping node: " << master_id << endl;