Remove unused files

The files weren't used or were built but not used.
This commit is contained in:
Markus Mäkelä 2018-11-02 18:10:38 +02:00
parent 6479656445
commit 4e87d7da4c
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
44 changed files with 1 additions and 3388 deletions

View File

@ -31,7 +31,7 @@ add_library(testcore SHARED testconnections.cpp nodes.cpp mariadb_nodes.cpp maxs
mariadb_func.cpp get_com_select_insert.cpp maxadmin_operations.cpp big_transaction.cpp
sql_t1.cpp test_binlog_fnc.cpp get_my_ip.cpp big_load.cpp get_com_select_insert.cpp
different_size.cpp fw_copy_rules maxinfo_func.cpp config_operations.cpp rds_vpc.cpp execute_cmd.cpp
blob_test.cpp keepalived_func.cpp tcp_connection.cpp base/stopwatch.cpp
blob_test.cpp keepalived_func.cpp tcp_connection.cpp base/stopwatch.cpp fw_copy_rules.cpp
# Include the CDC connector in the core library
${CMAKE_SOURCE_DIR}/connectors/cdc-connector/cdc_connector.cpp)
target_link_libraries(testcore ${MARIADB_CONNECTOR_LIBRARIES} ${JANSSON_LIBRARIES} z m pthread ssl dl rt crypto crypt maxbase)

View File

