Speed up binlog tests
The binlogrouter tests can safely use the sync_slaves functionality of the test framework as long as a sensible timeout is used. Cleaned up the tests by removing redundant code and allocating classes from the stack thus removing the need to handle memory allocation.
This commit is contained in:
@ -13,66 +13,48 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
TestConnections test(argc, argv);
|
||||||
|
|
||||||
TestConnections * Test = new TestConnections(argc, argv);
|
test.repl->connect();
|
||||||
Test->tprintf("Test object initialized");
|
test.binlog_cmd_option = 1;
|
||||||
Test->set_timeout(3000);
|
test.start_binlog();
|
||||||
Test->tprintf("Trying to connect to backend");
|
test.repl->connect();
|
||||||
|
test.tprintf("install semisync plugin");
|
||||||
|
execute_query(test.repl->nodes[0],
|
||||||
|
(char *) "INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';");
|
||||||
|
|
||||||
if (Test->repl->connect() == 0)
|
test.tprintf("Reconnect");
|
||||||
{
|
test.repl->close_connections();
|
||||||
Test->tprintf("DROP TABLE t1");
|
test.repl->connect();
|
||||||
execute_query(Test->repl->nodes[0], (char *) "DROP TABLE IF EXISTS t1;");
|
test.tprintf("SET GLOBAL rpl_semi_sync_master_enabled = 1;");
|
||||||
|
execute_query(test.repl->nodes[0], (char *) "SET GLOBAL rpl_semi_sync_master_enabled = 1;");
|
||||||
|
test.repl->close_connections();
|
||||||
|
test_binlog(&test);
|
||||||
|
|
||||||
Test->repl->close_connections();
|
test.repl->connect();
|
||||||
sleep(5);
|
test.tprintf("SET GLOBAL rpl_semi_sync_master_enabled = 0;");
|
||||||
|
execute_query(test.repl->nodes[0], (char *) "SET GLOBAL rpl_semi_sync_master_enabled = 0;");
|
||||||
|
test.repl->close_connections();
|
||||||
|
test_binlog(&test);
|
||||||
|
|
||||||
Test->binlog_cmd_option = 1;
|
test.repl->connect();
|
||||||
Test->start_binlog();
|
test.tprintf("uninstall semisync plugin");
|
||||||
Test->repl->connect();
|
execute_query(test.repl->nodes[0], (char *) "UNINSTALL PLUGIN rpl_semi_sync_master;");
|
||||||
Test->tprintf("install semisync plugin");
|
test.tprintf("Reconnect");
|
||||||
execute_query(Test->repl->nodes[0],
|
test.repl->close_connections();
|
||||||
(char *) "INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';");
|
test.repl->connect();
|
||||||
|
test.tprintf("SET GLOBAL rpl_semi_sync_master_enabled = 1;");
|
||||||
|
execute_query(test.repl->nodes[0], (char *) "SET GLOBAL rpl_semi_sync_master_enabled = 1;");
|
||||||
|
test.repl->close_connections();
|
||||||
|
test_binlog(&test);
|
||||||
|
|
||||||
Test->tprintf("Reconnect");
|
test.repl->connect();
|
||||||
Test->repl->close_connections();
|
test.tprintf("SET GLOBAL rpl_semi_sync_master_enabled = 0;");
|
||||||
Test->repl->connect();
|
execute_query(test.repl->nodes[0], (char *) "SET GLOBAL rpl_semi_sync_master_enabled = 0;");
|
||||||
Test->tprintf("SET GLOBAL rpl_semi_sync_master_enabled = 1;");
|
test.repl->sync_slaves();;
|
||||||
execute_query(Test->repl->nodes[0], (char *) "SET GLOBAL rpl_semi_sync_master_enabled = 1;");
|
test.repl->close_connections();
|
||||||
Test->repl->close_connections();
|
test_binlog(&test);
|
||||||
test_binlog(Test);
|
|
||||||
|
|
||||||
Test->repl->connect();
|
return test.global_result;
|
||||||
Test->tprintf("SET GLOBAL rpl_semi_sync_master_enabled = 0;");
|
|
||||||
execute_query(Test->repl->nodes[0], (char *) "SET GLOBAL rpl_semi_sync_master_enabled = 0;");
|
|
||||||
Test->repl->close_connections();
|
|
||||||
test_binlog(Test);
|
|
||||||
|
|
||||||
Test->repl->connect();
|
|
||||||
Test->tprintf("uninstall semisync plugin");
|
|
||||||
execute_query(Test->repl->nodes[0], (char *) "UNINSTALL PLUGIN rpl_semi_sync_master;");
|
|
||||||
Test->tprintf("Reconnect");
|
|
||||||
Test->repl->close_connections();
|
|
||||||
Test->repl->connect();
|
|
||||||
Test->tprintf("SET GLOBAL rpl_semi_sync_master_enabled = 1;");
|
|
||||||
execute_query(Test->repl->nodes[0], (char *) "SET GLOBAL rpl_semi_sync_master_enabled = 1;");
|
|
||||||
Test->repl->close_connections();
|
|
||||||
test_binlog(Test);
|
|
||||||
|
|
||||||
Test->repl->connect();
|
|
||||||
Test->tprintf("SET GLOBAL rpl_semi_sync_master_enabled = 0;");
|
|
||||||
execute_query(Test->repl->nodes[0], (char *) "SET GLOBAL rpl_semi_sync_master_enabled = 0;");
|
|
||||||
sleep(10);
|
|
||||||
Test->repl->close_connections();
|
|
||||||
test_binlog(Test);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Test->add_result(1, "Can't connect to backend");
|
|
||||||
}
|
|
||||||
|
|
||||||
int rval = Test->global_result;
|
|
||||||
delete Test;
|
|
||||||
return rval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,32 +38,15 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
TestConnections test(argc, argv);
|
||||||
|
|
||||||
TestConnections * Test = new TestConnections(argc, argv);
|
test.binlog_cmd_option = 1;
|
||||||
Test->set_timeout(3000);
|
test.start_binlog();
|
||||||
int options_set = 3;
|
test_binlog(&test);
|
||||||
if (Test->smoke)
|
|
||||||
{
|
|
||||||
options_set = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Test->repl->connect();
|
test.check_log_err("SET NAMES utf8mb4", false);
|
||||||
execute_query(Test->repl->nodes[0], (char *) "DROP TABLE IF EXISTS t1;");
|
test.check_log_err("set autocommit=1", false);
|
||||||
Test->repl->close_connections();
|
test.check_log_err("select USER()", false);
|
||||||
sleep(5);
|
|
||||||
|
|
||||||
for (int option = 0; option < options_set; option++)
|
return test.global_result;
|
||||||
{
|
|
||||||
Test->binlog_cmd_option = option;
|
|
||||||
Test->start_binlog();
|
|
||||||
test_binlog(Test);
|
|
||||||
}
|
|
||||||
|
|
||||||
Test->check_log_err("SET NAMES utf8mb4", false);
|
|
||||||
Test->check_log_err("set autocommit=1", false);
|
|
||||||
Test->check_log_err("select USER()", false);
|
|
||||||
|
|
||||||
int rval = Test->global_result;
|
|
||||||
delete Test;
|
|
||||||
return rval;
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ int check_sha1(TestConnections* Test)
|
|||||||
local_result += execute_query(Test->repl->nodes[0], (char *) "FLUSH LOGS");
|
local_result += execute_query(Test->repl->nodes[0], (char *) "FLUSH LOGS");
|
||||||
Test->tprintf("Logs flushed");
|
Test->tprintf("Logs flushed");
|
||||||
Test->set_timeout(100);
|
Test->set_timeout(100);
|
||||||
sleep(20);
|
Test->repl->sync_slaves();
|
||||||
Test->tprintf("ls after first FLUSH LOGS");
|
Test->tprintf("ls after first FLUSH LOGS");
|
||||||
Test->tprintf("Maxscale");
|
Test->tprintf("Maxscale");
|
||||||
Test->set_timeout(50);
|
Test->set_timeout(50);
|
||||||
@ -45,7 +45,7 @@ int check_sha1(TestConnections* Test)
|
|||||||
Test->tprintf("Logs flushed");
|
Test->tprintf("Logs flushed");
|
||||||
|
|
||||||
Test->set_timeout(50);
|
Test->set_timeout(50);
|
||||||
sleep(20);
|
Test->repl->sync_slaves();
|
||||||
Test->set_timeout(50);
|
Test->set_timeout(50);
|
||||||
Test->tprintf("ls before FLUSH LOGS");
|
Test->tprintf("ls before FLUSH LOGS");
|
||||||
Test->tprintf("Maxscale");
|
Test->tprintf("Maxscale");
|
||||||
@ -86,7 +86,7 @@ int check_sha1(TestConnections* Test)
|
|||||||
}
|
}
|
||||||
if (strcmp(s_maxscale, s) != 0)
|
if (strcmp(s_maxscale, s) != 0)
|
||||||
{
|
{
|
||||||
Test->tprintf("Binlog from master checksum is not eqiual to binlog checksum from Maxscale node");
|
Test->tprintf("Binlog from master checksum is not equal to binlog checksum from Maxscale node");
|
||||||
local_result++;
|
local_result++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,8 +103,9 @@ int start_transaction(TestConnections* Test)
|
|||||||
local_result += execute_query(Test->repl->nodes[0], (char *) "SET autocommit = 0");
|
local_result += execute_query(Test->repl->nodes[0], (char *) "SET autocommit = 0");
|
||||||
Test->tprintf("INSERT data");
|
Test->tprintf("INSERT data");
|
||||||
local_result += execute_query(Test->repl->nodes[0], (char *) "INSERT INTO t1 VALUES(111, 10)");
|
local_result += execute_query(Test->repl->nodes[0], (char *) "INSERT INTO t1 VALUES(111, 10)");
|
||||||
Test->stop_timeout();
|
Test->set_timeout(120);
|
||||||
sleep(20);
|
Test->repl->sync_slaves();
|
||||||
|
|
||||||
return local_result;
|
return local_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,8 +124,9 @@ void test_binlog(TestConnections* Test)
|
|||||||
create_t1(Test->repl->nodes[0]);
|
create_t1(Test->repl->nodes[0]);
|
||||||
Test->add_result(insert_into_t1(Test->repl->nodes[0], 4), "Data inserting to t1 failed");
|
Test->add_result(insert_into_t1(Test->repl->nodes[0], 4), "Data inserting to t1 failed");
|
||||||
Test->stop_timeout();
|
Test->stop_timeout();
|
||||||
Test->tprintf("Sleeping to let replication happen");
|
Test->tprintf("Waiting for replication to catch up");
|
||||||
sleep(60);
|
Test->set_timeout(120);
|
||||||
|
Test->repl->sync_slaves();
|
||||||
|
|
||||||
for (i = 0; i < Test->repl->N; i++)
|
for (i = 0; i < Test->repl->N; i++)
|
||||||
{
|
{
|
||||||
@ -150,8 +152,8 @@ void test_binlog(TestConnections* Test)
|
|||||||
Test->tprintf("INSERT INTO t1 VALUES(112, 10)");
|
Test->tprintf("INSERT INTO t1 VALUES(112, 10)");
|
||||||
Test->try_query(Test->repl->nodes[0], (char *) "INSERT INTO t1 VALUES(112, 10)");
|
Test->try_query(Test->repl->nodes[0], (char *) "INSERT INTO t1 VALUES(112, 10)");
|
||||||
Test->try_query(Test->repl->nodes[0], (char *) "COMMIT");
|
Test->try_query(Test->repl->nodes[0], (char *) "COMMIT");
|
||||||
Test->stop_timeout();
|
Test->set_timeout(120);
|
||||||
sleep(20);
|
Test->repl->sync_slaves();
|
||||||
|
|
||||||
Test->set_timeout(20);
|
Test->set_timeout(20);
|
||||||
Test->tprintf("SELECT * FROM t1 WHERE fl=10, checking inserted values");
|
Test->tprintf("SELECT * FROM t1 WHERE fl=10, checking inserted values");
|
||||||
@ -217,9 +219,8 @@ void test_binlog(TestConnections* Test)
|
|||||||
Test->tprintf("START SLAVE against Maxscale binlog");
|
Test->tprintf("START SLAVE against Maxscale binlog");
|
||||||
Test->try_query(binlog, (char *) "START SLAVE");
|
Test->try_query(binlog, (char *) "START SLAVE");
|
||||||
|
|
||||||
Test->tprintf("Sleeping to let replication happen");
|
Test->set_timeout(120);
|
||||||
Test->stop_timeout();
|
Test->repl->sync_slaves();
|
||||||
sleep(30);
|
|
||||||
|
|
||||||
for (i = 0; i < Test->repl->N; i++)
|
for (i = 0; i < Test->repl->N; i++)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user