Remove unnecessary SSHing to MaxScale at test startup

There were a total of five SSH connections opened at the start of each
test. Only two of these are currently required: the SSL certificate
directory check and the actual command that restarts MaxScale. Two of the
three remaining commands, stopping of MaxScale and copying of the
configuration, can be made conditional or combined into other
commands.

The stopping of MaxScale is done to prevent it from interfering with the
cluster setup process. As MaxScale does nothing if nothing is wrong, it is
safe to make the restart conditional so that it is done only when a
problem in the cluster setup is detected.

The final SSH command, the MaxScale health check via maxadmin, can be
removed as it is redundant: the daemonization already covers this by
exiting only after MaxScale is ready.
This commit is contained in:
Markus Mäkelä 2018-11-04 20:55:26 +02:00
parent 4e3d1a29b6
commit ff9b26b7fa
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 21 additions and 31 deletions

View File

@ -267,6 +267,15 @@ public:
return stop_maxscale(m);
}
// Helper for stopping all maxscales
void stop_all()
{
for (int i = 0; i < N; i++)
{
stop(i);
}
}
int execute_maxadmin_command(int m, const char* cmd);
int execute_maxadmin_command_print(int m, const char* cmd);
int check_maxadmin_param(int m, const char* command, const char* param, const char* value);

View File

@ -271,15 +271,6 @@ TestConnections::TestConnections(int argc, char* argv[])
maxscales->use_ipv6 = use_ipv6;
maxscales->ssl = ssl;
// Stop MaxScale to prevent it from interfering with the replication setup process
if (!maxscale::manual_debug)
{
for (int i = 0; i < maxscales->N; i++)
{
maxscales->stop(i);
}
}
if (maxscale::required_repl_version.length())
{
int ver_repl_required = get_int_version(maxscale::required_repl_version);
@ -323,8 +314,15 @@ TestConnections::TestConnections(int argc, char* argv[])
snapshot_reverted = revert_snapshot((char*) "clean");
}
if (!snapshot_reverted && maxscale::check_nodes)
if (!snapshot_reverted && maxscale::check_nodes
&& (repl->check_replication() || (!no_galera && galera->check_replication())))
{
// Stop MaxScale to prevent it from interfering with the replication setup process
if (!maxscale::manual_debug)
{
maxscales->stop_all();
}
if (!repl->fix_replication())
{
exit(200);
@ -679,7 +677,7 @@ void TestConnections::process_template(int m, const char* template_name, const c
system(ss.str().c_str());
maxscales->copy_to_node_legacy("maxscale.cnf", dest, m);
maxscales->ssh_node_f(m, true, "cp maxscale.cnf %s", maxscales->maxscale_cnf[m]);
// The config will now be in ~/maxscale.cnf and is moved into /etc before restarting maxscale
}
void TestConnections::init_maxscales()
@ -723,30 +721,13 @@ void TestConnections::init_maxscale(int m)
maxscales->ssh_node_f(m,
true,
"cp maxscale.cnf %s;"
"iptables -F INPUT;"
"rm -rf %s/*.log /tmp/core* /dev/shm/* /var/lib/maxscale/maxscale.cnf.d/ /var/lib/maxscale/*;"
"%s",
maxscales->maxscale_cnf[m],
maxscales->maxscale_log_dir[m],
maxscale::start ? "service maxscale start;" : "");
if (maxscale::start)
{
int waits;
for (waits = 0; waits < 15; waits++)
{
if (maxscales->ssh_node(m, "/bin/sh -c \"maxadmin help > /dev/null || exit 1\"", true) == 0)
{
break;
}
sleep(1);
}
if (waits > 0)
{
tprintf("Waited %d seconds for MaxScale to start", waits);
}
}
maxscale::start ? "service maxscale restart;" : "");
}
void TestConnections::copy_one_mariadb_log(int i, std::string filename)