@ -1,162 +0,0 @@
/**
* @file auroramon.cpp test of Aurora RDS monitor
* - create RDS cluster
* - find 'writer' node and uses 'maxadmin' to check that this node is "Master, Running"
* - do forced failover
* - find 'writer' again and repeat check
* - destroy RDS cluster
*/
#include "testconnections.h"
#include "execute_cmd.h"
#include "rds_vpc.h"
int set_endspoints(RDS* cluster)
{
json_t* endpoint;
long long int port;
const char* IP;
char p[64];
size_t i;
char cmd[1024];
json_t* endpoints = cluster->get_endpoints();
if (endpoints == NULL)
{
return -1;
}
json_array_foreach(endpoints, i, endpoint)
{
port = json_integer_value(json_object_get(endpoint, "Port"));
IP = json_string_value(json_object_get(endpoint, "Address"));
printf("host: %s \t port: %lld\n", IP, port);
sprintf(cmd, "node_%03d_network", (int) i);
setenv(cmd, IP, 1);
sprintf(cmd, "node_%03d_port", (int) i);
sprintf(p, "%lld", port);
setenv(cmd, p, 1);
}
setenv("node_password", "skysqlrds", 1);
setenv("maxscales->user_name", "skysql", 1);
setenv("maxscales->password", "skysqlrds", 1);
setenv("no_nodes_check", "yes", 1);
setenv("no_backend_log_copy", "yes", 1);
return 0;
}
void compare_masters(TestConnections* Test, RDS* cluster)
{
const char* aurora_master;
cluster->get_writer(&aurora_master);
Test->tprintf("Aurora writer node: %s\n", aurora_master);
char maxadmin_status[1024];
int i;
char cmd[1024];
for (i = 0; i < Test->repl->N; i++)
{
sprintf(cmd, "show server server%d", i + 1);
Test->maxscales->get_maxadmin_param(0, cmd, (char*) "Status:", &maxadmin_status[0]);
Test->tprintf("Server%d status %s\n", i + 1, maxadmin_status);
sprintf(cmd, "node%03d", i);
if (strcmp(aurora_master, cmd) == 0)
{
if (strcmp(maxadmin_status, "Master, Running"))
{
Test->tprintf("Maxadmin reports node%03d is a Master as expected", i);
}
else
{
Test->add_result(1,
"Server node%03d status is not 'Master, Running'', it is '%s'",
i,
maxadmin_status);
}
}
else
{
if (strcmp(maxadmin_status, "Slave, Running"))
{
Test->tprintf("Maxadmin reports node%03d is a Slave as expected", i);
}
else
{
Test->add_result(1,
"Server node%03d status is not 'Slave, Running'', it is '%s'",
i,
maxadmin_status);
}
}
}
}
int main(int argc, char* argv[])
{
RDS* cluster = new RDS((char*) "auroratest");
if (cluster->create_rds_db(4) != 0)
{
printf("Error RDS creation\n");
return 1;
}
cluster->wait_for_nodes(4);
if (set_endspoints(cluster) != 0)
{
printf("Error getting RDS endpoints\n");
return 1;
}
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(30);
compare_masters(Test, cluster);
Test->set_timeout(30);
Test->tprintf("Executing a query through readwritesplit before failover");
Test->maxscales->connect_rwsplit(0);
Test->try_query(Test->maxscales->conn_rwsplit[0][0], "show processlist");
char server_id[1024];
Test->tprintf("Get aurora_server_id\n");
find_field(Test->maxscales->conn_rwsplit[0][0], "select @@aurora_server_id;", "server_id", &server_id[0]);
Test->maxscales->close_rwsplit(0);
Test->tprintf("server_id before failover: %s\n", server_id);
Test->stop_timeout();
Test->tprintf("Performing cluster failover\n");
Test->add_result(cluster->do_failover(), "Failover failed\n");
Test->tprintf("Failover done\n");
// Do the failover here and wait until it is over
// sleep(10);
Test->set_timeout(30);
Test->tprintf("Executing a query through readwritesplit after failover");
Test->maxscales->connect_rwsplit(0);
Test->try_query(Test->maxscales->conn_rwsplit[0][0], "show processlist");
Test->tprintf("Get aurora_server_id\n");
find_field(Test->maxscales->conn_rwsplit[0][0], "select @@aurora_server_id;", "server_id", &server_id[0]);
Test->maxscales->close_rwsplit(0);
Test->tprintf("server_id after failover: %s\n", server_id);
compare_masters(Test, cluster);
// Test->check_maxscale_alive(0);
Test->stop_timeout();
cluster->delete_rds_cluster();
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,26 +0,0 @@
/**
* @file bad_pres.cpp check that Maxscale prints warning if persistpoolmax=-1 for all backends (bug MXS-576)
*
* - Maxscale.cnf contains persistpoolmax=-1 for all servers
* - check log warning about it
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->maxscales->connect_maxscale(0);
Test->check_log_err(0, (char*) "warning -1", true);
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,75 +0,0 @@
/**
* @file binlog_big_transaction.cpp test of simple binlog router setup and execute a number of big
* transactions
*/
#include <iostream>
#include "testconnections.h"
#include "maxadmin_operations.h"
#include "sql_t1.h"
#include "test_binlog_fnc.h"
#include "big_transaction.h"
void* disconnect_thread(void* ptr);
TestConnections* Test;
int exit_flag;
int main(int argc, char* argv[])
{
Test = new TestConnections(argc, argv);
Test->set_timeout(3000);
Test->set_log_copy_interval(300);
Test->repl->connect();
execute_query(Test->repl->nodes[0], (char*) "DROP TABLE IF EXISTS t1;");
Test->repl->close_connections();
sleep(5);
Test->start_binlog(0);
pthread_t threads;
exit_flag = 0;
pthread_create(&threads, NULL, disconnect_thread, NULL);
Test->repl->connect();
for (int i = 0; i < 100000; i++)
{
Test->set_timeout(3000);
Test->tprintf("Trying transactions: %d\n", i);
Test->add_result(big_transaction(Test->repl->nodes[0], 7), "Transaction %d failed!\n", i);
}
Test->repl->close_connections();
int rval = Test->global_result;
delete Test;
return rval;
}
void* disconnect_thread(void* ptr)
{
MYSQL* conn;
char cmd[256];
int i;
conn = open_conn(Test->maxscales->binlog_port[0],
Test->maxscales->IP[0],
Test->repl->user_name,
Test->repl->password,
Test->repl->ssl);
Test->add_result(mysql_errno(conn), "Error connecting to Binlog router, error: %s\n", mysql_error(conn));
i = 3;
while (exit_flag == 0)
{
sprintf(cmd, "DISCONNECT SERVER %d", i);
execute_query(conn, "%s", cmd);
i++;
if (i > Test->repl->N)
{
i = 3;
sleep(30);
execute_query(conn, (char*) "DISCONNECT SERVER ALL");
}
sleep(5);
}
return NULL;
}

View File

@ -1,17 +0,0 @@
/**
* @file binlog_failover.cpp binlog_failover Test of failover scenarion for binlog router
*
* - setup following configuration:
* - one master
* - two maxscale binlog machines
* - two slaves connected to each maxscale binlog mashine
* - put some date via master
* - block master
* - stop all Maxscale machines with STOP SLAVE command
* - check which Maxscale machine contains most recent data (let's call this machine 'most_recent_maxscale')
* - use CHANGE MASETER on the second Maxscale machine to point it to the Maxscale machine from the previous
* step ('most_recent_maxscale')
* - wait until second Maxscale is in sync with 'most_recent_maxscale' (use SHOW MASTER STATUS)
* - select new master (HOW??)
* - set all Maxscale machines to be a slaves of new master
*/

View File

@ -1,53 +0,0 @@
/**
* @file bug359.cpp bug359 regression case (router_options in readwritesplit causes errors in error log)
*
* - Maxscale.cnf contains RWSplit router definition with router_option=slave.
* - error is expected in the log. Maxscale should not start.
*/
/*
* Massimiliano 2013-11-22 09:45:13 UTC
* Setting router_options=slave in readwritesplit causes:
*
* in the error log
*
* 2013 11/22 10:35:43 Error : Couldn't find suitable Master from 3 candidates.
* 2013 11/22 10:35:43 Error : Failed to create router client session. Freeing allocated resources.
*
*
* If no options are allowed here, it could be better to log this and/or unload the module
*
*
* This is something could happen doing copy paste from readconnrouter as an example
* Comment 1 Mark Riddoch 2014-02-05 11:35:57 UTC
* I makes no sense for the read/write splitter to look at the slave and master router options.
*
* Vilho Raatikka 2014-05-22 07:02:50 UTC
* Added check for router option 'synced' which accepts only that, and warns the user of other unsupported
* options ('master'|'slave' for example). If router option is specified for read write split router, only a
* node in 'joined' state will be accepted as eligible backend candidate.
*
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->check_log_err(0, (char*) "Unsupported router option \"slave\"", true);
Test->check_log_err(0, (char*) "Failed to start all MaxScale services. Exiting", true);
Test->check_log_err(0, (char*) "Couldn't find suitable Master", false);
// Test->check_maxscale_alive(0);
Test->check_maxscale_processes(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,31 +0,0 @@
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
int global_result = 0;
Test->ReadEnv();
Test->PrintIP();
Test->ConnectMaxscale();
execute_query(Test->maxscales->conn_rwsplit[0],
(char*) "select @@server_id; -- max_slave_replication_lag=120");
Test->CloseMaxscaleConn();
global_result += CheckMaxscaleAlive();
Test->Copy_all_logs();
return global_result;
}

View File

@ -1,36 +0,0 @@
/**
* @file bug479.cpp regression case for bug 479 ( Undefined filter reference in MaxScale.cnf causes a crash)
*
* - Maxscale.cnf with "filters=non existing filter | не существуюший фильтер", cheks error log for warnings
* and
* - check if Maxscale is alive
*/
/*
* Markus Mäkelä 2014-08-15 17:38:06 UTC
* Undefined filters in services cause a crash when the service is accessed.
*
* How to reproduce:
* Define a service with a filter not defined in the MaxScale.cnf file, start MaxScale and access the
* service.
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->check_log_err(0, (char*) "Unable to find filter 'non existing filter", true);
// global_result =Test->check_log_err(0, (char *) "не существуюший фильтер", true);
// global_result +=Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,96 +0,0 @@
/**
* @file bug493.cpp regression case for bug 493 ( Can have same section name multiple times without warning)
*
* - Maxscale.cnf in which 'server2' is defined twice and tests checks error log for proper error message.
* - check if Maxscale is alive
*/
/*
* Hartmut Holzgraefe 2014-08-31 21:01:06 UTC
* Due to a copy/paste error I ended up with two [server2] sections instead of having [server2] and
* [server3].
*
* There were no error or warning messages about this in skygw_err1.log or skygw_msg1.log but only the second
* [server2] was actually used.
*
*
* Configuration file:
*
* ---8<------------------
* [maxscale]
* threads=1
*
* [CLI]
* type=service
* router=cli
*
* [CLI Listener]
* type=listener
* service=CLI
* protocol=maxscaled
* address=localhost
* port=6603
*
* [server1]
* type=server
* address=127.0.0.1
* port=3000
* protocol=MySQLBackend
*
* [server2]
* type=server
* address=127.0.0.1
* port=3001
* protocol=MySQLBackend
*
* [server2]
* type=server
* address=127.0.0.1
* port=3002
* protocol=MySQLBackend
* -------->8---
*
* maxadmin results:
*
*
* ---8<--------------------
* MaxScale> list servers
* Servers.
* -------------------+-----------------+-------+----------------------+------------
* Server | Address | Port | Status | Connections
* -------------------+-----------------+-------+----------------------+------------
* server1 | 127.0.0.1 | 3000 | Running | 0
* server2 | 127.0.0.1 | 3002 | Running | 0
* -------------------+-----------------+-------+----------------------+------------
* ------------->8---
*
* So no entry for the first (actually correct) [server2] on port 3001,
* but only for the duplicate 2nd [server2] with port set to 3002 ...
* Comment 1 Mark Riddoch 2014-09-01 16:17:51 UTC
* The ini file parser we use allows multiple sections with the same name and will combine the section
* contains. Within this restriction we now have added code that will detect the same parameter being set
* twice and will warn the user.
*
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->check_log_err(0, (char*) "Duplicate section found: server2", true);
Test->check_log_err(0,
(char*)
"Failed to open, read or process the MaxScale configuration file /etc/maxscale.cnf. Exiting",
true);
// Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,44 +0,0 @@
/**
* @file bug495.cpp regression case for bug 495 ( Referring to a nonexisting server in servers=... doesn't
* even raise a warning )
*
* - Maxscale.cnf with "servers= server1, server2,server3 ,server4,server5"
* but 'server5' is not defined. Test checks error log for proper error message.
* - check if Maxscale is alive
*/
/*
*
* Description Hartmut Holzgraefe 2014-08-31 21:32:09 UTC
* Only [server1] and [server2] are defined,
* service [test_service] and monitor [MySQL monitor]
* refer to a third server "server3" in their servers=...
* list though ...
*
* Nothing in the err or msg log hints towards a problem ...
* (which originally was caused by a copy/paste error that
* also lead to the "duplicate section name" error reported
* earlier ... and which would have been easy to track down
* if either of these problems would at least have raised a
* warning - took me almost an hour to track down the actual
* problem ... :(
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->check_log_err(0, (char*) "Unable to find server", true);
Test->check_log_err(0, (char*) "errors were encountered while processing the configuration", true);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,77 +0,0 @@
/**
* @file bug526.cpp regression case for bug 526 ( " Wrong module name crashes maxscale on connect" )
*
* - Maxscale.cnf with "filters=QLA|testfilter" for RWSplit router service, 'testfilter' is not defined.
* - check error log for proper error messages and checks if ReadConn services are alive
*/
/*
* Hartmut Holzgraefe 2014-09-08 13:08:46 UTC
* I mistyped a module name (for a filter in this case)
*
* [testfilter]
* type=filter
* module=foobar
*
* There were no warnings about this on startup at all, but at the first time trying to connect to a service
* this filter was used in maxscale crashed with a segmentation fault after writing the following error log
* entries:
*
* 2014 09/08 15:00:53 Error : Unable to find library for module: foobar.
* 2014 09/08 15:00:53 Failed to create filter 'testfilter' for service 'testrouter'.
* 2014 09/08 15:00:53 Error : Failed to create Read Connection Router session.
* 2014 09/08 15:00:53 Error : Invalid authentication message from backend. Error : 28000, Msg : Access
* denied for user 'maxuser'@'localhost' (using password: YES)
* 2014 09/08 15:00:53 Error : Backend server didn't accept authentication for user denied for user
* 'maxuser'@'localhost' (using password: YES).
*
* Two problems here:
*
* 1) can't check up front that my configuration is valid / without errors without connecting to each defined
* service
*
* 2) maxscale crashes instead of handling this situation gracefully (e.g. ignoring the misconfigured filter,
* or disabling the service that refers to it alltogether)
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
#include "maxadmin_operations.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(20);
if (Test->maxscales->connect_rwsplit(0) == 0)
{
Test->add_result(1, "Filter config is broken, but service is started\n");
}
if (Test->maxscales->connect_readconn_master(0) == 0)
{
Test->add_result(1, "Filter config is broken, but Maxscale is started\n");
}
if (Test->maxscales->connect_readconn_slave(0) == 0)
{
Test->add_result(1, "Filter config is broken, but Maxscale is started\n");
}
// sleep(5);
Test->maxscales->execute_maxadmin_command(0, (char*) "sync logs");
Test->check_log_err(0, (char*) "Unable to find library for module: foobar", true);
Test->check_log_err(0, (char*) "Failed to load filter module 'foobar'", true);
Test->check_log_err(0, (char*) "Failed to load filter 'testfilter' for service 'RW Split Router'", true);
Test->check_log_err(0,
(char*)
"Failed to open, read or process the MaxScale configuration file /etc/maxscale.cnf. Exiting",
true);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,61 +0,0 @@
/**
* @file bug539.cpp regression case for bug539 ("MaxScale crashes in session_setup_filters")
* using maxadmin execute "fail backendfd"
* try quries against all services
* using maxadmin execute "fail clientfd"
* try quries against all services
* check if MaxScale alive
*/
#include "testconnections.h"
#include "maxadmin_operations.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(20);
int i, j;
MYSQL* conn;
int N_cmd = 2;
char* fail_cmd[N_cmd - 1];
fail_cmd[0] = (char*) "fail backendfd";
fail_cmd[1] = (char*) "fail clientfd";
for (i = 0; i < N_cmd; i++)
{
for (j = 0; j < Test->maxscales->N_ports[0]; j++)
{
Test->tprintf("Executing MaxAdmin command '%s'\n", fail_cmd[i]);
if (maxscales->execute_maxadmin_command(0,
Test->maxscales->IP[0],
(char*) "admin",
Test->maxscales->maxadmin_password[0],
fail_cmd[i]) != 0)
{
Test->add_result(1, "MaxAdmin command failed\n");
}
else
{
printf("Trying query against %d\n", Test->maxscales->ports[0][j]);
conn = open_conn(ports[j],
Test->maxscales->IP[0],
Test->maxscales->user_name,
Test->maxscales->password,
Test->ssl);
Test->try_query(conn, (char*) "show processlist;");
}
}
}
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,55 +0,0 @@
/**
* @file bug643.cpp regression case for bugs 643 ("Hints, RWSplit: MaxScale goes into infinite loop and
* crashes") and bug645
* - setup RWSplit in the following way for bug643
* @verbatim
* [RW Split Router]
* type=service
* router=readwritesplit
* servers=server1,server2,server3,server4
* max_slave_connections=100%
* use_sql_variables_in=all
* user=skysql
* passwd=skysql
* filters=duplicate
*
* [duplicate]
* type=filter
* module=tee
* service=RW Split Router
* @endverbatim
* - try to connect
* - try simple query using ReadConn router (both, master and slave)
* - check warnig in the log "RW Split Router: Recursive use of tee filter in service"
*/
#include <iostream>
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->tprintf("Trying to connect to all Maxscale services\n");
fflush(stdout);
Test->maxscales->connect_maxscale(0);
Test->tprintf("Trying to send query to ReadConn master\n");
fflush(stdout);
Test->try_query(Test->maxscales->conn_master[0], (char*) "show processlist");
Test->tprintf("Trying to send query to ReadConn slave\n");
fflush(stdout);
Test->try_query(Test->maxscales->conn_slave[0], (char*) "show processlist");
Test->tprintf("Trying to send query to RWSplit, expecting failure\n");
fflush(stdout);
if (execute_query(Test->maxscales->conn_rwsplit[0], (char*) "show processlist") == 0)
{
Test->add_result(1, "FAIL: Query to broken service succeeded!\n");
}
Test->maxscales->close_maxscale_connections(0);
Test->check_log_err(0, "Recursive use of tee filter in service", true);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,96 +0,0 @@
/**
* @file bug643.cpp regression case for bugs 643 ("Hints, RWSplit: MaxScale goes into infinite loop and
* crashes") and bug645
* - setup RWSplit in the following way for bug643
* @verbatim
* [hints]
* type=filter
* module=hintfilter
*
*
* [regex]
* type=filter
* module=regexfilter
* match=fetch
* replace=select
*
* [typo]
* type=filter
* module=regexfilter
* match=[Ff][Oo0][Rr][Mm]
* replace=from
*
* [qla]
* type=filter
* module=qlafilter
* options=/tmp/QueryLog
*
* [duplicate]
* type=filter
* module=tee
* service=RW Split2
*
* [testfilter]
* type=filter
* module=foobar
*
* [RW Split Router]
* type=service
* router=readwritesplit
* servers=server1,server2,server3,server4
#servers=server1,server2
* max_slave_connections=100%
* use_sql_variables_in=all
#use_sql_variables_in=master
* user=skysql
* passwd=skysql
#filters=typo|qla|regex|hints|regex|hints
#enable_root_user=1
* filters=duplicate
*
* [RW Split2]
* type=service
* router=readwritesplit
* servers=server1,server2,server3,server4
* max_slave_connections=100%
* use_sql_variables_in=all
* user=skysql
* passwd=skysql
* filters=qla|tests|hints
*
* @endverbatim
* - try to connect
* - try simple query using all services
* - check warnig in the log "Failed to start service 'RW Split2"
* - check if Maxscale still alive
*/
#include <iostream>
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->tprintf("Trying to connect to all Maxscale services\n");
fflush(stdout);
Test->maxscales->connect_maxscale(0);
Test->tprintf("Trying to send query to RWSplit\n");
fflush(stdout);
execute_query(Test->maxscales->conn_rwsplit[0], (char*) "show processlist");
Test->tprintf("Trying to send query to ReadConn master\n");
fflush(stdout);
execute_query(Test->maxscales->conn_master[0], (char*) "show processlist");
Test->tprintf("Trying to send query to ReadConn slave\n");
fflush(stdout);
execute_query(Test->maxscales->conn_slave[0], (char*) "show processlist");
Test->maxscales->close_maxscale_connections(0);
Test->check_log_err(0, (char*) "Unable to find filter 'tests' for service 'RW Split2'", true);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,223 +0,0 @@
/**
* @file bug643.cpp regression case for bugs 645 ("Tee filter with readwritesplit service hangs MaxScale")
* - setup RWSplit in the following way
* @verbatim
* [RW_Router]
* type=service
* router=readconnroute
* servers=server1
* user=skysql
* passwd=skysql
* version_string=5.1-OLD-Bored-Mysql
* filters=DuplicaFilter
*
* [RW_Split]
* type=service
* router=readwritesplit
* servers=server1, server3,server2
* user=skysql
* passwd=skysql
*
* [DuplicaFilter]
* type=filter
* module=tee
* service=RW_Split
*
* [RW_Listener]
* type=listener
* service=RW_Router
* protocol=MySQLClient
* port=4006
*
* [RW_Split_list]
* type=listener
* service=RW_Split
* protocol=MySQLClient
* port=4016
*
* @endverbatim
* - try to connect
* - try simple query
* - check MaxScale is alive
*/
/*
* Massimiliano 2014-12-11 14:19:51 UTC
* When tee filter is used with a readwritesplit service MaxScale hangs (each service including admin
* interface)or there is a failed assetion in Debug mode:
*
* debug assert /source/GA/server/modules/routing/readwritesplit/readwritesplit.c:1825
* maxscale: /source/GA/server/modules/routing/readwritesplit/readwritesplit.c:1825: routeQuery: Assertion
* `!(querybuf->gwbuf_type == 0)' failed.
*
*
* Configuration:
*
*
* [RW_Router]
* type=service
* router=readconnroute
* servers=server1
* user=massi
* passwd=massi
* version_string=5.1-OLD-Bored-Mysql
* filters=DuplicaFilter
*
* [RW_Split]
* type=service
* router=readwritesplit
* servers=server3,server2
* user=massi
* passwd=massi
*
* [DuplicaFilter]
* type=filter
* module=tee
* service=RW_Split
*
* [RW_Listener]
* type=listener
* service=RW_Router
* protocol=MySQLClient
* port=4606
*
*
* Accessing the RW_listener:
*
* mysql -h 127.0.0.1 -P 4606 -umassi -pmassi
*
*
*
* Debug version:
*
* 2014-12-11 08:48:48 Fatal: MaxScale received fatal signal 6. Attempting backtrace.
* 2014-12-11 08:48:48 ./maxscale() [0x53c80e]
* 2014-12-11 08:48:48 /lib64/libpthread.so.0(+0xf710) [0x7fd418a62710]
* 2014-12-11 08:48:48 /lib64/libc.so.6(gsignal+0x35) [0x7fd417318925]
* 2014-12-11 08:48:48 /lib64/libc.so.6(abort+0x175) [0x7fd41731a105]
* 2014-12-11 08:48:48 /lib64/libc.so.6(+0x2ba4e) [0x7fd417311a4e]
* 2014-12-11 08:48:48 /lib64/libc.so.6(__assert_perror_fail+0) [0x7fd417311b10]
* 2014-12-11 08:48:48 /usr/local/skysql/maxscale/modules/libreadwritesplit.so(+0x69ca) [0x7fd4142789ca]
* 2014-12-11 08:48:48 /usr/local/skysql/maxscale/modules/libtee.so(+0x3707) [0x7fd3fc2db707]
* 2014-12-11 08:48:48 /usr/local/skysql/maxscale/modules/libMySQLClient.so(+0x595d) [0x7fd3fe34b95d]
* 2014-12-11 08:48:48 ./maxscale() [0x54d3ec]
* 2014-12-11 08:48:48 ./maxscale(poll_waitevents+0x63d) [0x54ca8a]
* 2014-12-11 08:48:48 ./maxscale(main+0x1acc) [0x53f616]
* 2014-12-11 08:48:48 /lib64/libc.so.6(__libc_start_main+0xfd) [0x7fd417304d1d]
* 2014-12-11 08:48:48 ./maxscale() [0x53a92d]
*
*
* Without debug:
*
* we got mysql prompt but then maxscale is stucked
* or
* when don't have the prompt, it hangs after few welcome messages
* Comment 1 Vilho Raatikka 2014-12-11 15:14:50 UTC
* The assertion occurs because query is is not statement - but packet type. That is, it was sent to read
* connection router which doesn't examine MySQL packets except the header. Thus, the type of query is not set
* in mysql_client.c:gw_read_client_event:
* >>>
* if (cap == 0 || (cap == RCAP_TYPE_PACKET_INPUT))
* {
* stmt_input = false;
* }
* else if (cap == RCAP_TYPE_STMT_INPUT)
* {
* stmt_input = true;
*
* gwbuf_set_type(read_buffer, GWBUF_TYPE_MYSQL);
* }
* >>>
* Comment 2 Massimiliano 2014-12-11 16:00:52 UTC
* Using readconnroute (with router_options=master) instead seems fine.
*
* I found that "USE dbname" is not passed via tee filter:
*
*
* 4606 is the listener to a service with tee filter
*
* root@maxscale-02 build]# mysql -h 127.0.0.1 -P 4606 -u massi -pmassi
*
*
*
* USE test; SELECT DATABASE()
* client to maxscale:
*
* T 127.0.0.1:40440 -> 127.0.0.1:4606 [AP]
* 05 00 00 00 02 74 65 73 74 .....test
*
* T 127.0.0.1:4606 -> 127.0.0.1:40440 [AP]
* 07 00 00 01 00 00 00 02 00 00 00 ...........
*
* T 127.0.0.1:40440 -> 127.0.0.1:4606 [AP]
* 12 00 00 00 03 53 45 4c 45 43 54 20 44 41 54 41 .....SELECT DATA
* 42 41 53 45 28 29 BASE()
*
* T 127.0.0.1:4606 -> 127.0.0.1:40440 [AP]
* 01 00 00 01 01 20 00 00 02 03 64 65 66 00 00 00 ..... ....def...
* 0a 44 41 54 41 42 41 53 45 28 29 00 0c 08 00 22 .DATABASE()...."
* 00 00 00 fd 00 00 1f 00 00 05 00 00 03 fe 00 00 ................
* 02 00 05 00 00 04 04 74 65 73 74 05 00 00 05 fe .......test.....
* 00 00 02 00 ....
*
* maxscale to backend:
*
*
* T 127.0.0.1:56578 -> 127.0.0.1:3308 [AP]
* 12 00 00 00 03 53 45 4c 45 43 54 20 44 41 54 41 .....SELECT DATA
* 42 41 53 45 28 29 BASE()
*
* T 127.0.0.1:3308 -> 127.0.0.1:56578 [AP]
* 01 00 00 01 01 20 00 00 02 03 64 65 66 00 00 00 ..... ....def...
* 0a 44 41 54 41 42 41 53 45 28 29 00 0c 08 00 22 .DATABASE()...."
* 00 00 00 fd 00 00 1f 00 00 05 00 00 03 fe 00 00 ................
* 02 00 01 00 00 04 fb 05 00 00 05 fe 00 00 02 00 ................
*
*
* USE test was not sent
*
*
*
* May be a similar issue is present with readwritesplit but I cannot test it
* Comment 3 Vilho Raatikka 2014-12-11 16:35:46 UTC
* (In reply to comment #2)
* > Using readconnroute (with router_options=master) instead seems fine.
*
* Using readconnroute _where_? in tee?
* Comment 4 Vilho Raatikka 2014-12-12 08:27:41 UTC
* gwbuf_type is not set and that is the immediate cause for assertion with Debug version.
* Reason why the type is not set is in the way the packets are first processed in mysql_client.c client
* protocol module and then passed optionally to filters and router. There is a bug because it is assumed that
* when client protocol module reads incoming packet it can resolve which router will handle the packet
* processing. The code doesn't take into account that same packet can be processed by many different
* maxscales->routers[0], like in the case of readconnrouter->tee->readwritesplit.
* Another problem is in readwritesplit where it is assumed that it is the first and the only router that
* will process tha data. So it includes checks that the buffer has correct type.
*
* Required changes are:
* - readwritesplit should check if buffer has no type and in that case, insted of asserting, merge incoming
* MySQL packet fragments into a single contiguous buffer.
* - remove checks which enforce rules which are based on false assumption.
*/
#include <iostream>
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->maxscales->connect_maxscale(0);
Test->try_query(Test->maxscales->conn_master[0], (char*) "show processlist");
Test->try_query(Test->maxscales->conn_slave[0], (char*) "show processlist");
Test->try_query(Test->maxscales->conn_rwsplit[0], (char*) "show processlist");
Test->maxscales->close_maxscale_connections(0);
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,17 +0,0 @@
/**
* @file bug643.cpp regression case for bugs 645 ("Tee filter with readwritesplit service hangs MaxScale")
*
* - Try to connect to all services except 4016
* - Try simple query on all services
* - Check log for presence of "Couldn't find suitable Master from 2 candidates" errors
*/
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections test(argc, argv);
test.check_maxscale_alive(0);
test.check_log_err(0, "Couldn't find suitable Master from 2 candidates", true);
return test.global_result;
}

