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:
parent
79fd01d4dd
commit
2440b48ccc
@ -926,9 +926,13 @@ add_test_executable_notest(delete_rds.cpp delete_rds replication LABELS EXTERN_B
|
||||
# a tool to create RDS Aurora cluster
|
||||
add_test_executable_notest(create_rds.cpp create_rds replication LABELS EXTERN_BACKEND)
|
||||
|
||||
# start sysbench ageints RWSplit for infinite execution
|
||||
# start sysbench against RWSplit for infinite execution
|
||||
add_test_executable_notest(long_sysbench.cpp long_sysbench replication LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# own long test
|
||||
# 'long_test_time' variable defines time of execution (in seconds)
|
||||
add_test_executable_notest(long_test.cpp long_test replication LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# test effect of local_address in configuration file
|
||||
add_test_executable(local_address.cpp local_address local_address LABELS REPL_BACKEND)
|
||||
|
||||
|
@ -62,7 +62,6 @@ int main(int argc, char *argv[])
|
||||
execute_query_silent(test.repl->nodes[0], "DROP USER user@'%%';");
|
||||
execute_query_silent(test.repl->nodes[0], "DROP TABLE test.t1");
|
||||
test.repl->disconnect();
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
||||
|
@ -1,57 +1,58 @@
|
||||
[maxscale]
|
||||
threads=###threads###
|
||||
#log_info=1
|
||||
|
||||
[MySQL Monitor]
|
||||
[MySQL-Monitor]
|
||||
type=monitor
|
||||
module=mysqlmon
|
||||
###repl51###
|
||||
servers=server1,server2,server3,server4
|
||||
user=maxskysql
|
||||
passwd=skysql
|
||||
password=skysql
|
||||
monitor_interval=1000
|
||||
detect_stale_master=false
|
||||
detect_standalone_master=false
|
||||
|
||||
[RW Split Router]
|
||||
[RW-Split-Router]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=server1,server2,server3,server4
|
||||
user=maxskysql
|
||||
passwd=skysql
|
||||
router_options=slave_selection_criteria=LEAST_GLOBAL_CONNECTIONS
|
||||
password=skysql
|
||||
slave_selection_criteria=LEAST_GLOBAL_CONNECTIONS
|
||||
max_slave_connections=1
|
||||
|
||||
[Read Connection Router Slave]
|
||||
[Read-Connection-Router-Slave]
|
||||
type=service
|
||||
router=readconnroute
|
||||
router_options=slave
|
||||
servers=server1,server2,server3,server4
|
||||
user=maxskysql
|
||||
passwd=skysql
|
||||
password=skysql
|
||||
|
||||
[Read Connection Router Master]
|
||||
[Read-Connection-Router-Master]
|
||||
type=service
|
||||
router=readconnroute
|
||||
router_options=master
|
||||
servers=server1,server2,server3,server4
|
||||
user=maxskysql
|
||||
passwd=skysql
|
||||
password=skysql
|
||||
|
||||
[RW Split Listener]
|
||||
[RW-Split-Listener]
|
||||
type=listener
|
||||
service=RW Split Router
|
||||
service=RW-Split-Router
|
||||
protocol=MySQLClient
|
||||
port=4006
|
||||
|
||||
[Read Connection Listener Slave]
|
||||
[Read-Connection-Listener-Slave]
|
||||
type=listener
|
||||
service=Read Connection Router Slave
|
||||
service=Read-Connection-Router-Slave
|
||||
protocol=MySQLClient
|
||||
port=4009
|
||||
|
||||
[Read Connection Listener Master]
|
||||
[Read-Connection-Listener-Master]
|
||||
type=listener
|
||||
service=Read Connection Router Master
|
||||
service=Read-Connection-Router-Master
|
||||
protocol=MySQLClient
|
||||
port=4008
|
||||
|
||||
@ -59,7 +60,7 @@ port=4008
|
||||
type=service
|
||||
router=cli
|
||||
|
||||
[CLI Listener]
|
||||
[CLI-Listener]
|
||||
type=listener
|
||||
service=CLI
|
||||
protocol=maxscaled
|
||||
|
352
maxscale-system-test/long_test.cpp
Normal file
352
maxscale-system-test/long_test.cpp
Normal file
@ -0,0 +1,352 @@
|
||||
/**
|
||||
* @file long_test.cpp Run different load for long long execution (long load test)
|
||||
*
|
||||
* time to execute test is defined by 'long_test_time' environmental variable
|
||||
* e.g. 'long_test_time=3600 ./long_test'
|
||||
*/
|
||||
|
||||
|
||||
#include "testconnections.h"
|
||||
#include "big_transaction.h"
|
||||
|
||||
typedef void * FUNC(void * ptr);
|
||||
|
||||
FUNC query_thread;
|
||||
FUNC prepared_stmt_thread;
|
||||
FUNC transaction_thread;
|
||||
FUNC short_session_thread;
|
||||
FUNC read_thread;
|
||||
|
||||
TestConnections * Test;
|
||||
|
||||
const int threads_type_num = 4;
|
||||
int threads_num[threads_type_num];
|
||||
const int max_threads_num = 32;
|
||||
int port;
|
||||
char * IP;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int id;
|
||||
bool exit_flag;
|
||||
char * sql;
|
||||
} t_data;
|
||||
|
||||
t_data data[threads_type_num][max_threads_num];
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Test = new TestConnections(argc, argv);
|
||||
int i, j;
|
||||
|
||||
Test->tprintf("***************************************************\n"
|
||||
"This is long running test to catch memory leaks and crashes\n"
|
||||
"please define 'long_test_time' variable to set running time (seconds)\n"
|
||||
"***************************************************\n");
|
||||
|
||||
pthread_t thread_id[threads_type_num][max_threads_num];
|
||||
FUNC * thread[threads_type_num];
|
||||
thread[0] = query_thread;
|
||||
threads_num[0] = 1;
|
||||
thread[1] = transaction_thread;
|
||||
threads_num[1] = 1;
|
||||
thread[2] = prepared_stmt_thread;
|
||||
threads_num[2] = 1;
|
||||
thread[3] = read_thread;
|
||||
threads_num[3] = 1;
|
||||
|
||||
//thread[4] = short_session_thread;
|
||||
//threads_num[4] = 4;
|
||||
|
||||
|
||||
port = Test->maxscales->rwsplit_port[0];
|
||||
IP = Test->maxscales->IP[0];
|
||||
|
||||
//port = 3306;
|
||||
//IP = Test->repl->IP[0];
|
||||
|
||||
|
||||
Test->set_timeout(60);
|
||||
Test->tprintf("Set big maximums\n");
|
||||
|
||||
Test->repl->execute_query_all_nodes((char *) "set global max_connections = 300000;");
|
||||
Test->repl->execute_query_all_nodes((char *) "set global max_connect_errors = 10000000;");
|
||||
Test->repl->execute_query_all_nodes((char *) "set global expire_logs_days = 1;");
|
||||
|
||||
|
||||
|
||||
Test->maxscales->connect_rwsplit(0);
|
||||
|
||||
Test->repl->execute_query_all_nodes( (char *) "set global max_allowed_packet=100000000");
|
||||
|
||||
Test->tprintf("create t1 in `test` DB\n");
|
||||
create_t1(Test->maxscales->conn_rwsplit[0]);
|
||||
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "DROP DATABASE test1");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "DROP DATABASE test2");
|
||||
Test->tprintf("create`test1` DB\n");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "CREATE DATABASE test1");
|
||||
|
||||
Test->tprintf("create`test2` DB\n");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "CREATE DATABASE test2");
|
||||
|
||||
Test->tprintf("Waiting for slaves after DB creation\n");
|
||||
Test->repl->sync_slaves(0);
|
||||
//sleep(15);
|
||||
Test->tprintf("...ok\n");
|
||||
|
||||
Test->tprintf("create t1 in `test1` DB\n");
|
||||
Test->tprintf("... use\n");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "USE test1");
|
||||
Test->tprintf("... create\n");
|
||||
create_t1(Test->maxscales->conn_rwsplit[0]);
|
||||
|
||||
Test->tprintf("create t1 in `test2` DB\n");
|
||||
Test->tprintf("... use\n");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "USE test2");
|
||||
Test->tprintf("... create\n");
|
||||
create_t1(Test->maxscales->conn_rwsplit[0]);
|
||||
|
||||
Test->tprintf("Waiting for slaves after tables creation\n");
|
||||
Test->repl->sync_slaves(0);
|
||||
|
||||
Test->tprintf("...ok\n");
|
||||
|
||||
Test->set_timeout(60);
|
||||
// Create threads
|
||||
Test->tprintf("Starting threads\n");
|
||||
|
||||
for (j = 0; j < threads_type_num; j++)
|
||||
{
|
||||
for (i = 0; i < threads_num[j]; i++)
|
||||
{
|
||||
data[j][i].sql = (char*) malloc((i +1) * 32 * 14 + 32);
|
||||
create_insert_string(data[j][i].sql, (i + 1) * 32 , i);
|
||||
Test->tprintf("sqL %d: %d\n", i, strlen(data[j][i].sql));
|
||||
data[j][i].exit_flag = false;
|
||||
data[j][i].id = i;
|
||||
pthread_create(&thread_id[j][i], NULL, thread[j], &data[j][i]);
|
||||
}
|
||||
}
|
||||
|
||||
Test->set_log_copy_interval(100);
|
||||
|
||||
Test->stop_timeout();
|
||||
|
||||
char * env = getenv("long_test_time");
|
||||
int test_time = 0;
|
||||
if (env != NULL)
|
||||
{
|
||||
sscanf(env, "%d", &test_time);
|
||||
}
|
||||
if (test_time <= 0)
|
||||
{
|
||||
test_time = 3600;
|
||||
Test->tprintf("´long_test_time´ variable is not defined, set test_time to %d\n", test_time);
|
||||
}
|
||||
Test->tprintf("´test_time´ is %d\n", test_time);
|
||||
sleep(test_time);
|
||||
|
||||
Test->set_timeout(180);
|
||||
|
||||
Test->tprintf("Stopping threads\n");
|
||||
|
||||
for (j = 0; j < threads_type_num; j++)
|
||||
{
|
||||
for (i = 0; i < threads_num[j]; i++)
|
||||
{
|
||||
data[j][i].exit_flag = true;
|
||||
pthread_join(thread_id[j][i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
//Test->tprintf("Checking if MaxScale is still alive!\n");
|
||||
//fflush(stdout);
|
||||
//Test->check_maxscale_alive(0);
|
||||
|
||||
Test->maxscales->stop_maxscale(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
}
|
||||
|
||||
void try_and_reconnect(MYSQL * conn, char * db, char * sql)
|
||||
{
|
||||
if (execute_query(conn, sql))
|
||||
{
|
||||
Test->tprintf("reconnect");
|
||||
mysql_close(conn);
|
||||
conn = open_conn_db_timeout(port,
|
||||
IP,
|
||||
db,
|
||||
Test->repl->user_name,
|
||||
Test->repl->password,
|
||||
20,
|
||||
Test->ssl);
|
||||
}
|
||||
}
|
||||
|
||||
void *query_thread(void *ptr )
|
||||
{
|
||||
MYSQL * conn;
|
||||
t_data * data = (t_data *) ptr;
|
||||
int inserts_until_optimize = 100000;
|
||||
int tn = 0;
|
||||
conn = open_conn_db_timeout(port,
|
||||
IP,
|
||||
(char *) "test",
|
||||
Test->repl->user_name,
|
||||
Test->repl->password,
|
||||
20,
|
||||
Test->ssl);
|
||||
while (!data->exit_flag)
|
||||
{
|
||||
|
||||
//Test->try_query(conn, data->sql);
|
||||
try_and_reconnect(conn, (char *) "test", data->sql);
|
||||
|
||||
if (tn >= inserts_until_optimize)
|
||||
{
|
||||
tn = 0;
|
||||
Test->tprintf("Removing everything from table in the queries thread");
|
||||
try_and_reconnect(conn, (char *) "test", (char *) "DELETE FROM t1");
|
||||
Test->tprintf("Optimizing table in the queries thread");
|
||||
try_and_reconnect(conn, (char *) "test", (char *) "OPTIMIZE TABLE t1");
|
||||
}
|
||||
tn++;
|
||||
}
|
||||
mysql_close(conn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *read_thread(void *ptr )
|
||||
{
|
||||
MYSQL * conn;
|
||||
t_data * data = (t_data *) ptr;
|
||||
int i = 0;
|
||||
char sql[256];
|
||||
conn = open_conn_db_timeout(port,
|
||||
IP,
|
||||
(char *) "test",
|
||||
Test->repl->user_name,
|
||||
Test->repl->password,
|
||||
20,
|
||||
Test->ssl);
|
||||
while (!data->exit_flag)
|
||||
{
|
||||
sprintf(sql, "SELECT * FROM t1 WHERE fl=%d", data->id);
|
||||
try_and_reconnect(conn, (char *) "test", sql);
|
||||
i++;
|
||||
}
|
||||
mysql_close(conn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *transaction_thread(void *ptr )
|
||||
{
|
||||
MYSQL * conn;
|
||||
int transactions_until_optimize = 10;
|
||||
int tn = 0;
|
||||
t_data * data = (t_data *) ptr;
|
||||
conn = open_conn_db_timeout(port,
|
||||
IP,
|
||||
(char *) "test1",
|
||||
Test->repl->user_name,
|
||||
Test->repl->password,
|
||||
20,
|
||||
Test->ssl);
|
||||
while (!data->exit_flag)
|
||||
{
|
||||
|
||||
try_and_reconnect(conn, (char *) "test1", (char *) "START TRANSACTION");
|
||||
try_and_reconnect(conn, (char *) "test1", (char *) "SET autocommit = 0");
|
||||
|
||||
int stmt_num = 200000 / strlen(data->sql);
|
||||
for (int i = 0; i < stmt_num; i++)
|
||||
{
|
||||
try_and_reconnect(conn, (char *) "test1", data->sql);
|
||||
}
|
||||
Test->try_query(conn, (char *) "COMMIT");
|
||||
if (tn >= transactions_until_optimize)
|
||||
{
|
||||
tn = 0;
|
||||
Test->tprintf("Removing everything from table in the transactions thread");
|
||||
try_and_reconnect(conn, (char *) "test1", (char *) "DELETE FROM t1");
|
||||
Test->tprintf("Optimizing table in the transactions thread");
|
||||
try_and_reconnect(conn, (char *) "test1", (char *) "OPTIMIZE TABLE t1");
|
||||
}
|
||||
tn++;
|
||||
}
|
||||
mysql_close(conn);
|
||||
|
||||
conn = open_conn_db_timeout(port,
|
||||
IP,
|
||||
(char *) "",
|
||||
Test->maxscales->user_name,
|
||||
Test->maxscales->password,
|
||||
20,
|
||||
Test->ssl);
|
||||
Test->try_query(conn, "DROP DATABASE test1");
|
||||
mysql_close(conn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *short_session_thread(void *ptr )
|
||||
{
|
||||
MYSQL * conn;
|
||||
t_data * data = (t_data *) ptr;
|
||||
while (!data->exit_flag)
|
||||
{
|
||||
conn = open_conn_db_timeout(port,
|
||||
IP,
|
||||
(char *) "test",
|
||||
Test->repl->user_name,
|
||||
Test->repl->password,
|
||||
20,
|
||||
Test->ssl);
|
||||
mysql_close(conn);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void *prepared_stmt_thread(void *ptr )
|
||||
{
|
||||
MYSQL * conn;
|
||||
t_data * data = (t_data *) ptr;
|
||||
char sql[256];
|
||||
conn = open_conn_db_timeout(port,
|
||||
IP,
|
||||
(char *) "test2",
|
||||
Test->repl->user_name,
|
||||
Test->repl->password,
|
||||
20,
|
||||
Test->ssl);
|
||||
while (!data->exit_flag)
|
||||
{
|
||||
sprintf(sql, "PREPARE stmt%d FROM 'SELECT * FROM t1 WHERE fl=@x;';", data->id);
|
||||
try_and_reconnect(conn, (char *) "test2", sql);
|
||||
try_and_reconnect(conn, (char *) "test2", (char *) "SET @x = 3;");
|
||||
sprintf(sql, "EXECUTE stmt%d", data->id);
|
||||
try_and_reconnect(conn, (char *) "test2", sql);
|
||||
try_and_reconnect(conn, (char *) "test2", (char *) "SET @x = 4;");
|
||||
try_and_reconnect(conn, (char *) "test2", sql);
|
||||
try_and_reconnect(conn, (char *) "test2", (char *) "SET @x = 400;");
|
||||
try_and_reconnect(conn, (char *) "test2", sql);
|
||||
sprintf(sql, "DEALLOCATE PREPARE stmt%d", data->id);
|
||||
try_and_reconnect(conn, (char *) "test2", sql);
|
||||
}
|
||||
mysql_close(conn);
|
||||
|
||||
conn = open_conn_db_timeout(port,
|
||||
IP,
|
||||
(char *) "",
|
||||
Test->maxscales->user_name,
|
||||
Test->maxscales->password,
|
||||
20,
|
||||
Test->ssl);
|
||||
Test->try_query(conn, "DROP DATABASE test2");
|
||||
mysql_close(conn);
|
||||
return NULL;
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
READCONN_SLAVE
|
||||
};
|
||||
|
||||
Maxscales(const char *pref, const char *test_cwd, bool verbose);
|
||||
Maxscales(const char *pref, const char *test_cwd, bool verbose, bool use_valgrind);
|
||||
int read_env();
|
||||
|
||||
/**
|
||||
@ -272,6 +272,17 @@ public:
|
||||
*/
|
||||
void wait_for_monitor(int intervals = 1, int m = 0);
|
||||
|
||||
/**
|
||||
* @brief use_valrind if true Maxscale will be executed under Valgrind
|
||||
*/
|
||||
bool use_valgrind;
|
||||
|
||||
/**
|
||||
* @brief valgring_log_num Counter for Maxscale restarts to avoid Valgrind log overwriting
|
||||
*/
|
||||
int valgring_log_num;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // MAXSCALES_H
|
||||
|
@ -40,6 +40,10 @@
|
||||
|
||||
# $test_set - parameters to be send to 'ctest' (e.g. '-I 1,100',
|
||||
# '-LE UNSTABLE'
|
||||
# if $test_set starts from 'NAME#' ctest will not be executed,
|
||||
# the value of $test_set after 'NAME#' is used as bash command
|
||||
# line
|
||||
# example: '#NAME long_test_time=3600 ./long_test'
|
||||
|
||||
export vm_memory=${vm_memory:-"2048"}
|
||||
export dir=`pwd`
|
||||
@ -71,11 +75,15 @@ if [ $res == 0 ] ; then
|
||||
set -x
|
||||
echo ${test_set} | grep "NAME#"
|
||||
if [ $? == 0 ] ; then
|
||||
named_test=`echo ${test_set} | sed "s/NAME#//" | sed "s/ //g"`
|
||||
named_test=`echo ${test_set} | sed "s/NAME#//"`
|
||||
echo ${named_test} | grep "\./"
|
||||
if [ $? != 0 ] ; then
|
||||
named_test="./"${named_test}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "${named_test}" ] ; then
|
||||
./${named_test}
|
||||
eval ${named_test}
|
||||
else
|
||||
./check_backend
|
||||
if [ $? != 0 ]; then
|
||||
|
@ -52,9 +52,9 @@
|
||||
}
|
||||
},
|
||||
|
||||
"maxscale" :
|
||||
"maxscale_000" :
|
||||
{
|
||||
"hostname" : "maxscale",
|
||||
"hostname" : "maxscale1",
|
||||
"box" : "${box}",
|
||||
"memory_size" : "${vm_memory}",
|
||||
"product" : {
|
||||
|
@ -87,7 +87,8 @@ TestConnections::TestConnections(int argc, char *argv[]):
|
||||
no_galera(false),
|
||||
no_vm_revert(true),
|
||||
threads(4),
|
||||
use_ipv6(false)
|
||||
use_ipv6(false),
|
||||
use_valgrind(false)
|
||||
{
|
||||
signal_set(SIGSEGV, sigfatal_handler);
|
||||
signal_set(SIGABRT, sigfatal_handler);
|
||||
@ -239,7 +240,7 @@ TestConnections::TestConnections(int argc, char *argv[]):
|
||||
repl->take_snapshot_command = take_snapshot_command;
|
||||
repl->revert_snapshot_command = revert_snapshot_command;
|
||||
|
||||
maxscales = new Maxscales("maxscale", test_dir, verbose);
|
||||
maxscales = new Maxscales("maxscale", test_dir, verbose, use_valgrind);
|
||||
|
||||
maxscales->use_ipv6 = use_ipv6;
|
||||
maxscales->ssl = ssl;
|
||||
@ -347,6 +348,16 @@ TestConnections::~TestConnections()
|
||||
//galera->disable_ssl();
|
||||
}
|
||||
|
||||
if (use_valgrind)
|
||||
{
|
||||
// stop all Maxscales to get proper Valgrind logs
|
||||
for (int i = 0; i < maxscales->N; i++)
|
||||
{
|
||||
stop_maxscale(i);
|
||||
}
|
||||
sleep(15); // sleep to let logs be written do disks
|
||||
}
|
||||
|
||||
copy_all_logs();
|
||||
|
||||
/* Temporary disable snapshot revert due to Galera failures
|
||||
@ -420,7 +431,6 @@ void TestConnections::expect(bool result, const char *format, ...)
|
||||
|
||||
void TestConnections::read_env()
|
||||
{
|
||||
|
||||
char *env;
|
||||
|
||||
if (verbose)
|
||||
@ -428,7 +438,6 @@ void TestConnections::read_env()
|
||||
printf("Reading test setup configuration from environmental variables\n");
|
||||
}
|
||||
|
||||
|
||||
//env = getenv("get_logs_command"); if (env != NULL) {sprintf(get_logs_command, "%s", env);}
|
||||
|
||||
//env = getenv("test_dir"); if (env != NULL) {sprintf(test_dir, "%s", env);}
|
||||
@ -531,6 +540,12 @@ void TestConnections::read_env()
|
||||
{
|
||||
no_vm_revert = false;
|
||||
}
|
||||
|
||||
env = getenv("use_valgrind");
|
||||
if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) ))
|
||||
{
|
||||
use_valgrind = true;
|
||||
}
|
||||
}
|
||||
|
||||
void TestConnections::print_env()
|
||||
@ -683,22 +698,18 @@ void TestConnections::init_maxscale(int m)
|
||||
"chmod a+x %s;"
|
||||
"%s"
|
||||
"iptables -F INPUT;"
|
||||
"rm -f %s/maxscale.log;"
|
||||
"rm -f %s/maxscale1.log;"
|
||||
"rm -rf /tmp/core* /dev/shm/* /var/lib/maxscale/maxscale.cnf.d/ /var/lib/maxscale/*;"
|
||||
"%s",
|
||||
"rm -f %s/*;"
|
||||
"rm -rf /tmp/core* /dev/shm/* /var/lib/maxscale/maxscale.cnf.d/ /var/lib/maxscale/*",
|
||||
maxscales->access_homedir[m],
|
||||
maxscales->access_homedir[m],
|
||||
maxscales->access_homedir[m],
|
||||
maxscale::start ? "killall -9 maxscale;" : "",
|
||||
maxscales->maxscale_log_dir[m],
|
||||
maxscales->maxscale_log_dir[m],
|
||||
maxscale::start ? "service maxscale restart" : "");
|
||||
|
||||
maxscales->maxscale_log_dir[m]);
|
||||
fflush(stdout);
|
||||
|
||||
if (maxscale::start)
|
||||
{
|
||||
maxscales->restart_maxscale(m);
|
||||
fflush(stdout);
|
||||
int waits;
|
||||
|
||||
for (waits = 0; waits < 15; waits++)
|
||||
@ -723,10 +734,17 @@ int TestConnections::copy_mariadb_logs(Mariadb_nodes * repl, char * prefix)
|
||||
int local_result = 0;
|
||||
char * mariadb_log;
|
||||
FILE * f;
|
||||
int i;
|
||||
int i, j;
|
||||
int exit_code;
|
||||
char str[4096];
|
||||
|
||||
const int log_retrive_command_num = 3;
|
||||
const char * log_retrive_command[log_retrive_command_num] = {
|
||||
"cat /var/lib/mysql/*.err",
|
||||
"cat /var/log/syslog | grep mysql",
|
||||
"cat /var/log/messages | grep mysql"
|
||||
};
|
||||
|
||||
if (repl == NULL) return local_result;
|
||||
|
||||
sprintf(str, "mkdir -p LOGS/%s", test_name);
|
||||
@ -735,20 +753,23 @@ int TestConnections::copy_mariadb_logs(Mariadb_nodes * repl, char * prefix)
|
||||
{
|
||||
if (strcmp(repl->IP[i], "127.0.0.1") != 0) // Do not copy MariaDB logs in case of local backend
|
||||
{
|
||||
mariadb_log = repl->ssh_node_output(i, (char *) "cat /var/lib/mysql/*.err", true, &exit_code);
|
||||
sprintf(str, "LOGS/%s/%s%d_mariadb_log", test_name, prefix, i);
|
||||
f = fopen(str, "w");
|
||||
if (f != NULL)
|
||||
for (j = 0; j < log_retrive_command_num; j++)
|
||||
{
|
||||
fwrite(mariadb_log, sizeof(char), strlen(mariadb_log), f);
|
||||
fclose(f);
|
||||
mariadb_log = repl->ssh_node_output(i, log_retrive_command[j], true, &exit_code);
|
||||
sprintf(str, "LOGS/%s/%s%d_mariadb_log_%d", test_name, prefix, i, j);
|
||||
f = fopen(str, "w");
|
||||
if (f != NULL)
|
||||
{
|
||||
fwrite(mariadb_log, sizeof(char), strlen(mariadb_log), f);
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error writing MariaDB log");
|
||||
local_result = 1;
|
||||
}
|
||||
free(mariadb_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error writing MariaDB log");
|
||||
local_result = 1;
|
||||
}
|
||||
free(mariadb_log);
|
||||
}
|
||||
}
|
||||
return local_result;
|
||||
@ -1054,9 +1075,9 @@ bool TestConnections::replicate_from_master(int m)
|
||||
repl->execute_query_all_nodes("STOP SLAVE");
|
||||
|
||||
/** Clean up MaxScale directories */
|
||||
maxscales->ssh_node(m, "service maxscale stop", true);
|
||||
maxscales->stop_maxscale(m);
|
||||
prepare_binlog(m);
|
||||
maxscales->ssh_node(m, "service maxscale start", true);
|
||||
maxscales->start_maxscale(m);
|
||||
|
||||
char log_file[256] = "";
|
||||
char log_pos[256] = "4";
|
||||
@ -1308,7 +1329,16 @@ int TestConnections::find_connected_slave1(int m)
|
||||
int TestConnections::check_maxscale_processes(int m, int expected)
|
||||
{
|
||||
int exit_code;
|
||||
char* maxscale_num = maxscales->ssh_node_output(m, "ps -C maxscale | grep maxscale | wc -l", false,
|
||||
const char * ps_cmd;
|
||||
if (use_valgrind)
|
||||
{
|
||||
ps_cmd = "ps ax | grep valgrind | grep maxscale | grep -v grep | wc -l";
|
||||
}
|
||||
else
|
||||
{
|
||||
ps_cmd = "ps -C maxscale | grep maxscale | wc -l";
|
||||
}
|
||||
char* maxscale_num = maxscales->ssh_node_output(m, ps_cmd, false,
|
||||
&exit_code);
|
||||
if ((maxscale_num == NULL) || (exit_code != 0))
|
||||
{
|
||||
@ -1322,9 +1352,9 @@ int TestConnections::check_maxscale_processes(int m, int expected)
|
||||
|
||||
if (atoi(maxscale_num) != expected)
|
||||
{
|
||||
tprintf("%s maxscale processes detected, trying agin in 5 seconds\n", maxscale_num);
|
||||
tprintf("%s maxscale processes detected, trying again in 5 seconds\n", maxscale_num);
|
||||
sleep(5);
|
||||
maxscale_num = maxscales->ssh_node_output(m, "ps -C maxscale | grep maxscale | wc -l", false, &exit_code);
|
||||
maxscale_num = maxscales->ssh_node_output(m, ps_cmd, false, &exit_code);
|
||||
if (atoi(maxscale_num) != expected)
|
||||
{
|
||||
add_result(1, "Number of MaxScale processes is not %d, it is %s\n", expected, maxscale_num);
|
||||
@ -1336,7 +1366,7 @@ int TestConnections::check_maxscale_processes(int m, int expected)
|
||||
|
||||
int TestConnections::stop_maxscale(int m)
|
||||
{
|
||||
int res = maxscales->ssh_node(m, "service maxscale stop", true);
|
||||
int res = maxscales->stop_maxscale(m);
|
||||
check_maxscale_processes(m, 0);
|
||||
fflush(stdout);
|
||||
return res;
|
||||
@ -1344,7 +1374,7 @@ int TestConnections::stop_maxscale(int m)
|
||||
|
||||
int TestConnections::start_maxscale(int m)
|
||||
{
|
||||
int res = maxscales->ssh_node(m, "service maxscale start", true);
|
||||
int res = maxscales->start_maxscale(m);
|
||||
check_maxscale_processes(m, 1);
|
||||
fflush(stdout);
|
||||
return res;
|
||||
@ -1370,7 +1400,6 @@ int TestConnections::check_maxscale_alive(int m)
|
||||
maxscales->close_maxscale_connections(m);
|
||||
add_result(global_result - gr, "Maxscale is not alive\n");
|
||||
stop_timeout();
|
||||
|
||||
check_maxscale_processes(m, 1);
|
||||
|
||||
return global_result - gr;
|
||||
|
@ -477,8 +477,6 @@ public:
|
||||
*/
|
||||
int list_dirs(int m = 0);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief make_snapshot Makes a snapshot for all running VMs
|
||||
* @param snapshot_name name of created snapshot
|
||||
@ -514,6 +512,11 @@ public:
|
||||
int start_maxscale(int m = 0);
|
||||
void process_template(const char *src, const char *dest = "/etc/maxscale.cnf");
|
||||
|
||||
/**
|
||||
* @brief use_valrind if true Maxscale will be executed under Valgrind
|
||||
*/
|
||||
bool use_valgrind;
|
||||
|
||||
private:
|
||||
void report_result(const char *format, va_list argp);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user