refactored tests (#147)
This commit is contained in:
parent
c6daf8c26b
commit
3c88bf1ec6
@ -46,11 +46,11 @@ else()
|
||||
endif()
|
||||
|
||||
# The core library
|
||||
add_library(testcore SHARED testconnections.cpp mariadb_nodes.cpp
|
||||
add_library(testcore SHARED testconnections.cpp nodes.cpp mariadb_nodes.cpp maxscales.cpp
|
||||
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)
|
||||
blob_test.cpp cdc_connector.cpp)
|
||||
target_link_libraries(testcore ${MYSQL_CLIENT} ${CDC_CONNECTOR_LIBRARIES} ${JANSSON_LIBRARIES} z nsl m pthread ssl dl rt crypto crypt)
|
||||
install(TARGETS testcore DESTINATION system-test)
|
||||
add_dependencies(testcore connector-c cdc_connector)
|
||||
@ -121,7 +121,7 @@ add_test_executable(bug547.cpp bug547 replication LABELS readwritesplit REPL_BAC
|
||||
add_test_executable(bug681.cpp bug681 galera.bug681 LABELS readwritesplit GALERA_BACKEND)
|
||||
|
||||
# Regression case for the bug "crash with tee filter"
|
||||
add_test_executable(bug643.cpp bug643 bug643 LABELS tee REPL_BACKEND)
|
||||
#add_test_executable(bug643.cpp bug643 bug643 LABELS tee REPL_BACKEND)
|
||||
|
||||
# Regression case for the bug ""Different error messages from MariaDB and Maxscale"
|
||||
add_test_script(bug561.sh bug561.sh replication LABELS MySQLAuth REPL_BACKEND)
|
||||
@ -166,13 +166,13 @@ add_test_executable(bug626.cpp bug626 replication LABELS MySQLAuth MySQLProtocol
|
||||
add_test_executable(bug634.cpp bug634 replication LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# Regression cases for several TEE filter hangs
|
||||
add_test_executable(bug645.cpp bug645 bug645 LABELS tee REPL_BACKEND)
|
||||
add_test_executable(bug645_1.cpp bug645_1 bug645_1 LABELS tee REPL_BACKEND)
|
||||
add_test_executable(bug649.cpp bug649 bug645 LABELS tee REPL_BACKEND)
|
||||
add_test_executable(bug650.cpp bug650 bug650 LABELS tee REPL_BACKEND)
|
||||
#add_test_executable(bug645.cpp bug645 bug645 LABELS tee REPL_BACKEND)
|
||||
#add_test_executable(bug645_1.cpp bug645_1 bug645_1 LABELS tee REPL_BACKEND)
|
||||
#add_test_executable(bug649.cpp bug649 bug645 LABELS tee)
|
||||
#add_test_executable(bug650.cpp bug650 bug650 LABELS tee REPL_BACKEND)
|
||||
|
||||
# Heavy test for TEE filter
|
||||
add_test_script(bug648 sql_queries bug648 LABELS tee HEAVY REPL_BACKEND)
|
||||
#add_test_script(bug648 sql_queries bug648 LABELS tee UNSTABLE HEAVY REPL_BACKEND)
|
||||
|
||||
# Crash when host name for some user in mysql.user is very long
|
||||
add_test_executable(bug653.cpp bug653 replication LABELS MySQLAuth MySQLProtocol REPL_BACKEND)
|
||||
@ -181,7 +181,7 @@ add_test_executable(bug653.cpp bug653 replication LABELS MySQLAuth MySQLProtocol
|
||||
add_test_executable(bug654.cpp bug654 replication LABELS maxscale REPL_BACKEND)
|
||||
|
||||
# Regression case for the bug "Tee filter: closing child session causes MaxScale to fail"
|
||||
add_test_executable(bug657.cpp bug657 bug657 LABELS tee REPL_BACKEND)
|
||||
#add_test_executable(bug657.cpp bug657 bug657 LABELS tee REPL_BACKEND)
|
||||
|
||||
# Block backends (master or all slaves) and tries to connect Maxscale
|
||||
add_test_executable(bug658.cpp bug658 replication LABELS readwritesplit readconnroute maxscale REPL_BACKEND)
|
||||
@ -193,7 +193,7 @@ add_test_executable(bug662.cpp bug662 bug662 LABELS readwritesplit readconnroute
|
||||
add_test_executable(bug664.cpp bug664 bug664 LABELS MySQLAuth MySQLProtocol)
|
||||
|
||||
# TEE fileter: execute long sequence of queries ans session commands in the loop
|
||||
add_test_executable(bug670.cpp bug670 bug670 LABELS tee REPL_BACKEND)
|
||||
#add_test_executable(bug670.cpp bug670 bug670 LABELS tee REPL_BACKEND)
|
||||
|
||||
# Regression case for the bug "MaxScale crashes if "Users table data" is empty and "show dbusers" is executed in maxadmin"
|
||||
add_test_executable(bug673.cpp bug673 bug673 LABELS MySQLAuth REPL_BACKEND)
|
||||
@ -260,6 +260,7 @@ add_test_executable(false_monitor_state_change.cpp false_monitor_state_change re
|
||||
|
||||
# A set of tests for Firewall filter
|
||||
add_test_executable(fwf.cpp fwf fwf LABELS dbfwfilter REPL_BACKEND)
|
||||
add_test_executable(fwf2.cpp fwf2 fwf LABELS dbfwfilter REPL_BACKEND)
|
||||
add_test_executable(fwf_duplicate_rules.cpp fwf_duplicate_rules fwf LABELS dbfwfilter REPL_BACKEND)
|
||||
add_test_executable(fwf_prepared_stmt.cpp fwf_prepared_stmt fwf LABELS dbfwfilter REPL_BACKEND)
|
||||
add_test_executable(fwf_actions.cpp fwf_actions fwf_action LABELS dbfwfilter REPL_BACKEND)
|
||||
@ -298,9 +299,6 @@ add_test_script(load_balancing_pers10 load_balancing load_pers10 LABELS readwrit
|
||||
# Test with extremely big blob inserting
|
||||
add_test_executable(longblob.cpp longblob longblob LABELS readwritesplit readconnroute UNSTABLE HEAVY REPL_BACKEND)
|
||||
|
||||
# Check that inserts of specific size don't cause a hang
|
||||
add_test_executable(large_insert_hang.cpp large_insert_hang replication LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# Test with extremely big blob inserting/selecting with > 16 mb data blocks
|
||||
add_test_executable(mxs1110_16mb.cpp mxs1110_16mb longblob_filters LABELS readwritesplit readconnroute HEAVY REPL_BACKEND)
|
||||
|
||||
@ -382,7 +380,7 @@ add_test_executable(mxs431.cpp mxs431 sharding LABELS schemarouter REPL_BACKEND
|
||||
add_test_executable(mxs47.cpp mxs47 replication LABELS MySQLProtocol LIGHT REPL_BACKEND)
|
||||
|
||||
# Regression case for the bug "USE <db> hangs when Tee filter uses matching"
|
||||
add_test_executable(mxs501_tee_usedb.cpp mxs501_tee_usedb mxs501 LABELS tee REPL_BACKEND)
|
||||
#add_test_executable(mxs501_tee_usedb.cpp mxs501_tee_usedb mxs501 LABELS tee REPL_BACKEND)
|
||||
|
||||
# Open connection, execute 'change user', close connection in the loop
|
||||
add_test_executable(mxs548_short_session_change_user.cpp mxs548_short_session_change_user mxs548 LABELS MySQLProtocol REPL_BACKEND)
|
||||
@ -393,6 +391,12 @@ add_test_executable(mxs559_block_master.cpp mxs559_block_master mxs559 LABELS re
|
||||
# Playing with blocking and unblocking nodes under INSERT load
|
||||
add_test_executable(mxs564_big_dump.cpp mxs564_big_dump galera_mxs564 LABELS readwritesplit readconnroute GALERA_BACKEND)
|
||||
|
||||
# Executes simple queries from python script in the loop
|
||||
add_test_script(mxs585.py mxs585.py replication LABELS readwritesplit readconnroute UNSTABLE HEAVY REPL_BACKEND)
|
||||
|
||||
# Simple transactions in the loop from python script with client SSL on
|
||||
add_test_script(mxs598.py mxs598.py ssl LABELS MySQLProtocol UNSTABLE HEAVY REPL_BACKEND)
|
||||
|
||||
# Regression case for the bug "MaxScale fails to start silently if config file is not readable"
|
||||
add_test_executable(mxs621_unreadable_cnf.cpp mxs621_unreadable_cnf replication LABELS maxscale REPL_BACKEND)
|
||||
|
||||
@ -516,6 +520,10 @@ add_test_executable(verify_master_failure.cpp verify_master_failure verify_maste
|
||||
# https://jira.mariadb.org/browse/MXS-1476
|
||||
add_test_executable(mxs1476.cpp mxs1476 mxs1476 LABELS GALERA_BACKEND)
|
||||
|
||||
# MXS-1509: Show correct server state for multisource replication
|
||||
# https://jira.mariadb.org/browse/MXS-1509
|
||||
add_test_executable(mxs1509.cpp mxs1509 mxs1509 LABELS REPL_BACKEND)
|
||||
|
||||
# 'namedserverfilter' test
|
||||
add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND)
|
||||
|
||||
@ -578,7 +586,7 @@ add_test_executable(rwsplit_multi_stmt.cpp rwsplit_multi_stmt rwsplit_multi_stmt
|
||||
add_test_executable(rwsplit_read_only_trx.cpp rwsplit_read_only_trx rwsplit_read_only_trx LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# Test replication-manager with MaxScale
|
||||
add_test_executable_notest(replication_manager.cpp replication_manager replication_manager LABELS maxscale REPL_BACKEND)
|
||||
#add_test_executable(replication_manager.cpp replication_manager replication_manager LABELS maxscale REPL_BACKEND)
|
||||
#add_test_executable_notest(replication_manager_2nodes.cpp replication_manager_2nodes replication_manager_2nodes LABELS maxscale REPL_BACKEND)
|
||||
#add_test_executable_notest(replication_manager_3nodes.cpp replication_manager_3nodes replication_manager_3nodes LABELS maxscale REPL_BACKEND)
|
||||
|
||||
@ -652,7 +660,7 @@ add_test_executable(temporal_tables.cpp temporal_tables replication LABELS readw
|
||||
add_test_executable(test_hints.cpp test_hints hints2 LABELS hintfilter LIGHT REPL_BACKEND)
|
||||
|
||||
# Run MaxCtrl test suite
|
||||
add_test_executable(test_maxctrl.cpp test_maxctrl maxctrl LABELS REPL_BACKEND)
|
||||
# add_test_executable(test_maxctrl.cpp test_maxctrl maxctrl LABELS REPL_BACKEND)
|
||||
|
||||
# Binlogrouter tests, these heavily alter the replication so they are run last
|
||||
add_test_executable(avro.cpp avro avro LABELS avrorouter binlogrouter LIGHT BREAKS_REPL)
|
||||
|
@ -41,8 +41,8 @@ int set_endspoints(RDS * cluster)
|
||||
}
|
||||
|
||||
setenv("node_password", "skysqlrds", 1);
|
||||
setenv("maxscale_user", "skysql", 1);
|
||||
setenv("maxscale_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;
|
||||
@ -60,7 +60,7 @@ void compare_masters(TestConnections* Test, RDS * cluster)
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
sprintf(cmd, "show server server%d", i + 1);
|
||||
Test->get_maxadmin_param(cmd, (char *) "Status:", &maxadmin_status[0]);
|
||||
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)
|
||||
@ -115,12 +115,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->tprintf("Executing a query through readwritesplit before failover");
|
||||
Test->connect_rwsplit();
|
||||
Test->try_query(Test->conn_rwsplit, "show processlist");
|
||||
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->conn_rwsplit, "select @@aurora_server_id;", "server_id", &server_id[0]);
|
||||
Test->close_rwsplit();
|
||||
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();
|
||||
@ -135,17 +135,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->tprintf("Executing a query through readwritesplit after failover");
|
||||
Test->connect_rwsplit();
|
||||
Test->try_query(Test->conn_rwsplit, "show processlist");
|
||||
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->conn_rwsplit, "select @@aurora_server_id;", "server_id", &server_id[0]);
|
||||
Test->close_rwsplit();
|
||||
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();
|
||||
//Test->check_maxscale_alive(0);
|
||||
|
||||
|
||||
Test->stop_timeout();
|
||||
|
@ -23,13 +23,13 @@ using std::endl;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
int exit_code;
|
||||
TestConnections test(argc, argv);
|
||||
test.set_timeout(600);
|
||||
test.ssh_maxscale(true, (char *) "rm -rf /var/lib/maxscale/avro");
|
||||
test.maxscales->ssh_node(0, (char *) "rm -rf /var/lib/maxscale/avro", true);
|
||||
|
||||
/** Start master to binlogrouter replication */
|
||||
if (!test.replicate_from_master())
|
||||
if (!test.replicate_from_master(0))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -48,7 +48,9 @@ int main(int argc, char *argv[])
|
||||
sleep(10);
|
||||
test.set_timeout(120);
|
||||
|
||||
char * output = test.ssh_maxscale_output(true, "maxavrocheck -d /var/lib/maxscale/avro/test.t1.000001.avro");
|
||||
char * output = test.maxscales->ssh_node_output(0,
|
||||
"maxavrocheck -d /var/lib/maxscale/avro/test.t1.000001.avro",
|
||||
true, &exit_code);
|
||||
|
||||
std::istringstream iss;
|
||||
iss.str(output);
|
||||
|
@ -9,13 +9,13 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
int exit_code;
|
||||
TestConnections test(argc, argv);
|
||||
test.set_timeout(600);
|
||||
test.ssh_maxscale(true, (char *) "rm -rf /var/lib/maxscale/avro");
|
||||
test.maxscales->ssh_node(0, (char *) "rm -rf /var/lib/maxscale/avro", true);
|
||||
|
||||
/** Start master to binlogrouter replication */
|
||||
if (!test.replicate_from_master())
|
||||
if (!test.replicate_from_master(0))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@ -48,11 +48,11 @@ int main(int argc, char *argv[])
|
||||
sleep(10);
|
||||
test.set_timeout(120);
|
||||
|
||||
for (int i = 1; i <=5; i++)
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
std::stringstream cmd;
|
||||
cmd << "maxavrocheck -d /var/lib/maxscale/avro/test.t1.00000" << i << ".avro";
|
||||
char* rows = test.ssh_maxscale_output(true, cmd.str().c_str());
|
||||
char* rows = test.maxscales->ssh_node_output(0, cmd.str().c_str(), true, &exit_code);
|
||||
int nrows = 0;
|
||||
std::istringstream iss;
|
||||
iss.str(rows);
|
||||
|
@ -17,10 +17,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(600);
|
||||
Test->stop_maxscale();
|
||||
Test->ssh_maxscale(true, (char *) "rm -rf /var/lib/maxscale/avro");
|
||||
Test->maxscales->stop_maxscale(0);
|
||||
Test->maxscales->ssh_node(0, (char *) "rm -rf /var/lib/maxscale/avro", true);
|
||||
|
||||
//Test->ssh_maxscale(true, (char *) "mkdir /var/lib/maxscale/avro; chown -R maxscale:maxscale /var/lib/maxscale/avro");
|
||||
//Test->maxscales->ssh_node(0, (char *) "mkdir /var/lib/maxscale/avro; chown -R maxscale:maxscale /var/lib/maxscale/avro", true);
|
||||
|
||||
Test->repl->connect();
|
||||
execute_query(Test->repl->nodes[0], (char *) "DROP TABLE IF EXISTS t1;");
|
||||
@ -28,17 +28,17 @@ int main(int argc, char *argv[])
|
||||
sleep(5);
|
||||
|
||||
|
||||
Test->start_binlog();
|
||||
Test->start_binlog(0);
|
||||
|
||||
Test->set_timeout(120);
|
||||
|
||||
Test->stop_maxscale();
|
||||
Test->maxscales->stop_maxscale(0);
|
||||
|
||||
Test->ssh_maxscale(true, (char *) "rm -rf /var/lib/maxscale/avro");
|
||||
Test->maxscales->ssh_node(0, (char *) "rm -rf /var/lib/maxscale/avro", true);
|
||||
|
||||
Test->set_timeout(120);
|
||||
|
||||
Test->start_maxscale();
|
||||
Test->maxscales->start_maxscale(0);
|
||||
|
||||
Test->set_timeout(60);
|
||||
|
||||
|
@ -19,7 +19,7 @@ int main(int argc, char** argv)
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
Test->set_timeout(30);
|
||||
mysql[i] = Test->open_readconn_master_connection();
|
||||
mysql[i] = Test->maxscales->open_readconn_master_connection(0);
|
||||
execute_query_silent(mysql[i], "select 1");
|
||||
}
|
||||
Test->stop_timeout();
|
||||
@ -35,7 +35,7 @@ int main(int argc, char** argv)
|
||||
Test->stop_timeout();
|
||||
sleep(5);
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -17,9 +17,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
Test->connect_maxscale();
|
||||
Test->check_log_err((char *) "warning -1", true);
|
||||
Test->check_maxscale_alive();
|
||||
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;
|
||||
|
@ -25,7 +25,7 @@ void load(long int *new_inserts, long int *new_selects, long int *selects, long
|
||||
}
|
||||
|
||||
nodes->connect();
|
||||
Test->connect_rwsplit();
|
||||
Test->maxscales->connect_rwsplit(0);
|
||||
|
||||
data.i1 = 0;
|
||||
data.i2 = 0;
|
||||
@ -34,7 +34,7 @@ void load(long int *new_inserts, long int *new_selects, long int *selects, long
|
||||
data.rwsplit_only = rwsplit_only;
|
||||
// connect to the MaxScale server (rwsplit)
|
||||
|
||||
if (Test->conn_rwsplit == NULL )
|
||||
if (Test->maxscales->conn_rwsplit[0] == NULL )
|
||||
{
|
||||
if (report_errors)
|
||||
{
|
||||
@ -45,15 +45,15 @@ void load(long int *new_inserts, long int *new_selects, long int *selects, long
|
||||
}
|
||||
else
|
||||
{
|
||||
create_t1(Test->conn_rwsplit);
|
||||
create_t1(Test->maxscales->conn_rwsplit[0]);
|
||||
create_insert_string(sql, sql_l, 1);
|
||||
|
||||
if ((execute_query(Test->conn_rwsplit, sql) != 0) && (report_errors))
|
||||
if ((execute_query(Test->maxscales->conn_rwsplit[0], sql) != 0) && (report_errors))
|
||||
{
|
||||
Test->add_result(1, "Query %s failed\n", sql);
|
||||
}
|
||||
// close connections
|
||||
Test->close_rwsplit();
|
||||
Test->maxscales->close_rwsplit(0);
|
||||
|
||||
Test->tprintf("Waiting for the table to replicate\n");
|
||||
Test->repl->sync_slaves();
|
||||
@ -104,38 +104,38 @@ void *query_thread1( void *ptr )
|
||||
MYSQL * conn3;
|
||||
int conn_err = 0;
|
||||
thread_data * data = (thread_data *) ptr;
|
||||
conn1 = open_conn_db_timeout(data->Test->rwsplit_port,
|
||||
data->Test->maxscale_IP,
|
||||
conn1 = open_conn_db_timeout(data->Test->maxscales->rwsplit_port[0],
|
||||
data->Test->maxscales->IP[0],
|
||||
(char *) "test",
|
||||
data->Test->maxscale_user,
|
||||
data->Test->maxscale_password,
|
||||
data->Test->maxscales->user_name,
|
||||
data->Test->maxscales->password,
|
||||
20,
|
||||
data->Test->ssl);
|
||||
//conn1 = data->Test->open_rwsplit_connection();
|
||||
//conn1 = data->Test->maxscales->open_rwsplit_connection(0);
|
||||
if (mysql_errno(conn1) != 0)
|
||||
{
|
||||
conn_err++;
|
||||
}
|
||||
if (data->rwsplit_only == 0)
|
||||
{
|
||||
//conn2 = data->Test->open_readconn_master_connection();
|
||||
conn2 = open_conn_db_timeout(data->Test->readconn_master_port,
|
||||
data->Test->maxscale_IP,
|
||||
//conn2 = data->Test->maxscales->open_readconn_master_connection(0);
|
||||
conn2 = open_conn_db_timeout(data->Test->maxscales->readconn_master_port[0],
|
||||
data->Test->maxscales->IP[0],
|
||||
(char *) "test",
|
||||
data->Test->maxscale_user,
|
||||
data->Test->maxscale_password,
|
||||
data->Test->maxscales->user_name,
|
||||
data->Test->maxscales->password,
|
||||
20,
|
||||
data->Test->ssl);
|
||||
if (mysql_errno(conn2) != 0)
|
||||
{
|
||||
conn_err++;
|
||||
}
|
||||
//conn3 = data->Test->open_readconn_slave_connection();
|
||||
conn3 = open_conn_db_timeout(data->Test->readconn_slave_port,
|
||||
data->Test->maxscale_IP,
|
||||
//conn3 = data->Test->maxscales->open_readconn_slave_connection(0);
|
||||
conn3 = open_conn_db_timeout(data->Test->maxscales->readconn_slave_port[0],
|
||||
data->Test->maxscales->IP[0],
|
||||
(char *) "test",
|
||||
data->Test->maxscale_user,
|
||||
data->Test->maxscale_password,
|
||||
data->Test->maxscales->user_name,
|
||||
data->Test->maxscales->password,
|
||||
20,
|
||||
data->Test->ssl);
|
||||
if (mysql_errno(conn3) != 0)
|
||||
@ -175,32 +175,32 @@ void *query_thread2(void *ptr )
|
||||
MYSQL * conn2;
|
||||
MYSQL * conn3;
|
||||
thread_data * data = (thread_data *) ptr;
|
||||
//conn1 = data->Test->open_rwsplit_connection();
|
||||
conn1 = open_conn_db_timeout(data->Test->rwsplit_port,
|
||||
data->Test->maxscale_IP,
|
||||
//conn1 = data->Test->maxscales->open_rwsplit_connection(0);
|
||||
conn1 = open_conn_db_timeout(data->Test->maxscales->rwsplit_port[0],
|
||||
data->Test->maxscales->IP[0],
|
||||
(char *) "test",
|
||||
data->Test->maxscale_user,
|
||||
data->Test->maxscale_password,
|
||||
data->Test->maxscales->user_name,
|
||||
data->Test->maxscales->password,
|
||||
20,
|
||||
data->Test->ssl);
|
||||
if (data->rwsplit_only == 0)
|
||||
{
|
||||
//conn2 = data->Test->open_readconn_master_connection();
|
||||
//conn3 = data->Test->open_readconn_slave_connection();
|
||||
//conn2 = data->Test->maxscales->open_readconn_master_connection(0);
|
||||
//conn3 = data->Test->maxscales->open_readconn_slave_connection(0);
|
||||
|
||||
conn2 = open_conn_db_timeout(data->Test->readconn_master_port,
|
||||
data->Test->maxscale_IP,
|
||||
conn2 = open_conn_db_timeout(data->Test->maxscales->readconn_master_port[0],
|
||||
data->Test->maxscales->IP[0],
|
||||
(char *) "test",
|
||||
data->Test->maxscale_user,
|
||||
data->Test->maxscale_password,
|
||||
data->Test->maxscales->user_name,
|
||||
data->Test->maxscales->password,
|
||||
20,
|
||||
data->Test->ssl);
|
||||
//if (mysql_errno(conn2) != 0) { conn_err++; }
|
||||
conn3 = open_conn_db_timeout(data->Test->readconn_slave_port,
|
||||
data->Test->maxscale_IP,
|
||||
conn3 = open_conn_db_timeout(data->Test->maxscales->readconn_slave_port[0],
|
||||
data->Test->maxscales->IP[0],
|
||||
(char *) "test",
|
||||
data->Test->maxscale_user,
|
||||
data->Test->maxscale_password,
|
||||
data->Test->maxscales->user_name,
|
||||
data->Test->maxscales->password,
|
||||
20,
|
||||
data->Test->ssl);
|
||||
//if (mysql_errno(conn3) != 0) { conn_err++; }
|
||||
|
@ -17,11 +17,11 @@ int main(int argc, char** argv)
|
||||
sprintf(server_id[i], "%d", test.repl->get_server_id(i));
|
||||
}
|
||||
|
||||
test.connect_maxscale();
|
||||
test.maxscales->connect_maxscale(0);
|
||||
|
||||
test.set_timeout(20);
|
||||
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(test.conn_rwsplit);
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(test.maxscales->conn_rwsplit[0]);
|
||||
const char* write_query = "SELECT @@server_id, @@last_insert_id";
|
||||
const char* read_query = "SELECT @@server_id";
|
||||
char buffer[100] = "";
|
||||
@ -47,7 +47,7 @@ int main(int argc, char** argv)
|
||||
test.add_result(strcmp(buffer, server_id[0]), "Expected server_id '%s', got '%s'", server_id[0], buffer);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
stmt = mysql_stmt_init(test.conn_rwsplit);
|
||||
stmt = mysql_stmt_init(test.maxscales->conn_rwsplit[0]);
|
||||
|
||||
// Execute read, should return a slave server ID
|
||||
test.add_result(mysql_stmt_prepare(stmt, read_query, strlen(read_query)), "Failed to prepare");
|
||||
@ -61,7 +61,7 @@ int main(int argc, char** argv)
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
test.close_maxscale_connections();
|
||||
test.maxscales->close_maxscale_connections(0);
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ using std::endl;
|
||||
|
||||
void test1(TestConnections& test)
|
||||
{
|
||||
test.connect_maxscale();
|
||||
test.maxscales->connect_maxscale(0);
|
||||
test.set_timeout(20);
|
||||
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(test.conn_rwsplit);
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(test.maxscales->conn_rwsplit[0]);
|
||||
const char* query = "SELECT @@server_id";
|
||||
char buffer[100] = "";
|
||||
my_bool err = false;
|
||||
@ -43,7 +43,7 @@ void test1(TestConnections& test)
|
||||
|
||||
cout << "Close statement" << endl;
|
||||
mysql_stmt_close(stmt);
|
||||
test.close_maxscale_connections();
|
||||
test.maxscales->close_maxscale_connections(0);
|
||||
|
||||
}
|
||||
|
||||
@ -51,8 +51,8 @@ void test2(TestConnections& test)
|
||||
{
|
||||
test.set_timeout(20);
|
||||
|
||||
MYSQL* conn = open_conn_db_timeout(test.rwsplit_port, test.maxscale_ip(), "test",
|
||||
test.maxscale_user, test.maxscale_password, 1, false);
|
||||
MYSQL* conn = open_conn_db_timeout(test.maxscales->rwsplit_port[0], test.maxscales->ip(0), "test",
|
||||
test.maxscales->user_name, test.maxscales->password, 1, false);
|
||||
|
||||
MYSQL_STMT* stmt1 = mysql_stmt_init(conn);
|
||||
MYSQL_STMT* stmt2 = mysql_stmt_init(conn);
|
||||
@ -120,10 +120,10 @@ void test2(TestConnections& test)
|
||||
|
||||
void test3(TestConnections& test)
|
||||
{
|
||||
test.connect_maxscale();
|
||||
test.maxscales->connect_maxscale(0);
|
||||
test.set_timeout(20);
|
||||
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(test.conn_rwsplit);
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(test.maxscales->conn_rwsplit[0]);
|
||||
const char* query = "SELECT @@server_id";
|
||||
char buffer[100] = "";
|
||||
my_bool err = false;
|
||||
@ -138,9 +138,9 @@ void test3(TestConnections& test)
|
||||
test.add_result(mysql_stmt_prepare(stmt, query, strlen(query)), "Failed to prepare");
|
||||
|
||||
cout << "Start transaction" << endl;
|
||||
test.add_result(mysql_query(test.conn_rwsplit, "START TRANSACTION"),
|
||||
test.add_result(mysql_query(test.maxscales->conn_rwsplit[0], "START TRANSACTION"),
|
||||
"START TRANSACTION should succeed: %s",
|
||||
mysql_error(test.conn_rwsplit));
|
||||
mysql_error(test.maxscales->conn_rwsplit[0]));
|
||||
|
||||
|
||||
unsigned long cursor_type = CURSOR_TYPE_READ_ONLY;
|
||||
@ -156,12 +156,12 @@ void test3(TestConnections& test)
|
||||
test.add_result(strlen(buffer) == 0, "Expected result buffer to not be empty");
|
||||
|
||||
cout << "Commit" << endl;
|
||||
test.add_result(mysql_query(test.conn_rwsplit, "COMMIT"),
|
||||
test.add_result(mysql_query(test.maxscales->conn_rwsplit[0], "COMMIT"),
|
||||
"COMMIT should succeed: %s",
|
||||
mysql_error(test.conn_rwsplit));
|
||||
mysql_error(test.maxscales->conn_rwsplit[0]));
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
test.close_maxscale_connections();
|
||||
test.maxscales->close_maxscale_connections(0);
|
||||
|
||||
char server_id[1024];
|
||||
test.repl->connect();
|
||||
|
@ -25,7 +25,7 @@ int main(int argc, char *argv[])
|
||||
Test->repl->close_connections();
|
||||
sleep(5);
|
||||
|
||||
Test->start_binlog();
|
||||
Test->start_binlog(0);
|
||||
|
||||
pthread_t threads;
|
||||
int iret;
|
||||
@ -51,7 +51,8 @@ void *disconnect_thread( void *ptr )
|
||||
MYSQL * conn;
|
||||
char cmd[256];
|
||||
int i;
|
||||
conn = open_conn(Test->binlog_port, Test->maxscale_IP, Test->repl->user_name, Test->repl->password,
|
||||
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;
|
||||
|
@ -95,8 +95,10 @@ int main(int argc, char *argv[])
|
||||
Test->repl->execute_query_all_nodes((char *) "RESET SLAVE ALL");
|
||||
Test->repl->execute_query_all_nodes((char *) "RESET MASTER");
|
||||
|
||||
Test->repl->verbose = true;
|
||||
|
||||
Test->tprintf("Starting binlog configuration\n");
|
||||
Test->start_binlog();
|
||||
Test->start_binlog(0);
|
||||
|
||||
pthread_t disconnec_thread_t;
|
||||
int disconnect_iret;
|
||||
@ -180,7 +182,7 @@ const char * setup_slave1 =
|
||||
MASTER_LOG_POS=%s,\
|
||||
MASTER_PORT=%d";
|
||||
const char * setup_slave_gtid =
|
||||
"change master to MASTER_HOST='%s',\
|
||||
"change master to MASTER_HOST='%s',\
|
||||
MASTER_USER='repl',\
|
||||
MASTER_PASSWORD='repl',\
|
||||
MASTER_PORT=%d, \
|
||||
@ -214,7 +216,8 @@ int select_new_master(TestConnections * test)
|
||||
test->tprintf("Real master pos : %s\n", log_pos);
|
||||
|
||||
test->tprintf("Connecting to MaxScale binlog router (with any DB)\n");
|
||||
MYSQL * binlog = open_conn_no_db(test->binlog_port, test->maxscale_IP, test->repl->user_name,
|
||||
MYSQL * binlog = open_conn_no_db(test->maxscales->binlog_port[0], test->maxscales->IP[0],
|
||||
test->repl->user_name,
|
||||
test->repl->password, test->ssl);
|
||||
test->add_result(mysql_errno(binlog), "Error connection to binlog router %s\n", mysql_error(binlog));
|
||||
|
||||
@ -253,7 +256,8 @@ int select_new_master(TestConnections * test)
|
||||
|
||||
test->tprintf("reconnect to binlog\n");
|
||||
mysql_close(binlog);
|
||||
binlog = open_conn_no_db(test->binlog_port, test->maxscale_IP, test->repl->user_name, test->repl->password,
|
||||
binlog = open_conn_no_db(test->maxscales->binlog_port[0], test->maxscales->IP[0], test->repl->user_name,
|
||||
test->repl->password,
|
||||
test->ssl);
|
||||
test->add_result(mysql_errno(binlog), "Error connection to binlog router %s\n", mysql_error(binlog));
|
||||
|
||||
@ -287,7 +291,8 @@ void *disconnect_thread( void *ptr )
|
||||
MYSQL * conn;
|
||||
char cmd[256];
|
||||
int i;
|
||||
conn = open_conn(Test->binlog_port, Test->maxscale_IP, Test->repl->user_name, Test->repl->password,
|
||||
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;
|
||||
|
@ -14,10 +14,10 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
|
||||
Test->set_timeout(60);
|
||||
Test->connect_maxscale();
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
sleep(10);
|
||||
Test->check_log_err("fatal signal 11", false);
|
||||
Test->check_log_err(0, "fatal signal 11", false);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -17,7 +17,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
test.repl->connect();
|
||||
test.binlog_cmd_option = 1;
|
||||
test.start_binlog();
|
||||
test.start_binlog(0);
|
||||
test.repl->connect();
|
||||
test.tprintf("install semisync plugin");
|
||||
execute_query(test.repl->nodes[0],
|
||||
@ -57,4 +57,3 @@ int main(int argc, char *argv[])
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
||||
|
@ -91,10 +91,10 @@ int check_longblob_data(TestConnections* Test, MYSQL * conn, unsigned long chunk
|
||||
{
|
||||
//char *select_stmt = (char *) "SELECT id, x, b FROM long_blob_table WHERE id = ?";
|
||||
char *select_stmt = (char *) "SELECT id, x, b FROM long_blob_table ";
|
||||
MYSQL_STMT * stmt = mysql_stmt_init(Test->conn_rwsplit);
|
||||
MYSQL_STMT * stmt = mysql_stmt_init(Test->maxscales->conn_rwsplit[0]);
|
||||
if (stmt == NULL)
|
||||
{
|
||||
Test->add_result(1, "stmt init error: %s\n", mysql_error(Test->conn_rwsplit));
|
||||
Test->add_result(1, "stmt init error: %s\n", mysql_error(Test->maxscales->conn_rwsplit[0]));
|
||||
}
|
||||
|
||||
Test->add_result(mysql_stmt_prepare(stmt, select_stmt, strlen(select_stmt)), "Error preparing stmt: %s\n",
|
||||
@ -154,7 +154,7 @@ int check_longblob_data(TestConnections* Test, MYSQL * conn, unsigned long chunk
|
||||
|
||||
if (mysql_stmt_execute(stmt) != 0)
|
||||
{
|
||||
Test->tprintf("Error executing stmt %s\n", mysql_error(Test->conn_rwsplit));
|
||||
Test->tprintf("Error executing stmt %s\n", mysql_error(Test->maxscales->conn_rwsplit[0]));
|
||||
}
|
||||
|
||||
if (mysql_stmt_store_result(stmt) != 0)
|
||||
|
@ -12,13 +12,13 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
|
||||
Test->tprintf("Creating user 'user' with 3 different passwords for different hosts\n");
|
||||
Test->connect_maxscale();
|
||||
execute_query(Test->conn_rwsplit, "CREATE USER 'user'@'non_existing_host1' IDENTIFIED BY 'pass1'");
|
||||
execute_query(Test->conn_rwsplit, "CREATE USER 'user'@'%%' IDENTIFIED BY 'pass2'");
|
||||
execute_query(Test->conn_rwsplit, "CREATE USER 'user'@'non_existing_host2' IDENTIFIED BY 'pass3'");
|
||||
execute_query(Test->conn_rwsplit, "GRANT ALL PRIVILEGES ON *.* TO 'user'@'non_existing_host1'");
|
||||
execute_query(Test->conn_rwsplit, "GRANT ALL PRIVILEGES ON *.* TO 'user'@'%%'");
|
||||
execute_query(Test->conn_rwsplit, "GRANT ALL PRIVILEGES ON *.* TO 'user'@'non_existing_host2'");
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "CREATE USER 'user'@'non_existing_host1' IDENTIFIED BY 'pass1'");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "CREATE USER 'user'@'%%' IDENTIFIED BY 'pass2'");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "CREATE USER 'user'@'non_existing_host2' IDENTIFIED BY 'pass3'");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "GRANT ALL PRIVILEGES ON *.* TO 'user'@'non_existing_host1'");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "GRANT ALL PRIVILEGES ON *.* TO 'user'@'%%'");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "GRANT ALL PRIVILEGES ON *.* TO 'user'@'non_existing_host2'");
|
||||
|
||||
Test->tprintf("Synchronizing slaves");
|
||||
Test->set_timeout(50);
|
||||
@ -26,7 +26,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->tprintf("Trying first hostname, expecting failure");
|
||||
Test->set_timeout(15);
|
||||
MYSQL * conn = open_conn(Test->rwsplit_port, Test->maxscale_IP, (char *) "user", (char *) "pass1", Test->ssl);
|
||||
MYSQL * conn = open_conn(Test->maxscales->rwsplit_port[0], Test->maxscales->IP[0], (char *) "user", (char *) "pass1", Test->ssl);
|
||||
if (mysql_errno(conn) == 0)
|
||||
{
|
||||
Test->add_result(1, "MaxScale ignores host in authentication\n");
|
||||
@ -38,7 +38,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->tprintf("Trying second hostname, expecting success");
|
||||
Test->set_timeout(15);
|
||||
conn = open_conn(Test->rwsplit_port, Test->maxscale_IP, (char *) "user", (char *) "pass2", Test->ssl);
|
||||
conn = open_conn(Test->maxscales->rwsplit_port[0], Test->maxscales->IP[0], (char *) "user", (char *) "pass2", Test->ssl);
|
||||
Test->add_result(mysql_errno(conn), "MaxScale can't connect: %s\n", mysql_error(conn));
|
||||
if (conn != NULL)
|
||||
{
|
||||
@ -47,7 +47,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->tprintf("Trying third hostname, expecting failure");
|
||||
Test->set_timeout(15);
|
||||
conn = open_conn(Test->rwsplit_port, Test->maxscale_IP, (char *) "user", (char *) "pass3", Test->ssl);
|
||||
conn = open_conn(Test->maxscales->rwsplit_port[0], Test->maxscales->IP[0], (char *) "user", (char *) "pass3", Test->ssl);
|
||||
if (mysql_errno(conn) == 0)
|
||||
{
|
||||
Test->add_result(1, "MaxScale ignores host in authentication\n");
|
||||
@ -57,10 +57,10 @@ int main(int argc, char *argv[])
|
||||
mysql_close(conn);
|
||||
}
|
||||
|
||||
execute_query(Test->conn_rwsplit, "DROP USER 'user'@'non_existing_host1'");
|
||||
execute_query(Test->conn_rwsplit, "DROP USER 'user'@'%%'");
|
||||
execute_query(Test->conn_rwsplit, "DROP USER 'user'@'non_existing_host2'");
|
||||
Test->close_maxscale_connections();
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "DROP USER 'user'@'non_existing_host1'");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "DROP USER 'user'@'%%'");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "DROP USER 'user'@'non_existing_host2'");
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -40,10 +40,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
Test->check_log_err((char *) "Unsupported router option \"slave\"", true);
|
||||
Test->check_log_err((char *) "Failed to start all MaxScale services. Exiting", true);
|
||||
Test->check_log_err((char *) "Couldn't find suitable Master", false);
|
||||
//Test->check_maxscale_alive();
|
||||
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;
|
||||
|
@ -89,7 +89,7 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->tprintf("Connecting to all MaxScale services\n");
|
||||
Test->add_result(Test->connect_maxscale(), "Can not connect to Maxscale\n");
|
||||
Test->add_result(Test->maxscales->connect_maxscale(0), "Can not connect to Maxscale\n");
|
||||
|
||||
Test->tprintf("executing show status %d times\n", iterations);
|
||||
|
||||
@ -97,25 +97,25 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < iterations; i++)
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
Test->add_result(execute_query(Test->conn_rwsplit, (char *) "show status"),
|
||||
Test->add_result(execute_query(Test->maxscales->conn_rwsplit[0], (char *) "show status"),
|
||||
"Query %d agains RWSplit failed\n", i);
|
||||
}
|
||||
for (i = 0; i < iterations; i++)
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
Test->add_result(execute_query(Test->conn_slave, (char *) "show status"),
|
||||
Test->add_result(execute_query(Test->maxscales->conn_slave[0], (char *) "show status"),
|
||||
"Query %d agains ReadConn Slave failed\n", i);
|
||||
}
|
||||
for (i = 0; i < iterations; i++)
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
Test->add_result(execute_query(Test->conn_master, (char *) "show status"),
|
||||
Test->add_result(execute_query(Test->maxscales->conn_master[0], (char *) "show status"),
|
||||
"Query %d agains ReadConn Master failed\n", i);
|
||||
}
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->check_maxscale_alive();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -19,10 +19,10 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(20);
|
||||
Test->repl->connect();
|
||||
|
||||
get_my_ip(Test->maxscale_IP, my_ip);
|
||||
get_my_ip(Test->maxscales->IP[0], my_ip);
|
||||
Test->tprintf("Test machine IP (got via network request) %s\n", my_ip);
|
||||
|
||||
Test->add_result(Test->get_client_ip(my_ip_db), "Unable to get IP using connection to DB\n");
|
||||
Test->add_result(Test->get_client_ip(0, my_ip_db), "Unable to get IP using connection to DB\n");
|
||||
|
||||
Test->tprintf("Test machine IP (got via Show processlist) %s\n", my_ip);
|
||||
|
||||
@ -32,19 +32,20 @@ int main(int argc, char *argv[])
|
||||
Test->tprintf("Test machine IP with %% %s\n", my_ip);
|
||||
|
||||
Test->tprintf("Connecting to Maxscale\n");
|
||||
Test->add_result(Test->connect_maxscale(), "Error connecting to Maxscale\n");
|
||||
Test->add_result(Test->maxscales->connect_maxscale(0), "Error connecting to Maxscale\n");
|
||||
Test->tprintf("Creating user 'user1' for %s host\n", my_ip);
|
||||
Test->set_timeout(30);
|
||||
|
||||
Test->add_result(execute_query(Test->conn_rwsplit, "CREATE USER user1@'%s';", my_ip),
|
||||
Test->add_result(execute_query(Test->maxscales->conn_rwsplit[0], "CREATE USER user1@'%s';", my_ip),
|
||||
"Failed to create user");
|
||||
Test->add_result(execute_query(Test->conn_rwsplit,
|
||||
Test->add_result(execute_query(Test->maxscales->conn_rwsplit[0],
|
||||
"GRANT ALL PRIVILEGES ON *.* TO user1@'%s' identified by 'pass1'; FLUSH PRIVILEGES;", my_ip),
|
||||
"Failed to grant privileges.");
|
||||
|
||||
Test->tprintf("Trying to open connection using user1\n");
|
||||
|
||||
MYSQL * conn = open_conn(Test->rwsplit_port, Test->maxscale_IP, (char *) "user1", (char *) "pass1",
|
||||
MYSQL * conn = open_conn(Test->maxscales->rwsplit_port[0], Test->maxscales->IP[0], (char *) "user1",
|
||||
(char *) "pass1",
|
||||
Test->ssl);
|
||||
if (mysql_errno(conn) != 0)
|
||||
{
|
||||
@ -59,11 +60,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
Test->add_result(execute_query(Test->conn_rwsplit, "DROP USER user1@'%s'; FLUSH PRIVILEGES;", my_ip),
|
||||
Test->add_result(execute_query(Test->maxscales->conn_rwsplit[0], "DROP USER user1@'%s'; FLUSH PRIVILEGES;",
|
||||
my_ip),
|
||||
"Query Failed\n");
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->check_maxscale_alive();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -17,7 +17,7 @@ int main(int argc, char *argv[])
|
||||
Test->ConnectMaxscale();
|
||||
|
||||
|
||||
execute_query(Test->conn_rwsplit, (char *) "select @@server_id; -- max_slave_replication_lag=120");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id; -- max_slave_replication_lag=120");
|
||||
|
||||
|
||||
|
||||
|
@ -51,29 +51,29 @@ int main(int argc, char *argv[])
|
||||
int res_d;
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->get_maxadmin_param((char *) "show server server1", (char *) "Current no. of conns:", res);
|
||||
Test->maxscales->get_maxadmin_param(0, (char *) "show server server1", (char *) "Current no. of conns:", res);
|
||||
sscanf(res, "%d", &res_d);
|
||||
Test->tprintf("Before: Current num of conn %d\n", res_d);
|
||||
Test->add_result(res_d, "curr num of conn is not 0\n");
|
||||
Test->get_maxadmin_param((char *) "show server server1", (char *) "Number of connections:", res);
|
||||
Test->maxscales->get_maxadmin_param(0, (char *) "show server server1", (char *) "Number of connections:", res);
|
||||
sscanf(res, "%d", &res_d);
|
||||
Test->tprintf("Before: num of conn %d\n", res_d);
|
||||
Test->add_result(res_d, "num of conn is not 0");
|
||||
|
||||
Test->connect_rwsplit();
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select 1");
|
||||
Test->close_rwsplit();
|
||||
Test->maxscales->connect_rwsplit(0);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select 1");
|
||||
Test->maxscales->close_rwsplit(0);
|
||||
|
||||
Test->stop_timeout();
|
||||
sleep(10);
|
||||
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->get_maxadmin_param((char *) "show server server1", (char *) "Current no. of conns:", res);
|
||||
Test->maxscales->get_maxadmin_param(0, (char *) "show server server1", (char *) "Current no. of conns:", res);
|
||||
sscanf(res, "%d", &res_d);
|
||||
Test->tprintf("After: Current num of conn %d\n", res_d);
|
||||
Test->add_result(res_d, "curr num of conn is not 0\n");
|
||||
Test->get_maxadmin_param((char *) "show server server1", (char *) "Number of connections:", res);
|
||||
Test->maxscales->get_maxadmin_param(0, (char *) "show server server1", (char *) "Number of connections:", res);
|
||||
sscanf(res, "%d", &res_d);
|
||||
Test->tprintf("After: num of conn %d\n", res_d);
|
||||
if (res_d != 1)
|
||||
@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
Test->add_result(1, "num of conn is not 1");
|
||||
}
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->repl->connect();
|
||||
Test->add_result(Test->connect_maxscale(), "Failed to connect to MaxScale\n");
|
||||
Test->add_result(Test->maxscales->connect_maxscale(0), "Failed to connect to MaxScale\n");
|
||||
|
||||
char server_id[256];
|
||||
char server_id_d[256];
|
||||
@ -169,7 +169,7 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(5);
|
||||
sprintf(hint_sql, "select @@server_id; -- maxscale route to server server%d", j + 1);
|
||||
|
||||
find_field(Test->conn_rwsplit, hint_sql, (char *) "@@server_id", &server_id[0]);
|
||||
find_field(Test->maxscales->conn_rwsplit[0], hint_sql, (char *) "@@server_id", &server_id[0]);
|
||||
find_field(Test->repl->nodes[j], (char *) "select @@server_id;", (char *) "@@server_id", &server_id_d[0]);
|
||||
|
||||
Test->tprintf("server%d ID from Maxscale: \t%s\n", j + 1, server_id);
|
||||
@ -182,10 +182,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->repl->close_connections();
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -56,40 +56,40 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->add_result(Test->connect_maxscale(), "Can not connect to Maxscale\n");
|
||||
Test->add_result(Test->maxscales->connect_maxscale(0), "Can not connect to Maxscale\n");
|
||||
|
||||
|
||||
Test->tprintf("Trying queries that caused crashes before fix: bug473\n");
|
||||
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select @@server_id; -- maxscale route to server =(");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select @@server_id; -- maxscale route to server =)");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select @@server_id; -- maxscale route to server =:");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select @@server_id; -- maxscale route to server =a");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select @@server_id; -- maxscale route to server = a");
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id; -- maxscale route to server =(");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id; -- maxscale route to server =)");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id; -- maxscale route to server =:");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id; -- maxscale route to server =a");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id; -- maxscale route to server = a");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "select @@server_id; -- maxscale route to server = кириллица åäö");
|
||||
|
||||
// bug472
|
||||
Test->tprintf("Trying queries that caused crashes before fix: bug472\n");
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "select @@server_id; -- maxscale s1 begin route to server server3");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select @@server_id; -- maxscale end");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select @@server_id; -- maxscale s1 begin");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id; -- maxscale end");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id; -- maxscale s1 begin");
|
||||
|
||||
// bug470
|
||||
Test->tprintf("Trying queries that caused crashes before fix: bug470\n");
|
||||
fflush(stdout);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select @@server_id; -- maxscale named begin route to master");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select @@server_id;");
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id; -- maxscale named begin route to master");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select @@server_id;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "select @@server_id; -- maxscale named begin route to master; select @@server_id;");
|
||||
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->tprintf("Checking if Maxscale is alive\n");
|
||||
fflush(stdout);
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -36,15 +36,15 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "select /* maxscale hintname prepare route to master */ @@server_id;");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select /* maxscale hintname begin */ @@server_id;");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select /* maxscale route to master*/ @@server_id;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select /* maxscale hintname begin */ @@server_id;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select /* maxscale route to master*/ @@server_id;");
|
||||
|
||||
Test->check_log_err((char *) "Syntax error in hint", false);
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_log_err(0, (char *) "Syntax error in hint", false);
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -25,9 +25,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
Test->check_log_err((char *) "Unable to find filter 'non existing filter", true);
|
||||
//global_result =Test->check_log_err((char *) "не существуюший фильтер", true);
|
||||
//global_result +=Test->check_maxscale_alive();
|
||||
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;
|
||||
|
@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
int i;
|
||||
|
||||
Test->repl->connect();
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->tprintf("Trying SHOW VARIABLES to different Maxscale services\n");
|
||||
fflush(stdout);
|
||||
@ -89,35 +89,35 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "SHOW VARIABLES;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "SHOW VARIABLES;");
|
||||
}
|
||||
Test->tprintf("ReadConn master\n");
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
Test->try_query(Test->conn_master, (char *) "SHOW VARIABLES;");
|
||||
Test->try_query(Test->maxscales->conn_master[0], (char *) "SHOW VARIABLES;");
|
||||
}
|
||||
Test->tprintf("ReadConn slave\n");
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
Test->try_query(Test->conn_slave, (char *) "SHOW VARIABLES;");
|
||||
Test->try_query(Test->maxscales->conn_slave[0], (char *) "SHOW VARIABLES;");
|
||||
}
|
||||
|
||||
Test->tprintf("All in one loop\n");
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "SHOW VARIABLES;");
|
||||
Test->try_query(Test->conn_master, (char *) "SHOW VARIABLES;");
|
||||
Test->try_query(Test->conn_slave, (char *) "SHOW VARIABLES;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "SHOW VARIABLES;");
|
||||
Test->try_query(Test->maxscales->conn_master[0], (char *) "SHOW VARIABLES;");
|
||||
Test->try_query(Test->maxscales->conn_slave[0], (char *) "SHOW VARIABLES;");
|
||||
}
|
||||
|
||||
Test->set_timeout(10);
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->repl->close_connections();
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -80,10 +80,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
Test->check_log_err((char *) "Duplicate section found: server2", true);
|
||||
Test->check_log_err((char *)
|
||||
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();
|
||||
//Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -34,8 +34,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
Test->check_log_err((char *) "Unable to find server", true);
|
||||
Test->check_log_err((char *) "errors were encountered while processing the configuration", true);
|
||||
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;
|
||||
|
@ -68,7 +68,7 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(60);
|
||||
|
||||
Test->repl->connect();
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
if (Test->repl->N < 3)
|
||||
{
|
||||
@ -79,12 +79,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->tprintf("Creating table\n");
|
||||
fflush(stdout);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "DROP TABLE IF EXISTS t2");
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "DROP TABLE IF EXISTS t2");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "CREATE TABLE t2 (id INT(10) NOT NULL AUTO_INCREMENT, x int, PRIMARY KEY (id));");
|
||||
Test->tprintf("Doing INSERTs\n");
|
||||
fflush(stdout);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "insert into t2 (x) values (1);");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "insert into t2 (x) values (1);");
|
||||
|
||||
Test->stop_timeout();
|
||||
Test->repl->sync_slaves();
|
||||
@ -95,7 +95,7 @@ int main(int argc, char *argv[])
|
||||
char last_insert_id2[1024];
|
||||
if ( (
|
||||
find_field(
|
||||
Test->conn_rwsplit, sel1,
|
||||
Test->maxscales->conn_rwsplit[0], sel1,
|
||||
"@@server_id", &last_insert_id1[0])
|
||||
!= 0 ) || (
|
||||
find_field(
|
||||
@ -115,10 +115,10 @@ int main(int argc, char *argv[])
|
||||
"last_insert_id() are different depending in which order terms are in SELECT\n");
|
||||
}
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->repl->close_connections();
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -1,14 +1,39 @@
|
||||
/**
|
||||
* @file bug509.cpp regression case for bug 509 "rw-split router does not send last_insert_id() to master"
|
||||
* @file bug509.cpp regression case for bug 509 and 507 ( "Referring to a nonexisting server in servers=... doesn't even raise a warning"
|
||||
* and "rw-split router does not send last_insert_id() to master" )
|
||||
*
|
||||
* - "CREATE TABLE t2 (id INT(10) NOT NULL AUTO_INCREMENT, x int, PRIMARY KEY (id));",
|
||||
* - do a number of INSERTs first using RWsplit, then directly Galera nodes.
|
||||
* - do "select @@wsrep_node_address, last_insert_id();" and "select last_insert_id(), @@wsrep_node_address;" and compares results.
|
||||
* - do "insert into t2 (x) values (i);" 50 times and compares results of
|
||||
* - do "insert into t2 (x) values (i);" 1000 times and compares results of
|
||||
* "select @@wsrep_node_address, last_insert_id();" and "select last_insert_id(), @@wsrep_node_address;"
|
||||
*
|
||||
* Test fails if results are different (after 5 seconds of waiting after last INSERT)
|
||||
*/
|
||||
|
||||
/*
|
||||
Kolbe Kegel 2014-09-01 14:48:12 UTC
|
||||
For some reason, the order of terms in the field list of a SELECT statement influences how the rw-split router decides where to send a statement.
|
||||
|
||||
mariadb> select @@wsrep_node_address, last_insert_id();
|
||||
+----------------------+------------------+
|
||||
| @@wsrep_node_address | last_insert_id() |
|
||||
+----------------------+------------------+
|
||||
| 192.168.30.31 | 7 |
|
||||
+----------------------+------------------+
|
||||
1 row in set (0.00 sec)
|
||||
|
||||
mariadb> select last_insert_id(), @@wsrep_node_address;
|
||||
+------------------+----------------------+
|
||||
| last_insert_id() | @@wsrep_node_address |
|
||||
+------------------+----------------------+
|
||||
| 0 | 192.168.30.33 |
|
||||
+------------------+----------------------+
|
||||
1 row in set (0.00 sec)
|
||||
Comment 1 Vilho Raatikka 2014-09-03 20:44:17 UTC
|
||||
Added code to detect last_insert_id() function and now both types of elements are routed to master and their order of appearance doesn't matter.
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "testconnections.h"
|
||||
@ -22,24 +47,61 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(60);
|
||||
|
||||
Test->galera->connect();
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->tprintf("Creating table");
|
||||
Test->try_query(Test->conn_rwsplit, "DROP TABLE IF EXISTS t2;");
|
||||
Test->try_query(Test->conn_rwsplit, "CREATE TABLE t2 (id INT(10) NOT NULL AUTO_INCREMENT, x int, PRIMARY KEY (id));");
|
||||
Test->tprintf("Doing INSERT through readwritesplit");
|
||||
Test->try_query(Test->conn_rwsplit, "START TRANSACTION");
|
||||
Test->try_query(Test->conn_rwsplit, "insert into t2 (x) values (1);");
|
||||
if (Test->galera->N < 3)
|
||||
{
|
||||
Test->tprintf("There is not enoght nodes for test\n");
|
||||
delete Test;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
char last_insert_id1[1024] = "";
|
||||
char last_insert_id2[1024] = "";
|
||||
find_field(Test->conn_rwsplit, sel1, "last_insert_id()", last_insert_id1);
|
||||
find_field(Test->conn_rwsplit, sel2, "last_insert_id()", last_insert_id2);
|
||||
Test->try_query(Test->conn_rwsplit, "COMMIT");
|
||||
Test->tprintf("Creating table\n");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "DROP TABLE IF EXISTS t2;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "CREATE TABLE t2 (id INT(10) NOT NULL AUTO_INCREMENT, x int, PRIMARY KEY (id));");
|
||||
Test->tprintf("Doing INSERTs\n");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "insert into t2 (x) values (1);");
|
||||
|
||||
Test->tprintf("'%s' gave last_insert_id() %s", sel1, last_insert_id1);
|
||||
Test->tprintf("'%s' gave last_insert_id() %s", sel2, last_insert_id2);
|
||||
Test->add_result(strcmp(last_insert_id1, last_insert_id2), "last_insert_id() are different depending in which order terms are in SELECT");
|
||||
Test->try_query(Test->galera->nodes[0], (char *) "insert into t2 (x) values (2);");
|
||||
Test->try_query(Test->galera->nodes[0], (char *) "insert into t2 (x) values (3);");
|
||||
|
||||
Test->try_query(Test->galera->nodes[1], (char *) "insert into t2 (x) values (4);");
|
||||
Test->try_query(Test->galera->nodes[1], (char *) "insert into t2 (x) values (5);");
|
||||
Test->try_query(Test->galera->nodes[1], (char *) "insert into t2 (x) values (6);");
|
||||
|
||||
Test->try_query(Test->galera->nodes[2], (char *) "insert into t2 (x) values (7);");
|
||||
Test->try_query(Test->galera->nodes[2], (char *) "insert into t2 (x) values (8);");
|
||||
Test->try_query(Test->galera->nodes[2], (char *) "insert into t2 (x) values (9);");
|
||||
Test->try_query(Test->galera->nodes[2], (char *) "insert into t2 (x) values (10);");
|
||||
|
||||
Test->stop_timeout();
|
||||
Test->repl->sync_slaves();
|
||||
|
||||
Test->tprintf("Trying \n");
|
||||
char last_insert_id1[1024];
|
||||
char last_insert_id2[1024];
|
||||
if ( (
|
||||
find_field(
|
||||
Test->maxscales->conn_rwsplit[0], sel1,
|
||||
"last_insert_id()", &last_insert_id1[0])
|
||||
!= 0 ) || (
|
||||
find_field(
|
||||
Test->maxscales->conn_rwsplit[0], sel2,
|
||||
"last_insert_id()", &last_insert_id2[0])
|
||||
!= 0 ))
|
||||
{
|
||||
Test->tprintf("last_insert_id() fied not found!!\n");
|
||||
delete Test;
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Test->tprintf("'%s' gave last_insert_id() %s\n", sel1, last_insert_id1);
|
||||
Test->tprintf("'%s' gave last_insert_id() %s\n", sel2, last_insert_id2);
|
||||
Test->add_result(strcmp(last_insert_id1, last_insert_id2),
|
||||
"last_insert_id() are different depending in which order terms are in SELECT\n");
|
||||
}
|
||||
|
||||
char id_str[1024];
|
||||
char str1[1024];
|
||||
@ -48,13 +110,12 @@ int main(int argc, char *argv[])
|
||||
for (int i = 100; i < iterations; i++)
|
||||
{
|
||||
Test->set_timeout(50);
|
||||
Test->try_query(Test->conn_rwsplit, "START TRANSACTION");
|
||||
Test->add_result(execute_query(Test->conn_rwsplit, "insert into t2 (x) values (%d);", i), "Query failed");
|
||||
Test->add_result(execute_query(Test->maxscales->conn_rwsplit[0], "insert into t2 (x) values (%d);", i), "Query failed");
|
||||
|
||||
sprintf(str1, "select * from t2 where x=%d;", i);
|
||||
|
||||
find_field(Test->conn_rwsplit, sel1, "last_insert_id()", last_insert_id1);
|
||||
find_field(Test->conn_rwsplit, str1, "id", id_str);
|
||||
find_field(Test->maxscales->conn_rwsplit[0], sel1, "last_insert_id()", &last_insert_id1[0]);
|
||||
find_field(Test->maxscales->conn_rwsplit[0], str1, "id", &id_str[0]);
|
||||
|
||||
int n = 0;
|
||||
|
||||
@ -62,12 +123,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Test->tprintf("Replication is lagging");
|
||||
sleep(1);
|
||||
find_field(Test->conn_rwsplit, str1, "id", &id_str[0]);
|
||||
find_field(Test->maxscales->conn_rwsplit[0], str1, "id", &id_str[0]);
|
||||
n++;
|
||||
}
|
||||
|
||||
Test->try_query(Test->conn_rwsplit, "COMMIT");
|
||||
|
||||
Test->add_result(strcmp(last_insert_id1, id_str),
|
||||
"last_insert_id is not equal to id even after waiting 5 seconds");
|
||||
|
||||
@ -77,8 +136,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
Test->try_query(Test->conn_rwsplit, "DROP TABLE t2;");
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file bug519.cpp - Jira task is MAX-345
|
||||
* - fill t1 with data
|
||||
* - execute SELECT * INTO OUTFILE '/tmp/t1.csv' FROM t1; against all routers
|
||||
* - execute SELECT * INTO OUTFILE '/tmp/t1.csv' FROM t1; against all maxscales->routers[0]
|
||||
* - DROP TABLE t1
|
||||
* - LOAD DATA LOCAL INFILE 't1.csv' INTO TABLE t1; using RWSplit
|
||||
* - check if t1 contains right data
|
||||
@ -76,50 +76,53 @@ int main(int argc, char *argv[])
|
||||
char str[1024];
|
||||
Test->set_timeout(60);
|
||||
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->repl->connect();
|
||||
|
||||
Test->tprintf("Create t1\n");
|
||||
create_t1(Test->conn_rwsplit);
|
||||
create_t1(Test->maxscales->conn_rwsplit[0]);
|
||||
Test->tprintf("Insert data into t1\n");
|
||||
Test->set_timeout(60);
|
||||
insert_into_t1(Test->conn_rwsplit, N);
|
||||
insert_into_t1(Test->maxscales->conn_rwsplit[0], N);
|
||||
Test->stop_timeout();
|
||||
Test->repl->sync_slaves();
|
||||
Test->set_timeout(200);
|
||||
|
||||
sprintf(str, "%s rm -f /tmp/t*.csv; %s chmod 777 /tmp", Test->repl->access_sudo[0],
|
||||
Test->repl->access_sudo[0]);
|
||||
Test->tprintf("%s\n", str);
|
||||
for (int k = 0; k < Test->repl->N; k++)
|
||||
{
|
||||
Test->repl->ssh_node(k, false, "%s rm -f /tmp/t*.csv; %s chmod 777 /tmp",
|
||||
Test->repl->access_sudo[0], Test->repl->access_sudo[0]);
|
||||
Test->repl->ssh_node(k, str, false);
|
||||
}
|
||||
//system(str);
|
||||
|
||||
Test->tprintf("Copying data from t1 to file...\n");
|
||||
Test->tprintf("using RWSplit: SELECT * INTO OUTFILE '/tmp/t1.csv' FROM t1;\n");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "SELECT * INTO OUTFILE '/tmp/t1.csv' FROM t1;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "SELECT * INTO OUTFILE '/tmp/t1.csv' FROM t1;");
|
||||
Test->tprintf("using ReadConn master: SELECT * INTO OUTFILE '/tmp/t2.csv' FROM t1;\n");
|
||||
Test->try_query(Test->conn_master, (char *) "SELECT * INTO OUTFILE '/tmp/t2.csv' FROM t1;");
|
||||
Test->try_query(Test->maxscales->conn_master[0], (char *) "SELECT * INTO OUTFILE '/tmp/t2.csv' FROM t1;");
|
||||
Test->tprintf("using ReadConn slave: SELECT * INTO OUTFILE '/tmp/t3.csv' FROM t1;\n");
|
||||
Test->try_query(Test->conn_slave, (char *) "SELECT * INTO OUTFILE '/tmp/t3.csv' FROM t1;");
|
||||
Test->try_query(Test->maxscales->conn_slave[0], (char *) "SELECT * INTO OUTFILE '/tmp/t3.csv' FROM t1;");
|
||||
|
||||
Test->tprintf("Copying t1.cvs from Maxscale machine:\n");
|
||||
Test->repl->copy_from_node("/tmp/t1.csv", "./t1.csv", 0);
|
||||
Test->repl->copy_from_node_legacy("/tmp/t1.csv", "./t1.csv", 0);
|
||||
|
||||
MYSQL *srv[2];
|
||||
|
||||
srv[0] = Test->conn_rwsplit;
|
||||
srv[1] = Test->conn_master;
|
||||
srv[0] = Test->maxscales->conn_rwsplit[0];
|
||||
srv[1] = Test->maxscales->conn_master[0];
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
Test->set_timeout(100);
|
||||
Test->tprintf("Dropping t1 \n");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "DROP TABLE t1;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "DROP TABLE t1;");
|
||||
Test->stop_timeout();
|
||||
Test->repl->sync_slaves();
|
||||
|
||||
Test->set_timeout(200);
|
||||
Test->tprintf("Create t1\n");
|
||||
create_t1(Test->conn_rwsplit);
|
||||
create_t1(Test->maxscales->conn_rwsplit[0]);
|
||||
Test->tprintf("Loading data to t1 from file\n");
|
||||
Test->try_query(srv[i], (char *) "LOAD DATA LOCAL INFILE 't1.csv' INTO TABLE t1;");
|
||||
Test->stop_timeout();
|
||||
@ -127,15 +130,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(100);
|
||||
Test->tprintf("SELECT: rwsplitter\n");
|
||||
Test->add_result(select_from_t1(Test->conn_rwsplit, N), "Wrong data in 't1'");
|
||||
Test->add_result(select_from_t1(Test->maxscales->conn_rwsplit[0], N), "Wrong data in 't1'");
|
||||
Test->tprintf("SELECT: master\n");
|
||||
Test->add_result(select_from_t1(Test->conn_master, N), "Wrong data in 't1'");
|
||||
Test->add_result(select_from_t1(Test->maxscales->conn_master[0], N), "Wrong data in 't1'");
|
||||
Test->tprintf("SELECT: slave\n");
|
||||
Test->add_result(select_from_t1(Test->conn_slave, N), "Wrong data in 't1'");
|
||||
Test->add_result(select_from_t1(Test->maxscales->conn_slave[0], N), "Wrong data in 't1'");
|
||||
}
|
||||
|
||||
Test->repl->close_connections();
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -42,25 +42,25 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(20);
|
||||
|
||||
if (Test->connect_rwsplit() == 0)
|
||||
if (Test->maxscales->connect_rwsplit(0) == 0)
|
||||
{
|
||||
Test->add_result(1, "Filter config is broken, but service is started\n");
|
||||
}
|
||||
if (Test->connect_readconn_master() == 0)
|
||||
if (Test->maxscales->connect_readconn_master(0) == 0)
|
||||
{
|
||||
Test->add_result(1, "Filter config is broken, but Maxscale is started\n");
|
||||
}
|
||||
if (Test->connect_readconn_slave() == 0)
|
||||
if (Test->maxscales->connect_readconn_slave(0) == 0)
|
||||
{
|
||||
Test->add_result(1, "Filter config is broken, but Maxscale is started\n");
|
||||
}
|
||||
|
||||
//sleep(5);
|
||||
Test->execute_maxadmin_command((char*) "sync logs");
|
||||
Test->check_log_err((char *) "Unable to find library for module: foobar", true);
|
||||
Test->check_log_err((char *) "Failed to load filter module 'foobar'", true);
|
||||
Test->check_log_err((char *) "Failed to load filter 'testfilter' for service 'RW Split Router'", true);
|
||||
Test->check_log_err((char *)
|
||||
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;
|
||||
|
@ -149,7 +149,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->repl->connect();
|
||||
|
||||
conn = Test->open_rwsplit_connection();
|
||||
conn = Test->maxscales->open_rwsplit_connection(0);
|
||||
execute_query(conn, (char *) "USE test;");
|
||||
create_t1(conn);
|
||||
mysql_close(conn);
|
||||
@ -158,9 +158,9 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < conn_N; i++)
|
||||
{
|
||||
Test->set_timeout(60);
|
||||
rwsplit_conn[i] = Test->open_rwsplit_connection();
|
||||
master_conn[i] = Test->open_readconn_master_connection();
|
||||
slave_conn[i] = Test->open_readconn_slave_connection();
|
||||
rwsplit_conn[i] = Test->maxscales->open_rwsplit_connection(0);
|
||||
master_conn[i] = Test->maxscales->open_readconn_master_connection(0);
|
||||
slave_conn[i] = Test->maxscales->open_readconn_slave_connection(0);
|
||||
sprintf(sql, "INSERT INTO t1 (x1, fl) VALUES(%d, 1);", i);
|
||||
execute_query(rwsplit_conn[i], sql);
|
||||
sprintf(sql, "INSERT INTO t1 (x1, fl) VALUES(%d, 2);", i);
|
||||
@ -171,7 +171,7 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
Test->set_timeout(60);
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscale_IP, Test->maxscale_hostname, (char *) "test");
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0], (char *) "test");
|
||||
Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn);
|
||||
if ((i == 0) && (num_conn > 2 * conn_N))
|
||||
{
|
||||
@ -189,7 +189,7 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
Test->set_timeout(60);
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscale_IP, Test->maxscale_hostname, (char *) "test");
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0], (char *) "test");
|
||||
printf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn);
|
||||
if ((i == 0) && (num_conn > 2 * conn_N))
|
||||
{
|
||||
@ -203,7 +203,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscale_IP, Test->maxscale_hostname, (char *) "test");
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0], (char *) "test");
|
||||
printf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn);
|
||||
if ((i == 0) && (num_conn > 2 * conn_N))
|
||||
{
|
||||
@ -218,7 +218,7 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
Test->set_timeout(60);
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscale_IP, Test->maxscale_hostname, (char *) "test");
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0], (char *) "test");
|
||||
printf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn);
|
||||
if ((i == 0) && (num_conn != 0))
|
||||
{
|
||||
@ -235,7 +235,7 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
Test->set_timeout(60);
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscale_IP, Test->maxscale_hostname, (char *) "test");
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0], (char *) "test");
|
||||
Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn);
|
||||
if ((i == 0) && (num_conn != 0))
|
||||
{
|
||||
@ -247,7 +247,7 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < conn_N; i++)
|
||||
{
|
||||
Test->set_timeout(60);
|
||||
slave_conn[i] = Test->open_readconn_slave_connection();
|
||||
slave_conn[i] = Test->maxscales->open_readconn_slave_connection(0);
|
||||
sprintf(sql, "SELECT * FROM t1");
|
||||
execute_query(slave_conn[i], sql);
|
||||
fflush(stdout);
|
||||
@ -256,7 +256,7 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
Test->set_timeout(60);
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscale_IP, Test->maxscale_hostname, (char *) "test");
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0], (char *) "test");
|
||||
Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn);
|
||||
if ((i == 0) && (num_conn != 0))
|
||||
{
|
||||
@ -275,7 +275,7 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
Test->set_timeout(60);
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscale_IP, Test->maxscale_hostname, (char *) "test");
|
||||
num_conn = get_conn_num(Test->repl->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0], (char *) "test");
|
||||
Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn);
|
||||
if ((i == 0) && (num_conn != 0))
|
||||
{
|
||||
@ -295,7 +295,7 @@ void *parall_traffic( void *ptr )
|
||||
int i;
|
||||
for (i = 0; i < conn_N; i++)
|
||||
{
|
||||
slave_conn1[i] = Test->open_readconn_slave_connection();
|
||||
slave_conn1[i] = Test->maxscales->open_readconn_slave_connection(0);
|
||||
execute_query(slave_conn1[i], "SELECT * FROM t1");
|
||||
}
|
||||
|
||||
|
@ -21,35 +21,32 @@ int main(int argc, char *argv[])
|
||||
int N_cmd = 2;
|
||||
char * fail_cmd[N_cmd - 1];
|
||||
|
||||
int N_ports = 3;
|
||||
int ports[N_ports];
|
||||
|
||||
|
||||
|
||||
fail_cmd[0] = (char *) "fail backendfd";
|
||||
fail_cmd[1] = (char *) "fail clientfd";
|
||||
|
||||
ports[0] = Test->rwsplit_port;
|
||||
ports[1] = Test->readconn_master_port;
|
||||
ports[2] = Test->readconn_slave_port;
|
||||
|
||||
for (i = 0; i < N_cmd; i++)
|
||||
{
|
||||
for (j = 0; j < N_ports; j++)
|
||||
for (j = 0; j < Test->maxscales->N_ports[0]; j++)
|
||||
{
|
||||
Test->tprintf("Executing MaxAdmin command '%s'\n", fail_cmd[i]);
|
||||
if (execute_maxadmin_command(Test->maxscale_IP, (char *) "admin", Test->maxadmin_password, fail_cmd[i]) != 0)
|
||||
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", ports[j]);
|
||||
conn = open_conn(ports[j], Test->maxscale_IP, Test->maxscale_user, Test->maxscale_user, Test->ssl);
|
||||
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();
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -39,27 +39,27 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->tprintf("Connecting to all MaxScale services, expecting error\n");
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->tprintf("Trying some queries, expecting failure, but not a crash\n");
|
||||
execute_query(Test->conn_rwsplit, "DROP TABLE IF EXISTS t1");
|
||||
execute_query(Test->conn_rwsplit, "CREATE TABLE t1 (x INT)");
|
||||
execute_query(Test->conn_rwsplit, "INSERT INTO t1 (x) VALUES (1)");
|
||||
execute_query(Test->conn_rwsplit, "select * from t1");
|
||||
execute_query(Test->conn_master, "select * from t1");
|
||||
execute_query(Test->conn_slave, "select * from t1");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "DROP TABLE IF EXISTS t1");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "CREATE TABLE t1 (x INT)");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "INSERT INTO t1 (x) VALUES (1)");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "select * from t1");
|
||||
execute_query(Test->maxscales->conn_master[0], "select * from t1");
|
||||
execute_query(Test->maxscales->conn_slave[0], "select * from t1");
|
||||
|
||||
Test->set_timeout(10);
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->repl->unblock_all_nodes();
|
||||
|
||||
Test->stop_timeout();
|
||||
sleep(15);
|
||||
Test->check_log_err("fatal signal 11", false);
|
||||
Test->check_log_err("Failed to create new router session for service", true);
|
||||
Test->check_log_err(0, "fatal signal 11", false);
|
||||
Test->check_log_err(0, "Failed to create new router session for service", true);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -62,19 +62,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
Test->repl->connect();
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
conn_found_rows = open_conn_db_flags(Test->rwsplit_port, Test->maxscale_IP, (char *) "test",
|
||||
Test->maxscale_user, Test->maxscale_password, CLIENT_FOUND_ROWS, Test->ssl);
|
||||
conn_found_rows = open_conn_db_flags(Test->maxscales->rwsplit_port[0], Test->maxscales->IP[0], (char *) "test",
|
||||
Test->maxscales->user_name, Test->maxscales->password, CLIENT_FOUND_ROWS, Test->ssl);
|
||||
|
||||
Test->set_timeout(30);
|
||||
execute_query(Test->conn_rwsplit, "DROP TABLE IF EXISTS t1");
|
||||
execute_query(Test->conn_rwsplit, "CREATE TABLE t1(id INT PRIMARY KEY, val INT, msg VARCHAR(100))");
|
||||
execute_query(Test->conn_rwsplit,
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "DROP TABLE IF EXISTS t1");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "CREATE TABLE t1(id INT PRIMARY KEY, val INT, msg VARCHAR(100))");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0],
|
||||
"INSERT INTO t1 VALUES (1, 1, 'foo'), (2, 1, 'bar'), (3, 2, 'baz'), (4, 2, 'abc')");
|
||||
|
||||
Test->set_timeout(30);
|
||||
execute_query_affected_rows(Test->conn_rwsplit, "UPDATE t1 SET msg='xyz' WHERE val=2", &rows);
|
||||
execute_query_affected_rows(Test->maxscales->conn_rwsplit[0], "UPDATE t1 SET msg='xyz' WHERE val=2", &rows);
|
||||
Test->tprintf("update #1: %ld (expeced value is 2)\n", (long) rows);
|
||||
if (rows != 2)
|
||||
{
|
||||
@ -82,7 +82,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
Test->set_timeout(30);
|
||||
execute_query_affected_rows(Test->conn_rwsplit, "UPDATE t1 SET msg='xyz' WHERE val=2", &rows);
|
||||
execute_query_affected_rows(Test->maxscales->conn_rwsplit[0], "UPDATE t1 SET msg='xyz' WHERE val=2", &rows);
|
||||
Test->tprintf("update #2: %ld (expeced value is 0)\n", (long) rows);
|
||||
if (rows != 0)
|
||||
{
|
||||
@ -97,7 +97,7 @@ int main(int argc, char *argv[])
|
||||
Test->add_result(1, "Affected rows is not 2\n");
|
||||
}
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -124,17 +124,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->tprintf("Connecting to all MaxScale services\n");
|
||||
Test->set_timeout(10);
|
||||
Test->add_result(Test->connect_maxscale(), "Error connectiong to Maxscale\n");
|
||||
Test->add_result(Test->maxscales->connect_maxscale(0), "Error connectiong to Maxscale\n");
|
||||
|
||||
Test->tprintf("executing fetch * from mysql.user \n");
|
||||
Test->set_timeout(10);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "fetch * from mysql.user;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "fetch * from mysql.user;");
|
||||
Test->set_timeout(10);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "fetch count(*) form mysql.user;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "fetch count(*) form mysql.user;");
|
||||
|
||||
Test->set_timeout(10);
|
||||
Test->close_maxscale_connections();
|
||||
Test->check_maxscale_alive();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -32,13 +32,13 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->repl->connect();
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->tprintf("Trying GRANT for with bad IP: RWSplit\n");
|
||||
create_drop_bad_user(Test->conn_rwsplit, Test);
|
||||
create_drop_bad_user(Test->maxscales->conn_rwsplit[0], Test);
|
||||
|
||||
Test->tprintf("Trying SELECT to check if Maxscale hangs\n");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "select * from mysql.user");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "select * from mysql.user");
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -72,7 +72,7 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
Test->repl->connect();
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
char server_id[256];
|
||||
char server_id_d[256];
|
||||
@ -87,7 +87,7 @@ int main(int argc, char *argv[])
|
||||
sprintf(hint_sql, "select @@server_id; -- maxscale route to server server%d", j + 1);
|
||||
Test->tprintf("%s\n", hint_sql);
|
||||
|
||||
find_field(Test->conn_rwsplit, hint_sql, (char *) "@@server_id", &server_id[0]);
|
||||
find_field(Test->maxscales->conn_rwsplit[0], hint_sql, (char *) "@@server_id", &server_id[0]);
|
||||
find_field(Test->repl->nodes[j], (char *) "select @@server_id;", (char *) "@@server_id", &server_id_d[0]);
|
||||
|
||||
Test->tprintf("server%d ID from Maxscale: \t%s\n", j + 1, server_id);
|
||||
@ -97,10 +97,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->repl->close_connections();
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -95,16 +95,16 @@ int main(int argc, char *argv[])
|
||||
int i;
|
||||
|
||||
Test->repl->connect();
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
for (i = 1; i < Test->repl->N; i++)
|
||||
{
|
||||
execute_query(Test->repl->nodes[i], (char *) "stop slave;");
|
||||
}
|
||||
|
||||
execute_query(Test->conn_rwsplit, (char *) "CREATE USER 'test_user'@'%%' IDENTIFIED BY 'pass'");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], (char *) "CREATE USER 'test_user'@'%%' IDENTIFIED BY 'pass'");
|
||||
|
||||
MYSQL * conn = open_conn_no_db(Test->rwsplit_port, Test->maxscale_IP, (char *) "test_user", (char *) "pass",
|
||||
MYSQL * conn = open_conn_no_db(Test->maxscales->rwsplit_port[0], Test->maxscales->IP[0], (char *) "test_user", (char *) "pass",
|
||||
Test->ssl);
|
||||
|
||||
if (conn == NULL)
|
||||
@ -117,10 +117,10 @@ int main(int argc, char *argv[])
|
||||
execute_query(Test->repl->nodes[i], (char *) "start slave;");
|
||||
}
|
||||
|
||||
execute_query(Test->conn_rwsplit, (char *) "DROP USER 'test_user'@'%%'");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], (char *) "DROP USER 'test_user'@'%%'");
|
||||
|
||||
Test->repl->close_connections();
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -64,12 +64,12 @@ int main(int argc, char *argv[])
|
||||
Test->repl->execute_query_all_nodes((char *) "set global max_connect_errors=1000;");
|
||||
Test->repl->execute_query_all_nodes((char *) "set global max_connections=1000;");
|
||||
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->tprintf("Creating one user 'user@%%'");
|
||||
execute_query_silent(Test->conn_rwsplit, (char *) "DROP USER user@'%'");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "CREATE USER user@'%%' identified by 'pass2'");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "GRANT SELECT ON test.* TO user@'%%';");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "FLUSH PRIVILEGES;");
|
||||
execute_query_silent(Test->maxscales->conn_rwsplit[0], (char *) "DROP USER user@'%'");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "CREATE USER user@'%%' identified by 'pass2'");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "GRANT SELECT ON test.* TO user@'%%';");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "FLUSH PRIVILEGES;");
|
||||
|
||||
Test->tprintf("Starting parallel thread which opens/closes session in the loop");
|
||||
|
||||
@ -82,10 +82,10 @@ int main(int argc, char *argv[])
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
Test->set_timeout(15);
|
||||
Test->add_result(mysql_change_user(Test->conn_rwsplit, "user", "pass2", (char *) "test"),
|
||||
"change_user failed! %", mysql_error(Test->conn_rwsplit));
|
||||
Test->add_result(mysql_change_user(Test->conn_rwsplit, Test->maxscale_user, Test->maxscale_password,
|
||||
(char *) "test"), "change_user failed! %s", mysql_error(Test->conn_rwsplit));
|
||||
Test->add_result(mysql_change_user(Test->maxscales->conn_rwsplit[0], "user", "pass2", (char *) "test"),
|
||||
"change_user failed! %", mysql_error(Test->maxscales->conn_rwsplit[0]));
|
||||
Test->add_result(mysql_change_user(Test->maxscales->conn_rwsplit[0], Test->maxscales->user_name, Test->maxscales->password,
|
||||
(char *) "test"), "change_user failed! %s", mysql_error(Test->maxscales->conn_rwsplit[0]));
|
||||
}
|
||||
|
||||
Test->tprintf("Waiting for all threads to finish");
|
||||
@ -98,13 +98,13 @@ int main(int argc, char *argv[])
|
||||
Test->tprintf("All threads are finished");
|
||||
Test->repl->flush_hosts();
|
||||
|
||||
Test->tprintf("Change user to '%s' in order to be able to DROP user", Test->maxscale_user);
|
||||
Test->tprintf("Change user to '%s' in order to be able to DROP user", Test->maxscales->user_name);
|
||||
Test->set_timeout(30);
|
||||
mysql_change_user(Test->conn_rwsplit, Test->maxscale_user, Test->maxscale_password, NULL);
|
||||
mysql_change_user(Test->maxscales->conn_rwsplit[0], Test->maxscales->user_name, Test->maxscales->password, NULL);
|
||||
|
||||
Test->tprintf("Dropping user", Test->maxscale_user);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "DROP USER user@'%%';");
|
||||
Test->check_maxscale_alive();
|
||||
Test->tprintf("Dropping user", Test->maxscales->user_name);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "DROP USER user@'%%';");
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
@ -116,7 +116,7 @@ void *parall_traffic( void *ptr )
|
||||
MYSQL * conn;
|
||||
while (exit_flag == 0)
|
||||
{
|
||||
conn = Test->open_rwsplit_connection();
|
||||
conn = Test->maxscales->open_rwsplit_connection(0);
|
||||
mysql_close(conn);
|
||||
if (Test->backend_ssl)
|
||||
{
|
||||
|
@ -221,21 +221,21 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(30);
|
||||
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->tprintf("Creating 'root'@'%%'\n");
|
||||
//global_result += execute_query(Test->conn_rwsplit, (char *) "CREATE USER 'root'@'%'; SET PASSWORD FOR 'root'@'%' = PASSWORD('skysqlroot');");
|
||||
//global_result += execute_query(Test->maxscales->conn_rwsplit[0], (char *) "CREATE USER 'root'@'%'; SET PASSWORD FOR 'root'@'%' = PASSWORD('skysqlroot');");
|
||||
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%%' IDENTIFIED BY 'skysqlroot';");
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'skysqlroot';");
|
||||
sleep(10);
|
||||
|
||||
MYSQL * conn;
|
||||
|
||||
Test->tprintf("Connecting using 'root'@'%%'\n");
|
||||
conn = open_conn(Test->rwsplit_port, Test->maxscale_IP, (char *) "root", (char *) "skysqlroot", Test->ssl);
|
||||
conn = open_conn(Test->maxscales->rwsplit_port[0], Test->maxscales->IP[0], (char *) "root", (char *) "skysqlroot", Test->ssl);
|
||||
if (mysql_errno(conn) != 0)
|
||||
{
|
||||
Test->add_result(1, "Connection using 'root' user failed, error: %s\n", mysql_error(conn));
|
||||
@ -253,15 +253,15 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
Test->tprintf("Dropping 'root'@'%%'\n");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "DROP USER 'root'@'%%';");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "DROP USER 'root'@'%%';");
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->check_log_err((char *) "Failed to add user skysql", false);
|
||||
Test->check_log_err((char *) "getaddrinfo failed", false);
|
||||
Test->check_log_err((char *) "Couldn't find suitable Master", false);
|
||||
Test->check_log_err(0, (char *) "Failed to add user skysql", false);
|
||||
Test->check_log_err(0, (char *) "getaddrinfo failed", false);
|
||||
Test->check_log_err(0, (char *) "Couldn't find suitable Master", false);
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -154,7 +154,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(20);
|
||||
printf("Trying to connect using user with old style password\n");
|
||||
MYSQL * conn = open_conn(Test->rwsplit_port, Test->maxscale_IP, (char *) "old", (char *) "old", Test->ssl);
|
||||
MYSQL * conn = open_conn(Test->maxscales->rwsplit_port[0], Test->maxscales->IP[0], (char *) "old", (char *) "old", Test->ssl);
|
||||
|
||||
if ( mysql_errno(conn) != 0)
|
||||
{
|
||||
@ -171,8 +171,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
execute_query(Test->repl->nodes[0], "DROP USER 'old'@'%%'");
|
||||
|
||||
Test->check_log_err((char *) "MaxScale does not support these old passwords", true);
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_log_err(0, (char *) "MaxScale does not support these old passwords", true);
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -25,17 +25,17 @@ int main(int argc, char *argv[])
|
||||
|
||||
char master_ip[100];
|
||||
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
Test->add_result(find_field(Test->conn_rwsplit, (char *) "SHOW SLAVE STATUS", (char *) "Master_Host",
|
||||
Test->add_result(find_field(Test->maxscales->conn_rwsplit[0], (char *) "SHOW SLAVE STATUS", (char *) "Master_Host",
|
||||
master_ip), "Master_host files is not found in the SHOW SLAVE STATUS reply, probably query went to master\n");
|
||||
Test->add_result(strcmp(master_ip, Test->repl->IP_private[0]), "Master IP is wrong\n");
|
||||
}
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -32,21 +32,21 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->tprintf("Trying to connect to all Maxscale services\n");
|
||||
fflush(stdout);
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->tprintf("Trying to send query to ReadConn master\n");
|
||||
fflush(stdout);
|
||||
Test->try_query(Test->conn_master, (char *) "show processlist");
|
||||
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->conn_slave, (char *) "show processlist");
|
||||
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->conn_rwsplit, (char *) "show processlist") == 0)
|
||||
if (execute_query(Test->maxscales->conn_rwsplit[0], (char *) "show processlist") == 0)
|
||||
{
|
||||
Test->add_result(1, "FAIL: Query to broken service succeeded!\n");
|
||||
}
|
||||
Test->close_maxscale_connections();
|
||||
Test->check_log_err("Recursive use of tee filter in service", true);
|
||||
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;
|
||||
|
@ -75,19 +75,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->tprintf("Trying to connect to all Maxscale services\n");
|
||||
fflush(stdout);
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->tprintf("Trying to send query to RWSplit\n");
|
||||
fflush(stdout);
|
||||
execute_query(Test->conn_rwsplit, (char *) "show processlist");
|
||||
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->conn_master, (char *) "show processlist");
|
||||
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->conn_slave, (char *) "show processlist");
|
||||
Test->close_maxscale_connections();
|
||||
execute_query(Test->maxscales->conn_slave[0], (char *) "show processlist");
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->check_log_err((char *) "Unable to find filter 'tests' for service 'RW Split2'", true);
|
||||
Test->check_log_err(0, (char *) "Unable to find filter 'tests' for service 'RW Split2'", true);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -182,7 +182,7 @@ Comment 3 Vilho Raatikka 2014-12-11 16:35:46 UTC
|
||||
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 routers, like in the case of readconnrouter->tee->readwritesplit.
|
||||
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:
|
||||
@ -199,13 +199,13 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->connect_maxscale();
|
||||
Test->try_query(Test->conn_master, (char *) "show processlist");
|
||||
Test->try_query(Test->conn_slave, (char *) "show processlist");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "show processlist");
|
||||
Test->close_maxscale_connections();
|
||||
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();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -11,7 +11,7 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
test.check_maxscale_alive();
|
||||
test.check_log_err( "Couldn't find suitable Master from 2 candidates", true);
|
||||
test.check_maxscale_alive(0);
|
||||
test.check_log_err(0, "Couldn't find suitable Master from 2 candidates", true);
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -53,14 +53,22 @@ int main(int argc, char *argv[])
|
||||
int check_iret[threads_num];
|
||||
|
||||
Test = new TestConnections(argc, argv);
|
||||
int time_to_run = 10;
|
||||
Test->set_timeout(60);
|
||||
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();
|
||||
create_t1(Test->repl->nodes[0]);
|
||||
Test->repl->sync_slaves();
|
||||
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++)
|
||||
@ -82,7 +90,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->tprintf("Trying query to RWSplit, expecting failure, but not a crash\n");
|
||||
Test->add_result(execute_query(Test->conn_rwsplit, "show processlist;") == 0, "Query should fail");
|
||||
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);
|
||||
@ -95,14 +110,23 @@ int main(int argc, char *argv[])
|
||||
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();
|
||||
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 t1;");
|
||||
execute_query(Test->repl->nodes[0], "DROP TABLE IF EXISTS t1;");
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
@ -114,7 +138,7 @@ void *parall_traffic( void *ptr )
|
||||
{
|
||||
MYSQL * conn;
|
||||
mysql_thread_init();
|
||||
conn = Test->open_rwsplit_connection();
|
||||
conn = Test->maxscales->open_rwsplit_connection(0);
|
||||
if ((conn != NULL) && (mysql_errno(conn) == 0))
|
||||
{
|
||||
while (exit_flag == 0)
|
||||
|
@ -9,8 +9,8 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
test.check_maxscale_alive();
|
||||
test.check_log_err( "Couldn't find suitable Master from 2 candidates", true);
|
||||
test.check_log_err( "Failed to create new router session for service 'RW_Split'", true);
|
||||
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;
|
||||
}
|
||||
|
@ -42,17 +42,17 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(50);
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->tprintf("Creating user with old style password\n");
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "CREATE USER 'user_long_host11'@'very_long_hostname_that_probably_caused_crashhh.com.net.org' IDENTIFIED BY 'old'");
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "GRANT ALL PRIVILEGES ON *.* TO 'user_long_host11'@'very_long_hostname_that_probably_caused_crashhh.com.net.org' WITH GRANT OPTION");
|
||||
sleep(10);
|
||||
|
||||
Test->tprintf("Trying to connect using user with old style password\n");
|
||||
MYSQL * conn = open_conn(Test->rwsplit_port, Test->maxscale_IP, (char *) "user_long_host11", (char *) "old",
|
||||
MYSQL * conn = open_conn(Test->maxscales->rwsplit_port[0], Test->maxscales->IP[0], (char *) "user_long_host11", (char *) "old",
|
||||
Test->ssl);
|
||||
|
||||
if ( mysql_errno(conn) != 0 )
|
||||
@ -68,11 +68,11 @@ int main(int argc, char *argv[])
|
||||
mysql_close(conn);
|
||||
}
|
||||
|
||||
Test->try_query(Test->conn_rwsplit,
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0],
|
||||
(char *) "DROP USER 'user_long_host11'@'very_long_hostname_that_probably_caused_crashhh.com.net.org'");
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -62,7 +62,7 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(30);
|
||||
char result[1024];
|
||||
|
||||
Test->get_maxadmin_param((char *) "show dbusers RW Split Router", (char *) "Incorrect number of arguments:",
|
||||
Test->maxscales->get_maxadmin_param(0, (char *) "show dbusers RW Split Router", (char *) "Incorrect number of arguments:",
|
||||
result);
|
||||
Test->tprintf("result %s\n", result);
|
||||
|
||||
@ -71,57 +71,57 @@ int main(int argc, char *argv[])
|
||||
Test->add_result(1, "there is NO \"show dbusers expects 1 argument\" message");
|
||||
}
|
||||
Test->set_timeout(30);
|
||||
Test->get_maxadmin_param((char *) "show dbusers \"RW Split Router\"", (char *) "User names:", result);
|
||||
Test->maxscales->get_maxadmin_param(0, (char *) "show dbusers \"RW Split Router\"", (char *) "User names:", result);
|
||||
Test->tprintf("result %s\n", result);
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "reload dbusers 0x232fed0");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "reload dbusers 0x232fed0");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "reload dbusers Хрен");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "reload dbusers Хрен");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "reload dbusers Хрен моржовый");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "reload dbusers Хрен моржовый");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "Хрен моржовый");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "Хрен моржовый");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "khren morzhovyj");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "khren morzhovyj");
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show Хрен");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show Хрен");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show Хрен моржовый");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show Хрен моржовый");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show khren morzhovyj");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show khren morzhovyj");
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show dcb Хрен");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show dcb Хрен");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show dcb Хрен моржовый");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show dcb Хрен моржовый");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show dcb khren morzhovyj");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show dcb khren morzhovyj");
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show server Хрен");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show server Хрен");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show server Хрен моржовый");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show server Хрен моржовый");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show server khren morzhovyj");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show server khren morzhovyj");
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show service Хрен");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show service Хрен");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show service Хрен моржовый");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show service Хрен моржовый");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show service khren morzhovyj");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show service khren morzhovyj");
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "show service khren morzhovyj");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "show service khren morzhovyj");
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "list listeners");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "list listeners");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "restart monitor");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "restart monitor");
|
||||
Test->set_timeout(30);
|
||||
Test->execute_maxadmin_command((char *) "restart service");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "restart service");
|
||||
|
||||
if (!Test->smoke)
|
||||
{
|
||||
@ -186,15 +186,15 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(30);
|
||||
sprintf(str1, "%s %s", cmd[i1], garbage[i2]);
|
||||
Test->tprintf("Trying '%s'\n", str1);
|
||||
Test->execute_maxadmin_command(str1);
|
||||
Test->maxscales->execute_maxadmin_command(0, str1);
|
||||
|
||||
sprintf(str1, "%s %s%s%s%s %s ", cmd[i1], garbage[i2], garbage[i2], garbage[i2], garbage[i2], garbage[i2]);
|
||||
Test->tprintf("Trying '%s'\n", str1);
|
||||
Test->execute_maxadmin_command(str1);
|
||||
Test->maxscales->execute_maxadmin_command(0, str1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -15,24 +15,24 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(30);
|
||||
|
||||
Test->tprintf("Connecting to RWSplit %s\n", Test->maxscale_IP);
|
||||
Test->connect_rwsplit();
|
||||
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->conn_rwsplit, (char *) "show processlist;");
|
||||
execute_maxadmin_command_print(Test->maxscale_IP, (char *) "admin", Test->maxadmin_password,
|
||||
//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->close_rwsplit();
|
||||
Test->maxscales->close_rwsplit(0);
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -49,8 +49,8 @@ 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->maxscale_IP);
|
||||
Test->connect_readconn_master();
|
||||
Test->tprintf("Connecting to ReadConn Master %s\n", Test->maxscales->IP[0]);
|
||||
Test->maxscales->connect_readconn_master(0);
|
||||
|
||||
sleep(1);
|
||||
|
||||
@ -60,8 +60,8 @@ int main(int argc, char *argv[])
|
||||
sleep(10);
|
||||
|
||||
Test->tprintf("Reconnecting to ReadConnMaster\n");
|
||||
Test->close_readconn_master();
|
||||
Test->connect_readconn_master();
|
||||
Test->maxscales->close_readconn_master(0);
|
||||
Test->maxscales->connect_readconn_master(0);
|
||||
|
||||
sleep(5);
|
||||
|
||||
@ -70,12 +70,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->tprintf("Closing connection\n");
|
||||
|
||||
Test->close_readconn_master();
|
||||
Test->maxscales->close_readconn_master(0);
|
||||
fflush(stdout);
|
||||
|
||||
Test->tprintf("Checking Maxscale is alive\n");
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -31,8 +31,8 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(40);
|
||||
int i;
|
||||
|
||||
Test->tprintf("Connecting to Maxscale %s\n", Test->maxscale_IP);
|
||||
Test->connect_maxscale();
|
||||
Test->tprintf("Connecting to Maxscale %s\n", Test->maxscales->IP[0]);
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
printf("Setup firewall to block mysql on master\n");
|
||||
fflush(stdout);
|
||||
@ -41,13 +41,13 @@ int main(int argc, char *argv[])
|
||||
sleep(1);
|
||||
|
||||
Test->tprintf("Trying query to RWSplit, expecting failure, but not a crash\n");
|
||||
execute_query(Test->conn_rwsplit, (char *) "show processlist;");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], (char *) "show processlist;");
|
||||
fflush(stdout);
|
||||
Test->tprintf("Trying query to ReadConn master, expecting failure, but not a crash\n");
|
||||
execute_query(Test->conn_master, (char *) "show processlist;");
|
||||
execute_query(Test->maxscales->conn_master[0], (char *) "show processlist;");
|
||||
fflush(stdout);
|
||||
Test->tprintf("Trying query to ReadConn slave, expecting failure, but not a crash\n");
|
||||
execute_query(Test->conn_slave, (char *) "show processlist;");
|
||||
execute_query(Test->maxscales->conn_slave[0], (char *) "show processlist;");
|
||||
fflush(stdout);
|
||||
|
||||
sleep(1);
|
||||
@ -55,16 +55,16 @@ int main(int argc, char *argv[])
|
||||
Test->repl->unblock_node(0);
|
||||
sleep(10);
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->tprintf("Checking Maxscale is alive\n");
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
Test->set_timeout(20);
|
||||
|
||||
Test->tprintf("Connecting to Maxscale %s to check its behaviour in case of blocking all bacxkends\n",
|
||||
Test->maxscale_IP);
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->IP[0]);
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
if (!Test->smoke)
|
||||
{
|
||||
@ -77,13 +77,13 @@ int main(int argc, char *argv[])
|
||||
sleep(1);
|
||||
|
||||
Test->tprintf("Trying query to RWSplit, expecting failure, but not a crash\n");
|
||||
execute_query(Test->conn_rwsplit, (char *) "show processlist;");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], (char *) "show processlist;");
|
||||
fflush(stdout);
|
||||
Test->tprintf("Trying query to ReadConn master, expecting failure, but not a crash\n");
|
||||
execute_query(Test->conn_master, (char *) "show processlist;");
|
||||
execute_query(Test->maxscales->conn_master[0], (char *) "show processlist;");
|
||||
fflush(stdout);
|
||||
Test->tprintf("Trying query to ReadConn slave, expecting failure, but not a crash\n");
|
||||
execute_query(Test->conn_slave, (char *) "show processlist;");
|
||||
execute_query(Test->maxscales->conn_slave[0], (char *) "show processlist;");
|
||||
fflush(stdout);
|
||||
|
||||
sleep(1);
|
||||
@ -101,9 +101,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(20);
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->tprintf("Checking Maxscale is alive\n");
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -15,11 +15,11 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
int i;
|
||||
|
||||
Test->tprintf("Connecting to Maxscale %s\n", Test->maxscale_IP);
|
||||
Test->tprintf("Connecting to Maxscale %s\n", Test->maxscales->IP[0]);
|
||||
|
||||
Test->tprintf("Connecting to Maxscale %s to check its behaviour in case of blocking all backends\n",
|
||||
Test->maxscale_IP);
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->IP[0]);
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
@ -31,10 +31,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(200);
|
||||
Test->tprintf("Restarting MaxScale");
|
||||
Test->restart_maxscale();
|
||||
Test->maxscales->restart_maxscale(0);
|
||||
|
||||
Test->tprintf("Checking if MaxScale is alive by connecting to MaxAdmin\n");
|
||||
Test->add_result(Test->execute_maxadmin_command((char* ) "show servers"), "Maxadmin execution failed.\n");
|
||||
Test->add_result(Test->maxscales->execute_maxadmin_command(0, (char* ) "show servers"), "Maxadmin execution failed.\n");
|
||||
|
||||
for (i = 0; i < Test->repl->N; i++)
|
||||
{
|
||||
@ -50,7 +50,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Test->set_timeout(30);
|
||||
Test->tprintf("Checking Maxscale is alive\n");
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -11,7 +11,7 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
test.check_maxscale_alive();
|
||||
test.check_log_err("Failed to create new router session for service 'RW_Split'", true);
|
||||
test.check_maxscale_alive(0);
|
||||
test.check_log_err(0, "Failed to create new router session for service 'RW_Split'", true);
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ 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 routers 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.
|
||||
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
|
||||
@ -233,33 +233,33 @@ int main(int argc, char *argv[])
|
||||
int i;
|
||||
|
||||
Test->tprintf("Connecting to all MaxScale services\n");
|
||||
Test->add_result(Test->connect_maxscale(), "Error connecting to Maxscale\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->conn_slave, bug670_sql);
|
||||
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->conn_master, bug670_sql);
|
||||
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->conn_rwsplit, bug670_sql);
|
||||
execute_query_silent(Test->maxscales->conn_rwsplit[0], bug670_sql);
|
||||
}
|
||||
|
||||
Test->set_timeout(10);
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -18,9 +18,9 @@ int main(int argc, char *argv[])
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
char result[1024];
|
||||
test.add_result(test.get_maxadmin_param("show dbusers \"RW Split Router\"", "User names:", result) == 0,
|
||||
test.add_result(test.maxscales->get_maxadmin_param(0, "show dbusers \"RW Split Router\"", "User names:", result) == 0,
|
||||
"Old style objects in maxadmin commands should fail");
|
||||
test.add_result(test.get_maxadmin_param("show dbusers RW-Split-Router", "User names:", result),
|
||||
test.add_result(test.maxscales->get_maxadmin_param(0, "show dbusers RW-Split-Router", "User names:", result),
|
||||
"New style objects in maxadmin commands should succeed");
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
test.set_timeout(30);
|
||||
|
||||
test.connect_maxscale();
|
||||
test.maxscales->connect_maxscale(0);
|
||||
test.tprintf("Stopping node 0");
|
||||
test.galera->block_node(0);
|
||||
test.close_maxscale_connections();
|
||||
test.maxscales->close_maxscale_connections(0);
|
||||
|
||||
test.stop_timeout();
|
||||
|
||||
@ -30,10 +30,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
test.set_timeout(30);
|
||||
|
||||
test.connect_maxscale();
|
||||
test.try_query(test.conn_rwsplit, "USE test");
|
||||
test.try_query(test.conn_rwsplit, "show processlist;");
|
||||
test.close_maxscale_connections();
|
||||
test.maxscales->connect_maxscale(0);
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "USE test");
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "show processlist;");
|
||||
test.maxscales->close_maxscale_connections(0);
|
||||
|
||||
test.stop_timeout();
|
||||
|
||||
|
@ -30,21 +30,21 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(20);
|
||||
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
if (mysql_errno(Test->conn_rwsplit) == 0)
|
||||
if (mysql_errno(Test->maxscales->conn_rwsplit[0]) == 0)
|
||||
{
|
||||
Test->add_result(1, "RWSplit services should fail, but it is started\n");
|
||||
}
|
||||
|
||||
Test->tprintf("Trying query to ReadConn master\n");
|
||||
Test->try_query(Test->conn_master, "show processlist;");
|
||||
Test->try_query(Test->maxscales->conn_master[0], "show processlist;");
|
||||
Test->tprintf("Trying query to ReadConn slave\n");
|
||||
Test->try_query(Test->conn_slave, "show processlist;");
|
||||
Test->try_query(Test->maxscales->conn_slave[0], "show processlist;");
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->check_log_err("There are too few backend servers configured in", true);
|
||||
Test->check_log_err(0, "There are too few backend servers configured in", true);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -41,11 +41,11 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
|
||||
Test->set_timeout(120);
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->try_query(Test->conn_rwsplit, "USE test");
|
||||
Test->try_query(Test->conn_rwsplit, "DROP TABLE IF EXISTS test");
|
||||
Test->try_query(Test->conn_rwsplit, "CREATE TABLE test (b integer)");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "USE test");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP TABLE IF EXISTS test");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "CREATE TABLE test (b integer)");
|
||||
|
||||
const int iter = Test->smoke ? 10 : 100;
|
||||
Test->tprintf("Creating and inserting %d rows into a table\n", iter);
|
||||
@ -53,34 +53,34 @@ int main(int argc, char *argv[])
|
||||
for (int i = 0; i < iter; i++)
|
||||
{
|
||||
Test->set_timeout(30);
|
||||
execute_query(Test->conn_rwsplit, "insert into test value(2);");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "insert into test value(2);");
|
||||
Test->stop_timeout();
|
||||
}
|
||||
|
||||
Test->set_timeout(200);
|
||||
|
||||
Test->tprintf("Trying SELECT @a:=@a+1 as a, test.b FROM test\n");
|
||||
if (execute_query(Test->conn_rwsplit, "SELECT @a:=@a+1 as a, test.b FROM test;") == 0)
|
||||
if (execute_query(Test->maxscales->conn_rwsplit[0], "SELECT @a:=@a+1 as a, test.b FROM test;") == 0)
|
||||
{
|
||||
Test->add_result(1, "Query succeded, but expected to fail.\n");
|
||||
}
|
||||
Test->tprintf("Trying USE test\n");
|
||||
Test->try_query(Test->conn_rwsplit, "USE test");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "USE test");
|
||||
|
||||
Test->try_query(Test->conn_rwsplit, "DROP TABLE IF EXISTS test");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP TABLE IF EXISTS test");
|
||||
|
||||
Test->tprintf("Checking if MaxScale alive\n");
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->tprintf("Checking logs\n");
|
||||
Test->check_log_err((char *)
|
||||
Test->check_log_err(0, (char *)
|
||||
"The query can't be routed to all backend servers because it includes SELECT and SQL variable modifications which is not supported",
|
||||
true);
|
||||
Test->check_log_err((char *)
|
||||
Test->check_log_err(0, (char *)
|
||||
"SELECT with session data modification is not supported if configuration parameter use_sql_variables_in=all",
|
||||
true);
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -188,7 +188,7 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(20);
|
||||
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->tprintf("Trying \n");
|
||||
|
||||
@ -197,11 +197,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
if ( (
|
||||
find_field(
|
||||
Test->conn_rwsplit, sel3,
|
||||
Test->maxscales->conn_rwsplit[0], sel3,
|
||||
"@@server_id", &serverid1[0])
|
||||
!= 0 ) || (
|
||||
find_field(
|
||||
Test->conn_rwsplit, sel4,
|
||||
Test->maxscales->conn_rwsplit[0], sel4,
|
||||
"@@server_id", &serverid2[0])
|
||||
!= 0 ))
|
||||
{
|
||||
@ -219,11 +219,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
if ( (
|
||||
find_field(
|
||||
Test->conn_rwsplit, sel1,
|
||||
Test->maxscales->conn_rwsplit[0], sel1,
|
||||
"@@hostname", &serverid1[0])
|
||||
!= 0 ) || (
|
||||
find_field(
|
||||
Test->conn_rwsplit, sel2,
|
||||
Test->maxscales->conn_rwsplit[0], sel2,
|
||||
"@@hostname", &serverid2[0])
|
||||
!= 0 ))
|
||||
{
|
||||
@ -239,8 +239,8 @@ int main(int argc, char *argv[])
|
||||
"hostname are different depending in which order terms are in SELECT\n");
|
||||
}
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->check_maxscale_alive();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -243,10 +243,10 @@ int main(int argc, char *argv[])
|
||||
Test->tprintf("Restarting MaxScale\n");
|
||||
|
||||
Test->set_timeout(120);
|
||||
Test->restart_maxscale();
|
||||
Test->maxscales->restart_maxscale(0);
|
||||
|
||||
Test->check_log_err((char *) "Loading database names", false);
|
||||
Test->check_log_err((char *) "Unknown column", false);
|
||||
Test->check_log_err(0, (char *) "Loading database names", false);
|
||||
Test->check_log_err(0, (char *) "Unknown column", false);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file bug711.cpp bug711 regression case (Some MySQL Workbench Management actions hang with R/W split router)
|
||||
* - configure rwsplit with use_sql_variables_in=all
|
||||
* - try SHOW GLOBAL STATUS with all routers
|
||||
* - try SHOW GLOBAL STATUS with all maxscales->routers[0]
|
||||
* - check if Maxscale is still alive
|
||||
*/
|
||||
|
||||
@ -43,15 +43,15 @@ using namespace std;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->set_timeout(10);
|
||||
Test->tprintf("Trying SHOW GLOBAL STATUS against RWSplit\n");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "SHOW GLOBAL STATUS;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "SHOW GLOBAL STATUS;");
|
||||
Test->tprintf("Trying SHOW GLOBAL STATUS against ReadConn master\n");
|
||||
Test->try_query(Test->conn_master, (char *) "SHOW GLOBAL STATUS;");
|
||||
Test->try_query(Test->maxscales->conn_master[0], (char *) "SHOW GLOBAL STATUS;");
|
||||
Test->tprintf("Trying SHOW GLOBAL STATUS against ReadConn slave\n");
|
||||
Test->try_query(Test->conn_slave, (char *) "SHOW GLOBAL STATUS;");
|
||||
Test->check_maxscale_alive();
|
||||
Test->try_query(Test->maxscales->conn_slave[0], (char *) "SHOW GLOBAL STATUS;");
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -27,18 +27,18 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(20);
|
||||
int i;
|
||||
|
||||
Test->execute_maxadmin_command((char *) "set server server1 master");
|
||||
Test->execute_maxadmin_command((char *) "set server server2 slave");
|
||||
Test->execute_maxadmin_command((char *) "set server server3 slave");
|
||||
Test->execute_maxadmin_command((char *) "set server server4 slave");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "set server server1 master");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "set server server2 slave");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "set server server3 slave");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "set server server4 slave");
|
||||
|
||||
Test->execute_maxadmin_command((char *) "set server g_server1 master");
|
||||
Test->execute_maxadmin_command((char *) "set server g_server2 slave");
|
||||
Test->execute_maxadmin_command((char *) "set server g_server3 slave");
|
||||
Test->execute_maxadmin_command((char *) "set server g_server4 slave");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "set server g_server1 master");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "set server g_server2 slave");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "set server g_server3 slave");
|
||||
Test->maxscales->execute_maxadmin_command(0, (char *) "set server g_server4 slave");
|
||||
|
||||
Test->tprintf("Connecting to all MaxScale services\n");
|
||||
Test->add_result(Test->connect_maxscale(), "Error connection to Maxscale\n");
|
||||
Test->add_result(Test->maxscales->connect_maxscale(0), "Error connection to Maxscale\n");
|
||||
|
||||
//MYSQL * galera_rwsplit = open_conn(4016, Test->Maxscale_IP, Test->Maxscale_User, Test->Maxscale_Password);
|
||||
|
||||
@ -53,11 +53,11 @@ int main(int argc, char *argv[])
|
||||
iret1[i] = pthread_create(&thread_v1[i], NULL, thread1, NULL);
|
||||
}
|
||||
|
||||
create_t1(Test->conn_rwsplit);
|
||||
create_t1(Test->maxscales->conn_rwsplit[0]);
|
||||
for (i = 0; i < iterations; i++)
|
||||
{
|
||||
Test->set_timeout(200);
|
||||
insert_into_t1(Test->conn_rwsplit, 4);
|
||||
insert_into_t1(Test->maxscales->conn_rwsplit[0], 4);
|
||||
printf("i=%d\n", i);
|
||||
}
|
||||
Test->set_timeout(300);
|
||||
@ -66,8 +66,8 @@ int main(int argc, char *argv[])
|
||||
pthread_join(thread_v1[i], NULL);
|
||||
}
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->check_maxscale_alive();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
@ -76,9 +76,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
void *thread1( void *ptr )
|
||||
{
|
||||
MYSQL * conn = open_conn(Test->rwsplit_port , Test->maxscale_IP, Test->maxscale_user, Test->maxscale_password,
|
||||
MYSQL * conn = open_conn(Test->maxscales->rwsplit_port[0] , Test->maxscales->IP[0], Test->maxscales->user_name, Test->maxscales->password,
|
||||
Test->ssl);
|
||||
MYSQL * g_conn = open_conn(4016 , Test->maxscale_IP, Test->maxscale_user, Test->maxscale_password, Test->ssl);
|
||||
MYSQL * g_conn = open_conn(4016 , Test->maxscales->IP[0], Test->maxscales->user_name, Test->maxscales->password, Test->ssl);
|
||||
char sql[1034];
|
||||
|
||||
sprintf(sql, "CREATE DATABASE IF NOT EXISTS test%d;", db1_num);
|
||||
|
@ -58,13 +58,13 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(30);
|
||||
char str[1024];
|
||||
|
||||
sprintf(str, "php %s/bug729.php %s %d %s %s", test_dir, Test->maxscale_IP, Test->rwsplit_port,
|
||||
Test->maxscale_user, Test->maxscale_password);
|
||||
sprintf(str, "php %s/bug729.php %s %d %s %s", test_dir, Test->maxscales->IP[0], Test->maxscales->rwsplit_port[0],
|
||||
Test->maxscales->user_name, Test->maxscales->password);
|
||||
|
||||
Test->tprintf("Executing PHP script: %s\n", str);
|
||||
Test->add_result(system(str), "PHP script FAILED!\n");
|
||||
|
||||
Test->check_log_err((char *) "Can't route MYSQL_COM_STMT_PREPARE", false);
|
||||
Test->check_log_err(0, (char *) "Can't route MYSQL_COM_STMT_PREPARE", false);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file bug730.cpp regression case for bug 730 ("Regex filter and shorter than original replacement queries MaxScale")
|
||||
*
|
||||
* - setup regex filter, add it to all routers
|
||||
* - setup regex filter, add it to all maxscales->routers[0]
|
||||
* @verbatim
|
||||
[MySetOptionFilter]
|
||||
type=filter
|
||||
@ -11,7 +11,7 @@ match=SET OPTION SQL_QUOTE_SHOW_CREATE
|
||||
replace=SET SQL_QUOTE_SHOW_CREATE
|
||||
|
||||
@endverbatim
|
||||
* - try SET OPTION SQL_QUOTE_SHOW_CREATE = 1; against all routers
|
||||
* - try SET OPTION SQL_QUOTE_SHOW_CREATE = 1; against all maxscales->routers[0]
|
||||
* - check if Maxscale alive
|
||||
*/
|
||||
|
||||
@ -45,21 +45,21 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->tprintf("RWSplit: \n");
|
||||
fflush(stdout);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "SET OPTION SQL_QUOTE_SHOW_CREATE = 1;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "SET OPTION SQL_QUOTE_SHOW_CREATE = 1;");
|
||||
Test->tprintf("ReadConn master: \n");
|
||||
fflush(stdout);
|
||||
Test->try_query(Test->conn_master, (char *) "SET OPTION SQL_QUOTE_SHOW_CREATE = 1;");
|
||||
Test->try_query(Test->maxscales->conn_master[0], (char *) "SET OPTION SQL_QUOTE_SHOW_CREATE = 1;");
|
||||
Test->tprintf("readConn slave: \n");
|
||||
fflush(stdout);
|
||||
Test->try_query(Test->conn_slave, (char *) "SET OPTION SQL_QUOTE_SHOW_CREATE = 1;");
|
||||
Test->try_query(Test->maxscales->conn_slave[0], (char *) "SET OPTION SQL_QUOTE_SHOW_CREATE = 1;");
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -202,23 +202,24 @@ int main(int argc, char** argv)
|
||||
{
|
||||
TestConnections::require_repl_version("10.2");
|
||||
TestConnections test(argc, argv);
|
||||
test.connect_maxscale();
|
||||
test.maxscales->connect_maxscale(0);
|
||||
test.repl->connect();
|
||||
|
||||
|
||||
test.tprintf("Testing column-wise binding with a direct connection");
|
||||
test.add_result(bind_by_column(test.repl->nodes[0]), "Bulk inserts with a direct connection should work");
|
||||
test.tprintf("Testing column-wise binding with readwritesplit");
|
||||
test.add_result(bind_by_column(test.conn_rwsplit), "Bulk inserts with readwritesplit should work");
|
||||
test.add_result(bind_by_column(test.maxscales->conn_rwsplit[0]), "Bulk inserts with readwritesplit should work");
|
||||
test.tprintf("Testing column-wise binding with readconnroute");
|
||||
test.add_result(bind_by_column(test.conn_master), "Bulk inserts with readconnroute should work");
|
||||
test.add_result(bind_by_column(test.maxscales->conn_master[0]), "Bulk inserts with readconnroute should work");
|
||||
|
||||
test.tprintf("Testing row-wise binding with a direct connection");
|
||||
test.add_result(bind_by_row(test.repl->nodes[0]), "Bulk inserts with a direct connection should work");
|
||||
test.tprintf("Testing row-wise binding with readwritesplit");
|
||||
test.add_result(bind_by_row(test.conn_rwsplit), "Bulk inserts with readwritesplit should work");
|
||||
test.add_result(bind_by_row(test.maxscales->conn_rwsplit[0]), "Bulk inserts with readwritesplit should work");
|
||||
test.tprintf("Testing row-wise binding with readconnroute");
|
||||
test.add_result(bind_by_row(test.conn_master), "Bulk inserts with readconnroute should work");
|
||||
test.add_result(bind_by_row(test.maxscales->conn_master[0]), "Bulk inserts with readconnroute should work");
|
||||
|
||||
test.close_maxscale_connections();
|
||||
test.maxscales->close_maxscale_connections(0);
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -56,84 +56,84 @@ int main(int argc, char *argv[])
|
||||
execute_query(test->repl->nodes[0], "CREATE OR REPLACE TABLE test.t1 (id INT);");
|
||||
execute_query(test->repl->nodes[0], "CREATE OR REPLACE TABLE test.t2 (id INT);");
|
||||
|
||||
test->connect_maxscale();
|
||||
test->maxscales->connect_maxscale(0);
|
||||
|
||||
test->tprintf("Test `time`. The first SELECT within 10 seconds should go the "
|
||||
"master and all SELECTs after it should go to the slaves.");
|
||||
|
||||
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
|
||||
sleep(1);
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the first SELECT");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the first SELECT");
|
||||
sleep(11);
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the second SELECT");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the second SELECT");
|
||||
|
||||
|
||||
test->tprintf("Change test setup for `count`, the first three selects after an "
|
||||
"insert should go to the master.");
|
||||
|
||||
test->close_maxscale_connections();
|
||||
test->ssh_maxscale(true, "sed -i -e 's/time.*/time=0/' /etc/maxscale.cnf");
|
||||
test->ssh_maxscale(true, "sed -i -e 's/###count/count/' /etc/maxscale.cnf");
|
||||
test->restart_maxscale();
|
||||
test->connect_maxscale();
|
||||
test->maxscales->close_maxscale_connections(0);
|
||||
test->maxscales->ssh_node(0, "sed -i -e 's/time.*/time=0/' /etc/maxscale.cnf", true);
|
||||
test->maxscales->ssh_node(0, "sed -i -e 's/###count/count/' /etc/maxscale.cnf", true);
|
||||
test->maxscales->restart_maxscale(0);
|
||||
test->maxscales->connect_maxscale(0);
|
||||
|
||||
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the first SELECT");
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the second SELECT");
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the third SELECT");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the fourth SELECT");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the fifth SELECT");
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the first SELECT");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the second SELECT");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the third SELECT");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the fourth SELECT");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the fifth SELECT");
|
||||
|
||||
|
||||
test->tprintf("Change test setup for `count` and `match`, selects after an insert "
|
||||
"to t1 should go to the slaves and selects after an insert to t2 "
|
||||
"should go to the master.");
|
||||
|
||||
test->close_maxscale_connections();
|
||||
test->ssh_maxscale(true, "sed -i -e 's/###match/match/' /etc/maxscale.cnf");
|
||||
test->restart_maxscale();
|
||||
test->connect_maxscale();
|
||||
test->maxscales->close_maxscale_connections(0);
|
||||
test->maxscales->ssh_node(0, "sed -i -e 's/###match/match/' /etc/maxscale.cnf", true);
|
||||
test->maxscales->restart_maxscale(0);
|
||||
test->maxscales->connect_maxscale(0);
|
||||
|
||||
|
||||
test->tprintf("t1 first, should be ignored");
|
||||
|
||||
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the first SELECT");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the second SELECT");
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the first SELECT");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the second SELECT");
|
||||
|
||||
test->tprintf("t2 should match and trigger the critical reads");
|
||||
|
||||
test->try_query(test->conn_rwsplit, "INSERT INTO test.t2 VALUES (1)");
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the first SELECT");
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the second SELECT");
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the third SELECT");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the fourth SELECT");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the fifth SELECT");
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "INSERT INTO test.t2 VALUES (1)");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the first SELECT");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the second SELECT");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the third SELECT");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the fourth SELECT");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the fifth SELECT");
|
||||
|
||||
|
||||
test->tprintf("Change test setup for `count` and `ignore`, expects the same "
|
||||
"results as previous test.");
|
||||
|
||||
test->close_maxscale_connections();
|
||||
test->ssh_maxscale(true, "sed -i -e 's/match/###match/' /etc/maxscale.cnf");
|
||||
test->ssh_maxscale(true, "sed -i -e 's/###ignore/ignore/' /etc/maxscale.cnf");
|
||||
test->restart_maxscale();
|
||||
test->connect_maxscale();
|
||||
test->maxscales->close_maxscale_connections(0);
|
||||
test->maxscales->ssh_node(0, "sed -i -e 's/match/###match/' /etc/maxscale.cnf", true);
|
||||
test->maxscales->ssh_node(0, "sed -i -e 's/###ignore/ignore/' /etc/maxscale.cnf", true);
|
||||
test->maxscales->restart_maxscale(0);
|
||||
test->maxscales->connect_maxscale(0);
|
||||
|
||||
test->tprintf("t1 first, should be ignored");
|
||||
|
||||
test->try_query(test->conn_rwsplit, "INSERT INTO test.t1 VALUES (1)");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the first SELECT");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the second SELECT");
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the first SELECT");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the second SELECT");
|
||||
|
||||
test->tprintf("t2 should match and trigger the critical reads");
|
||||
|
||||
test->try_query(test->conn_rwsplit, "INSERT INTO test.t2 VALUES (1)");
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the first SELECT");
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the second SELECT");
|
||||
test->add_result(!is_master(test->conn_rwsplit), "Master should reply to the third SELECT");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the fourth SELECT");
|
||||
test->add_result(is_master(test->conn_rwsplit), "Master should NOT reply to the fifth SELECT");
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "INSERT INTO test.t2 VALUES (1)");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the first SELECT");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the second SELECT");
|
||||
test->add_result(!is_master(test->maxscales->conn_rwsplit[0]), "Master should reply to the third SELECT");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the fourth SELECT");
|
||||
test->add_result(is_master(test->maxscales->conn_rwsplit[0]), "Master should NOT reply to the fifth SELECT");
|
||||
|
||||
execute_query(test->repl->nodes[0], "DROP TABLE test.t1");
|
||||
execute_query(test->repl->nodes[0], "DROP TABLE test.t2");
|
||||
|
@ -38,7 +38,7 @@ bool cdc_com(TestConnections *Test)
|
||||
{
|
||||
int max_inserted_val = Test->smoke ? 25 : 100;
|
||||
int sock = create_tcp_socket();
|
||||
char *ip = get_ip(Test->maxscale_IP);
|
||||
char *ip = get_ip(Test->maxscales->IP[0]);
|
||||
|
||||
if (ip == NULL)
|
||||
{
|
||||
@ -187,26 +187,26 @@ int main(int argc, char *argv[])
|
||||
Test = new TestConnections(argc, argv);
|
||||
|
||||
Test->set_timeout(600);
|
||||
Test->stop_maxscale();
|
||||
Test->maxscales->stop_maxscale(0);
|
||||
|
||||
// Remove old data files and make sure that port 4001 is open
|
||||
Test->ssh_maxscale(true, "rm -rf /var/lib/maxscale/avro;"
|
||||
"iptables -n -L INPUT|grep 4001 || iptables -I INPUT -p tcp --dport 4001 -j ACCEPT;");
|
||||
Test->maxscales->ssh_node_f(0, true, "rm -rf /var/lib/maxscale/avro;"
|
||||
"iptables -n -L INPUT|grep 4001 || iptables -I INPUT -p tcp --dport 4001 -j ACCEPT;");
|
||||
|
||||
Test->repl->connect();
|
||||
execute_query(Test->repl->nodes[0], "DROP TABLE IF EXISTS t1;");
|
||||
Test->repl->close_connections();
|
||||
sleep(5);
|
||||
|
||||
Test->start_binlog();
|
||||
Test->start_binlog(0);
|
||||
|
||||
Test->set_timeout(120);
|
||||
Test->stop_maxscale();
|
||||
Test->maxscales->stop_maxscale(0);
|
||||
|
||||
Test->ssh_maxscale(true, "rm -rf /var/lib/maxscale/avro");
|
||||
Test->maxscales->ssh_node(0, "rm -rf /var/lib/maxscale/avro", true);
|
||||
|
||||
Test->set_timeout(120);
|
||||
Test->start_maxscale();
|
||||
Test->maxscales->start_maxscale(0);
|
||||
|
||||
Test->set_timeout(60);
|
||||
Test->repl->connect();
|
||||
|
316
maxscale-system-test/cdc_connector.cpp
Normal file
316
maxscale-system-test/cdc_connector.cpp
Normal file
@ -0,0 +1,316 @@
|
||||
#include "cdc_connector.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <stdexcept>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define CDC_CONNECTOR_VERSION "1.0.0"
|
||||
|
||||
#define ERRBUF_SIZE 512
|
||||
#define READBUF_SIZE 1024
|
||||
|
||||
static const char OK_RESPONSE[] = "OK\n";
|
||||
|
||||
static const char CLOSE_MSG[] = "CLOSE";
|
||||
static const char REGISTER_MSG[] = "REGISTER UUID=CDC_CONNECTOR-" CDC_CONNECTOR_VERSION ", TYPE=";
|
||||
static const char REQUEST_MSG[] = "REQUEST-DATA ";
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
static inline int nointr_read(int fd, void *dest, size_t size)
|
||||
{
|
||||
int rc = read(fd, dest, size);
|
||||
|
||||
while (rc == -1 && errno == EINTR)
|
||||
{
|
||||
rc = read(fd, dest, size);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static inline int nointr_write(int fd, const void *src, size_t size)
|
||||
{
|
||||
int rc = write(fd, src, size);
|
||||
|
||||
while (rc == -1 && errno == EINTR)
|
||||
{
|
||||
rc = write(fd, src, size);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static std::string bin2hex(const uint8_t *data, size_t len)
|
||||
{
|
||||
std::string result;
|
||||
static const char hexconvtab[] = "0123456789abcdef";
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
result += hexconvtab[data[i] >> 4];
|
||||
result += hexconvtab[data[i] & 0x0f];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string generateAuthString(const std::string& user, const std::string& password)
|
||||
{
|
||||
uint8_t digest[SHA_DIGEST_LENGTH];
|
||||
SHA1(reinterpret_cast<const uint8_t*> (password.c_str()), password.length(), digest);
|
||||
|
||||
std::string auth_str = user;
|
||||
auth_str += ":";
|
||||
|
||||
std::string part1 = bin2hex((uint8_t*)auth_str.c_str(), auth_str.length());
|
||||
std::string part2 = bin2hex(digest, sizeof(digest));
|
||||
|
||||
return part1 + part2;
|
||||
}
|
||||
}
|
||||
|
||||
namespace CDC
|
||||
{
|
||||
|
||||
/**
|
||||
* Public functions
|
||||
*/
|
||||
|
||||
Connection::Connection(const std::string& address,
|
||||
uint16_t port,
|
||||
const std::string& user,
|
||||
const std::string& password,
|
||||
uint32_t flags) :
|
||||
m_fd(-1),
|
||||
m_address(address),
|
||||
m_port(port),
|
||||
m_user(user),
|
||||
m_password(password),
|
||||
m_flags(flags) { }
|
||||
|
||||
Connection::~Connection()
|
||||
{
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
bool Connection::createConnection()
|
||||
{
|
||||
bool rval = false;
|
||||
struct sockaddr_in remote = {};
|
||||
|
||||
remote.sin_port = htons(m_port);
|
||||
remote.sin_family = AF_INET;
|
||||
|
||||
if (inet_aton(m_address.c_str(), (struct in_addr*)&remote.sin_addr.s_addr) == 0)
|
||||
{
|
||||
m_error = "Invalid address: ";
|
||||
m_error += m_address;
|
||||
}
|
||||
else
|
||||
{
|
||||
int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to create socket: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
|
||||
m_fd = fd;
|
||||
|
||||
if (connect(fd, (struct sockaddr*) &remote, sizeof (remote)) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to connect: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else if (doAuth())
|
||||
{
|
||||
rval = doRegistration();
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
void Connection::closeConnection()
|
||||
{
|
||||
if (m_fd != -1)
|
||||
{
|
||||
nointr_write(m_fd, CLOSE_MSG, sizeof (CLOSE_MSG) - 1);
|
||||
close(m_fd);
|
||||
m_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool Connection::requestData(const std::string& table, const std::string& gtid)
|
||||
{
|
||||
bool rval = true;
|
||||
|
||||
std::string req_msg(REQUEST_MSG);
|
||||
req_msg += table;
|
||||
|
||||
if (gtid.length())
|
||||
{
|
||||
req_msg += " ";
|
||||
req_msg += gtid;
|
||||
}
|
||||
|
||||
if (nointr_write(m_fd, req_msg.c_str(), req_msg.length()) == -1)
|
||||
{
|
||||
rval = false;
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to write request: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
|
||||
if (rval)
|
||||
{
|
||||
/** Read the Avro schema */
|
||||
rval = readRow(m_schema);
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
bool Connection::readRow(std::string& dest)
|
||||
{
|
||||
bool rval = true;
|
||||
|
||||
while (true)
|
||||
{
|
||||
char buf;
|
||||
int rc = nointr_read(m_fd, &buf, 1);
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
rval = false;
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to read row: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
break;
|
||||
}
|
||||
|
||||
if (buf == '\n')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
dest += buf;
|
||||
|
||||
if (dest[0] == 'E' && dest[1] == 'R' & dest[2] == 'R')
|
||||
{
|
||||
m_error = "Server responded with an error: ";
|
||||
m_error += dest;
|
||||
rval = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private functions
|
||||
*/
|
||||
|
||||
bool Connection::doAuth()
|
||||
{
|
||||
bool rval = false;
|
||||
std::string auth_str = generateAuthString(m_user, m_password);
|
||||
|
||||
/** Send the auth string */
|
||||
if (nointr_write(m_fd, auth_str.c_str(), auth_str.length()) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to write authentication data: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else
|
||||
{
|
||||
/** Read the response */
|
||||
char buf[READBUF_SIZE];
|
||||
int bytes;
|
||||
|
||||
if ((bytes = nointr_read(m_fd, buf, sizeof (buf))) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to read authentication response: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else if (memcmp(buf, OK_RESPONSE, sizeof (OK_RESPONSE) - 1) != 0)
|
||||
{
|
||||
buf[bytes] = '\0';
|
||||
m_error = "Authentication failed: ";
|
||||
m_error += buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
rval = true;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
bool Connection::doRegistration()
|
||||
{
|
||||
bool rval = false;
|
||||
std::string reg_msg(REGISTER_MSG);
|
||||
|
||||
const char *type = "";
|
||||
|
||||
if (m_flags & CDC_REQUEST_TYPE_JSON)
|
||||
{
|
||||
type = "JSON";
|
||||
}
|
||||
else if (m_flags & CDC_REQUEST_TYPE_AVRO)
|
||||
{
|
||||
type = "AVRO";
|
||||
}
|
||||
|
||||
reg_msg += type;
|
||||
|
||||
/** Send the registration message */
|
||||
if (nointr_write(m_fd, reg_msg.c_str(), reg_msg.length()) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to write registration message: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else
|
||||
{
|
||||
/** Read the response */
|
||||
char buf[READBUF_SIZE];
|
||||
int bytes;
|
||||
|
||||
if ((bytes = nointr_read(m_fd, buf, sizeof (buf))) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to read registration response: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else if (memcmp(buf, OK_RESPONSE, sizeof (OK_RESPONSE) - 1) != 0)
|
||||
{
|
||||
buf[bytes] = '\0';
|
||||
m_error = "Registration failed: ";
|
||||
m_error += buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
rval = true;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
}
|
47
maxscale-system-test/cdc_connector.h
Normal file
47
maxscale-system-test/cdc_connector.h
Normal file
@ -0,0 +1,47 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
/** Request format flags */
|
||||
#define CDC_REQUEST_TYPE_JSON (1 << 0)
|
||||
#define CDC_REQUEST_TYPE_AVRO (1 << 1)
|
||||
|
||||
namespace CDC
|
||||
{
|
||||
|
||||
class Connection
|
||||
{
|
||||
public:
|
||||
Connection(const std::string& address,
|
||||
uint16_t port,
|
||||
const std::string& user,
|
||||
const std::string& password,
|
||||
uint32_t flags = CDC_REQUEST_TYPE_JSON);
|
||||
virtual ~Connection();
|
||||
bool createConnection();
|
||||
bool requestData(const std::string& table, const std::string& gtid = "");
|
||||
bool readRow(std::string& dest);
|
||||
void closeConnection();
|
||||
const std::string& getSchema() const
|
||||
{
|
||||
return m_schema;
|
||||
}
|
||||
const std::string& getError() const
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_fd;
|
||||
uint32_t m_flags;
|
||||
uint16_t m_port;
|
||||
std::string m_address;
|
||||
std::string m_user;
|
||||
std::string m_password;
|
||||
std::string m_error;
|
||||
std::string m_schema;
|
||||
|
||||
bool doAuth();
|
||||
bool doRegistration();
|
||||
};
|
||||
|
||||
}
|
21
maxscale-system-test/cdc_connector/CMakeLists.txt
Normal file
21
maxscale-system-test/cdc_connector/CMakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
||||
project(cdc_connector)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
enable_testing()
|
||||
|
||||
include(ExternalProject)
|
||||
include(cmake/BuildJansson.cmake)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-fPIC -std=c++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-fPIC -std=c++0x -ggdb")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-fPIC -std=c++0x -O2")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-fPIC -std=c++0x -O2")
|
||||
|
||||
include_directories(${JANSSON_INCLUDE_DIR})
|
||||
add_library(cdc_connector SHARED cdc_connector.cpp)
|
||||
target_link_libraries(cdc_connector ${JANSSON_LIBRARIES} crypto)
|
||||
add_dependencies(cdc_connector jansson)
|
||||
install(TARGETS cdc_connector DESTINATION lib)
|
||||
install(FILES cdc_connector.h DESTINATION include)
|
||||
|
||||
include(CTest)
|
454
maxscale-system-test/cdc_connector/cdc_connector.cpp
Normal file
454
maxscale-system-test/cdc_connector/cdc_connector.cpp
Normal file
@ -0,0 +1,454 @@
|
||||
#include "cdc_connector.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <stdexcept>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <openssl/sha.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <jansson.h>
|
||||
|
||||
#define CDC_CONNECTOR_VERSION "1.0.0"
|
||||
|
||||
#define ERRBUF_SIZE 512
|
||||
#define READBUF_SIZE 1024
|
||||
|
||||
static const char OK_RESPONSE[] = "OK\n";
|
||||
|
||||
static const char CLOSE_MSG[] = "CLOSE";
|
||||
static const char REGISTER_MSG[] = "REGISTER UUID=CDC_CONNECTOR-" CDC_CONNECTOR_VERSION ", TYPE=";
|
||||
static const char REQUEST_MSG[] = "REQUEST-DATA ";
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
static inline int nointr_read(int fd, void *dest, size_t size)
|
||||
{
|
||||
int rc = read(fd, dest, size);
|
||||
|
||||
while (rc == -1 && errno == EINTR)
|
||||
{
|
||||
rc = read(fd, dest, size);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static inline int nointr_write(int fd, const void *src, size_t size)
|
||||
{
|
||||
int rc = write(fd, src, size);
|
||||
|
||||
while (rc == -1 && errno == EINTR)
|
||||
{
|
||||
rc = write(fd, src, size);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static std::string bin2hex(const uint8_t *data, size_t len)
|
||||
{
|
||||
std::string result;
|
||||
static const char hexconvtab[] = "0123456789abcdef";
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
result += hexconvtab[data[i] >> 4];
|
||||
result += hexconvtab[data[i] & 0x0f];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string generateAuthString(const std::string& user, const std::string& password)
|
||||
{
|
||||
uint8_t digest[SHA_DIGEST_LENGTH];
|
||||
SHA1(reinterpret_cast<const uint8_t*> (password.c_str()), password.length(), digest);
|
||||
|
||||
std::string auth_str = user;
|
||||
auth_str += ":";
|
||||
|
||||
std::string part1 = bin2hex((uint8_t*)auth_str.c_str(), auth_str.length());
|
||||
std::string part2 = bin2hex(digest, sizeof(digest));
|
||||
|
||||
return part1 + part2;
|
||||
}
|
||||
|
||||
|
||||
std::string json_to_string(json_t* json)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
switch (json_typeof(json))
|
||||
{
|
||||
case JSON_STRING:
|
||||
ss << json_string_value(json);
|
||||
break;
|
||||
|
||||
case JSON_INTEGER:
|
||||
ss << json_integer_value(json);
|
||||
break;
|
||||
|
||||
case JSON_REAL:
|
||||
ss << json_real_value(json);
|
||||
break;
|
||||
|
||||
case JSON_TRUE:
|
||||
ss << "true";
|
||||
break;
|
||||
|
||||
case JSON_FALSE:
|
||||
ss << "false";
|
||||
break;
|
||||
|
||||
case JSON_NULL:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace CDC
|
||||
{
|
||||
|
||||
/**
|
||||
* Public functions
|
||||
*/
|
||||
|
||||
Connection::Connection(const std::string& address,
|
||||
uint16_t port,
|
||||
const std::string& user,
|
||||
const std::string& password,
|
||||
uint32_t flags) :
|
||||
m_fd(-1),
|
||||
m_address(address),
|
||||
m_port(port),
|
||||
m_user(user),
|
||||
m_password(password),
|
||||
m_flags(flags)
|
||||
{
|
||||
}
|
||||
|
||||
Connection::~Connection()
|
||||
{
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
bool Connection::createConnection()
|
||||
{
|
||||
bool rval = false;
|
||||
struct sockaddr_in remote = {};
|
||||
|
||||
remote.sin_port = htons(m_port);
|
||||
remote.sin_family = AF_INET;
|
||||
|
||||
if (inet_aton(m_address.c_str(), (struct in_addr*)&remote.sin_addr.s_addr) == 0)
|
||||
{
|
||||
m_error = "Invalid address: ";
|
||||
m_error += m_address;
|
||||
}
|
||||
else
|
||||
{
|
||||
int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to create socket: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
|
||||
m_fd = fd;
|
||||
|
||||
if (connect(fd, (struct sockaddr*) &remote, sizeof (remote)) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to connect: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else if (doAuth())
|
||||
{
|
||||
rval = doRegistration();
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
void Connection::closeConnection()
|
||||
{
|
||||
if (m_fd != -1)
|
||||
{
|
||||
nointr_write(m_fd, CLOSE_MSG, sizeof (CLOSE_MSG) - 1);
|
||||
close(m_fd);
|
||||
m_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool Connection::requestData(const std::string& table, const std::string& gtid)
|
||||
{
|
||||
bool rval = true;
|
||||
|
||||
std::string req_msg(REQUEST_MSG);
|
||||
req_msg += table;
|
||||
|
||||
if (gtid.length())
|
||||
{
|
||||
req_msg += " ";
|
||||
req_msg += gtid;
|
||||
}
|
||||
|
||||
if (nointr_write(m_fd, req_msg.c_str(), req_msg.length()) == -1)
|
||||
{
|
||||
rval = false;
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to write request: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
static inline bool is_schema(json_t* json)
|
||||
{
|
||||
bool rval = false;
|
||||
json_t* j = json_object_get(json, "fields");
|
||||
|
||||
if (j && json_is_array(j) && json_array_size(j))
|
||||
{
|
||||
rval = json_object_get(json_array_get(j, 0), "name") != NULL;
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
void Connection::processSchema(json_t* json)
|
||||
{
|
||||
m_keys.clear();
|
||||
m_types.clear();
|
||||
|
||||
json_t* arr = json_object_get(json, "fields");
|
||||
char* raw = json_dumps(json, 0);
|
||||
size_t i;
|
||||
json_t* v;
|
||||
|
||||
json_array_foreach(arr, i, v)
|
||||
{
|
||||
json_t* name = json_object_get(v, "name");
|
||||
json_t* type = json_object_get(v, "real_type");
|
||||
std::string nameval = name ? json_string_value(name) : "";
|
||||
std::string typeval = type ? json_string_value(type) : "undefined";
|
||||
m_keys.push_back(nameval);
|
||||
m_types.push_back(typeval);
|
||||
}
|
||||
}
|
||||
|
||||
Row Connection::processRow(json_t* js)
|
||||
{
|
||||
ValueList values;
|
||||
m_error.clear();
|
||||
|
||||
for (ValueList::iterator it = m_keys.begin();
|
||||
it != m_keys.end(); it++)
|
||||
{
|
||||
json_t* v = json_object_get(js, it->c_str());
|
||||
|
||||
if (v)
|
||||
{
|
||||
values.push_back(json_to_string(v));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_error = "No value for key found: ";
|
||||
m_error += *it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Row rval;
|
||||
|
||||
if (m_error.empty())
|
||||
{
|
||||
rval = Row(new InternalRow(m_keys, m_types, values));
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
Row Connection::read()
|
||||
{
|
||||
Row rval;
|
||||
std::string row;
|
||||
|
||||
if (readRow(row))
|
||||
{
|
||||
json_error_t err;
|
||||
json_t* js = json_loads(row.c_str(), JSON_ALLOW_NUL, &err);
|
||||
|
||||
if (js)
|
||||
{
|
||||
if (is_schema(js))
|
||||
{
|
||||
processSchema(js);
|
||||
rval = Connection::read();
|
||||
}
|
||||
else
|
||||
{
|
||||
rval = processRow(js);
|
||||
}
|
||||
|
||||
json_decref(js);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_error = "Failed to parse JSON: ";
|
||||
m_error += err.text;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private functions
|
||||
*/
|
||||
|
||||
bool Connection::doAuth()
|
||||
{
|
||||
bool rval = false;
|
||||
std::string auth_str = generateAuthString(m_user, m_password);
|
||||
|
||||
/** Send the auth string */
|
||||
if (nointr_write(m_fd, auth_str.c_str(), auth_str.length()) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to write authentication data: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else
|
||||
{
|
||||
/** Read the response */
|
||||
char buf[READBUF_SIZE];
|
||||
int bytes;
|
||||
|
||||
if ((bytes = nointr_read(m_fd, buf, sizeof (buf))) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to read authentication response: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else if (memcmp(buf, OK_RESPONSE, sizeof (OK_RESPONSE) - 1) != 0)
|
||||
{
|
||||
buf[bytes] = '\0';
|
||||
m_error = "Authentication failed: ";
|
||||
m_error += buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
rval = true;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
bool Connection::doRegistration()
|
||||
{
|
||||
bool rval = false;
|
||||
std::string reg_msg(REGISTER_MSG);
|
||||
|
||||
const char *type = "";
|
||||
|
||||
if (m_flags & CDC_REQUEST_TYPE_JSON)
|
||||
{
|
||||
type = "JSON";
|
||||
}
|
||||
else if (m_flags & CDC_REQUEST_TYPE_AVRO)
|
||||
{
|
||||
type = "AVRO";
|
||||
}
|
||||
|
||||
reg_msg += type;
|
||||
|
||||
/** Send the registration message */
|
||||
if (nointr_write(m_fd, reg_msg.c_str(), reg_msg.length()) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to write registration message: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else
|
||||
{
|
||||
/** Read the response */
|
||||
char buf[READBUF_SIZE];
|
||||
int bytes;
|
||||
|
||||
if ((bytes = nointr_read(m_fd, buf, sizeof (buf))) == -1)
|
||||
{
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to read registration response: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
}
|
||||
else if (memcmp(buf, OK_RESPONSE, sizeof (OK_RESPONSE) - 1) != 0)
|
||||
{
|
||||
buf[bytes] = '\0';
|
||||
m_error = "Registration failed: ";
|
||||
m_error += buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
rval = true;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
bool Connection::readRow(std::string& dest)
|
||||
{
|
||||
bool rval = true;
|
||||
|
||||
while (true)
|
||||
{
|
||||
char buf;
|
||||
int rc = nointr_read(m_fd, &buf, 1);
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
rval = false;
|
||||
char err[ERRBUF_SIZE];
|
||||
m_error = "Failed to read row: ";
|
||||
m_error += strerror_r(errno, err, sizeof (err));
|
||||
break;
|
||||
}
|
||||
|
||||
if (buf == '\n')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
dest += buf;
|
||||
|
||||
if (dest[0] == 'E' && dest[1] == 'R' & dest[2] == 'R')
|
||||
{
|
||||
m_error = "Server responded with an error: ";
|
||||
m_error += dest;
|
||||
rval = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
}
|
122
maxscale-system-test/cdc_connector/cdc_connector.h
Normal file
122
maxscale-system-test/cdc_connector/cdc_connector.h
Normal file
@ -0,0 +1,122 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <tr1/memory>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <jansson.h>
|
||||
|
||||
/** Request format flags */
|
||||
#define CDC_REQUEST_TYPE_JSON (1 << 0)
|
||||
#define CDC_REQUEST_TYPE_AVRO (1 << 1)
|
||||
|
||||
namespace CDC
|
||||
{
|
||||
|
||||
// The typedef for the Row type
|
||||
class InternalRow;
|
||||
typedef std::tr1::shared_ptr<InternalRow> Row;
|
||||
|
||||
typedef std::vector<std::string> ValueList;
|
||||
|
||||
// A class that represents a CDC connection
|
||||
class Connection
|
||||
{
|
||||
public:
|
||||
Connection(const std::string& address,
|
||||
uint16_t port,
|
||||
const std::string& user,
|
||||
const std::string& password,
|
||||
uint32_t flags = CDC_REQUEST_TYPE_JSON);
|
||||
virtual ~Connection();
|
||||
bool createConnection();
|
||||
bool requestData(const std::string& table, const std::string& gtid = "");
|
||||
Row read();
|
||||
void closeConnection();
|
||||
const std::string& getSchema() const
|
||||
{
|
||||
return m_schema;
|
||||
}
|
||||
const std::string& getError() const
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_fd;
|
||||
uint32_t m_flags;
|
||||
uint16_t m_port;
|
||||
std::string m_address;
|
||||
std::string m_user;
|
||||
std::string m_password;
|
||||
std::string m_error;
|
||||
std::string m_schema;
|
||||
ValueList m_keys;
|
||||
ValueList m_types;
|
||||
|
||||
bool doAuth();
|
||||
bool doRegistration();
|
||||
bool readRow(std::string& dest);
|
||||
void processSchema(json_t* json);
|
||||
Row processRow(json_t*);
|
||||
};
|
||||
|
||||
// Internal representation of a row, used via the Row type
|
||||
class InternalRow
|
||||
{
|
||||
public:
|
||||
|
||||
size_t fieldCount() const
|
||||
{
|
||||
return m_values.size();
|
||||
}
|
||||
|
||||
const std::string& value(size_t i) const
|
||||
{
|
||||
return m_values[i];
|
||||
}
|
||||
|
||||
const std::string& value(const std::string& str) const
|
||||
{
|
||||
ValueList::const_iterator it = std::find(m_keys.begin(), m_keys.end(), str);
|
||||
return m_values[it - m_keys.begin()];
|
||||
}
|
||||
|
||||
const std::string& key(size_t i) const
|
||||
{
|
||||
return m_keys[i];
|
||||
}
|
||||
|
||||
const std::string& type(size_t i) const
|
||||
{
|
||||
return m_types[i];
|
||||
}
|
||||
|
||||
~InternalRow()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
ValueList m_keys;
|
||||
ValueList m_types;
|
||||
ValueList m_values;
|
||||
|
||||
// Not intended to be copied
|
||||
InternalRow(const InternalRow&);
|
||||
InternalRow& operator=(const InternalRow&);
|
||||
InternalRow();
|
||||
|
||||
// Only a Connection should construct an InternalRow
|
||||
friend class Connection;
|
||||
|
||||
InternalRow(const ValueList& keys,
|
||||
const ValueList& types,
|
||||
const ValueList& values):
|
||||
m_keys(keys),
|
||||
m_types(types),
|
||||
m_values(values)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
20
maxscale-system-test/cdc_connector/cmake/BuildJansson.cmake
Normal file
20
maxscale-system-test/cdc_connector/cmake/BuildJansson.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
# If the Jansson library is not found, download it and build it from source.
|
||||
|
||||
set(JANSSON_REPO "https://github.com/akheron/jansson.git" CACHE STRING "Jansson Git repository")
|
||||
|
||||
# Release 2.9 of Jansson
|
||||
set(JANSSON_TAG "v2.9" CACHE STRING "Jansson Git tag")
|
||||
|
||||
ExternalProject_Add(jansson
|
||||
GIT_REPOSITORY ${JANSSON_REPO}
|
||||
GIT_TAG ${JANSSON_TAG}
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/jansson/install -DCMAKE_C_FLAGS=-fPIC -DJANSSON_BUILD_DOCS=OFF
|
||||
BINARY_DIR ${CMAKE_BINARY_DIR}/jansson
|
||||
INSTALL_DIR ${CMAKE_BINARY_DIR}/jansson/install
|
||||
UPDATE_COMMAND "")
|
||||
|
||||
set(JANSSON_FOUND TRUE CACHE INTERNAL "")
|
||||
set(JANSSON_STATIC_FOUND TRUE CACHE INTERNAL "")
|
||||
set(JANSSON_INCLUDE_DIR ${CMAKE_BINARY_DIR}/jansson/install/include CACHE INTERNAL "")
|
||||
set(JANSSON_STATIC_LIBRARIES ${CMAKE_BINARY_DIR}/jansson/install/lib/libjansson.a CACHE INTERNAL "")
|
||||
set(JANSSON_LIBRARIES ${JANSSON_STATIC_LIBRARIES} CACHE INTERNAL "")
|
@ -176,9 +176,9 @@ bool run_test(TestConnections& test)
|
||||
test.set_timeout(60);
|
||||
test.tprintf("Testing type: %s", test_set[x].types[i]);
|
||||
std::string name = type_to_table_name(test_set[x].types[i]);
|
||||
CDC::Connection conn(test.maxscale_IP, 4001, "skysql", "skysql");
|
||||
CDC::Connection conn(test.maxscales->IP[0], 4001, "skysql", "skysql");
|
||||
|
||||
if (conn.connect(name))
|
||||
if (conn.createConnection() && conn.requestData(name))
|
||||
{
|
||||
for (int j = 0; test_set[x].values[j]; j++)
|
||||
{
|
||||
@ -198,14 +198,14 @@ bool run_test(TestConnections& test)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string err = conn.error();
|
||||
std::string err = conn.getError();
|
||||
test.tprintf("Failed to read data: %s", err.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string err = conn.error();
|
||||
std::string err = conn.getError();
|
||||
test.tprintf("Failed to request data: %s", err.c_str());
|
||||
rval = false;
|
||||
break;
|
||||
@ -222,13 +222,13 @@ int main(int argc, char *argv[])
|
||||
TestConnections::check_nodes(false);
|
||||
TestConnections test(argc, argv);
|
||||
|
||||
test.replicate_from_master();
|
||||
test.replicate_from_master(0);
|
||||
|
||||
if (!run_test(test))
|
||||
{
|
||||
test.add_result(1, "Test failed");
|
||||
}
|
||||
|
||||
test.check_maxscale_processes(1);
|
||||
test.check_maxscale_processes(0, 1);
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ int main(int argc, char *argv[])
|
||||
Test->repl->connect();
|
||||
|
||||
printf("Connecting to RWsplit\n");
|
||||
Test->connect_rwsplit();
|
||||
Test->maxscales->connect_rwsplit(0);
|
||||
Test->set_timeout(30);
|
||||
Test->add_result(create_t1(Test->conn_rwsplit), "Error creating 't1'\n");
|
||||
Test->add_result(create_t1(Test->maxscales->conn_rwsplit[0]), "Error creating 't1'\n");
|
||||
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "INSERT INTO t1 (x1, fl) VALUES(0, 1);");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "INSERT INTO t1 (x1, fl) VALUES(0, 1);");
|
||||
Test->tprintf("Changing master to node 1\n");
|
||||
Test->set_timeout(60);
|
||||
Test->repl->change_master(1, 0);
|
||||
@ -35,13 +35,13 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(60);
|
||||
sprintf(sql, "INSERT INTO t1 (x1, fl) VALUES(%d, 2);", i);
|
||||
Test->tprintf("Trying: %d\n", i);
|
||||
execute_query(Test->conn_rwsplit, sql);
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], sql);
|
||||
}
|
||||
Test->set_timeout(60);
|
||||
Test->tprintf("executing SELECT\n");
|
||||
execute_query(Test->conn_rwsplit, (char *) "SELECT * FROM t1;");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], (char *) "SELECT * FROM t1;");
|
||||
|
||||
Test->close_rwsplit();
|
||||
Test->maxscales->close_rwsplit(0);
|
||||
|
||||
/** Sleep for at least one monitor interval */
|
||||
Test->tprintf("Waiting for monitor to detect changes\n");
|
||||
@ -49,10 +49,10 @@ int main(int argc, char *argv[])
|
||||
sleep(3);
|
||||
|
||||
Test->set_timeout(60);
|
||||
Test->connect_rwsplit();
|
||||
Test->maxscales->connect_rwsplit(0);
|
||||
Test->tprintf("Reconnecting and executing SELECT again\n");
|
||||
Test->set_timeout(60);
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "SELECT * FROM t1;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "SELECT * FROM t1;");
|
||||
|
||||
Test->tprintf("Changing master back to node 0\n");
|
||||
Test->set_timeout(60);
|
||||
|
@ -20,69 +20,69 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(60);
|
||||
|
||||
Test->repl->connect();
|
||||
Test->connect_maxscale();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
|
||||
Test->tprintf("Creating user 'user' \n");
|
||||
|
||||
execute_query(Test->conn_rwsplit, "DROP USER 'user'@'%%'");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "CREATE USER user@'%%' identified by 'pass2'");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "GRANT SELECT ON test.* TO user@'%%'");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "FLUSH PRIVILEGES;");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "DROP TABLE IF EXISTS t1");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "CREATE TABLE t1 (x1 int, fl int)");
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "DROP USER 'user'@'%%'");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "CREATE USER user@'%%' identified by 'pass2'");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "GRANT SELECT ON test.* TO user@'%%'");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "FLUSH PRIVILEGES;");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "DROP TABLE IF EXISTS t1");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "CREATE TABLE t1 (x1 int, fl int)");
|
||||
|
||||
Test->tprintf("Changing user... \n");
|
||||
Test->add_result(mysql_change_user(Test->conn_rwsplit, (char *) "user", (char *) "pass2", (char *) "test") ,
|
||||
Test->add_result(mysql_change_user(Test->maxscales->conn_rwsplit[0], (char *) "user", (char *) "pass2", (char *) "test") ,
|
||||
"changing user failed \n");
|
||||
Test->tprintf("mysql_error is %s\n", mysql_error(Test->conn_rwsplit));
|
||||
Test->tprintf("mysql_error is %s\n", mysql_error(Test->maxscales->conn_rwsplit[0]));
|
||||
|
||||
Test->tprintf("Trying INSERT (expecting access denied)... \n");
|
||||
if ( execute_query(Test->conn_rwsplit, (char *) "INSERT INTO t1 VALUES (77, 11);") == 0)
|
||||
if ( execute_query(Test->maxscales->conn_rwsplit[0], (char *) "INSERT INTO t1 VALUES (77, 11);") == 0)
|
||||
{
|
||||
Test->add_result(1, "INSERT query succedded to user which does not have INSERT PRIVILEGES\n");
|
||||
}
|
||||
|
||||
Test->tprintf("Changing user back... \n");
|
||||
Test->add_result(mysql_change_user(Test->conn_rwsplit, Test->repl->user_name, Test->repl->password,
|
||||
Test->add_result(mysql_change_user(Test->maxscales->conn_rwsplit[0], Test->repl->user_name, Test->repl->password,
|
||||
(char *) "test"), "changing user failed \n");
|
||||
|
||||
Test->tprintf("Trying INSERT (expecting success)... \n");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "INSERT INTO t1 VALUES (77, 12);");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "INSERT INTO t1 VALUES (77, 12);");
|
||||
|
||||
Test->tprintf("Changing user with wrong password... \n");
|
||||
if (mysql_change_user(Test->conn_rwsplit, (char *) "user", (char *) "wrong_pass2", (char *) "test") == 0)
|
||||
if (mysql_change_user(Test->maxscales->conn_rwsplit[0], (char *) "user", (char *) "wrong_pass2", (char *) "test") == 0)
|
||||
{
|
||||
Test->add_result(1, "changing user with wrong password successed! \n");
|
||||
}
|
||||
Test->tprintf("%s\n", mysql_error(Test->conn_rwsplit));
|
||||
if ((strstr(mysql_error(Test->conn_rwsplit), "Access denied for user")) == NULL)
|
||||
Test->tprintf("%s\n", mysql_error(Test->maxscales->conn_rwsplit[0]));
|
||||
if ((strstr(mysql_error(Test->maxscales->conn_rwsplit[0]), "Access denied for user")) == NULL)
|
||||
{
|
||||
Test->add_result(1, "There is no proper error message\n");
|
||||
}
|
||||
|
||||
Test->tprintf("Trying INSERT again (expecting success - use change should fail)... \n");
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "INSERT INTO t1 VALUES (77, 13);");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "INSERT INTO t1 VALUES (77, 13);");
|
||||
|
||||
|
||||
Test->tprintf("Changing user with wrong password using ReadConn \n");
|
||||
if (mysql_change_user(Test->conn_slave, (char *) "user", (char *) "wrong_pass2", (char *) "test") == 0)
|
||||
if (mysql_change_user(Test->maxscales->conn_slave[0], (char *) "user", (char *) "wrong_pass2", (char *) "test") == 0)
|
||||
{
|
||||
Test->add_result(1, "FAILED: changing user with wrong password successed! \n");
|
||||
}
|
||||
Test->tprintf("%s\n", mysql_error(Test->conn_slave));
|
||||
if ((strstr(mysql_error(Test->conn_slave), "Access denied for user")) == NULL)
|
||||
Test->tprintf("%s\n", mysql_error(Test->maxscales->conn_slave[0]));
|
||||
if ((strstr(mysql_error(Test->maxscales->conn_slave[0]), "Access denied for user")) == NULL)
|
||||
{
|
||||
Test->add_result(1, "There is no proper error message\n");
|
||||
}
|
||||
|
||||
Test->tprintf("Changing user for ReadConn \n");
|
||||
Test->add_result(mysql_change_user(Test->conn_slave, (char *) "user", (char *) "pass2", (char *) "test") ,
|
||||
Test->add_result(mysql_change_user(Test->maxscales->conn_slave[0], (char *) "user", (char *) "pass2", (char *) "test") ,
|
||||
"changing user failed \n");
|
||||
|
||||
Test->try_query(Test->conn_rwsplit, (char *) "DROP USER user@'%%';");
|
||||
execute_query_silent(Test->conn_rwsplit, "DROP TABLE test.t1");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "DROP USER user@'%%';");
|
||||
execute_query_silent(Test->maxscales->conn_rwsplit[0], "DROP TABLE test.t1");
|
||||
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -8,18 +8,20 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int exit_code;
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
|
||||
/*Test->restart_maxscale();
|
||||
/*Test->maxscales->restart_maxscale(0);
|
||||
sleep(5);*/
|
||||
Test->set_timeout(10);
|
||||
|
||||
Test->tprintf("Connecting to Maxscale routers with Master/Slave backend\n");
|
||||
Test->connect_maxscale();
|
||||
Test->tprintf("Connecting to Maxscale maxscales->routers[0] with Master/Slave backend\n");
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->tprintf("Testing connections\n");
|
||||
Test->add_result(Test->test_maxscale_connections(true, true, true), "Can't connect to backend\n");
|
||||
Test->add_result(Test->test_maxscale_connections(0, true, true, true), "Can't connect to backend\n");
|
||||
Test->tprintf("Connecting to Maxscale router with Galera backend\n");
|
||||
MYSQL * g_conn = open_conn(4016 , Test->maxscale_IP, Test->maxscale_user, Test->maxscale_password, Test->ssl);
|
||||
MYSQL * g_conn = open_conn(4016 , Test->maxscales->IP[0], Test->maxscales->user_name,
|
||||
Test->maxscales->password, Test->ssl);
|
||||
if (g_conn != NULL )
|
||||
{
|
||||
Test->tprintf("Testing connection\n");
|
||||
@ -27,10 +29,10 @@ int main(int argc, char *argv[])
|
||||
(char *) "Error executing query against RWSplit Galera\n");
|
||||
}
|
||||
Test->tprintf("Closing connections\n");
|
||||
Test->close_maxscale_connections();
|
||||
Test->check_maxscale_alive();
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
Test->check_maxscale_alive(0);
|
||||
|
||||
char * ver = Test->ssh_maxscale_output(false, "maxscale --version-full");
|
||||
char * ver = Test->maxscales->ssh_node_output(0, "maxscale --version-full", false, &exit_code);
|
||||
Test->tprintf("Maxscale_full_version_start:\n%s\nMaxscale_full_version_end\n", ver);
|
||||
|
||||
if ((Test->global_result == 0) && (Test->use_snapshots))
|
||||
|
@ -12,8 +12,6 @@ monitor_interval=1000
|
||||
detect_standalone_master=true
|
||||
failcount=2
|
||||
allow_cluster_recovery=true
|
||||
events=master_down
|
||||
script=/home/vagrant/replication-manager --hosts=$LIST --user=skysql:skysql --rpluser=skysql:skysql --switchover-at-sync=false --log-level=3 --logfile=/tmp/mrm.log switchover
|
||||
|
||||
[RW Split Router]
|
||||
type=service
|
||||
|
@ -33,13 +33,13 @@ void Config::add_server(int num)
|
||||
{
|
||||
test_->tprintf("Adding the servers");
|
||||
test_->set_timeout(120);
|
||||
test_->ssh_maxscale(true, "maxadmin add server server%d " SERVICE_NAME1, num);
|
||||
test_->ssh_maxscale(true, "maxadmin add server server%d " SERVICE_NAME2, num);
|
||||
test_->ssh_maxscale(true, "maxadmin add server server%d " SERVICE_NAME3, num);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin add server server%d " SERVICE_NAME1, num);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin add server server%d " SERVICE_NAME2, num);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin add server server%d " SERVICE_NAME3, num);
|
||||
|
||||
for (auto& a : created_monitors_)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin add server server%d %s", num, a.c_str());
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin add server server%d %s", num, a.c_str());
|
||||
}
|
||||
|
||||
test_->stop_timeout();
|
||||
@ -48,13 +48,13 @@ void Config::add_server(int num)
|
||||
void Config::remove_server(int num)
|
||||
{
|
||||
test_->set_timeout(120);
|
||||
test_->ssh_maxscale(true, "maxadmin remove server server%d " SERVICE_NAME1, num);
|
||||
test_->ssh_maxscale(true, "maxadmin remove server server%d " SERVICE_NAME2, num);
|
||||
test_->ssh_maxscale(true, "maxadmin remove server server%d " SERVICE_NAME3, num);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin remove server server%d " SERVICE_NAME1, num);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin remove server server%d " SERVICE_NAME2, num);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin remove server server%d " SERVICE_NAME3, num);
|
||||
|
||||
for (auto& a : created_monitors_)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin remove server server%d %s", num, a.c_str());
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin remove server server%d %s", num, a.c_str());
|
||||
}
|
||||
|
||||
test_->stop_timeout();
|
||||
@ -64,14 +64,14 @@ void Config::add_created_servers(const char *object)
|
||||
{
|
||||
for (auto a : created_servers_)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin add server server%d %s", a, object);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin add server server%d %s", a, object);
|
||||
}
|
||||
}
|
||||
|
||||
void Config::destroy_server(int num)
|
||||
{
|
||||
test_->set_timeout(120);
|
||||
test_->ssh_maxscale(true, "maxadmin destroy server server%d", num);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin destroy server server%d", num);
|
||||
created_servers_.erase(num);
|
||||
test_->stop_timeout();
|
||||
}
|
||||
@ -79,35 +79,35 @@ void Config::destroy_server(int num)
|
||||
void Config::create_server(int num)
|
||||
{
|
||||
test_->set_timeout(120);
|
||||
test_->ssh_maxscale(true, "maxadmin create server server%d %s %d",
|
||||
num, test_->repl->IP[num], test_->repl->port[num]);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin create server server%d %s %d",
|
||||
num, test_->repl->IP[num], test_->repl->port[num]);
|
||||
created_servers_.insert(num);
|
||||
test_->stop_timeout();
|
||||
}
|
||||
|
||||
void Config::alter_server(int num, const char *key, const char *value)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin alter server server%d %s=%s", num, key, value);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin alter server server%d %s=%s", num, key, value);
|
||||
}
|
||||
|
||||
void Config::alter_server(int num, const char *key, int value)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin alter server server%d %s=%d", num, key, value);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin alter server server%d %s=%d", num, key, value);
|
||||
}
|
||||
|
||||
void Config::alter_server(int num, const char *key, float value)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin alter server server%d %s=%f", num, key, value);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin alter server server%d %s=%f", num, key, value);
|
||||
}
|
||||
|
||||
void Config::create_monitor(const char *name, const char *module, int interval)
|
||||
{
|
||||
test_->set_timeout(120);
|
||||
test_->ssh_maxscale(true, "maxadmin create monitor %s %s", name, module);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin create monitor %s %s", name, module);
|
||||
alter_monitor(name, "monitor_interval", interval);
|
||||
alter_monitor(name, "user", test_->maxscale_user);
|
||||
alter_monitor(name, "password", test_->maxscale_password);
|
||||
test_->ssh_maxscale(true, "maxadmin restart monitor %s", name);
|
||||
alter_monitor(name, "user", test_->maxscales->user_name);
|
||||
alter_monitor(name, "password", test_->maxscales->password);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin restart monitor %s", name);
|
||||
test_->stop_timeout();
|
||||
|
||||
created_monitors_.insert(std::string(name));
|
||||
@ -115,28 +115,28 @@ void Config::create_monitor(const char *name, const char *module, int interval)
|
||||
|
||||
void Config::alter_monitor(const char* name, const char *key, const char *value)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin alter monitor %s %s=%s", name, key, value);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin alter monitor %s %s=%s", name, key, value);
|
||||
}
|
||||
|
||||
void Config::alter_monitor(const char* name, const char *key, int value)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin alter monitor %s %s=%d", name, key, value);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin alter monitor %s %s=%d", name, key, value);
|
||||
}
|
||||
|
||||
void Config::alter_monitor(const char* name, const char *key, float value)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin alter monitor %s %s=%f", name, key, value);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin alter monitor %s %s=%f", name, key, value);
|
||||
}
|
||||
|
||||
void Config::start_monitor(const char *name)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin restart monitor %s", name);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin restart monitor %s", name);
|
||||
}
|
||||
|
||||
void Config::destroy_monitor(const char *name)
|
||||
{
|
||||
test_->set_timeout(120);
|
||||
test_->ssh_maxscale(true, "maxadmin destroy monitor %s", name);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin destroy monitor %s", name);
|
||||
test_->stop_timeout();
|
||||
created_monitors_.erase(std::string(name));
|
||||
}
|
||||
@ -145,8 +145,8 @@ void Config::restart_monitors()
|
||||
{
|
||||
for (auto& a : created_monitors_)
|
||||
{
|
||||
test_->ssh_maxscale(true, "maxadmin shutdown monitor \"%s\"", a.c_str());
|
||||
test_->ssh_maxscale(true, "maxadmin restart monitor \"%s\"", a.c_str());
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin shutdown monitor \"%s\"", a.c_str());
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin restart monitor \"%s\"", a.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,10 +155,10 @@ void Config::create_listener(Config::Service service)
|
||||
int i = static_cast<int>(service);
|
||||
|
||||
test_->set_timeout(120);
|
||||
test_->ssh_maxscale(true, "maxadmin create listener %s %s default %d",
|
||||
services[i].service,
|
||||
services[i].listener,
|
||||
services[i].port);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin create listener %s %s default %d",
|
||||
services[i].service,
|
||||
services[i].listener,
|
||||
services[i].port);
|
||||
test_->stop_timeout();
|
||||
}
|
||||
|
||||
@ -167,13 +167,13 @@ void Config::create_ssl_listener(Config::Service service)
|
||||
int i = static_cast<int>(service);
|
||||
|
||||
test_->set_timeout(120);
|
||||
test_->ssh_maxscale(true, "maxadmin create listener %s %s default %d default default default "
|
||||
"/home/vagrant/certs/server-key.pem "
|
||||
"/home/vagrant/certs/server-cert.pem "
|
||||
"/home/vagrant/certs/ca.pem ",
|
||||
services[i].service,
|
||||
services[i].listener,
|
||||
services[i].port);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin create listener %s %s default %d default default default "
|
||||
"/home/vagrant/certs/server-key.pem "
|
||||
"/home/vagrant/certs/server-cert.pem "
|
||||
"/home/vagrant/certs/ca.pem ",
|
||||
services[i].service,
|
||||
services[i].listener,
|
||||
services[i].port);
|
||||
test_->stop_timeout();
|
||||
}
|
||||
|
||||
@ -182,8 +182,8 @@ void Config::destroy_listener(Config::Service service)
|
||||
int i = static_cast<int>(service);
|
||||
|
||||
test_->set_timeout(120);
|
||||
test_->ssh_maxscale(true, "maxadmin destroy listener %s %s",
|
||||
services[i].service, services[i].listener);
|
||||
test_->maxscales->ssh_node_f(0, true, "maxadmin destroy listener %s %s",
|
||||
services[i].service, services[i].listener);
|
||||
test_->stop_timeout();
|
||||
}
|
||||
|
||||
@ -211,8 +211,9 @@ bool Config::check_server_count(int expected)
|
||||
{
|
||||
bool rval = true;
|
||||
|
||||
if (test_->ssh_maxscale(true, "test \"`maxadmin list servers|grep 'server[0-9]'|wc -l`\" == \"%d\"",
|
||||
expected))
|
||||
if (test_->maxscales->ssh_node_f(0, true,
|
||||
"test \"`maxadmin list servers|grep 'server[0-9]'|wc -l`\" == \"%d\"",
|
||||
expected))
|
||||
{
|
||||
test_->add_result(1, "Number of servers is not %d.", expected);
|
||||
rval = false;
|
||||
|
@ -28,12 +28,12 @@ int main(int argc, char **argv)
|
||||
TestConnections *test = new TestConnections(argc, argv);
|
||||
int rval = 0;
|
||||
|
||||
test->stop_maxscale();
|
||||
test->maxscales->stop_maxscale(0);
|
||||
|
||||
for (int i = 0; bad_configs[i]; i++)
|
||||
{
|
||||
printf("Testing %s...\n", bad_configs[i]);
|
||||
if (test->test_bad_config(bad_configs[i]))
|
||||
if (test->test_bad_config(0, bad_configs[i]))
|
||||
{
|
||||
printf("FAILED\n");
|
||||
rval++;
|
||||
|
@ -7,14 +7,14 @@
|
||||
|
||||
bool try_connect(TestConnections& test)
|
||||
{
|
||||
const char* ip = test.maxscale_IP;
|
||||
const char* user = test.maxscale_user;
|
||||
const char* pw = test.maxscale_password;
|
||||
const char* ip = test.maxscales->IP[0];
|
||||
const char* user = test.maxscales->user_name;
|
||||
const char* pw = test.maxscales->password;
|
||||
const char* db = "test_db";
|
||||
|
||||
MYSQL* rwsplit = open_conn_db(test.rwsplit_port, ip, db, user, pw, false);
|
||||
MYSQL* master = open_conn_db(test.readconn_master_port, ip, db, user, pw, false);
|
||||
MYSQL* slave = open_conn_db(test.readconn_slave_port, ip, db, user, pw, false);
|
||||
MYSQL* rwsplit = open_conn_db(test.maxscales->rwsplit_port[0], ip, db, user, pw, false);
|
||||
MYSQL* master = open_conn_db(test.maxscales->readconn_master_port[0], ip, db, user, pw, false);
|
||||
MYSQL* slave = open_conn_db(test.maxscales->readconn_slave_port[0], ip, db, user, pw, false);
|
||||
bool rval = false;
|
||||
|
||||
if (rwsplit && master && slave &&
|
||||
@ -40,8 +40,9 @@ int main(int argc, char *argv[])
|
||||
test.tprintf("Connecting to RWSplit");
|
||||
|
||||
test.set_timeout(30);
|
||||
MYSQL* conn = open_conn_no_db(test.rwsplit_port, test.maxscale_IP, test.maxscale_user,
|
||||
test.maxscale_password, test.ssl);
|
||||
MYSQL* conn = open_conn_no_db(test.maxscales->rwsplit_port[0], test.maxscales->IP[0],
|
||||
test.maxscales->user_name,
|
||||
test.maxscales->password, test.ssl);
|
||||
test.add_result(conn == NULL, "Error connecting to MaxScale");
|
||||
|
||||
test.tprintf("Removing 'test_db' DB");
|
||||
@ -52,12 +53,12 @@ int main(int argc, char *argv[])
|
||||
sleep(5);
|
||||
|
||||
test.set_timeout(30);
|
||||
test.tprintf("Connection to non-existing DB (all routers)");
|
||||
test.tprintf("Connection to non-existing DB (all maxscales->routers[0])");
|
||||
test.add_result(try_connect(test), "Connection with dropped database should fail");
|
||||
|
||||
test.tprintf("Connecting to RWSplit again to recreate 'test_db' db");
|
||||
conn = open_conn_no_db(test.rwsplit_port, test.maxscale_IP, test.maxscale_user,
|
||||
test.maxscale_password, test.ssl);
|
||||
conn = open_conn_no_db(test.maxscales->rwsplit_port[0], test.maxscales->IP[0], test.maxscales->user_name,
|
||||
test.maxscales->password, test.ssl);
|
||||
test.add_result(conn == NULL, "Error connecting to MaxScale");
|
||||
|
||||
test.tprintf("Creating and selecting 'test_db' DB");
|
||||
@ -72,8 +73,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
test.tprintf("Trying simple operations with t1 ");
|
||||
conn = open_conn_no_db(test.rwsplit_port, test.maxscale_IP, test.maxscale_user,
|
||||
test.maxscale_password, test.ssl);
|
||||
conn = open_conn_no_db(test.maxscales->rwsplit_port[0], test.maxscales->IP[0], test.maxscales->user_name,
|
||||
test.maxscales->password, test.ssl);
|
||||
test.try_query(conn, "USE test_db");
|
||||
test.try_query(conn, "INSERT INTO t1 (x1, fl) VALUES(0, 1)");
|
||||
test.set_timeout(60);
|
||||
|
@ -19,15 +19,17 @@ int check_max_conn(int router, int max_conn, TestConnections * Test)
|
||||
int i;
|
||||
for (i = 0; i < max_conn; i++)
|
||||
{
|
||||
conn[i] = open_conn(Test->ports[router], Test->maxscale_IP, Test->maxscale_user, Test->maxscale_password,
|
||||
conn[i] = open_conn(Test->maxscales->ports[0][router], Test->maxscales->IP[0], Test->maxscales->user_name,
|
||||
Test->maxscales->password,
|
||||
Test->ssl);
|
||||
if (mysql_errno(conn[i]) != 0)
|
||||
{
|
||||
Test->add_result(1, "Connection %d failed, error is %s\n", i, mysql_error(conn[i]));
|
||||
}
|
||||
}
|
||||
conn[max_conn] = open_conn(Test->ports[router], Test->maxscale_IP, Test->maxscale_user,
|
||||
Test->maxscale_password, Test->ssl);
|
||||
conn[max_conn] = open_conn(Test->maxscales->ports[0][router], Test->maxscales->IP[0],
|
||||
Test->maxscales->user_name,
|
||||
Test->maxscales->password, Test->ssl);
|
||||
if (mysql_errno(conn[i]) != 1040)
|
||||
{
|
||||
Test->add_result(1, "Max_xonnections reached, but error is not 1040, it is %d %s\n", mysql_errno(conn[i]),
|
||||
@ -52,9 +54,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
sleep(10);
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ int main(int argc, char *argv[])
|
||||
Test->repl->close_connections();
|
||||
Test->stop_timeout();
|
||||
|
||||
Test->check_log_err((char *) "refresh rate limit exceeded", false);
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_log_err(0, (char *) "refresh rate limit exceeded", false);
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -42,11 +42,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
Test->galera->close_connections();
|
||||
|
||||
Test->check_log_err((char *) "refresh rate limit exceeded", false);
|
||||
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();
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -36,7 +36,7 @@ MYSQL * connect_to_serv(TestConnections* Test, bool binlog)
|
||||
}
|
||||
else
|
||||
{
|
||||
conn = Test->open_rwsplit_connection();
|
||||
conn = Test->maxscales->open_rwsplit_connection(0);
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
@ -52,9 +52,9 @@ void set_max_packet(TestConnections* Test, bool binlog, char * cmd)
|
||||
}
|
||||
else
|
||||
{
|
||||
Test->connect_maxscale();
|
||||
Test->try_query(Test->conn_rwsplit, cmd);
|
||||
Test->close_maxscale_connections();
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], cmd);
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
}
|
||||
Test->tprintf(".. done\n");
|
||||
}
|
||||
|
@ -19,10 +19,10 @@ int main(int argc, char *argv[])
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
|
||||
Test->set_timeout(300);
|
||||
Test->start_binlog();
|
||||
Test->start_binlog(0);
|
||||
different_packet_size(Test, true);
|
||||
|
||||
Test->check_maxscale_processes(1);
|
||||
Test->check_maxscale_processes(0, 1);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -19,7 +19,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
different_packet_size(Test, false);
|
||||
|
||||
Test->check_maxscale_alive();
|
||||
Test->check_maxscale_alive(0);
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
|
@ -10,11 +10,14 @@
|
||||
int create_key(TestConnections *test)
|
||||
{
|
||||
int res = 0;
|
||||
int exit_code;
|
||||
test->set_timeout(120);
|
||||
test->tprintf("Creating new encryption keys\n");
|
||||
test->ssh_maxscale(true, "test -f /var/lib/maxscale/.secrets && sudo rm /var/lib/maxscale/.secrets");
|
||||
test->ssh_maxscale(true, "maxkeys");
|
||||
char *result = test->ssh_maxscale_output(false, "sudo test -f /var/lib/maxscale/.secrets && echo SUCCESS");
|
||||
test->maxscales->ssh_node(0, "test -f /var/lib/maxscale/.secrets && sudo rm /var/lib/maxscale/.secrets",
|
||||
true);
|
||||
test->maxscales->ssh_node(0, "maxkeys", true);
|
||||
char *result = test->maxscales->ssh_node_output(0, "sudo test -f /var/lib/maxscale/.secrets && echo SUCCESS",
|
||||
false, &exit_code);
|
||||
|
||||
if (strncmp(result, "SUCCESS", 7) != 0)
|
||||
{
|
||||
@ -23,7 +26,7 @@ int create_key(TestConnections *test)
|
||||
}
|
||||
else
|
||||
{
|
||||
test->ssh_maxscale(true, "sudo chown maxscale:maxscale /var/lib/maxscale/.secrets");
|
||||
test->maxscales->ssh_node(0, "sudo chown maxscale:maxscale /var/lib/maxscale/.secrets", true);
|
||||
}
|
||||
|
||||
free(result);
|
||||
@ -34,12 +37,13 @@ int create_key(TestConnections *test)
|
||||
/** Hash a new password and start MaxScale */
|
||||
int hash_password(TestConnections *test)
|
||||
{
|
||||
test->stop_maxscale();
|
||||
test->maxscales->stop_maxscale(0);
|
||||
test->stop_timeout();
|
||||
|
||||
int res = 0;
|
||||
int exit_code;
|
||||
test->tprintf("Creating a new encrypted password\n");
|
||||
char *enc_pw = test->ssh_maxscale_output(true, "maxpasswd /var/lib/maxscale/ skysql");
|
||||
char *enc_pw = test->maxscales->ssh_node_output(0, "maxpasswd /var/lib/maxscale/ skysql", true, &exit_code);
|
||||
|
||||
char *ptr = strchr(enc_pw, '\n');
|
||||
if (ptr)
|
||||
@ -48,15 +52,16 @@ int hash_password(TestConnections *test)
|
||||
}
|
||||
|
||||
test->tprintf("Encrypted password is: %s\n", enc_pw);
|
||||
test->ssh_maxscale(true, "sed -i -e 's/passwd[[:space:]]*=[[:space:]]*skysql/passwd=%s/' /etc/maxscale.cnf",
|
||||
enc_pw);
|
||||
test->maxscales->ssh_node_f(0, true,
|
||||
"sed -i -e 's/passwd[[:space:]]*=[[:space:]]*skysql/passwd=%s/' /etc/maxscale.cnf",
|
||||
enc_pw);
|
||||
free(enc_pw);
|
||||
|
||||
test->tprintf("Starting MaxScale\n");
|
||||
test->start_maxscale();
|
||||
test->maxscales->start_maxscale(0);
|
||||
|
||||
test->tprintf("Checking if MaxScale is alive\n");
|
||||
return test->check_maxscale_alive();
|
||||
return test->check_maxscale_alive(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,13 +15,14 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int exit_code;
|
||||
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->maxscales->connect_maxscale(0);
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "CREATE OR REPLACE TABLE test.t1 (id int)");
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
|
||||
test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
test->tprintf(" Block all but one node ");
|
||||
test->repl->block_node(0);
|
||||
@ -34,12 +35,12 @@ int main(int argc, char *argv[])
|
||||
sleep(15);
|
||||
|
||||
test->tprintf(" Connect and insert should work ");
|
||||
char *output = test->ssh_maxscale_output(true, "maxadmin list servers");
|
||||
char *output = test->maxscales->ssh_node_output(0, "maxadmin list servers", true, &exit_code);
|
||||
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->maxscales->connect_maxscale(0);
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "INSERT INTO test.t1 VALUES (1)");
|
||||
test->maxscales->close_maxscale_connections(0);
|
||||
|
||||
test->tprintf(" Unblock nodes ");
|
||||
test->repl->unblock_node(0);
|
||||
@ -52,18 +53,18 @@ int main(int argc, char *argv[])
|
||||
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)");
|
||||
test->maxscales->connect_maxscale(0);
|
||||
test->try_query(test->maxscales->conn_rwsplit[0], "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);
|
||||
find_field(test->maxscales->conn_rwsplit[0], "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->maxscales->close_maxscale_connections(0);
|
||||
|
||||
test->tprintf(" Check that MaxScale is running ");
|
||||
test->check_maxscale_alive();
|
||||
test->check_maxscale_alive(0);
|
||||
|
||||
int rval = test->global_result;
|
||||
delete test;
|
||||
|
@ -6,14 +6,16 @@
|
||||
|
||||
void get_output(TestConnections& test)
|
||||
{
|
||||
int ec;
|
||||
test.tprintf("Maxadmin output:");
|
||||
char *output = test.ssh_maxscale_output(true, "maxadmin list servers");
|
||||
char *output = test.maxscales->ssh_node_output(0, "maxadmin list servers", true, &ec);
|
||||
test.tprintf("%s", output);
|
||||
free(output);
|
||||
|
||||
test.tprintf("MaxScale output:");
|
||||
output = test.ssh_maxscale_output(true, "cat /var/log/maxscale/maxscale.log && "
|
||||
"sudo truncate -s 0 /var/log/maxscale/maxscale.log");
|
||||
output = test.maxscales->ssh_node_output(0, "cat /var/log/maxscale/maxscale.log && "
|
||||
"sudo truncate -s 0 /var/log/maxscale/maxscale.log",
|
||||
true, &ec);
|
||||
test.tprintf("%s", output);
|
||||
free(output);
|
||||
}
|
||||
@ -22,7 +24,7 @@ static int inserts = 0;
|
||||
|
||||
void check(TestConnections& test)
|
||||
{
|
||||
MYSQL *conn = test.open_rwsplit_connection();
|
||||
MYSQL *conn = test.maxscales->open_rwsplit_connection(0);
|
||||
const char *query1 = "INSERT INTO test.t1 VALUES (%d)";
|
||||
const char *query2 = "SELECT * FROM test.t1";
|
||||
|
||||
@ -63,7 +65,7 @@ void check(TestConnections& test)
|
||||
*/
|
||||
int get_server_id(TestConnections& test)
|
||||
{
|
||||
MYSQL *conn = test.open_rwsplit_connection();
|
||||
MYSQL *conn = test.maxscales->open_rwsplit_connection(0);
|
||||
int id = -1;
|
||||
char str[1024];
|
||||
|
||||
@ -90,10 +92,10 @@ void get_input()
|
||||
void fix_replication_create_table(TestConnections& test)
|
||||
{
|
||||
test.tprintf("Fix replication and recreate table.");
|
||||
test.close_maxscale_connections();
|
||||
test.maxscales->close_maxscale_connections(0);
|
||||
test.repl->fix_replication();
|
||||
test.connect_maxscale();
|
||||
test.try_query(test.conn_rwsplit, "CREATE OR REPLACE TABLE test.t1(id INT)");
|
||||
test.maxscales->connect_maxscale(0);
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "CREATE OR REPLACE TABLE test.t1(id INT)");
|
||||
test.repl->sync_slaves();
|
||||
inserts = 0;
|
||||
|
||||
@ -116,8 +118,8 @@ int main(int argc, char** argv)
|
||||
|
||||
test.tprintf("Creating table and inserting data.");
|
||||
get_input();
|
||||
test.connect_maxscale();
|
||||
test.try_query(test.conn_rwsplit, "CREATE OR REPLACE TABLE test.t1(id INT)");
|
||||
test.maxscales->connect_maxscale(0);
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "CREATE OR REPLACE TABLE test.t1(id INT)");
|
||||
test.repl->sync_slaves();
|
||||
|
||||
check(test);
|
||||
@ -175,8 +177,8 @@ int main(int argc, char** argv)
|
||||
const char* log_slave = "log_slave_updates=1";
|
||||
test.repl->add_server_setting(1, log_slave);
|
||||
test.repl->add_server_setting(3, log_slave);
|
||||
test.repl->start_node(1, "");
|
||||
test.repl->start_node(3, "");
|
||||
test.repl->start_node(1, (char *) "");
|
||||
test.repl->start_node(3, (char *) "");
|
||||
sleep(4);
|
||||
test.tprintf("Settings changed.");
|
||||
get_output(test);
|
||||
@ -196,17 +198,17 @@ int main(int argc, char** argv)
|
||||
// Restore server 2 and 4 settings. Because server 4 is now the master, shutting it down causes
|
||||
// another failover. Prevent this by stopping maxscale.
|
||||
test.tprintf("Restoring server settings.");
|
||||
test.stop_maxscale();
|
||||
test.maxscales->stop_maxscale(0);
|
||||
test.repl->stop_node(1);
|
||||
test.repl->stop_node(3);
|
||||
sleep(4);
|
||||
test.repl->restore_server_settings(1);
|
||||
test.repl->restore_server_settings(3);
|
||||
test.repl->start_node(0, "");
|
||||
test.repl->start_node(1, "");
|
||||
test.repl->start_node(3, "");
|
||||
test.repl->start_node(0, (char *) "");
|
||||
test.repl->start_node(1, (char *) "");
|
||||
test.repl->start_node(3, (char *) "");
|
||||
sleep(4);
|
||||
test.start_maxscale();
|
||||
test.maxscales->start_maxscale(0);
|
||||
sleep(2);
|
||||
get_output(test);
|
||||
get_input();
|
||||
|
@ -15,14 +15,14 @@ int main(int argc, char *argv[])
|
||||
sleep(10);
|
||||
|
||||
test.tprintf("Clear master status");
|
||||
test.ssh_maxscale(true, "maxadmin clear server server1 master");
|
||||
test.maxscales->ssh_node(0, "maxadmin clear server server1 master", true);
|
||||
sleep(5);
|
||||
|
||||
test.repl->unblock_node(0);
|
||||
sleep(5);
|
||||
|
||||
test.check_maxscale_alive();
|
||||
test.check_log_err("debug assert", false);
|
||||
test.check_maxscale_alive(0);
|
||||
test.check_log_err(0, "debug assert", false);
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
3
maxscale-system-test/fw2/deny1
Normal file
3
maxscale-system-test/fw2/deny1
Normal file
@ -0,0 +1,3 @@
|
||||
drop table if exists t1;
|
||||
create table t1(id int);
|
||||
alter table t1 add column b int;
|
2
maxscale-system-test/fw2/deny2
Normal file
2
maxscale-system-test/fw2/deny2
Normal file
@ -0,0 +1,2 @@
|
||||
grant select on *.* to 'skysql'@'localhost';
|
||||
revoke select on *.* from 'skysql'@'localhost';
|
2
maxscale-system-test/fw2/deny3
Normal file
2
maxscale-system-test/fw2/deny3
Normal file
@ -0,0 +1,2 @@
|
||||
use test;
|
||||
load data local infile 'test.csv' into table test.t1;
|
12
maxscale-system-test/fw2/deny4
Normal file
12
maxscale-system-test/fw2/deny4
Normal file
@ -0,0 +1,12 @@
|
||||
select sum(1) from test.t1;
|
||||
select avg(1) from test.t1;
|
||||
select sum(avg(1)) from test.t1;
|
||||
select my_function(1) from test.t1;
|
||||
select my_function("1") from test.t1;
|
||||
select * from test.t1 where 1 = 1;
|
||||
select * from test.t1 where 1 >= 1;
|
||||
select * from test.t1 where 1 <= 1;
|
||||
select * from test.t1 where 1 != 1;
|
||||
select * from test.t1 where 1 <> 1;
|
||||
select function(*) from test.t1;
|
||||
select insert(*) from test.t1;
|
1
maxscale-system-test/fw2/deny5
Normal file
1
maxscale-system-test/fw2/deny5
Normal file
@ -0,0 +1 @@
|
||||
select 1;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user