From d881630204e1431215c44876d0797c76b9870d22 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 12 Sep 2018 08:41:52 +0300 Subject: [PATCH] Allow programatic control of galera restarting If a test program needs other than the default Galera config (e.g. log_slave_updates enabled), then it should be able to programmatically cause galera to be restarted as part of the TestConnections construction. --- maxscale-system-test/testconnections.cpp | 11 ++++++++--- maxscale-system-test/testconnections.h | 12 ++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 581a1e8ed..4efcbd5a8 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -24,6 +24,7 @@ static bool check_nodes = true; static bool manual_debug = false; static std::string required_repl_version; static std::string required_galera_version; +static bool restart_galera = false; } static void signal_set(int sig, void (* handler)(int)) @@ -66,6 +67,11 @@ void TestConnections::require_galera_version(const char* version) maxscale::required_galera_version = version; } +void TestConnections::restart_galera(bool value) +{ + maxscale::restart_galera = value; +} + TestConnections::TestConnections(int argc, char* argv[]) : enable_timeouts(true) , global_result(0) @@ -123,7 +129,6 @@ TestConnections::TestConnections(int argc, char* argv[]) int c; int option_index = 0; - bool restart_galera = false; while ((c = getopt_long(argc, argv, "hvnqsirgzyl", long_options, &option_index)) != -1) { @@ -174,7 +179,7 @@ TestConnections::TestConnections(int argc, char* argv[]) case 'g': printf("Restarting Galera setup\n"); - restart_galera = true; + maxscale::restart_galera = true; break; case 'z': @@ -280,7 +285,7 @@ TestConnections::TestConnections(int argc, char* argv[]) } } - if ((restart_galera) && (!no_galera)) + if ((maxscale::restart_galera) && (!no_galera)) { galera->stop_nodes(); galera->start_replication(); diff --git a/maxscale-system-test/testconnections.h b/maxscale-system-test/testconnections.h index 8c88cb166..03f84e98d 100644 --- a/maxscale-system-test/testconnections.h +++ b/maxscale-system-test/testconnections.h @@ -254,6 +254,18 @@ public: static void require_repl_version(const char* version); static void require_galera_version(const char* version); + /** + * @brief Specify whether galera should be restarted. + * + * @param value If true, galera should be restarted. + * + * @note Even if set to false (which is also the default), '-g' or '--restart-galera' at + * the command line will still cause a restart, unless '-y' or '--no-galera' has + * been specified. '-y' will prevent galera from being restarted even if the value + * has been set to true. + */ + static void restart_galera(bool value); + /** * @brief add_result adds result to global_result and prints error message if result is not 0 * @param result 0 if step PASSED