Merge branch '2.1' into develop
This commit is contained in:
@ -607,6 +607,7 @@ add_test_executable(test_hints.cpp test_hints hints2 LABELS hintfilter LIGHT REP
|
||||
|
||||
# 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)
|
||||
add_test_executable(avro_alter.cpp avro_alter avro LABELS avrorouter binlogrouter LIGHT BREAKS_REPL)
|
||||
|
||||
# Test avrorouter file compression
|
||||
#add_test_script(avro_compression avro avro_compression LABELS avrorouter binlogrouter LIGHT BREAKS_REPL)
|
||||
|
@ -87,6 +87,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
execute_query(test.repl->nodes[0], "DROP TABLE test.t1;RESET MASTER");
|
||||
test.stop_timeout();
|
||||
test.repl->fix_replication();
|
||||
|
||||
return test.global_result;
|
||||
|
57
maxscale-system-test/avro_alter.cpp
Normal file
57
maxscale-system-test/avro_alter.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @file avro_alter.cpp Test ALTER TABLE handling of avrorouter
|
||||
*/
|
||||
|
||||
#include "testconnections.h"
|
||||
#include <sstream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
TestConnections test(argc, argv);
|
||||
test.set_timeout(600);
|
||||
test.ssh_maxscale(true, (char *) "rm -rf /var/lib/maxscale/avro");
|
||||
|
||||
/** Start master to binlogrouter replication */
|
||||
if (!test.replicate_from_master())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
test.set_timeout(120);
|
||||
test.repl->connect();
|
||||
|
||||
execute_query_silent(test.repl->nodes[0], "DROP TABLE test.t1");
|
||||
execute_query(test.repl->nodes[0], "CREATE TABLE test.t1(id INT)");
|
||||
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (1)");
|
||||
execute_query(test.repl->nodes[0], "ALTER TABLE test.t1 ADD COLUMN a VARCHAR(100)");
|
||||
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (2, \"a\")");
|
||||
execute_query(test.repl->nodes[0], "ALTER TABLE test.t1 ADD COLUMN b FLOAT");
|
||||
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (3, \"b\", 3.0)");
|
||||
execute_query(test.repl->nodes[0], "ALTER TABLE test.t1 CHANGE COLUMN b c DATETIME(3)");
|
||||
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (4, \"c\", NOW())");
|
||||
execute_query(test.repl->nodes[0], "ALTER TABLE test.t1 DROP COLUMN c");
|
||||
execute_query(test.repl->nodes[0], "INSERT INTO test.t1 VALUES (5, \"d\")");
|
||||
|
||||
test.repl->close_connections();
|
||||
|
||||
/** Give avrorouter some time to process the events */
|
||||
test.stop_timeout();
|
||||
sleep(10);
|
||||
test.set_timeout(120);
|
||||
|
||||
for (int i = 1; i <=5; i++)
|
||||
{
|
||||
std::stringstream cmd;
|
||||
cmd << "maxavrocheck -d /var/lib/maxscale/avro/test.t1.00000" << i << ".avro|wc -l";
|
||||
char* rows = test.ssh_maxscale_output(true, cmd.str().c_str());
|
||||
int nrows = atoi(rows);
|
||||
free(rows);
|
||||
test.add_result(nrows != 1, "Expected 1 line in file number %d, got %d", i, nrows);
|
||||
}
|
||||
|
||||
execute_query(test.repl->nodes[0], "DROP TABLE test.t1;RESET MASTER");
|
||||
test.repl->fix_replication();
|
||||
|
||||
return test.global_result;
|
||||
}
|
@ -11,7 +11,7 @@ user=maxskysql
|
||||
passwd= skysql
|
||||
|
||||
[RW Split Router]
|
||||
connection_timeout=30
|
||||
connection_timeout=10
|
||||
type=service
|
||||
router= readwritesplit
|
||||
servers=server1, server2, server3,server4
|
||||
|
@ -47,7 +47,8 @@ int main(int argc, char** argv)
|
||||
test.add_result(!mysql_stmt_prepare(stmt, query, strlen(query)), "Binary protocol preparation should fail");
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
test.try_query(test.conn_rwsplit, "DROP TABLE test.t1");
|
||||
test.repl->connect();
|
||||
test.try_query(test.repl->nodes[0], "DROP TABLE test.t1");
|
||||
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -432,6 +432,7 @@ int Mariadb_nodes::start_replication()
|
||||
"mysql -u root %s -e \"STOP SLAVE; RESET SLAVE; RESET SLAVE ALL; RESET MASTER; SET GLOBAL read_only=OFF;\"",
|
||||
socket_cmd[i]);
|
||||
ssh_node(i, str, true);
|
||||
ssh_node(i, "sudo rm -f /etc/my.cnf.d/kerb.cnf", true);
|
||||
}
|
||||
|
||||
sprintf(str, "%s/create_user.sh", test_dir);
|
||||
|
@ -14,49 +14,40 @@ router_options=max_sescmd_history=10
|
||||
* - execute one more session commad, excpect failure
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "testconnections.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
Test->set_timeout(200);
|
||||
int i;
|
||||
char sql[256];
|
||||
TestConnections test(argc, argv);
|
||||
int first_sleep = 5;
|
||||
int second_sleep = 12;
|
||||
|
||||
Test->tprintf("Open session and wait 20 seconds\n");
|
||||
Test->connect_maxscale();
|
||||
sleep(20);
|
||||
Test->tprintf("Execute query to check session\n");
|
||||
Test->try_query(Test->conn_rwsplit, "SELECT 1");
|
||||
test.set_timeout(200);
|
||||
|
||||
Test->tprintf("Wait 35 seconds more and try quiry again expecting failure\n");
|
||||
sleep(35);
|
||||
if (execute_query(Test->conn_rwsplit, "SELECT 1") == 0)
|
||||
test.tprintf("Open session, wait %d seconds and execute a query", first_sleep);
|
||||
test.connect_maxscale();
|
||||
sleep(first_sleep);
|
||||
test.try_query(test.conn_rwsplit, "SELECT 1");
|
||||
|
||||
test.tprintf("Wait %d seconds and execute query, expecting failure", second_sleep);
|
||||
sleep(second_sleep);
|
||||
test.add_result(execute_query(test.conn_rwsplit, "SELECT 1") == 0,
|
||||
"Session was not closed after %d seconds",
|
||||
second_sleep);
|
||||
test.close_maxscale_connections();
|
||||
|
||||
test.tprintf("Open session and execute 10 session commands");
|
||||
test.connect_maxscale();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Test->add_result(1, "Session was not closed after 40 seconds\n");
|
||||
test.try_query(test.conn_rwsplit, "set @test=1");
|
||||
}
|
||||
Test->close_maxscale_connections();
|
||||
|
||||
Test->tprintf("Open session and execute 10 session commands\n");
|
||||
fflush(stdout);
|
||||
Test->connect_maxscale();
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
sprintf(sql, "set @test=%d", i);
|
||||
Test->try_query(Test->conn_rwsplit, sql);
|
||||
}
|
||||
Test->tprintf("done!\n");
|
||||
test.tprintf("Execute one more session command and expect message in error log");
|
||||
execute_query(test.conn_rwsplit, "set @test=1");
|
||||
sleep(1);
|
||||
test.check_log_err("Router session exceeded session command history limit", true);
|
||||
test.close_maxscale_connections();
|
||||
|
||||
Test->tprintf("Execute one more session command and expect message in error log\n");
|
||||
execute_query(Test->conn_rwsplit, "set @test=11");
|
||||
sleep(5);
|
||||
Test->check_log_err((char *) "Router session exceeded session command history limit", true);
|
||||
Test->close_maxscale_connections();
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
return test.global_result;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static char** sql = NULL;
|
||||
static size_t sql_size = 0;
|
||||
|
||||
int execute_select_query_and_check(MYSQL *conn, char *sql, unsigned long long int rows)
|
||||
int execute_select_query_and_check(MYSQL *conn, const char *sql, unsigned long long int rows)
|
||||
{
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -11,7 +11,7 @@
|
||||
* @param rows Expected number of rows
|
||||
* @return 0 in case of success
|
||||
*/
|
||||
int execute_select_query_and_check(MYSQL *conn, char *sql, unsigned long long int rows);
|
||||
int execute_select_query_and_check(MYSQL *conn, const char *sql, unsigned long long int rows);
|
||||
|
||||
/**
|
||||
* @brief create_t1 Create t1 table, fileds: (x1 int, fl int)
|
||||
|
@ -1,16 +1,16 @@
|
||||
/**
|
||||
* @file temporal_tables.cpp Check temporal tables commands functionality (relates to bug 430)
|
||||
* Check temporary tables commands functionality (relates to bug 430)
|
||||
*
|
||||
* - create t1 table and put some data into it
|
||||
* - create tempral table t1
|
||||
* - create temporary table t1
|
||||
* - insert different data into t1
|
||||
* - check that SELECT FROM t1 gives data from tempral table
|
||||
* - create other connections using all Maxscale services and check that SELECT via these connections gives data from main t1, not temporal
|
||||
* - dropping tempral t1
|
||||
* - check that SELECT FROM t1 gives data from temporary table
|
||||
* - create other connections using all MaxScale services and check that SELECT
|
||||
* via these connections gives data from main t1, not temporary
|
||||
* - dropping temporary t1
|
||||
* - check that data from main t1 is not affected
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "testconnections.h"
|
||||
#include "sql_t1.h"
|
||||
|
||||
@ -18,82 +18,45 @@ using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
test.connect_maxscale();
|
||||
|
||||
TestConnections * Test = new TestConnections(argc, argv);
|
||||
test.tprintf("Create a table and insert two rows into it");
|
||||
test.set_timeout(30);
|
||||
|
||||
Test->repl->connect();
|
||||
execute_query(test.conn_rwsplit, "USE test");
|
||||
create_t1(test.conn_rwsplit);
|
||||
execute_query(test.conn_rwsplit, "INSERT INTO t1 (x1, fl) VALUES(0, 1)");
|
||||
execute_query(test.conn_rwsplit, "INSERT INTO t1 (x1, fl) VALUES(1, 1)");
|
||||
|
||||
MYSQL * conn;
|
||||
char sql[100];
|
||||
test.tprintf("Create temporary table and insert one row");
|
||||
test.set_timeout(30);
|
||||
|
||||
Test->set_timeout(40);
|
||||
conn = Test->open_rwsplit_connection();
|
||||
execute_query(test.conn_rwsplit, "create temporary table t1 as (SELECT * FROM t1 WHERE fl=3)");
|
||||
execute_query(test.conn_rwsplit, "INSERT INTO t1 (x1, fl) VALUES(0, 1)");
|
||||
|
||||
Test->tprintf("Cleaning up DB\n");
|
||||
execute_query(conn, (char *) "DROP DATABASE IF EXISTS test");
|
||||
execute_query(conn, (char *) "CREATE DATABASE test");
|
||||
execute_query(conn, (char *) "USE test");
|
||||
test.tprintf("Check that the temporary table has one row");
|
||||
test.set_timeout(90);
|
||||
|
||||
Test->tprintf("creating table t1\n");
|
||||
Test->set_timeout(40);
|
||||
create_t1(conn);
|
||||
test.add_result(execute_select_query_and_check(test.conn_rwsplit, "SELECT * FROM t1", 1),
|
||||
"Current connection should show one row");
|
||||
test.add_result(execute_select_query_and_check(test.conn_master, "SELECT * FROM t1", 2),
|
||||
"New connection should show two rows");
|
||||
test.add_result(execute_select_query_and_check(test.conn_slave, "SELECT * FROM t1", 2),
|
||||
"New connection should show two rows");
|
||||
|
||||
Test->tprintf("Inserting two rows into t1\n");
|
||||
Test->set_timeout(40);
|
||||
execute_query(conn, "INSERT INTO t1 (x1, fl) VALUES(0, 1);");
|
||||
execute_query(conn, "INSERT INTO t1 (x1, fl) VALUES(1, 1);");
|
||||
printf("Drop temporary table and check that the real table has two rows");
|
||||
test.set_timeout(90);
|
||||
|
||||
Test->tprintf("Creating temporal table t1\n");
|
||||
execute_query(conn, "create temporary table t1 as (SELECT * FROM t1 WHERE fl=3);");
|
||||
execute_query(test.conn_rwsplit, "DROP TABLE t1");
|
||||
test.add_result(execute_select_query_and_check(test.conn_rwsplit, "SELECT * FROM t1", 2),
|
||||
"check failed");
|
||||
test.add_result(execute_select_query_and_check(test.conn_master, "SELECT * FROM t1", 2),
|
||||
"check failed");
|
||||
test.add_result(execute_select_query_and_check(test.conn_slave, "SELECT * FROM t1", 2),
|
||||
"check failed");
|
||||
|
||||
Test->tprintf("Inserting one row into temporal table\n");
|
||||
execute_query(conn, "INSERT INTO t1 (x1, fl) VALUES(0, 1);");
|
||||
test.close_maxscale_connections();
|
||||
|
||||
Test->tprintf("Checking t1 temporal table\n");
|
||||
Test->set_timeout(240);
|
||||
Test->add_result(execute_select_query_and_check(conn, (char *) "SELECT * FROM t1;", 1), "check failed\n");
|
||||
|
||||
|
||||
Test->tprintf("Connecting to all MaxScale routers and checking main t1 table (not temporal)\n");
|
||||
Test->set_timeout(240);
|
||||
Test->add_result(Test->connect_maxscale(), "Connectiong to Maxscale failed\n");
|
||||
Test->tprintf("Checking t1 table using RWSplit router\n");
|
||||
Test->set_timeout(240);
|
||||
Test->add_result(execute_select_query_and_check(Test->conn_rwsplit, (char *) "SELECT * FROM t1;", 2),
|
||||
"check failed\n");
|
||||
Test->tprintf("Checking t1 table using ReadConn router in master mode\n");
|
||||
Test->set_timeout(240);
|
||||
Test->add_result(execute_select_query_and_check(Test->conn_master, (char *) "SELECT * FROM t1;", 2),
|
||||
"check failed\n");
|
||||
Test->tprintf("Checking t1 table using ReadConn router in slave mode\n");
|
||||
Test->set_timeout(240);
|
||||
Test->add_result(execute_select_query_and_check(Test->conn_slave, (char *) "SELECT * FROM t1;", 2),
|
||||
"check failed\n");
|
||||
Test->close_maxscale_connections();
|
||||
|
||||
|
||||
printf("Dropping temparal table and check main table again\n");
|
||||
execute_query(conn, "DROP TABLE t1;");
|
||||
|
||||
printf("Connecting to all MaxScale routers and checking main t1 table (not temporal)\n");
|
||||
Test->add_result(Test->connect_maxscale(), "Connectiong to Maxscale failed\n");
|
||||
Test->tprintf("Checking t1 table using RWSplit router\n");
|
||||
Test->set_timeout(240);
|
||||
Test->add_result(execute_select_query_and_check(Test->conn_rwsplit, (char *) "SELECT * FROM t1;", 2),
|
||||
"check failed\n");
|
||||
Test->tprintf("Checking t1 table using ReadConn router in master mode\n");
|
||||
Test->set_timeout(240);
|
||||
Test->add_result(execute_select_query_and_check(Test->conn_master, (char *) "SELECT * FROM t1;", 2),
|
||||
"check failed\n");
|
||||
Test->tprintf("Checking t1 table using ReadConn router in slave mode\n");
|
||||
Test->set_timeout(240);
|
||||
Test->add_result(execute_select_query_and_check(Test->conn_slave, (char *) "SELECT * FROM t1;", 2),
|
||||
"check failed\n");
|
||||
Test->close_maxscale_connections();
|
||||
|
||||
mysql_close(conn);
|
||||
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
return rval;
|
||||
return test.global_result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user