View File

@ -1,160 +0,0 @@
/**
* @file bug649.cpp regression case for bug 649 ("Segfault using RW Splitter")
* @verbatim
*
* [RW_Router]
* type=service
* router=readconnroute
* servers=server1
* user=skysql
* passwd=skysql
* version_string=5.1-OLD-Bored-Mysql
* filters=DuplicaFilter
*
* [RW_Split]
* type=service
* router=readwritesplit
* servers=server1,server3,server2
* user=skysql
* passwd=skysql
*
* [DuplicaFilter]
* type=filter
* module=tee
* service=RW_Split
*
* @endverbatim
* - Connect to RWSplit
* - create load on RWSplit (25 threads doing long INSERTs in the loop)
* - block Mariadb server on Master node by Firewall
* - unblock Mariadb server
* - check if Maxscale is alive
* - reconnect and check if query execution is ok
*/
#include <iostream>
#include "testconnections.h"
#include "sql_t1.h"
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int exit_flag = 0;
TestConnections* Test;
char sql[1000000];
void* parall_traffic(void* ptr);
int main(int argc, char* argv[])
{
int threads_num = 20;
pthread_t parall_traffic1[threads_num];
int check_iret[threads_num];
Test = new TestConnections(argc, argv);
int time_to_run = (Test->smoke) ? 10 : 30;
Test->set_timeout(10);
Test->tprintf("Connecting to RWSplit %s\n", Test->maxscales->IP[0]);
Test->maxscales->connect_rwsplit(0);
Test->repl->connect();
Test->tprintf("Drop t1 if exists\n");
execute_query(Test->repl->nodes[0], "DROP TABLE IF EXISTS t1;");
Test->tprintf("Create t1\n");
Test->add_result(create_t1(Test->repl->nodes[0]), "t1 creation Failed\n");
Test->repl->close_connections();
Test->stop_timeout();
sleep(5);
create_insert_string(sql, 65000, 1);
Test->tprintf("Creating query threads\n", time_to_run);
for (int j = 0; j < threads_num; j++)
{
Test->set_timeout(20);
check_iret[j] = pthread_create(&parall_traffic1[j], NULL, parall_traffic, NULL);
}
Test->stop_timeout();
Test->tprintf("Waiting %d seconds\n", time_to_run);
sleep(time_to_run);
Test->tprintf("Setup firewall to block mysql on master\n");
Test->repl->block_node(0);
fflush(stdout);
Test->tprintf("Waiting %d seconds\n", time_to_run);
sleep(time_to_run);
Test->set_timeout(30);
Test->tprintf("Trying query to RWSplit, expecting failure, but not a crash\n");
if (execute_query_silent(Test->maxscales->conn_rwsplit[0], (char*) "show processlist;") == 0)
{
Test->add_result(1, "Failure is expected, but query is ok\n");
}
Test->stop_timeout();
sleep(time_to_run);
Test->tprintf("Setup firewall back to allow mysql\n");
Test->repl->unblock_node(0);
fflush(stdout);
Test->stop_timeout();
sleep(time_to_run);
exit_flag = 1;
for (int i = 0; i < threads_num; i++)
{
Test->set_timeout(30);
pthread_join(parall_traffic1[i], NULL);
Test->tprintf("exit %d\n", i);
}
Test->stop_timeout();
sleep(5);
Test->set_timeout(20);
Test->tprintf("Checking Maxscale is alive\n");
Test->check_maxscale_alive(0);
Test->set_timeout(20);
Test->tprintf("Reconnecting to RWSplit ...\n");
Test->maxscales->connect_rwsplit(0);
Test->tprintf(" ... and trying query\n");
Test->try_query(Test->maxscales->conn_rwsplit[0], (char*) "show processlist;");
Test->maxscales->close_rwsplit(0);
/** Clean up */
Test->repl->connect();
execute_query(Test->repl->nodes[0], "DROP TABLE IF EXISTS t1;");
int rval = Test->global_result;
delete Test;
return rval;
}
void* parall_traffic(void* ptr)
{
MYSQL* conn;
mysql_thread_init();
conn = Test->maxscales->open_rwsplit_connection(0);
if ((conn != NULL) && (mysql_errno(conn) == 0))
{
while (exit_flag == 0)
{
execute_query_silent(conn, sql);
fflush(stdout);
}
}
else
{
Test->tprintf("Error opening connection");
}
if (conn != NULL)
{
mysql_close(conn);
}
return NULL;
}

View File

@ -1,17 +0,0 @@
/**
* @file bug650.cpp regression case for bug 650 ("Hints, RWSplit: MaxScale goes into infinite loop and
* crashes") and bug645
* - try simple query using all services
* - check for errors in the log
*/
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections test(argc, argv);
test.check_maxscale_alive(0);
test.check_log_err(0, "Couldn't find suitable Master from 2 candidates", true);
test.check_log_err(0, "Failed to create new router session for service 'RW_Split'", true);
return test.global_result;
}

View File

