Merge branch '2.3' into develop

This commit is contained in:
Markus Mäkelä
2019-04-12 13:23:49 +03:00
31 changed files with 625 additions and 243 deletions

View File

@ -940,6 +940,9 @@ add_test_executable(mxs2326_hint_clone.cpp mxs2326_hint_clone mxs2326_hint_clone
# MXS-2313: `rank` functional test
add_test_executable(mxs2313_rank.cpp mxs2313_rank mxs2313_rank LABELS readwritesplit REPL_BACKEND)
# MXS-2417: Ignore persisted configs with load_persisted_configs=false
add_test_executable(mxs2417_ignore_persisted_cnf.cpp mxs2417_ignore_persisted_cnf mxs2417_ignore_persisted_cnf LABELS REPL_BACKEND)
############################################
# BEGIN: binlogrouter and avrorouter tests #
############################################

View File

@ -0,0 +1,3 @@
[maxscale]
threads=###threads###
load_persisted_configs=false

View File

@ -2,6 +2,7 @@
#include <string>
#include <stdio.h>
#include "labels_table.h"
#include "testconnections.h"
std::string get_mdbci_lables(const char *labels_string)
{
@ -9,12 +10,20 @@ std::string get_mdbci_lables(const char *labels_string)
for (size_t i = 0; i < sizeof(labels_table) / sizeof(labels_table_t); i++)
{
printf("%lu\t %s\n", i, labels_table[i].test_label);
if (TestConnections::verbose)
{
printf("%lu\t %s\n", i, labels_table[i].test_label);
}
if (strstr(labels_string, labels_table[i].test_label))
{
mdbci_labels += "," + std::string(labels_table[i].mdbci_label);
}
}
printf("mdbci labels %s\n", mdbci_labels.c_str());
if (TestConnections::verbose)
{
printf("mdbci labels %s\n", mdbci_labels.c_str());
}
return mdbci_labels;
}

View File

@ -18,6 +18,8 @@
#include <iostream>
#include <vector>
#include <future>
#include <functional>
#include <algorithm>
#include "envv.h"
using std::cout;
@ -1102,19 +1104,22 @@ std::string Mariadb_nodes::get_lowest_version()
int Mariadb_nodes::truncate_mariadb_logs()
{
int local_result = 0;
std::vector<std::future<int>> results;
for (int node = 0; node < N; node++)
{
if (strcmp(IP[node], "127.0.0.1") != 0)
{
local_result += ssh_node_f(node, true,
"truncate -s 0 /var/lib/mysql/*.err;"
"truncate -s 0 /var/log/syslog;"
"truncate -s 0 /var/log/messages;"
"rm -f /etc/my.cnf.d/binlog_enc*;");
auto f = std::async(std::launch::async, &Nodes::ssh_node_f, this, node, true,
"truncate -s 0 /var/lib/mysql/*.err;"
"truncate -s 0 /var/log/syslog;"
"truncate -s 0 /var/log/messages;"
"rm -f /etc/my.cnf.d/binlog_enc*;");
results.push_back(std::move(f));
}
}
return local_result;
return std::count_if(results.begin(), results.end(), std::mem_fn(&std::future<int>::get));
}
int Mariadb_nodes::configure_ssl(bool require)

View File

@ -0,0 +1,24 @@
/**
* MXS-2417: Ignore persisted configs with load_persisted_configs=false
* https://jira.mariadb.org/browse/MXS-2417
*/
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections test(argc, argv);
test.tprintf("Creating a server and verifying it exists");
test.check_maxctrl("create server server1234 127.0.0.1 3306");
test.check_maxctrl("show server server1234");
test.tprintf("Restarting MaxScale");
test.maxscales->restart_maxscale();
test.tprintf("Creating the server again and verifying it is successful");
test.check_maxctrl("create server server1234 127.0.0.1 3306");
test.check_maxctrl("show server server1234");
return test.global_result;
}

View File

