From ba0e3bd6b76df829b4bca343ebe127f2887cd94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 7 Jun 2018 22:46:57 +0300 Subject: [PATCH] Speed up avrorouter testing Cut test time from about 300 seconds to 200 seconds. --- maxscale-system-test/avro.cpp | 11 ++++---- maxscale-system-test/avro_alter.cpp | 9 +++---- maxscale-system-test/cdc_client.cpp | 22 +++------------- .../cdc_datatypes/cdc_datatypes.cpp | 4 ++- maxscale-system-test/mxs1542.cpp | 1 + maxscale-system-test/mxs1543.cpp | 2 ++ maxscale-system-test/testconnections.cpp | 25 +++++++++++++------ maxscale-system-test/testconnections.h | 5 ++++ 8 files changed, 42 insertions(+), 37 deletions(-) diff --git a/maxscale-system-test/avro.cpp b/maxscale-system-test/avro.cpp index 12daff13a..0da4810bd 100644 --- a/maxscale-system-test/avro.cpp +++ b/maxscale-system-test/avro.cpp @@ -24,15 +24,14 @@ using std::endl; int main(int argc, char *argv[]) { int exit_code; + TestConnections::skip_maxscale_start(true); + TestConnections::check_nodes(false); TestConnections test(argc, argv); test.set_timeout(600); test.maxscales->ssh_node(0, (char *) "rm -rf /var/lib/maxscale/avro", true); /** Start master to binlogrouter replication */ - if (!test.replicate_from_master(0)) - { - return 1; - } + test.replicate_from_master(); test.set_timeout(120); test.repl->connect(); @@ -85,9 +84,9 @@ int main(int argc, char *argv[]) test.add_result(1, "not enough lines in avrocheck output"); } - execute_query(test.repl->nodes[0], "DROP TABLE test.t1;RESET MASTER"); + execute_query(test.repl->nodes[0], "DROP TABLE test.t1"); test.stop_timeout(); - test.repl->fix_replication(); + test.revert_replicate_from_master(); return test.global_result; } diff --git a/maxscale-system-test/avro_alter.cpp b/maxscale-system-test/avro_alter.cpp index 91e954d32..041f7a031 100644 --- a/maxscale-system-test/avro_alter.cpp +++ b/maxscale-system-test/avro_alter.cpp @@ -10,15 +10,14 @@ int main(int argc, char *argv[]) { int exit_code; + TestConnections::skip_maxscale_start(true); + TestConnections::check_nodes(false); TestConnections test(argc, argv); test.set_timeout(600); test.maxscales->ssh_node(0, (char *) "rm -rf /var/lib/maxscale/avro", true); /** Start master to binlogrouter replication */ - if (!test.replicate_from_master(0)) - { - return 1; - } + test.replicate_from_master(); test.set_timeout(120); test.repl->connect(); @@ -75,7 +74,7 @@ int main(int argc, char *argv[]) test.stop_timeout(); execute_query(test.repl->nodes[0], "DROP TABLE test.t1;RESET MASTER"); - test.repl->fix_replication(); + test.revert_replicate_from_master(); return test.global_result; } diff --git a/maxscale-system-test/cdc_client.cpp b/maxscale-system-test/cdc_client.cpp index 07cfd80e4..034321264 100644 --- a/maxscale-system-test/cdc_client.cpp +++ b/maxscale-system-test/cdc_client.cpp @@ -179,29 +179,14 @@ static TestConnections *Test; int main(int argc, char *argv[]) { - + TestConnections::skip_maxscale_start(true); + TestConnections::check_nodes(false); Test = new TestConnections(argc, argv); Test->set_timeout(600); - Test->maxscales->stop_maxscale(0); - // Remove old data files Test->maxscales->ssh_node_f(0, true, "rm -rf /var/lib/maxscale/avro;"); - - Test->repl->connect(); - execute_query(Test->repl->nodes[0], "DROP TABLE IF EXISTS t1;"); - Test->repl->close_connections(); - sleep(5); - - Test->start_binlog(0); - - Test->set_timeout(120); - Test->maxscales->stop_maxscale(0); - - Test->maxscales->ssh_node(0, "rm -rf /var/lib/maxscale/avro", true); - - Test->set_timeout(120); - Test->maxscales->start_maxscale(0); + Test->replicate_from_master(); Test->set_timeout(60); Test->repl->connect(); @@ -225,6 +210,7 @@ int main(int argc, char *argv[]) pthread_join(thread, NULL); int rval = Test->global_result; + Test->revert_replicate_from_master(); delete Test; return rval; } diff --git a/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp b/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp index d73ac7d04..ec0044f28 100644 --- a/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp +++ b/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp @@ -283,7 +283,7 @@ int main(int argc, char *argv[]) TestConnections::check_nodes(false); TestConnections test(argc, argv); - test.replicate_from_master(0); + test.replicate_from_master(); if (!run_test(test)) { @@ -291,5 +291,7 @@ int main(int argc, char *argv[]) } test.check_maxscale_processes(0, 1); + test.revert_replicate_from_master(); + return test.global_result; } diff --git a/maxscale-system-test/mxs1542.cpp b/maxscale-system-test/mxs1542.cpp index b5e3cde56..172d0cd6a 100644 --- a/maxscale-system-test/mxs1542.cpp +++ b/maxscale-system-test/mxs1542.cpp @@ -36,5 +36,6 @@ int main(int argc, char** argv) "o-------------------------------------------------------------------o\n" "\n"); + test.revert_replicate_from_master(); return test.global_result; } diff --git a/maxscale-system-test/mxs1543.cpp b/maxscale-system-test/mxs1543.cpp index 84b3c23cb..98d92585a 100644 --- a/maxscale-system-test/mxs1543.cpp +++ b/maxscale-system-test/mxs1543.cpp @@ -28,5 +28,7 @@ int main(int argc, char** argv) sleep(10); test.check_log_err(0, "Possible STATEMENT or MIXED", true); + test.revert_replicate_from_master(); + return test.global_result; } diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index caad08b4d..f45591e43 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -1026,13 +1026,9 @@ bool TestConnections::replicate_from_master(int m) bool rval = true; /** Stop the binlogrouter */ - MYSQL* conn = open_conn_no_db(maxscales->binlog_port[m], maxscales->IP[m], repl->user_name, repl->password, - ssl); - - if (execute_query(conn, "stop slave")) - { - rval = false; - } + MYSQL* conn = open_conn_no_db(maxscales->binlog_port[m], maxscales->IP[m], + repl->user_name, repl->password, ssl); + execute_query_silent(conn, "stop slave"); mysql_close(conn); repl->execute_query_all_nodes("STOP SLAVE"); @@ -1062,6 +1058,21 @@ bool TestConnections::replicate_from_master(int m) return rval; } +void TestConnections::revert_replicate_from_master(int m) +{ + char log_file[256] = ""; + + repl->connect(); + execute_query(repl->nodes[0], "RESET MASTER"); + find_field(repl->nodes[0], "show master status", "File", log_file); + + for (int i = 1; i < repl->N; i++) + { + repl->set_slave(repl->nodes[i], repl->IP[0], repl->port[0], log_file, (char*)"4"); + execute_query(repl->nodes[i], "start slave"); + } +} + int TestConnections::start_mm(int m) { int i; diff --git a/maxscale-system-test/testconnections.h b/maxscale-system-test/testconnections.h index 324f8a54f..43a67671f 100644 --- a/maxscale-system-test/testconnections.h +++ b/maxscale-system-test/testconnections.h @@ -286,6 +286,11 @@ public: */ bool replicate_from_master(int m = 0); + /** + * @brief Stop binlogrouter replication from master + */ + void revert_replicate_from_master(int m = 0); + /** * @brief prepare_binlog clean up binlog directory, set proper access rights to it * @return 0