@ -1,43 +0,0 @@
/**
* @file bug656.cpp Checks Maxscale behaviour in case if Master node is blocked - NOT NEEDED BECAUSE IT IS
* ALREADY CHECKED BY OTHER TESTS!!!!
*
* - ConnecT to RWSplit
* - block Mariadb server on Master node by Firewall
* - try simple query *show servers" via Maxadmin
*/
#include "testconnections.h"
#include "maxadmin_operations.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(30);
Test->tprintf("Connecting to RWSplit %s\n", Test->maxscales->IP[0]);
Test->maxscales->connect_rwsplit(0);
Test->tprintf("Setup firewall to block mysql on master\n");
Test->repl->block_node(0);
// printf("Trying query to RWSplit, expecting failure, but not a crash\n"); fflush(stdout);
// execute_query(Test->maxscales->conn_rwsplit[0], (char *) "show processlist;");
execute_maxadmin_command_print(Test->maxscales->IP[0],
(char*) "admin",
Test->maxscales->maxadmin_password[0],
(char*) "show servers");
Test->tprintf("Setup firewall back to allow mysql and wait\n");
Test->repl->unblock_node(0);
sleep(10);
Test->maxscales->close_rwsplit(0);
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,83 +0,0 @@
/**
* @file bug657.cpp regression case for bug 657 ("Tee filter: closing child session causes MaxScale to fail")
*
* - Configure readconnrouter with tee filter and tee filter with a readwritesplit as a child service.
* @verbatim
* [RW Split Router]
* type=service
* router= readwritesplit
* servers=server1, server2, server3,server4
* user=skysql
* passwd=skysql
#filters=QLA
*
* [Read Connection Router Slave]
* type=service
* router=readconnroute
* router_options= slave
* servers=server1,server2,server3,server4
* user=skysql
* passwd=skysql
* filters=TEE
*
* [Read Connection Router Master]
* type=service
* router=readconnroute
* router_options=master
* servers=server1,server2,server3,server4
* user=skysql
* passwd=skysql
* filters=TEE
*
* [TEE]
* type=filter
* module=tee
* service=RW Split Router
* @endverbatim
* - Start MaxScale
* - Connect readconnrouter
* - Fail the master node
* - Reconnect readconnrouter
*/
#include <iostream>
#include "testconnections.h"
#include "sql_t1.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(200);
Test->tprintf("Connecting to ReadConn Master %s\n", Test->maxscales->IP[0]);
Test->maxscales->connect_readconn_master(0);
sleep(1);
Test->tprintf("Setup firewall to block mysql on master\n");
Test->repl->block_node(0);
sleep(10);
Test->tprintf("Reconnecting to ReadConnMaster\n");
Test->maxscales->close_readconn_master(0);
Test->maxscales->connect_readconn_master(0);
sleep(5);
Test->repl->unblock_node(0);
sleep(10);
Test->tprintf("Closing connection\n");
Test->maxscales->close_readconn_master(0);
fflush(stdout);
Test->tprintf("Checking Maxscale is alive\n");
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,277 +0,0 @@
/**
* @file bug670.cpp bug670 regression case
* configuration
* @verbatim
* [MySQL Monitor]
* type=monitor
* module=mysqlmon
* monitor_interval=10000
* servers=server1,server2,server3,server4
* detect_replication_lag=1
* detect_stale_master=1
* user=maxuser
* passwd=maxpwd
*
* [hints]
* type=filter
* module=hintfilter
*
* [regex]
* type=filter
* module=regexfilter
* match=fetch
* replace=select
*
* [typo]
* type=filter
* module=regexfilter
* match=[Ff][Oo0][Rr][Mm]
* replace=from
*
* [qla]
* type=filter
* module=qlafilter
* options=/tmp/QueryLog
*
* [duplicate]
* type=filter
* module=tee
* service=RW Split2
*
* [testfilter]
* type=filter
* module=foobar
*
* [RW Split Router]
* type=service
* router=readwritesplit
* servers=server1,server2,server3,server4
#servers=server1
* max_slave_connections=100%
* use_sql_variables_in=all
#use_sql_variables_in=master
* user=maxuser
* passwd=maxpwd
* filters=typo|qla|regex|hints|regex|hints
* enable_root_user=1
*
* [RW Split2]
* type=service
* router=readwritesplit
* servers=server1,server2
* max_slave_connections=100%
* use_sql_variables_in=all
* user=maxuser
* passwd=maxpwd
#filters=qla|tests|hints
*
* [Read Connection Router]
* type=service
* router=readconnroute
* router_options=slave
* servers=server1,server2
* user=maxuser
* passwd=maxpwd
* filters=duplicate
*
* [HTTPD Router]
* type=service
* router=testroute
* servers=server1,server2,server3
*
* [Debug Interface]
* type=service
* router=debugcli
*
* [CLI]
* type=service
* router=cli
*
* [RW Split Listener]
* type=listener
* service=RW Split Router
* protocol=MySQLClient
* port=4006
#socket=/tmp/rwsplit.sock
*
* [RW Split Listener2]
* type=listener
* service=RW Split2
* protocol=MySQLClient
* port=4012
*
* [Read Connection Listener]
* type=listener
* service=Read Connection Router
* protocol=MySQLClient
* port=4008
#socket=/tmp/readconn.sock
*
* @endverbatim
* execute following SQLs against all services in the loop (100 times)
* @verbatim
* set autocommit=0;
* use mysql;
* set autocommit=1;
* use test;
* set autocommit=0;
* use mysql;
* set autocommit=1;
* select user,host from user;
* set autocommit=0;
* use fakedb;
* use test;
* use mysql;
* use dontuse;
* use mysql;
* drop table if exists t1;
* commit;
* use test;
* use mysql;
* set autocommit=1;
* create table t1(id integer primary key);
* insert into t1 values(5);
* use test;
* use mysql;
* select user from user;
* set autocommit=0;
* set autocommit=1;
* set autocommit=0;
* insert into mysql.t1 values(7);
* use mysql;
* rollback work;
* commit;
* delete from mysql.t1 where id=7;
* insert into mysql.t1 values(7);
* select host,user from mysql.user;
* set autocommit=1;
* delete from mysql.t1 where id = 7;
* select 1 as "endof cycle" from dual;
* @endverbatim
*
* check that Maxscale is alive, no crash
*/
/*
*
* Description Vilho Raatikka 2014-12-30 11:54:52 UTC
* Statement router (readwritesplit) loses pending statement if the other router executes statements faster
* than it. Statement router assumes that client doesn't send next statement before previous has replied. The
* only supported exception is session command which doesn't need to reply before client may send the next
* statement.
*
* What happens in practice, is, that when 'next' statement arrives router's routeQuery it finds previous,
* still pending statement. In Debug build process traps. In Release build the pending command is overwritten.
*
* (gdb) bt
#0 0x00007f050fa56065 in raise () from /lib64/libc.so.6
#1 0x00007f050fa574e8 in abort () from /lib64/libc.so.6
#2 0x00007f050fa4ef72 in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007f050fa4f022 in __assert_fail () from /lib64/libc.so.6
#4 0x00007f050c06ddbb in route_single_stmt (inst=0x25ea750, rses=0x7f04d4002350, querybuf=0x7f04d400f130)
* at /home/raatikka/src/git/MaxScale/server/modules/routing/readwritesplit/readwritesplit.c:2372
#5 0x00007f050c06c2ef in routeQuery (instance=0x25ea750, router_session=0x7f04d4002350,
* querybuf=0x7f04d400f130)
* at /home/raatikka/src/git/MaxScale/server/modules/routing/readwritesplit/readwritesplit.c:1895
#6 0x00007f04f03ca573 in routeQuery (instance=0x7f04d4001f20, session=0x7f04d4002050, queue=0x7f04d400f130)
* at /home/raatikka/src/git/MaxScale/server/modules/filter/tee.c:597
#7 0x00007f04f8df700a in gw_read_client_event (dcb=0x7f04cc0009c0)
* at /home/raatikka/src/git/MaxScale/server/modules/protocol/mysql_client.c:867
#8 0x000000000058b351 in process_pollq (thread_id=4) at
* /home/raatikka/src/git/MaxScale/server/core/poll.c:858
#9 0x000000000058a9eb in poll_waitevents (arg=0x4) at /home/raatikka/src/git/MaxScale/server/core/poll.c:608
#10 0x00007f0511223e0f in start_thread () from /lib64/libpthread.so.0
#11 0x00007f050fb0a0dd in clone () from /lib64/libc.so.6
* (gdb)
* Comment 1 Vilho Raatikka 2014-12-30 12:04:06 UTC
* Created attachment 171 [details]
* Configuration.
*
* 1. Start MaxScale
* 2. feed session command/statement load to port 4008 which belongs to readconnrouter. Statements are then
* duplicated to rwsplit which starts to lag behind immediately.
* Comment 2 Vilho Raatikka 2014-12-30 12:05:26 UTC
* Created attachment 172 [details]
* Simple script to run session command/statement load
*
* Requires setmix.sql
* Comment 3 Vilho Raatikka 2014-12-30 12:05:49 UTC
* Created attachment 173 [details]
* List of statements used by run_setmix.sh
* Comment 4 Vilho Raatikka 2014-12-31 19:13:21 UTC
* tee filter doesn't send reply to client before both maxscales->routers[0] have replied. This required
* adding upstream processing to tee filter. First reply is routed to client. By this tee ensures that new
* query is never sent to either router before they have replied to previous one.
* Comment 5 Timofey Turenko 2015-01-08 12:40:34 UTC
* test added, closing
* Comment 6 Timofey Turenko 2015-02-28 18:11:16 UTC
* Reopen: starting from 1.0.5 test for bug670 start to fail with debug assert:
*
* (gdb) bt
#0 0x00007f542de05625 in raise () from /lib64/libc.so.6
#1 0x00007f542de06e05 in abort () from /lib64/libc.so.6
#2 0x00007f542ddfe74e in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007f542ddfe810 in __assert_fail () from /lib64/libc.so.6
#4 0x00007f53fe7a2daf in clientReply (instance=0x7f53ec001970, session=0x7f53ec001aa0, reply=0x7f5404000b70)
* at /usr/local/skysql/maxscale/server/modules/filter/tee.c:973
#5 0x00007f54292c1b55 in clientReply (instance=0x335ae20, router_session=0x7f53ec000f90,
* queue=0x7f5404000b70,
* backend_dcb=0x7f53ec000fd0) at /usr/local/skysql/maxscale/server/modules/routing/readconnroute.c:814
#6 0x00007f54143f7fb7 in gw_read_backend_event (dcb=0x7f53ec000fd0)
* at /usr/local/skysql/maxscale/server/modules/protocol/mysql_backend.c:577
#7 0x000000000056962d in process_pollq (thread_id=3) at /usr/local/skysql/maxscale/server/core/poll.c:867
#8 0x0000000000568508 in poll_waitevents (arg=0x3) at /usr/local/skysql/maxscale/server/core/poll.c:608
#9 0x00007f542f54a9d1 in start_thread () from /lib64/libpthread.so.0
#10 0x00007f542debb8fd in clone () from /lib64/libc.so.6
*
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
#include "bug670_sql.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
int i;
Test->tprintf("Connecting to all MaxScale services\n");
Test->add_result(Test->maxscales->connect_maxscale(0), "Error connecting to Maxscale\n");
Test->tprintf("executing sql 100 times (ReadConn Slave)\n");
for (i = 0; i < 100; i++)
{
Test->set_timeout(15);
execute_query_silent(Test->maxscales->conn_slave[0], bug670_sql);
}
Test->tprintf("executing sql 100 times (ReadConn Master)\n");
for (i = 0; i < 100; i++)
{
Test->set_timeout(15);
execute_query_silent(Test->maxscales->conn_master[0], bug670_sql);
}
Test->tprintf("executing sql 100 times (RWSplit)\n");
for (i = 0; i < 100; i++)
{
Test->set_timeout(15);
execute_query_silent(Test->maxscales->conn_rwsplit[0], bug670_sql);
}
Test->set_timeout(10);
Test->maxscales->close_maxscale_connections(0);
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,52 +0,0 @@
/**
* @file crash_ot_of_files_galera.cpp Tries to open to many connections, expect no crash, Galera backend
* - set global max_connections = 20
* - create load on RWSplit using big number of threads (e.g. 100)
* - check that no backends are disconnected with error ""refresh rate limit exceeded"
*/
#include "testconnections.h"
#include "sql_t1.h"
#include "get_com_select_insert.h"
#include "big_load.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(20);
long int i1, i2;
long int selects[256];
long int inserts[256];
long int new_selects[256];
long int new_inserts[256];
Test->galera->execute_query_all_nodes((char*) "set global max_connections = 20;");
Test->set_timeout(1200);
load(&new_inserts[0], &new_selects[0], &selects[0], &inserts[0], 100, Test, &i1, &i2, 0, true, false);
sleep(10);
// load(&new_inserts[0], &new_selects[0], &selects[0], &inserts[0], 1000, Test, &i1, &i2, 0, true, false);
// sleep(10);
Test->set_timeout(1200);
load(&new_inserts[0], &new_selects[0], &selects[0], &inserts[0], 100, Test, &i1, &i2, 0, true, false);
Test->set_timeout(20);
Test->galera->connect();
for (int i = 0; i < Test->galera->N; i++)
{
execute_query(Test->galera->nodes[i], (char*) "flush hosts;");
execute_query(Test->galera->nodes[i], (char*) "set global max_connections = 151;");
}
Test->galera->close_connections();
Test->check_log_err(0, (char*) "refresh rate limit exceeded", false);
Test->galera->execute_query_all_nodes((char*) "set global max_connections = 100;");
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,80 +0,0 @@
/**
* @file failover_mysqlmon.cpp MySQL Monitor Failover Test
* - block all nodes, but one
* - wait for minitor (monitor_interval)
* - check maxadmin output
* - check that queries work
* - unblock backend nodes
* - wait for monitor
* - check that we are still using the last node to which we failed over to and that the old nodes are in
* maintenance mode
*/
#include <iostream>
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections* test = new TestConnections(argc, argv);
test->tprintf("Create the test table and insert some data ");
test->connect_maxscale();
test->try_query(test->conn_rwsplit, "CREATE OR REPLACE TABLE test.t1 (id int)");
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
test->close_maxscale_connections();
test->repl->connect();
test->repl->sync_slaves();
test->tprintf("Block all but one node ");
test->repl->block_node(0);
test->repl->block_node(1);
test->repl->block_node(2);
execute_query(test->repl->nodes[3], "STOP SLAVE;RESET SLAVE ALL;");
test->tprintf("Wait for the monitor to detect it ");
test.maxscales->wait_for_monitor();
test->tprintf("Connect and insert should work ");
char* output = test->ssh_maxscale_output(true, "maxadmin list servers");
test->tprintf("%s", output);
free(output);
test->connect_maxscale();
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
test->close_maxscale_connections();
test->tprintf("Unblock nodes ");
test->repl->unblock_node(0);
test->repl->unblock_node(1);
test->repl->unblock_node(2);
test->tprintf("Wait for the monitor to detect it ");
test.maxscales->wait_for_monitor();
test->tprintf("Check that we are still using the last node to which we failed over "
"to and that the old nodes are in maintenance mode");
test->connect_maxscale();
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
char maxscale_id[256], real_id[256];
find_field(test->conn_rwsplit, "SELECT @@server_id", "@@server_id", maxscale_id);
test->repl->connect();
find_field(test->repl->nodes[3], "SELECT @@server_id", "@@server_id", real_id);
test->add_result(strcmp(maxscale_id, real_id) != 0,
"@@server_id is different: %s != %s",
maxscale_id,
real_id);
test->close_maxscale_connections();
test->stop_maxscale();
test->repl->fix_replication();
test->start_maxscale();
test->tprintf("Check that MaxScale is running ");
test->check_maxscale_alive();
int rval = test->global_result;
delete test;
return rval;
}

