Do node checks in parallel

The checking of MariaDB and Galera nodes is now done asynchronously while
the MaxScale check is done which leads to faster testing. Rough
measurements show that doing all the work in parallel reduces test startup
time by two seconds. Most of the time appears to still be in the MaxScale
startup which takes on average three to four seconds per test.
This commit is contained in:
Markus Mäkelä
2019-04-07 20:11:07 +03:00
parent 5e3af05d48
commit 0932d10169
2 changed files with 50 additions and 62 deletions

View File

@ -12,6 +12,7 @@
#include <string>
#include <fstream>
#include <iostream>
#include <future>
#include <maxbase/stacktrace.hh>
#include "mariadb_func.h"
@ -337,19 +338,16 @@ TestConnections::TestConnections(int argc, char* argv[])
exit(0);
}
std::future<bool> repl_future;
std::future<bool> galera_future;
if (!no_repl)
{
repl = new Mariadb_nodes("node", test_dir, verbose, network_config);
repl->use_ipv6 = use_ipv6;
repl->take_snapshot_command = take_snapshot_command;
repl->revert_snapshot_command = revert_snapshot_command;
if (!repl->check_nodes())
{
if (call_mdbci("--recreate"))
{
exit(MDBCI_FAUILT);
}
}
repl_future = std::async(std::launch::async, &Mariadb_nodes::check_nodes, repl);
}
else
{
@ -363,13 +361,7 @@ TestConnections::TestConnections(int argc, char* argv[])
galera->use_ipv6 = false;
galera->take_snapshot_command = take_snapshot_command;
galera->revert_snapshot_command = revert_snapshot_command;
if (!galera->check_nodes())
{
if (call_mdbci("--recreate"))
{
exit(MDBCI_FAUILT);
}
}
galera_future = std::async(std::launch::async, &Galera_nodes::check_nodes, galera);
}
else
{
@ -377,23 +369,26 @@ TestConnections::TestConnections(int argc, char* argv[])
}
maxscales = new Maxscales("maxscale", test_dir, verbose, use_valgrind, network_config);
if (!maxscales->check_nodes() ||
((maxscales->N < 2) && (mdbci_labels.find(std::string("SECOND_MAXSCALE")) != std::string::npos))
)
bool maxscale_ok = maxscales->check_nodes();
bool repl_ok = no_repl || repl_future.get();
bool galera_ok = no_galera || galera_future.get();
bool node_error = !maxscale_ok || !repl_ok || !galera_ok;
if (node_error || too_many_maxscales())
{
tprintf("Recreating VMs: %s", node_error ? "node check failed" : "too many maxscales");
if (call_mdbci("--recreate"))
{
exit(MDBCI_FAUILT);
}
}
if (reinstall_maxscale)
if (reinstall_maxscale && reinstall_maxscales())
{
if (reinstall_maxscales())
{
tprintf("Failed to install Maxscale: target is %s", target);
exit(MDBCI_FAUILT);
}
tprintf("Failed to install Maxscale: target is %s", target);
exit(MDBCI_FAUILT);
}
std::string src = std::string(test_dir) + "/mdbci/add_core_cnf.sh";
@ -414,39 +409,33 @@ TestConnections::TestConnections(int argc, char* argv[])
}
}
if (repl)
if (repl && maxscale::required_repl_version.length())
{
if (maxscale::required_repl_version.length())
{
int ver_repl_required = get_int_version(maxscale::required_repl_version);
std::string ver_repl = repl->get_lowest_version();
int int_ver_repl = get_int_version(ver_repl);
int ver_repl_required = get_int_version(maxscale::required_repl_version);
std::string ver_repl = repl->get_lowest_version();
int int_ver_repl = get_int_version(ver_repl);
if (int_ver_repl < ver_repl_required)
{
tprintf("Test requires a higher version of backend servers, skipping test.");
tprintf("Required version: %s", maxscale::required_repl_version.c_str());
tprintf("Master-slave version: %s", ver_repl.c_str());
exit(0);
}
if (int_ver_repl < ver_repl_required)
{
tprintf("Test requires a higher version of backend servers, skipping test.");
tprintf("Required version: %s", maxscale::required_repl_version.c_str());
tprintf("Master-slave version: %s", ver_repl.c_str());
exit(0);
}
}
if (galera)
if (galera && maxscale::required_galera_version.length())
{
if (maxscale::required_galera_version.length())
{
int ver_galera_required = get_int_version(maxscale::required_galera_version);
std::string ver_galera = galera->get_lowest_version();
int int_ver_galera = get_int_version(ver_galera);
int ver_galera_required = get_int_version(maxscale::required_galera_version);
std::string ver_galera = galera->get_lowest_version();
int int_ver_galera = get_int_version(ver_galera);
if (int_ver_galera < ver_galera_required)
{
tprintf("Test requires a higher version of backend servers, skipping test.");
tprintf("Required version: %s", maxscale::required_galera_version.c_str());
tprintf("Galera version: %s", ver_galera.c_str());
exit(0);
}
if (int_ver_galera < ver_galera_required)
{
tprintf("Test requires a higher version of backend servers, skipping test.");
tprintf("Required version: %s", maxscale::required_galera_version.c_str());
tprintf("Galera version: %s", ver_galera.c_str());
exit(0);
}
}
@ -456,22 +445,15 @@ TestConnections::TestConnections(int argc, char* argv[])
galera->start_replication();
}
if (maxscale::check_nodes)
{
if (repl)
if (repl && !repl->fix_replication())
{
if (!repl->fix_replication() )
{
exit(BROKEN_VM_FAUILT);
}
exit(BROKEN_VM_FAUILT);
}
if (galera)
if (galera && !galera->fix_replication())
{
if (!galera->fix_replication())
{
exit(BROKEN_VM_FAUILT);
}
exit(BROKEN_VM_FAUILT);
}
}