From ab507ebfe9ebbc1fa212cf2b03883db8520e9a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 14 Aug 2018 09:33:39 +0300 Subject: [PATCH] Add missing timeouts to mxs1743_rconn_bitmask Also did some minor cleanup. --- .../mxs1743_rconn_bitmask.cpp | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/maxscale-system-test/mxs1743_rconn_bitmask.cpp b/maxscale-system-test/mxs1743_rconn_bitmask.cpp index 4543e37cd..237237b50 100644 --- a/maxscale-system-test/mxs1743_rconn_bitmask.cpp +++ b/maxscale-system-test/mxs1743_rconn_bitmask.cpp @@ -10,28 +10,31 @@ int main(int argc, char** argv) { TestConnections test(argc, argv); + auto do_test = [&]() + { + test.set_timeout(20); + test.maxscales->connect(); + test.try_query(test.maxscales->conn_master[0], "SELECT 1"); + test.maxscales->disconnect(); + test.stop_timeout(); + }; + test.tprintf("Testing with both master and slave up"); - test.maxscales->connect(); - test.try_query(test.maxscales->conn_master[0], "SELECT 1"); - test.maxscales->disconnect(); + do_test(); test.tprintf("Testing with only the master"); test.repl->block_node(0); - sleep(5); - test.maxscales->connect(); - test.try_query(test.maxscales->conn_master[0], "SELECT 1"); - test.maxscales->disconnect(); + test.maxscales->wait_for_monitor(); + do_test(); test.repl->unblock_node(0); - sleep(5); + test.maxscales->wait_for_monitor(); test.tprintf("Testing with only the slave"); test.repl->block_node(1); - sleep(5); - test.maxscales->connect(); - test.try_query(test.maxscales->conn_master[0], "SELECT 1"); - test.maxscales->disconnect(); + test.maxscales->wait_for_monitor(); + do_test(); test.repl->unblock_node(1); - sleep(5); + test.maxscales->wait_for_monitor(); test.tprintf("Checking that both the master and slave are used"); std::vector connections; @@ -45,10 +48,12 @@ int main(int argc, char** argv) for (int i = 0; i < 20; i++) { // Open a connection and make sure it works + test.set_timeout(20); MYSQL* conn = open_conn(test.maxscales->readconn_master_port[0], test.maxscales->IP[0], "mxs1743", "mxs1743", false); test.try_query(conn, "SELECT 1"); connections.push_back(conn); + test.stop_timeout(); } // Give the connections a few seconds to establish