View File

@ -1,94 +0,0 @@
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
/**
* Test for the gatekeeper module
*/
const char* training_queries[] =
{
"SELECT * FROM test.t1 WHERE id = 1",
"INSERT INTO test.t1 VALUES (1)",
"UPDATE test.t1 SET id = 2 WHERE id = 1",
NULL
};
const char* allowed_queries[] =
{
"SELECT * FROM test.t1 WHERE id = 1",
"SELECT * FROM test.t1 WHERE id = 2",
"SELECT * FROM test.t1 WHERE id = 102",
"INSERT INTO test.t1 VALUES (1)",
"INSERT INTO test.t1 VALUES (124)",
"INSERT INTO test.t1 VALUES (127419823)",
"UPDATE test.t1 SET id = 4 WHERE id = 1",
"UPDATE test.t1 SET id = 3 WHERE id = 2",
"UPDATE test.t1 SET id = 2 WHERE id = 3",
"UPDATE test.t1 SET id = 1 WHERE id = 4",
" UPDATE test.t1 SET id = 1 WHERE id = 4 ",
NULL
};
const char* denied_queries[] =
{
"SELECT * FROM test.t1 WHERE id = 1 OR 1=1",
"INSERT INTO test.t1 VALUES (1), ('This is not a number')",
"UPDATE test.t1 SET id = 2 WHERE id = 1 OR id > 0",
NULL
};
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->maxscales->ssh_node_f(0, true, "rm -f /var/lib/maxscale/gatekeeper.data");
Test->set_timeout(30);
Test->maxscales->connect_rwsplit(0);
Test->try_query(Test->maxscales->conn_rwsplit[0], "CREATE OR REPLACE TABLE test.t1 (id INT)");
for (int i = 0; training_queries[i]; i++)
{
Test->try_query(Test->maxscales->conn_rwsplit[0], training_queries[i]);
}
Test->maxscales->close_rwsplit(0);
Test->maxscales->ssh_node_f(0, true, "sed -i -e 's/mode=learn/mode=enforce/' /etc/maxscale.cnf");
Test->maxscales->restart_maxscale(0);
sleep(5);
Test->maxscales->connect_rwsplit(0);
for (int i = 0; training_queries[i]; i++)
{
Test->set_timeout(30);
Test->add_result(execute_query(Test->maxscales->conn_rwsplit[0], training_queries[i]),
"Query should not fail: %s",
training_queries[i]);
}
for (int i = 0; allowed_queries[i]; i++)
{
Test->set_timeout(30);
Test->add_result(execute_query(Test->maxscales->conn_rwsplit[0], allowed_queries[i]),
"Query should not fail: %s",
allowed_queries[i]);
}
for (int i = 0; denied_queries[i]; i++)
{
Test->set_timeout(30);
Test->add_result(execute_query(Test->maxscales->conn_rwsplit[0], denied_queries[i]) == 0,
"Query should fail: %s",
denied_queries[i]);
}
Test->maxscales->ssh_node_f(0, true, "rm -f /var/lib/maxscale/gatekeeper.data");
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,28 +0,0 @@
#include <iostream>
#include "testconnections.h"
#include "sql_t1.h"
using namespace std;
int main(int argc, char* argv[])
{
char sql[1000000];
create_insert_string(sql, 16, 0);
printf("%s\n", sql);
create_insert_string(sql, 256, 1);
printf("%s\n", sql);
create_insert_string(sql, 4096, 2);
printf("%s\n", sql);
create_insert_string(sql, 65536, 3);
printf("%s\n", sql);
exit(0);
}

View File

@ -1,29 +0,0 @@
/**
* Check that the OK packet flags are read correctly
*/
#include "testconnections.h"
#include <sstream>
int main(int argc, char* argv[])
{
TestConnections test(argc, argv);
test.set_timeout(30);
test.connect_maxscale();
test.try_query(test.conn_rwsplit, "CREATE OR REPLACE TABLE test.t1(id int)");
std::stringstream ss;
ss << "INSERT INTO test.t1 VALUES (0)";
for (int i = 0; i < 2299; i++)
{
ss << ",(" << i << ")";
}
test.try_query(test.conn_rwsplit, ss.str().c_str());
test.try_query(test.conn_rwsplit, "DROP TABLE test.t1");
test.close_maxscale_connections();
return test.global_result;
}

View File

