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:
@ -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,24 +369,27 @@ 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_maxscales())
|
||||
if (reinstall_maxscale && reinstall_maxscales())
|
||||
{
|
||||
tprintf("Failed to install Maxscale: target is %s", target);
|
||||
exit(MDBCI_FAUILT);
|
||||
}
|
||||
}
|
||||
|
||||
std::string src = std::string(test_dir) + "/mdbci/add_core_cnf.sh";
|
||||
maxscales->copy_to_node(0, src.c_str(), maxscales->access_homedir[0]);
|
||||
@ -414,9 +409,7 @@ TestConnections::TestConnections(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (repl)
|
||||
{
|
||||
if (maxscale::required_repl_version.length())
|
||||
if (repl && maxscale::required_repl_version.length())
|
||||
{
|
||||
int ver_repl_required = get_int_version(maxscale::required_repl_version);
|
||||
std::string ver_repl = repl->get_lowest_version();
|
||||
@ -430,11 +423,8 @@ TestConnections::TestConnections(int argc, char* argv[])
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (galera)
|
||||
{
|
||||
if (maxscale::required_galera_version.length())
|
||||
if (galera && maxscale::required_galera_version.length())
|
||||
{
|
||||
int ver_galera_required = get_int_version(maxscale::required_galera_version);
|
||||
std::string ver_galera = galera->get_lowest_version();
|
||||
@ -448,7 +438,6 @@ TestConnections::TestConnections(int argc, char* argv[])
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((maxscale::restart_galera) && (galera))
|
||||
{
|
||||
@ -456,24 +445,17 @@ TestConnections::TestConnections(int argc, char* argv[])
|
||||
galera->start_replication();
|
||||
}
|
||||
|
||||
|
||||
if (maxscale::check_nodes)
|
||||
{
|
||||
if (repl)
|
||||
{
|
||||
if (!repl->fix_replication() )
|
||||
if (repl && !repl->fix_replication())
|
||||
{
|
||||
exit(BROKEN_VM_FAUILT);
|
||||
}
|
||||
}
|
||||
if (galera)
|
||||
{
|
||||
if (!galera->fix_replication())
|
||||
if (galera && !galera->fix_replication())
|
||||
{
|
||||
exit(BROKEN_VM_FAUILT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (maxscale_init)
|
||||
{
|
||||
|
||||
@ -700,9 +700,15 @@ public:
|
||||
|
||||
private:
|
||||
void report_result(const char* format, va_list argp);
|
||||
void copy_one_mariadb_log(Mariadb_nodes *nrepl, int i, std::string filename);
|
||||
void copy_one_mariadb_log(Mariadb_nodes* nrepl, int i, std::string filename);
|
||||
|
||||
std::vector<std::function<void (void)>> m_on_destroy;
|
||||
bool too_many_maxscales() const
|
||||
{
|
||||
return maxscales->N < 2
|
||||
&& mdbci_labels.find("SECOND_MAXSCALE") != std::string::npos;
|
||||
}
|
||||
|
||||
std::vector<std::function<void(void)>> m_on_destroy;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user