Test: Provide additional control of local MaxScale
When running BLR locally, you need to be able to specify what IP the BLR is visible at (127.0.0.1 does not work for VM nodes) and also to perform cleanup etc. action when needed.
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
#include <sys/stat.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <maxbase/stacktrace.hh>
|
||||
|
||||
@ -19,6 +20,7 @@ using namespace mxb;
|
||||
|
||||
namespace maxscale
|
||||
{
|
||||
|
||||
static bool start = true;
|
||||
static bool check_nodes = true;
|
||||
static bool manual_debug = false;
|
||||
@ -26,6 +28,15 @@ static std::string required_repl_version;
|
||||
static std::string required_galera_version;
|
||||
static bool restart_galera = false;
|
||||
static bool multiple_maxscales = false;
|
||||
|
||||
}
|
||||
|
||||
static void perform_manual_action(const char* zMessage)
|
||||
{
|
||||
std::cout << zMessage << " (press enter when done)." << std::endl;
|
||||
std::string not_used;
|
||||
std::getline(std::cin, not_used);
|
||||
std::cout << "Ok" << std::endl;
|
||||
}
|
||||
|
||||
static void signal_set(int sig, void (* handler)(int))
|
||||
@ -82,6 +93,7 @@ TestConnections::TestConnections(int argc, char* argv[])
|
||||
: enable_timeouts(true)
|
||||
, global_result(0)
|
||||
, use_snapshots(false)
|
||||
, local_maxscale(false)
|
||||
, no_backend_log_copy(false)
|
||||
, no_maxscale_log_copy(false)
|
||||
, verbose(false)
|
||||
@ -129,14 +141,14 @@ TestConnections::TestConnections(int argc, char* argv[])
|
||||
{"restart-galera", no_argument, 0, 'g' },
|
||||
{"no-timeouts", no_argument, 0, 'z' },
|
||||
{"no-galera", no_argument, 0, 'y' },
|
||||
{"local-maxscale", no_argument, 0, 'l' },
|
||||
{"local-maxscale", optional_argument, 0, 'l' },
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
int c;
|
||||
int option_index = 0;
|
||||
|
||||
while ((c = getopt_long(argc, argv, "hvnqsirgzyl", long_options, &option_index)) != -1)
|
||||
while ((c = getopt_long(argc, argv, "hvnqsirgzyl::", long_options, &option_index)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@ -198,12 +210,18 @@ TestConnections::TestConnections(int argc, char* argv[])
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
printf("MaxScale assumed to be running locally; not started and logs not downloaded.\n");
|
||||
{
|
||||
const char* local_ip = optarg ? optarg : "127.0.0.1";
|
||||
printf("MaxScale assumed to be running locally; not started and logs not downloaded. IP: %s\n", local_ip);
|
||||
|
||||
maxscale_init = false;
|
||||
no_maxscale_log_copy = true;
|
||||
setenv("maxscale_IP", "127.0.0.1", true);
|
||||
setenv("maxscale_network", "127.0.0.1", true);
|
||||
setenv("maxscale_private_ip", "127.0.0.1", true);
|
||||
local_maxscale=true;
|
||||
|
||||
setenv("maxscale_IP", local_ip, true);
|
||||
setenv("maxscale_network", local_ip, true);
|
||||
setenv("maxscale_private_ip", local_ip, true);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -899,6 +917,8 @@ int TestConnections::prepare_binlog(int m)
|
||||
"Error editing maxscale.cnf");
|
||||
}
|
||||
|
||||
if (!local_maxscale)
|
||||
{
|
||||
tprintf("Removing all binlog data from Maxscale node");
|
||||
add_result(maxscales->ssh_node_f(m, true, "rm -rf %s", maxscales->maxscale_binlog_dir[m]),
|
||||
"Removing binlog data failed");
|
||||
@ -915,6 +935,12 @@ int TestConnections::prepare_binlog(int m)
|
||||
maxscales->access_sudo[m],
|
||||
maxscales->maxscale_binlog_dir[m]),
|
||||
"directory ownership change failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
perform_manual_action("Remove all local binlog data");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -948,6 +974,8 @@ int TestConnections::start_binlog(int m)
|
||||
|
||||
repl->stop_nodes();
|
||||
|
||||
if (!local_maxscale)
|
||||
{
|
||||
binlog =
|
||||
open_conn_no_db(maxscales->binlog_port[m], maxscales->IP[m], repl->user_name, repl->password, ssl);
|
||||
execute_query(binlog, "stop slave");
|
||||
@ -956,6 +984,11 @@ int TestConnections::start_binlog(int m)
|
||||
|
||||
tprintf("Stopping maxscale\n");
|
||||
add_result(maxscales->stop_maxscale(m), "Maxscale stopping failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
perform_manual_action("Perform the equivalent of 'STOP SLAVE; RESET SLAVE ALL' and stop local Maxscale");
|
||||
}
|
||||
|
||||
for (i = 0; i < repl->N; i++)
|
||||
{
|
||||
@ -978,9 +1011,12 @@ int TestConnections::start_binlog(int m)
|
||||
|
||||
tprintf("Testing binlog when MariaDB is started with '%s' option\n", cmd_opt);
|
||||
|
||||
if (!local_maxscale)
|
||||
{
|
||||
tprintf("ls binlog data dir on Maxscale node\n");
|
||||
add_result(maxscales->ssh_node_f(m, true, "ls -la %s/", maxscales->maxscale_binlog_dir[m]),
|
||||
"ls failed\n");
|
||||
}
|
||||
|
||||
if (binlog_master_gtid)
|
||||
{
|
||||
@ -1011,8 +1047,15 @@ int TestConnections::start_binlog(int m)
|
||||
repl->set_slave(repl->nodes[1], repl->IP[0], repl->port[0], log_file, log_pos);
|
||||
}
|
||||
|
||||
if (!local_maxscale)
|
||||
{
|
||||
tprintf("Starting back Maxscale\n");
|
||||
add_result(maxscales->start_maxscale(m), "Maxscale start failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
perform_manual_action("Start Maxscale");
|
||||
}
|
||||
|
||||
tprintf("Connecting to MaxScale binlog router (with any DB)\n");
|
||||
binlog =
|
||||
|
||||
@ -140,6 +140,11 @@ public:
|
||||
*/
|
||||
int copy_mariadb_logs(Mariadb_nodes* repl, const char* prefix, std::vector<std::thread>& threads);
|
||||
|
||||
/**
|
||||
* @brief MaxScale runs locally, specified using -l.
|
||||
*/
|
||||
bool local_maxscale;
|
||||
|
||||
/**
|
||||
* @brief no_backend_log_copy if true logs from backends are not copied
|
||||
* (needed if case of Aurora RDS backend or similar)
|
||||
|
||||
Reference in New Issue
Block a user