@ -1,115 +0,0 @@
/**
* @file load_balancing_galera.cpp Checks how Maxscale balances load
*
* - also used for 'load_balancing_galera_pers1' and 'load_balancing_galera_pers10' tests (with
*'persistpoolmax=1' and 'persistpoolmax=10' for all servers)
*
* - start two groups of threads: each group consists of 25 threads, each thread creates connections to
* RWSplit,
* threads from first group try to execute as many SELECTs as possible, from second group - one query per
* second
* - after 100 seconds all threads are stopped
* - check number of connections to every slave: test PASSED if COM_SELECT difference between slaves is not
* greater then 3 times and no
* more then 10% of quesries went to Master
*/
#include "testconnections.h"
#include "sql_t1.h"
#include "get_com_select_insert.h"
#include "big_load.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
int master;
long int q;
int threads_num = 25;
long int selects[256];
long int inserts[256];
long int new_selects[256];
long int new_inserts[256];
long int i1, i2;
Test->set_timeout(20);
master = Test->maxscales->find_master_maxadmin(Test->galera);
if (master >= 0)
{
Test->tprintf("Master node is %d (server%d)\n", master, master + 1);
Test->set_timeout(20);
if (Test->smoke)
{
threads_num = 15;
}
Test->galera->connect();
for (int i = 0; i < Test->galera->N; i++)
{
execute_query(Test->galera->nodes[i], (char*) "set global max_connections = 300;");
execute_query(Test->galera->nodes[i], (char*) "set global max_connect_errors = 100000;");
}
Test->galera->close_connections();
Test->set_timeout(1200);
load(&new_inserts[0],
&new_selects[0],
&selects[0],
&inserts[0],
threads_num,
Test,
&i1,
&i2,
1,
true,
true);
long int avr = (i1 + i2 ) / (Test->galera->N);
Test->tprintf("average number of quries per node %ld\n", avr);
long int min_q = avr / 3;
long int max_q = avr * 3;
Test->tprintf("Acceplable value for every node from %ld until %ld\n", min_q, max_q);
for (int i = 0; i < Test->galera->N; i++)
{
if (i != master)
{
q = new_selects[i] - selects[i];
if ((q > max_q) || (q < min_q))
{
Test->add_result(1, "number of queries for node %d is %ld\n", i + 1, q);
}
}
}
if ((new_selects[master] - selects[master]) > avr / 3)
{
Test->add_result(1,
"number of queries for master greater then 30%% of averange number of queries per node\n");
}
Test->tprintf("Restoring nodes\n");
Test->galera->connect();
for (int i = 0; i < Test->galera->N; i++)
{
execute_query(Test->galera->nodes[i], (char*) "flush hosts;");
execute_query(Test->galera->nodes[i], (char*) "set global max_connections = 151;");
}
Test->galera->close_connections();
Test->check_maxscale_alive(0);
}
else
{
Test->add_result(1, "Master is not found\n");
}
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,81 +0,0 @@
/**
* @file maxinfo.cpp maxinfo JSON listener test
* - sends 1000 'status' request to the listener
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
#include <stdio.h>
#include <string.h>
#include "maxinfo_func.h"
using namespace std;
// const int N = 9;
// const char * resources[N] = {"variables", "status", "services", "listeners", "modules", "sessions",
// "clients", "servers", "eventTimes"};
const int N = 8;
const char* resources[N] =
{"variables", "status", "services", "listeners", "modules", "sessions", "clients", "servers"};
bool exit_flag = false;
void* maxinfo_thread(void* ptr);
int threads_num = 25;
TestConnections* Test;
int main(int argc, char* argv[])
{
Test = new TestConnections(argc, argv);
int sleep_time = Test->smoke ? 30 : 1000;
Test->set_timeout(sleep_time + 100);
pthread_t thread1[threads_num];
int iret1[threads_num];
int i;
for (i = 0; i < threads_num; i++)
{
iret1[i] = pthread_create(&thread1[i], NULL, maxinfo_thread, NULL);
}
sleep(sleep_time);
exit_flag = true;
Test->set_timeout(120);
for (i = 0; i < threads_num; i++)
{
pthread_join(thread1[i], NULL);
}
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}
void* maxinfo_thread(void* ptr)
{
char* result;
int ind;
while (!exit_flag)
{
ind = rand() % N;
result = get_maxinfo(resources[ind], Test);
if (result != NULL)
{
Test->tprintf("Query %s, result: \n%s\n", resources[ind], result);
free(result);
}
else
{
Test->add_result(1, "Can't get result from maxinfo, query %s\n", resources[ind]);
}
}
}

View File

@ -1,257 +0,0 @@
/**
* @file mxs1073_binlog_enc.cpp Test binlog router setup with binlogs encryption
* - configure binlog router with follwoing options
* @verbatim
* encrypt_binlog=1,encryption_key_file=/etc/mariadb_binlog_keys.txt,encryption_algorithm=aes_cbc
* @endverbatim
* - put some date to Master
* - check that all slave have the same data
* - 'maxbinlogcheck' against Maxscale binlog file
* - check 'maxbinlogcheck' output for lack of errors and presence of 'Decrypting binlog file with algorithm'
* message
* - try remote access to Maxscale binlog with 'mysqlbinlog'
* - copy Maxscale binlogs to Master and check output of 'show binary logs' before and after copying
* (expect same file name and size, but different checksums)
*/
#include <iostream>
#include <stdio.h>
#include "testconnections.h"
#include "test_binlog_fnc.h"
/**
* @brief get_first_binlog_file Get name, size and checksum of first binlog file from 'show binary logs'
* output list
* @param Test TestConnections object
* @param name string for file name
* @param size variable for file size
* @param checksum Pointer to checksum string
* @return 0 in case of success
*/
int get_first_binlog_file(TestConnections* Test, char* name, long long unsigned* size, char** checksum)
{
char size_str[64];
char cmd[256];
int res = 0;
int exit_code;
res = find_field(Test->repl->nodes[0], (char*) "SHOW BINARY LOGS", (char*) "Log_name", name);
res += find_field(Test->repl->nodes[0], (char*) "SHOW BINARY LOGS", (char*) "File_size", size_str);
sscanf(size_str, "%llu", size);
sprintf(cmd, "sha1sum /var/lib/mysql/%s | cut -f 1 -d \" \"", name);
*checksum = Test->repl->ssh_node_output(0, cmd, true, &exit_code);
if (exit_code != 0)
{
res++;
}
Test->tprintf("First master binlog file:\nname: '%s'\nsize: %llu\nchecksum: %s\n",
name,
*size,
*checksum
);
return res;
}
int main(int argc, char* argv[])
{
printf("ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!\n"
"ERROR! ERROR!\n"
"ERROR! This test require file key management plugin! ERROR!\n"
"ERROR! ERROR!\n"
"ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!ERROR!\n");
return 1;
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(1000);
char str1[1024];
char str2[1024];
char* alg;
char* alg1 = (char*) "aes_cbc";
char* alg2 = (char*) "aes_ctr";
Test->tprintf("%s %s\n", Test->test_name, argv[1]);
if (strcmp(Test->test_name, "mxs1073_binlog_enc_aes_ctr") == 0)
{
alg = alg2;
}
else
{
alg = alg1;
}
int i;
Test->repl->connect();
Test->try_query(Test->repl->nodes[0], (char*) "DROP TABLE IF EXISTS t1");
Test->tprintf("Coping encription config .cnf files to all nodes \n");
sprintf(str1, "%s/binlog_enc_%s.cnf", Test->test_dir, alg);
sprintf(str2, "%s/mariadb_binlog_keys.txt", Test->test_dir);
for (i = 0; i < Test->repl->N; i++)
{
Test->repl->copy_to_node(str1, (char*) "~/", i);
Test->repl->ssh_node(i, (char*) "cp ~/binlog_enc*.cnf /etc/my.cnf.d/", true);
Test->repl->copy_to_node(str2, (char*) "~/", i);
Test->repl->ssh_node(i, (char*) "cp ~/mariadb_binlog_keys.txt /etc/", true);
}
Test->maxscales->copy_to_node(str2, (char*) "~/", 0);
Test->maxscales->ssh_node_f(0, true, "cp ~/mariadb_binlog_keys.txt /etc/");
Test->start_binlog();
Test->repl->connect();
Test->tprintf("Put some data to DB\n");
Test->set_timeout(100);
create_t1(Test->repl->nodes[0]);
Test->add_result(insert_into_t1(Test->repl->nodes[0], 4), "Data inserting to t1 failed\n");
Test->stop_timeout();
Test->tprintf("Sleeping to let replication happen\n");
sleep(60);
for (i = 0; i < Test->repl->N; i++)
{
Test->tprintf("Checking data from node %d (%s)\n", i, Test->repl->IP[i]);
Test->set_timeout(100);
Test->add_result(select_from_t1(Test->repl->nodes[i], 4), "Selecting from t1 failed\n");
Test->stop_timeout();
}
Test->tprintf("Flush logs\n");
execute_query(Test->repl->nodes[0], (char*) "FLUSH LOGS");
Test->tprintf("Running 'maxbinlogcheck' against Maxscale binlog file\n");
char* maxscale_binlogcheck_output = Test->maxscales->ssh_node_f(0,
true,
"maxbinlogcheck -M -K /etc/mariadb_binlog_keys.txt -H /var/lib/maxscale/Binlog_Service/mar-bin.000001 --aes_algo=%s 2> 1",
alg);
// puts(maxscale_binlogcheck_output);
if (strstr(maxscale_binlogcheck_output, "error") != NULL)
{
Test->add_result(1, "Errors in the maxbinlogcheck output:\n%s\n", maxscale_binlogcheck_output);
}
sprintf(str1, "Decrypting binlog file with algorithm: %s", alg);
if (strstr(maxscale_binlogcheck_output, str1) == NULL)
{
Test->add_result(1, "No '%s' in the maxbinlogcheck output:\n%s\n", str1, maxscale_binlogcheck_output);
}
sprintf(str1,
"mysqlbinlog -R -h %s -P %d -u%s -p%s mar-bin.000001 --stop-position=60000",
Test->maxscales->IP[0],
Test->maxscales->binlog_port[0],
Test->maxscales->user_name,
Test->maxscales->password);
Test->tprintf("running mysqlbinlog on node_000 to connecto Maxscale: %s\n", str1);
int exit_code;
char* mysql_binlog_connect_output = Test->repl->ssh_node_output(0, str1, false, &exit_code);
Test->add_result(exit_code, "Remote access to Maxscale binlog failed");
sprintf(str1, "LOGS/%s/mysql_binlog_connect_output", Test->test_name);
FILE* f = fopen(str1, "wt");
fprintf(f, "%s", mysql_binlog_connect_output);
fclose(f);
Test->tprintf("Checking binlog files on master\n");
long long unsigned size_before;
long long unsigned size_after;
long long unsigned size_after_restart;
char* checksum_before;
char* checksum_after;
char* checksum_after_restart;
char name_before[256];
char name_after[256];
char name_after_restart[256];
Test->add_result(get_first_binlog_file(Test, name_before, &size_before, &checksum_before),
"Error getting binlog name and size\n");
Test->tprintf("Copying binlogs from Maxscale to Master\n");
system("rm -rf binlogs");
system("mkdir binlogs");
Test->maxscales->copy_from_node((char*) "/var/lib/maxscale/Binlog_Service/*", (char*) "binlogs/", 0);
Test->repl->ssh_node(0, "rm -rf binlogs", true);
Test->repl->copy_to_node("-r binlogs", "./", 0);
Test->repl->ssh_node(0, "chown mysql:mysql binlogs/*", true);
// Test->repl->ssh_node(0, "rm /var/lib/mysql/mar-bin*", true);
Test->repl->ssh_node(0, "cp binlogs/* /var/lib/mysql/", true);
sleep(5);
Test->tprintf("Checking binlog files on master after copying binlogs from Maxscale\n");
Test->add_result(get_first_binlog_file(Test, name_after, &size_after, &checksum_after),
"Error getting binlog name and size\n");
Test->repl->close_connections();
if (size_before != size_after)
{
Test->add_result(1,
"Master binlog file size after copying Maxscale binlogs to Master is different\n");
}
if (strcmp(name_before, name_after) != 0)
{
Test->add_result(1,
"Master binlog file name after copying Maxscale binlogs to Master is different\n");
}
if (strcmp(checksum_before, checksum_after) == 0)
{
Test->add_result(1,
"Master binlog file checksum after copying Maxscale binlogs to Master is the same. Probably binlog copying error different\n");
}
Test->repl->stop_node(0);
Test->repl->start_node(0, (char*) "");
sleep(5);
Test->tprintf("Checking binlog files on master after copying binlogs from Maxscale and Master restart\n");
Test->repl->connect();
Test->add_result(get_first_binlog_file(Test,
name_after_restart,
&size_after_restart,
&checksum_after_restart),
"Error getting binlog name and size\n");
Test->repl->close_connections();
if (size_before != size_after_restart)
{
Test->add_result(1,
"Master binlog file size after copying Maxscale binlogs to Master and restart is different\n");
}
if (strcmp(name_before, name_after_restart) != 0)
{
Test->add_result(1,
"Master binlog file name after copying Maxscale binlogs to Master and restart is different\n");
}
if (strcmp(checksum_after_restart, checksum_after) != 0)
{
Test->add_result(1, "Master binlog file checksum after Master restart is different\n");
}
// clean up
Test->tprintf("Cleaning up nodes and restart replication\n");
Test->repl->stop_nodes();
for (i = 0; i < Test->repl->N; i++)
{
Test->repl->ssh_node(i, (char*) "rm /etc/my.cnf.d/binlog_enc*.cnf", true);
Test->repl->ssh_node(i, (char*) "rm /etc/mariadb_binlog_keys.txt", true);
}
Test->repl->start_replication();
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,37 +0,0 @@
/**
* @file mxs419_lots_of_connections.cpp ("Socket creation failed due 24, Too many open files")
* Trying to create 500 connections to every router
* checks Maxscale is alive
*/
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
int connections = 500;
Test->set_timeout(30);
Test->tprintf("set global max_connections = 2000");
Test->maxscales->connect_maxscale(0);
Test->try_query(Test->maxscales->conn_rwsplit[0], (char*) "set global max_connections = 2000;\n");
Test->maxscales->close_maxscale_connections(0);
Test->tprintf("Trying %d connections\n", connections);
Test->add_result(Test->create_connections(connections, true, true, true, false),
"Error creating connections\n");
Test->set_timeout(30);
Test->tprintf("set global max_connections = 100");
Test->maxscales->connect_maxscale(0);
Test->try_query(Test->maxscales->conn_rwsplit[0], (char*) "set global max_connections = 100;\n");
Test->maxscales->close_maxscale_connections(0);
Test->tprintf("Checking if Maxscale alive\n");
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,76 +0,0 @@
/**
* @file mxs501_tee_usedb.cpp mxs501 regression case ("USE <db> hangs when Tee filter uses matching")
* @verbatim
* [RW Split Router]
* type=service
* router= readwritesplit
* servers=server1, server2, server3,server4
* user=skysql
* passwd=skysql
* router_options=slave_selection_criteria=LEAST_ROUTER_CONNECTIONS
* max_slave_connections=1
* filters=QLA,duplicate
*
* [duplicate]
* type=filter
* module=tee
* match=insert
* service=Connection Router Master
*
*
* [Read Connection Router Slave]
* type=service
* router=readconnroute
* router_options= slave
* servers=server1,server2,server3,server4
* user=skysql
* passwd=skysql
* filters=QLA
*
* [Read Connection Router Master]
* type=service
* router=readconnroute
* router_options=master
* servers=server1,server2,server3,server4
* user=skysql
* passwd=skysql
* filters=QLA
* @endverbatim
*
* try USE test command against all maxscales->routers[0]
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->maxscales->connect_maxscale(0);
Test->set_timeout(10);
Test->tprintf("Trying USE db against RWSplit\n");
Test->try_query(Test->maxscales->conn_rwsplit[0], (char*) "USE mysql");
Test->try_query(Test->maxscales->conn_rwsplit[0], (char*) "USE test");
Test->set_timeout(10);
Test->tprintf("Trying USE db against ReadConn master\n");
Test->try_query(Test->maxscales->conn_master[0], (char*) "USE mysql");
Test->try_query(Test->maxscales->conn_master[0], (char*) "USE test");
Test->set_timeout(10);
Test->tprintf("Trying USE db against ReadConn slave\n");
Test->try_query(Test->maxscales->conn_master[0], (char*) "USE mysql");
Test->try_query(Test->maxscales->conn_slave[0], (char*) "USE test");
Test->set_timeout(10);
Test->maxscales->close_maxscale_connections(0);
Test->check_maxscale_alive(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,67 +0,0 @@
/**
* @file mxs652_bad_ssl.cpp mxs652 regression case ("ssl is configured in a wrong way, but Maxscale can be
* started and works")
*
* - Maxscale.cnf contains ssl configuration for all services in 'router' section instead of 'listener' with
*'ssl=require'
* - trying to connect to all maxscales->routers[0] without ssl and expect error
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->check_log_err(0, (char*) "Unexpected parameter 'ssl_version'", true);
Test->tprintf("Trying RWSplit, expecting fault\n");
MYSQL* conn = open_conn(Test->maxscales->rwsplit_port[0],
Test->maxscales->IP[0],
Test->maxscales->user_name,
Test->maxscales->password,
false);
if (mysql_errno(conn) == 0)
{
Test->add_result(1, "Configurations is wrong, but connection to RWSplit is ok\n");
mysql_close(conn);
}
Test->tprintf("Trying ReadConn master, expecting fault\n");
conn = open_conn(Test->maxscales->readconn_master_port[0],
Test->maxscales->IP[0],
Test->maxscales->user_name,
Test->maxscales->password,
false);
if (mysql_errno(conn) == 0)
{
Test->add_result(1, "Configurations is wrong, but connection to ReadConn master is ok\n");
mysql_close(conn);
}
Test->tprintf("Trying ReadConn slave, expecting fault\n");
conn = open_conn(Test->maxscales->readconn_slave_port[0][0],
Test->maxscales->IP[0],
Test->maxscales->user_name,
Test->maxscales->password,
false);
if (mysql_errno(conn) == 0)
{
Test->add_result(1, "Configurations is wrong, but connection to ReadConn slave is ok\n");
mysql_close(conn);
}
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,25 +0,0 @@
/**
* @file mxs710_bad_socket.cpp mxs710_bad_socket regression case (Maxscale does not startup properly and
* crashes after trying to login to database)
* - try to start maxscale with "socket=/var/lib/mysqld/mysql.sock" in the listener definition
* - do not expect crash
* - try the same with two listers for one service, one of them uses unreachable port
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->check_maxscale_processes(0);
Test->check_log_err(0, "Fatal", false);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,27 +0,0 @@
/**
* @file max720_line_with_no_equal.cpp mxs720 regression case - first part: line without "=", second - weird
* lines ("MaxScale fails to start and doesn't log any useful message when there are spurious characters in
* the config file")
*
* - use incorrect maxscale.cnf
* - check log for error
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(30);
Test->check_log_err(0, (char*) "Failed to pre-parse configuration file", true);
Test->check_maxscale_processes(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,27 +0,0 @@
/**
* @file max720_wierd_line.cpp mxs720 regression case - second part: weird lines ("MaxScale fails to start
* and doesn't log any useful message when there are spurious characters in the config file")
*
* - use incorrect maxscale.cnf
* - check log for error
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h"
using namespace std;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(30);
Test->check_log_err(0, (char*) "Unexpected parameter 'укпоукц'", true);
Test->check_log_err(0, (char*) "Unexpected parameter 'hren'", true);
Test->check_maxscale_processes(0);
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,112 +0,0 @@
/**
* MySQL Monitor crash safety test
*
* - Start MaxScale
* - Kill slaves to trigger stale master status
* - Kill MaxScale process and restart MaxScale
* - Expect stale master status to still exist for the master
*/
#include "testconnections.h"
void check_master(TestConnections& test)
{
test.add_result(test.find_master_maxadmin(test.repl) != 0, "Node 0 is not the master");
test.maxscales->connect_maxscale(0);
test.try_query(test.maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
test.maxscales->close_maxscale_connections(0);
}
void check_slave(TestConnections& test)
{
test.add_result(test.find_slave_maxadmin(test.repl) == -1, "No slaves found");
test.maxscales->connect_maxscale(0);
test.try_query(test.maxscales->conn_rwsplit[0], "SELECT * FROM test.t1");
test.maxscales->close_maxscale_connections(0);
}
void kill_maxscale(TestConnections& test)
{
test.tprintf("Killing and restarting MaxScale");
test.maxscales->ssh_node_f(0, true, "pkill -9 maxscale");
test.maxscales->start_maxscale(0);
test.tprintf("Waiting for MaxScale to start");
sleep(10);
}
void restart_maxscale(TestConnections& test)
{
test.maxscales->restart_maxscale(0);
test.tprintf("Waiting for MaxScale to start");
sleep(10);
}
int main(int argc, char** argv)
{
TestConnections test(argc, argv);
test.maxscales->connect_maxscale(0);
test.try_query(test.maxscales->conn_rwsplit[0], "CREATE OR REPLACE TABLE test.t1(id int)");
test.maxscales->close_maxscale_connections(0);
test.tprintf("Checking that node 0 is the master and slaves are OK");
check_master(test);
check_slave(test);
test.tprintf("Blocking slaves to trigger stale master status");
test.repl->block_node(1);
test.repl->block_node(2);
test.repl->block_node(3);
sleep(10);
test.tprintf("Checking that master has stale status");
check_master(test);
kill_maxscale(test);
test.tprintf("Checking that master still has stale status");
check_master(test);
restart_maxscale(test);
test.tprintf("Checking that master has stale status after restart");
check_master(test);
test.repl->unblock_node(1);
test.repl->unblock_node(2);
test.repl->unblock_node(3);
sleep(10);
test.tprintf("Checking that node 0 is the master and slaves are OK");
check_master(test);
check_slave(test);
test.tprintf("Blocking master to trigger stale slave status");
test.repl->block_node(0);
sleep(10);
test.tprintf("Checking that slaves have stale status");
check_slave(test);
kill_maxscale(test);
test.tprintf("Checking that slaves still have stale status");
check_slave(test);
restart_maxscale(test);
test.tprintf("Checking that slaves have stale status after restart");
check_slave(test);
test.repl->unblock_node(0);
sleep(10);
test.tprintf("Checking that node 0 is the master and slaves are OK");
check_master(test);
check_slave(test);
return test.global_result;
}

View File

@ -1,62 +0,0 @@
/**
* @file rw_galera_select_insert.cpp NOT IMPLEMENTET YET
*
*/
#include "testconnections.h"
#include "get_com_select_insert.h"
#include "maxadmin_operations.h"
long int selects[256];
long int inserts[256];
long int new_selects[256];
long int new_inserts[256];
int silent = 0;
int tolerance;
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->set_timeout(30);
Test->galera->connect();
tolerance = 0;
// connect to the MaxScale server (rwsplit)
Test->maxscales->connect_rwsplit(0);
Test->maxscales->execute_maxadmin_command(0, (char*) "shutdown monitor \"Galera Monitor\"");
if (Test->maxscales->conn_rwsplit[0] == NULL)
{
Test->add_result(1, "Can't connect to MaxScale\n");
int rval = Test->global_result;
delete Test;
exit(1);
}
else
{
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP TABLE IF EXISTS t1;");
Test->try_query(Test->maxscales->conn_rwsplit[0], "create table t1 (x1 int);");
get_global_status_allnodes(&selects[0], &inserts[0], Test->galera, silent);
Test->try_query(Test->maxscales->conn_rwsplit[0], "select * from t1;");
get_global_status_allnodes(&new_selects[0], &new_inserts[0], Test->galera, silent);
print_delta(&new_selects[0], &new_inserts[0], &selects[0], &inserts[0], Test->galera->N);
Test->try_query(Test->maxscales->conn_rwsplit[0], "insert into t1 values(1);");
get_global_status_allnodes(&new_selects[0], &new_inserts[0], Test->galera, silent);
print_delta(&new_selects[0], &new_inserts[0], &selects[0], &inserts[0], Test->galera->N);
// close connections
Test->maxscales->close_rwsplit(0);
}
Test->galera->close_connections();
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,45 +0,0 @@
/**
* @file setup_binlog test of simple binlog router setup
* setup one master, one slave directly connected to real master and two slaves connected to binlog router
* create table and put data into it using connection to master
* check data using direct commection to all backend
*/
#include <iostream>
#include "testconnections.h"
#include "maxadmin_operations.h"
#include "sql_t1.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
if (!Test->smoke)
{
Test->set_timeout(1000);
Test->binlog_cmd_option = 1;
Test->start_binlog();
Test->repl->connect();
create_t1(Test->repl->nodes[0]);
Test->add_result(insert_into_t1(Test->repl->nodes[0], 4), "error inserting data into t1\n");
Test->tprintf("Sleeping to let replication happen\n");
sleep(30);
for (int i = 0; i < Test->repl->N; i++)
{
Test->tprintf("Checking data from node %d (%s)\n", i, Test->repl->IP[i]);
Test->add_result(select_from_t1(Test->repl->nodes[i], 4), "error SELECT for t1\n");
}
Test->repl->close_connections();
}
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,42 +0,0 @@
/**
* @file setup_binlog test of simple binlog router setup
* setup one master, one slave directly connected to real master and two slaves connected to binlog router
* create table and put data into it using connection to master
* check data using direct commection to all backend
*/
#include <iostream>
#include "testconnections.h"
#include "maxadmin_operations.h"
#include "sql_t1.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
if (!Test->smoke)
{
Test->binlog_cmd_option = 2;
Test->start_binlog();
Test->repl->connect();
create_t1(Test->repl->nodes[0]);
Test->add_result(insert_into_t1(Test->repl->nodes[0], 4), "error inserting data into t1\n");
Test->tprintf("Sleeping to let replication happen\n");
sleep(30);
for (int i = 0; i < Test->repl->N; i++)
{
Test->tprintf("Checking data from node %d (%s)\n", i, Test->repl->IP[i]);
Test->add_result(select_from_t1(Test->repl->nodes[i], 4), "error SELECT for t1\n");
}
Test->repl->close_connections();
}
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,225 +0,0 @@
/**
* @file server_lag.cpp Create high INSERT load to create slave lag and check that Maxscale start routing
* queries to Master
*
* - in Maxscqale.cnf set max_slave_replication_lag=20
* - in parallel thread execute as many INSERTs as possible
* - using "select @@server_id;" check that queries go to one of the slave
* - wait when slave lag > 20 (control lag using maxadmin interface)
* - check that now queries go to Master
*/
#include "testconnections.h"
#include "sql_t1.h"
#include "maxadmin_operations.h"
char sql[1000000];
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int exit_flag = 0;
int exited = 0;
void* query_thread(void* ptr);
void* checks_thread(void* ptr);
TestConnections* Test;
int check_lag(int* min_lag)
{
char result[1024];
char server_id[1024];
char ma_cmd[256];
int res_d;
int server1_id_d;
int server_id_d;
int i;
int ret = 0;
*min_lag = 0;
for (i = 1; i < Test->repl->N; i++)
{
sprintf(ma_cmd, "show server server%d", i + 1);
maxscales->get_maxadmin_param(0,
Test->maxscales->IP[0],
(char*) "admin",
Test->maxscales->maxadmin_password[0],
ma_cmd,
(char*) "Slave delay:",
result);
sscanf(result, "%d", &res_d);
Test->tprintf("server%d lag: %d\n", i + 1, res_d);
if (i == 1)
{
*min_lag = res_d;
}
if (*min_lag > res_d)
{
*min_lag = res_d;
}
}
Test->tprintf("Minimum lag: %d\n", *min_lag);
Test->maxscales->connect_rwsplit(0);
find_field(Test->maxscales->conn_rwsplit[0],
(char*) "select @@server_id; -- maxscale max_slave_replication_lag=20",
(char*) "@@server_id",
&server_id[0]);
Test->maxscales->close_rwsplit(0);
sscanf(server_id, "%d", &server_id_d);
Test->tprintf("Connected to the server with server_id %d\n", server_id_d);
if ((server1_id_d == server_id_d))
{
Test->add_result(1, "Connected to the master!\n");
ret = 0;
}
else
{
Test->tprintf("Connected to slave\n");
ret = 1;
}
return ret;
}
int main(int argc, char* argv[])
{
char server1_id[1024];
int server1_id_d;
int i;
int min_lag = 0;
int ms;
Test = new TestConnections(argc, argv);
Test->set_timeout(2000);
Test->repl->connect();
Test->maxscales->connect_rwsplit(0);
// connect to the MaxScale server (rwsplit)
if (Test->maxscales->conn_rwsplit[0] == NULL)
{
printf("Can't connect to MaxScale\n");
int rval = Test->global_result;
delete Test;
exit(1);
}
else
{
for (i = 0; i < Test->repl->N; i++)
{
Test->tprintf("set max_connections = 200 for node %d\n", i);
execute_query(Test->repl->nodes[i], (char*) "set global max_connections = 200;");
}
create_t1(Test->maxscales->conn_rwsplit[0]);
create_t2(Test->maxscales->conn_rwsplit[0]);
create_insert_string(sql, 50000, 1);
Test->tprintf("sql_len=%lu\n", strlen(sql));
/* for ( i = 0; i < 100; i++) {
* Test->try_query(Test->maxscales->conn_rwsplit[0], sql);
* }*/
pthread_t threads[1000];
// pthread_t check_thread;
int iret[1000];
// int check_iret;
int j;
exit_flag = 0;
/* Create independent threads each of them will execute function */
for (j = 0; j < 100; j++)
{
iret[j] = pthread_create(&threads[j], NULL, query_thread, &sql);
}
execute_query(Test->maxscales->conn_rwsplit[0],
(char*) "select @@server_id; -- maxscale max_slave_replication_lag=10");
find_field(Test->repl->nodes[0],
(char*) "select @@server_id;",
(char*) "@@server_id",
&server1_id[0]);
sscanf(server1_id, "%d", &server1_id_d);
Test->tprintf("Master server_id: %d\n", server1_id_d);
Test->maxscales->close_rwsplit(0);
for (i = 0; i < 1000; i++)
{
ms = check_lag(&min_lag);
if ((ms = 0) && (min_lag < 20))
{
Test->add_result(1, "Lag is small, but connected to master\n");
}
if ((ms = 1) && (min_lag > 20))
{
Test->add_result(1, "Lag is big, but connected to slave\n");
}
}
exit_flag = 1;
}
while (exited == 0)
{
Test->tprintf("Waiting for load thread end\n");
sleep(5);
}
Test->repl->close_connections();
Test->repl->start_replication();
int rval = Test->global_result;
delete Test;
return rval;
}
void* query_thread(void* ptr)
{
MYSQL* conn;
conn = open_conn(Test->repl->port[0],
Test->repl->IP[0],
Test->repl->user_name,
Test->repl->password,
Test->repl->ssl);
while (exit_flag == 0)
{
// execute_query(conn, (char *) "INSERT INTO t2 (x1, fl) SELECT x1,fl FROM t1");
execute_query_silent(conn, (char*) ptr);
}
exited = 1;
return NULL;
}
void* checks_thread(void* ptr)
{
char result[1024];
for (int i = 0; i < 1000; i++)
{
maxscales->get_maxadmin_param(0,
Test->maxscales->IP[0],
(char*) "admin",
Test->maxscales->maxadmin_password[0],
(char*) "show server server2",
(char*) "Slave delay:",
result);
printf("server2: %s\n", result);
maxscales->get_maxadmin_param(0,
Test->maxscales->IP[0],
(char*) "admin",
Test->maxscales->maxadmin_password[0],
(char*) "show server server3",
(char*) "Slave delay:",
result);
printf("server3: %s\n", result);
maxscales->get_maxadmin_param(0,
Test->maxscales->IP[0],
(char*) "admin",
Test->maxscales->maxadmin_password[0],
(char*) "show server server4",
(char*) "Slave delay:",
result);
printf("server4: %s\n", result);
}
exit_flag = 1;
return NULL;
}

View File

@ -1,42 +0,0 @@
/**
* Run MaxCtrl test suite on the MaxScale machine
*/
#include "testconnections.h"
int main(int argc, char* argv[])
{
// Use galera_003 as the secondary MaxScale node
TestConnections::set_secondary_maxscale("galera_003_network", "galera_003_network6");
TestConnections test(argc, argv);
// This is not very nice as it's a bit too intrusive
system("envsubst < maxctrl_scripts.sh.in > maxctrl_scripts.sh");
system("chmod +x maxctrl_scripts.sh");
test.copy_to_maxscale("test_maxctrl.sh", "~");
test.copy_to_maxscale("maxctrl_scripts.sh", "~");
test.ssh_maxscale(true, "ssh-keygen -f maxscale_key -P \"\"");
test.copy_from_maxscale((char*)"~/maxscale_key.pub", (char*)".");
test.galera->copy_to_node("./maxscale_key.pub", "~", 3);
test.galera->ssh_node(3,
false,
"cat ~/maxscale_key.pub >> ~/.ssh/authorized_keys;"
"sudo iptables -I INPUT -p tcp --dport 8989 -j ACCEPT;");
// TODO: Don't handle test dependencies in tests
test.tprintf("Installing NPM");
test.ssh_maxscale(true, "yum -y install epel-release;yum -y install npm git;");
test.tprintf("Starting test");
test.verbose = true;
int rv = test.ssh_maxscale(true,
"export maxscale_access_homedir=%s; export maxscale2_API=%s:8989; ./test_maxctrl.sh",
test.maxscale_access_homedir,
test.galera->IP[3]);
test.verbose = false;
test.tprintf("Removing NPM");
test.ssh_maxscale(true, "yum -y remove npm epel-release");
return rv;
}

View File

@ -1,140 +0,0 @@
/**
* @file transaction_test_wo_maxscale.cpp
*/
#include <iostream>
#include "testconnections.h"
#include "maxadmin_operations.h"
#include "sql_t1.h"
int check_sha1(TestConnections* Test)
{
Test->tprintf("ls before FLUSH LOGS\n");
Test->tprintf("Master");
Test->repl->ssh_node(0, (char*) "ls -la /var/lib/mysql/mar-bin.0000*", false);
Test->tprintf("FLUSH LOGS\n");
Test->try_query(Test->repl->nodes[0], (char*) "FLUSH LOGS");
Test->tprintf("Logs flushed\n");
sleep(20);
Test->tprintf("ls after first FLUSH LOGS\n");
Test->tprintf("Master\n");
Test->repl->ssh_node(0, (char*) "ls -la /var/lib/mysql/mar-bin.0000*", false);
Test->tprintf("FLUSH LOGS\n");
Test->try_query(Test->repl->nodes[0], (char*) "FLUSH LOGS");
Test->tprintf("Logs flushed\n");
fflush(stdout);
sleep(19);
printf("ls before FLUSH LOGS\n");
printf("Master");
Test->repl->ssh_node(0, (char*) "ls -la /var/lib/mysql/mar-bin.0000*", false);
return Test->global_result;
}
int start_transaction(TestConnections* Test)
{
int global_result = 0;
Test->tprintf("Transaction test\n");
Test->tprintf("Start transaction\n");
global_result += execute_query(Test->repl->nodes[0], (char*) "START TRANSACTION");
// global_result += execute_query(Test->repl->nodes[0], (char *) "SET autocommit = 0");
Test->tprintf("INSERT data\n");
global_result += execute_query(Test->repl->nodes[0], (char*) "INSERT INTO t1 VALUES(111, 10)");
sleep(20);
return global_result;
}
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
int i;
for (int option = 0; option < 3; option++)
{
Test->repl->connect();
create_t1(Test->repl->nodes[0]);
Test->add_result(insert_into_t1(Test->repl->nodes[0], 4), "INSER into t1 failed\n");
Test->tprintf("Sleeping to let replication happen\n");
sleep(30);
for (i = 0; i < Test->repl->N; i++)
{
Test->tprintf("Checking data from node %d (%s)\n", i, Test->repl->IP[i]);
Test->add_result(select_from_t1(Test->repl->nodes[i], 4), "select form t1 wrong\n");
}
Test->tprintf("First transaction test (with ROLLBACK)\n");
start_transaction(Test);
Test->tprintf("SELECT * FROM t1 WHERE fl=10, checking inserted values\n");
Test->add_result(execute_query_check_one(Test->repl->nodes[0],
(char*) "SELECT * FROM t1 WHERE fl=10",
"111"),
"failed\n");
// printf("SELECT, checking inserted values from slave\n");
// global_result += execute_query_check_one(Test->repl->nodes[2], (char *) "SELECT * FROM t1 WHERE
// fl=10", "111");
Test->add_result(check_sha1(Test), "sha1 wrong\n");
Test->tprintf("ROLLBACK\n");
Test->try_query(Test->repl->nodes[0], (char*) "ROLLBACK");
Test->tprintf("INSERT INTO t1 VALUES(112, 10)\n");
Test->try_query(Test->repl->nodes[0], (char*) "INSERT INTO t1 VALUES(112, 10)");
sleep(20);
Test->tprintf("SELECT * FROM t1 WHERE fl=10, checking inserted values\n");
Test->add_result(execute_query_check_one(Test->repl->nodes[0],
(char*) "SELECT * FROM t1 WHERE fl=10",
"112"),
"failed\n");
Test->tprintf("SELECT * FROM t1 WHERE fl=10, checking inserted values from slave\n");
Test->add_result(execute_query_check_one(Test->repl->nodes[2],
(char*) "SELECT * FROM t1 WHERE fl=10",
"112"),
"failed\n");
Test->tprintf("DELETE FROM t1 WHERE fl=10\n");
Test->try_query(Test->repl->nodes[0], (char*) "DELETE FROM t1 WHERE fl=10");
Test->tprintf("Checking t1\n");
Test->add_result(select_from_t1(Test->repl->nodes[0], 4), "failed\n");
Test->tprintf("Second transaction test (with COMMIT)\n");
start_transaction(Test);
Test->tprintf("COMMIT\n");
Test->try_query(Test->repl->nodes[0], (char*) "COMMIT");
printf("SELECT, checking inserted values\n");
Test->add_result(execute_query_check_one(Test->repl->nodes[0],
(char*) "SELECT * FROM t1 WHERE fl=10",
"111"),
"failed\n");
Test->tprintf("SELECT, checking inserted values from slave\n");
Test->add_result(execute_query_check_one(Test->repl->nodes[2],
(char*) "SELECT * FROM t1 WHERE fl=10",
"111"),
"failed\n");
Test->tprintf("DELETE FROM t1 WHERE fl=10\n");
Test->try_query(Test->repl->nodes[0], (char*) "DELETE FROM t1 WHERE fl=10");
Test->add_result(check_sha1(Test), "sha1 wrong\n");
Test->repl->close_connections();
}
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -1,72 +0,0 @@
/**
* @file user_cache.cpp Test user caching mechanism of MaxScale
*
* - Create 'testuser'@'%' user
* - Start up MaxScale with 'testuser' as the service user
* - Delete 'testuser'@'%'
* - Restart MaxScale
* - Check that queries through MaxScale are OK
*/
#include <iostream>
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections* Test = new TestConnections(argc, argv);
Test->stop_timeout();
Test->maxscales->stop_maxscale(0);
/** Create the test user and give required grants */
Test->tprintf("Creating 'testuser'@'%'\n");
Test->repl->connect();
execute_query_silent(Test->repl->nodes[0], "CREATE USER 'testuser'@'%' IDENTIFIED BY 'testpasswd'");
execute_query_silent(Test->repl->nodes[0], "GRANT SELECT ON mysql.user TO 'testuser'@'%'");
execute_query_silent(Test->repl->nodes[0], "GRANT SELECT ON mysql.db TO 'testuser'@'%'");
execute_query_silent(Test->repl->nodes[0], "GRANT SELECT ON mysql.tables_priv TO 'testuser'@'%'");
execute_query_silent(Test->repl->nodes[0], "GRANT SHOW DATABASES ON *.* TO 'testuser'@'%'");
/** Wait for the user to replicate */
Test->tprintf("Waiting for users to replicate\n");
sleep(10);
/** Test that MaxScale works and initialize the cache */
Test->tprintf("Test that MaxScale works and initialize the cache\n");
Test->maxscales->start_maxscale(0);
Test->maxscales->connect_maxscale(0);
Test->set_timeout(30);
Test->add_result(Test->try_query_all("SHOW DATABASES"), "Initial query without user cache should work\n");
Test->stop_timeout();
/** Block all nodes */
Test->tprintf("Blocking all nodes\n");
for (int i = 0; i < Test->repl->N; i++)
{
Test->repl->block_node(i);
}
/** Restart MaxScale and check that the user cache works */
Test->tprintf("Restarting MaxScale\n");
Test->maxscales->restart_maxscale(0);
sleep(5);
Test->tprintf("Unblocking all nodes\n");
Test->repl->unblock_all_nodes();
sleep(5);
Test->tprintf("Dropping 'testuser'@'%'\n");
execute_query_silent(Test->repl->nodes[0], "DROP USER 'testuser'@'%'");
sleep(5);
Test->tprintf("Checking that the user cache works and queries are accepted\n");
Test->set_timeout(30);
Test->maxscales->connect_maxscale(0);
Test->add_result(Test->try_query_all("SHOW DATABASES"), "Second query with user cache should work\n");
Test->stop_timeout();
int rval = Test->global_result;
delete Test;
return rval;
}

View File

@ -99,10 +99,7 @@ macro(unstable_tests)
endmacro()
# Test utilities
add_test_executable_notest(t.cpp t replication)
add_test_executable_notest(non_native_setup.cpp non_native_setup replication)
add_test_executable_notest(binlog_big_transaction.cpp binlog_big_transaction setup_binlog2)
add_test_executable_notest(avro_long.cpp avro_long avro)
add_test_executable_notest(sysbench_example.cpp sysbench_example replication)
#