@ -2,6 +2,9 @@
#include <string>
#include <cstring>
#include <iostream>
#include <future>
#include <functional>
#include <algorithm>
#include "envv.h"
@ -9,36 +12,29 @@ Nodes::Nodes()
{
}
int Nodes::check_node_ssh(int node)
bool Nodes::check_node_ssh(int node)
{
int res = 0;
bool res = true;
if (ssh_node(node, (char*) "ls > /dev/null", false) != 0)
if (ssh_node(node, "ls > /dev/null", false) != 0)
{
printf("Node %d is not available\n", node);
fflush(stdout);
res = 1;
}
else
{
fflush(stdout);
std::cout << "Node " << node << " is not available" << std::endl;
res = false;
}
return res;
}
int Nodes::check_nodes()
bool Nodes::check_nodes()
{
std::cout << "Checking nodes..." << std::endl;
std::vector<std::future<bool>> f;
for (int i = 0; i < N; i++)
{
if (check_node_ssh(i) != 0)
{
return 1;
}
f.push_back(std::async(std::launch::async, &Nodes::check_node_ssh, this, i));
}
return 0;
return std::all_of(f.begin(), f.end(), std::mem_fn(&std::future<bool>::get));
}
void Nodes::generate_ssh_cmd(char* cmd, int node, const char* ssh, bool sudo)
@ -168,6 +164,11 @@ int Nodes::ssh_node(int node, const char* ssh, bool sudo)
verbose ? "" : " > /dev/null");
}
if (verbose)
{
std::cout << ssh << std::endl;
}
int rc = 1;
FILE* in = popen(cmd, "w");

View File

@ -168,9 +168,9 @@ public:
/**
* @brief Check node via ssh and restart it if it is not resposible
* @param node Node index
* @return 0 if node is ok, 1 if start failed
* @return True if node is ok, false if start failed
*/
int check_nodes();
bool check_nodes();
/**
* @brief read_basic_env Read IP, sshkey, etc - common parameters for all kinds of nodes
@ -206,5 +206,5 @@ public:
int stop_vm(int node);
private:
int check_node_ssh(int node);
bool check_node_ssh(int node);
};

View File

@ -12,6 +12,7 @@
#include <string>
#include <fstream>
#include <iostream>
#include <future>
#include <maxbase/stacktrace.hh>
#include "mariadb_func.h"
@ -119,6 +120,8 @@ void TestConnections::restart_galera(bool value)
maxscale::restart_galera = value;
}
bool TestConnections::verbose = false;
TestConnections::TestConnections(int argc, char* argv[])
: enable_timeouts(true)
, global_result(0)
@ -126,7 +129,6 @@ TestConnections::TestConnections(int argc, char* argv[])
, local_maxscale(false)
, no_backend_log_copy(false)
, no_maxscale_log_copy(false)
, verbose(false)
, smoke(true)
, binlog_cmd_option(0)
, ssl(false)
@ -303,7 +305,7 @@ TestConnections::TestConnections(int argc, char* argv[])
mdbci_call_needed = true;
tprintf("Machines with label '%s' are not running, MDBCI UP call is needed", label.c_str());
}
else
else if (verbose)
{
tprintf("Machines with label '%s' are running, MDBCI UP call is not needed", label.c_str());
}
@ -321,13 +323,19 @@ TestConnections::TestConnections(int argc, char* argv[])
if (mdbci_labels.find(std::string("REPL_BACKEND")) == std::string::npos)
{
no_repl = true;
tprintf("No need to use Master/Slave");
if (verbose)
{
tprintf("No need to use Master/Slave");
}
}
if (mdbci_labels.find(std::string("GALERA_BACKEND")) == std::string::npos)
{
no_galera = true;
tprintf("No need to use Galera");
if (verbose)
{
tprintf("No need to use Galera");
}
}
get_logs_command = (char *) malloc(strlen(test_dir) + 14);
@ -345,19 +353,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
{
@ -371,13 +376,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
{
@ -385,23 +384,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";
@ -422,39 +424,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);
}
}
@ -464,22 +460,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);
}
}

View File

@ -186,7 +186,7 @@ public:
/**
* @brief verbose if true more printing activated
*/
bool verbose;
static bool verbose;
/**
* @brief smoke if true all tests are executed in quick mode
@ -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;
};
/**