From 87e350f17124aeb29fba1e0c8d19c5352fd82f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 19 Nov 2018 12:22:42 +0200 Subject: [PATCH] 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. --- .../mysqlmon_failover_stress.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/maxscale-system-test/mysqlmon_failover_stress.cpp b/maxscale-system-test/mysqlmon_failover_stress.cpp index 017110451..bb152bb17 100644 --- a/maxscale-system-test/mysqlmon_failover_stress.cpp +++ b/maxscale-system-test/mysqlmon_failover_stress.cpp @@ -501,6 +501,20 @@ void check_server_statuses(TestConnections& test) } } +bool is_valid_server_id(TestConnections& test, int id) +{ + std::set 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;