Mxs 2236 own longtest (#189)

MXS-2236 Add own long test and possibility to run tests under Valgrind

Long test executes INSERT queries, transactions, prepared statements in parallel to create weird load on Maxscale to catch crashes and leaks

Test is not included into ctest scope. Test should be executed manually. For BuildBot (and also for run_test.sh) 'test_set' should be set 'NAME# ./long_test'

Time to run test is defined by 'long_test_time' variable (in seconds)

Possibility to run Maxscale under Valgrind is also added. To run Maxscale under Vaslgrind 'use_valgrind=yes' variable have to be defined
This commit is contained in:
Timofey Turenko
2019-02-22 16:12:57 +02:00
committed by GitHub
parent 79fd01d4dd
commit 2440b48ccc
10 changed files with 515 additions and 63 deletions

View File

@ -2,12 +2,24 @@
#include <sstream>
#include <unordered_map>
Maxscales::Maxscales(const char *pref, const char *test_cwd, bool verbose)
Maxscales::Maxscales(const char *pref, const char *test_cwd, bool verbose, bool use_valgrind)
{
strcpy(prefix, pref);
this->verbose = verbose;
this->use_valgrind = use_valgrind;
valgring_log_num = 0;
strcpy(test_dir, test_cwd);
read_env();
if (use_valgrind)
{
for (int i = 0; i < N; i++)
{
ssh_node_f(i, true, "yum install -y valgrind gdb 2>&1", maxscale_log_dir[i]);
ssh_node_f(i, true, "apt install -y --force-yes valgrind gdb 2>&1", maxscale_log_dir[i]);
ssh_node_f(i, true, "zypper -n install valgrind gdb 2>&1", maxscale_log_dir[i]);
ssh_node_f(i, true, "rm -rf /var/cache/maxscale/maxscale.lock");
}
}
}
int Maxscales::read_env()
@ -208,21 +220,54 @@ int Maxscales::close_maxscale_connections(int m)
int Maxscales::restart_maxscale(int m)
{
int res = ssh_node(m, "service maxscale restart", true);
int res;
if (use_valgrind)
{
res = stop_maxscale(m);
res += start_maxscale(m);
}
else
{
res =ssh_node(m, "service maxscale restart", true);
}
fflush(stdout);
return res;
}
int Maxscales::start_maxscale(int m)
{
int res = ssh_node(m, "service maxscale start", true);
int res;
if (use_valgrind)
{
res = ssh_node_f(m, false,
"sudo --user=maxscale valgrind --leak-check=full --show-leak-kinds=all "
"--log-file=/%s/valgrind%02d.log --trace-children=yes "
"--track-origins=yes /usr/bin/maxscale", maxscale_log_dir[m], valgring_log_num);
valgring_log_num++;
}
else
{
res = ssh_node(m, "service maxscale start", true);
}
fflush(stdout);
return res;
}
int Maxscales::stop_maxscale(int m)
{
int res = ssh_node(m, "service maxscale stop", true);
int res;
if (use_valgrind)
{
res = ssh_node_f(m, true, "sudo kill $(pidof valgrind) 2>&1 > /dev/null");
if ((res != 0) || atoi(ssh_node_output(m, "pidof valgrind", true, &res)) > 0)
{
res = ssh_node_f(m, true, "sudo kill -9 $(pidof valgrind) 2>&1 > /dev/null");
}
}
else
{
res = ssh_node(m, "service maxscale stop", true);
}
fflush(stdout);
return res;
}