From 6672202c2614194b77b1aa3b00d1307b70175729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Mar 2019 13:57:05 +0200 Subject: [PATCH] MXS-2313: Add readconnroute `rank` test The server rank test now checks that readconnroute works as expected. --- .../cnf/maxscale.cnf.template.mxs2313_rank | 2 +- maxscale-system-test/mxs2313_rank.cpp | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs2313_rank b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2313_rank index ebc2a6d56..34002f68c 100755 --- a/maxscale-system-test/cnf/maxscale.cnf.template.mxs2313_rank +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2313_rank @@ -61,4 +61,4 @@ port=4006 type=listener service=Read-Connection-Router protocol=MySQLClient -port=4009 +port=4008 diff --git a/maxscale-system-test/mxs2313_rank.cpp b/maxscale-system-test/mxs2313_rank.cpp index c76e98278..989d64c08 100644 --- a/maxscale-system-test/mxs2313_rank.cpp +++ b/maxscale-system-test/mxs2313_rank.cpp @@ -72,11 +72,36 @@ void test_rwsplit(TestConnections& test, std::vector ids) auto id = c.field("SELECT @@server_id"); test.expect(!id.empty() && id != ids[3], "Third slave should not reply"); } +} + +void test_readconnroute(TestConnections& test, std::vector ids) +{ + std::cout << "Readconnroute with descending server rank" << std::endl; test.check_maxctrl("alter server server1 rank 1"); test.check_maxctrl("alter server server2 rank 2"); test.check_maxctrl("alter server server3 rank 3"); test.check_maxctrl("alter server server4 rank 4"); + + auto do_test = [&](int node) { + Connection c = test.maxscales->readconn_master(); + c.connect(); + test.expect(c.field("SELECT @@server_id") == ids[node], "server%d should reply", node + 1); + }; + + do_test(0); + block_wait(0); + do_test(1); + block_wait(1); + do_test(2); + block_wait(2); + do_test(3); + unblock_wait(2); + do_test(2); + unblock_wait(1); + do_test(1); + unblock_wait(0); + do_test(0); } int main(int argc, char* argv[]) @@ -99,6 +124,7 @@ int main(int argc, char* argv[]) test.repl->disconnect(); test_rwsplit(test, ids); + test_readconnroute(test, ids); return test.global_result; }