From 64ca8d4aaa54c712d3015ec1073fdeaac06deb45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 27 Nov 2018 09:02:00 +0200 Subject: [PATCH] Simplify mxs1743_rconn_bitmask The test now uses maxctrl to count how many connections there are. This helps avoid creating new users on the database and works around the slave syncing problems. --- .../mxs1743_rconn_bitmask.cpp | 54 ++++--------------- 1 file changed, 9 insertions(+), 45 deletions(-) diff --git a/maxscale-system-test/mxs1743_rconn_bitmask.cpp b/maxscale-system-test/mxs1743_rconn_bitmask.cpp index 032a9ecb5..3784b9624 100644 --- a/maxscale-system-test/mxs1743_rconn_bitmask.cpp +++ b/maxscale-system-test/mxs1743_rconn_bitmask.cpp @@ -36,62 +36,26 @@ int main(int argc, char** argv) test.maxscales->wait_for_monitor(); test.tprintf("Checking that both the master and slave are used"); - std::vector connections; - - test.set_timeout(60); - test.repl->connect(); - execute_query_silent(test.repl->nodes[0], "DROP USER IF EXISTS 'mxs1743'@'%'"); - test.try_query(test.repl->nodes[0], "%s", "CREATE USER 'mxs1743'@'%' IDENTIFIED BY 'mxs1743'"); - test.try_query(test.repl->nodes[0], "%s", "GRANT ALL ON *.* TO 'mxs1743'@'%'"); - - test.set_timeout(120); - test.tprintf("Syncing slaves"); - test.repl->connect(); - test.repl->sync_slaves(); - test.repl->disconnect(); + std::vector connections; test.tprintf("Opening new connections to verify readconnroute works"); - test.set_timeout(60); 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); + connections.push_back(test.maxscales->readconn_master()); + Connection& c = connections.back(); + test.expect(c.connect(), "Connect should work: %s", c.error()); + test.expect(c.query("SELECT 1"), "Query should work: %s", c.error()); test.stop_timeout(); } - // Give the connections a few seconds to establish - sleep(5); + auto s1 = test.maxscales->ssh_output("maxctrl --tsv list servers|grep server1|cut -f 4").second; + auto s2 = test.maxscales->ssh_output("maxctrl --tsv list servers|grep server2|cut -f 4").second; - test.tprintf("Checking the number of connections"); - std::string query = - "SELECT COUNT(*) AS connections FROM information_schema.processlist WHERE user = 'mxs1743'"; - char master_connections[1024]; - char slave_connections[1024]; - test.set_timeout(60); - test.repl->connect(); - find_field(test.repl->nodes[0], query.c_str(), "connections", master_connections); - find_field(test.repl->nodes[1], query.c_str(), "connections", slave_connections); - - test.expect(strcmp(master_connections, slave_connections) == 0, + test.expect(s1 == s2, "Master and slave shoud have the same amount of connections: %s != %s", - master_connections, - slave_connections); - - for (auto a : connections) - { - mysql_close(a); - } - - execute_query_silent(test.repl->nodes[0], "DROP USER 'mxs1743'@'%'"); - test.repl->disconnect(); + s1.c_str(), s2.c_str()); return test.global_result; }