From de23297944aeb7bed511bd9f4cd3609fcbc438ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 6 Jun 2017 12:45:20 +0300 Subject: [PATCH] Speed up session_limits test The test now waits for a shorter time. Also refactored the test to use stack allocated objects. --- .../cnf/maxscale.cnf.template.session_limits | 2 +- maxscale-system-test/session_limits.cpp | 61 ++++++++----------- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.session_limits b/maxscale-system-test/cnf/maxscale.cnf.template.session_limits index 68f9fac21..c3a91c42d 100755 --- a/maxscale-system-test/cnf/maxscale.cnf.template.session_limits +++ b/maxscale-system-test/cnf/maxscale.cnf.template.session_limits @@ -11,7 +11,7 @@ user=maxskysql passwd= skysql [RW Split Router] -connection_timeout=30 +connection_timeout=10 type=service router= readwritesplit servers=server1, server2, server3,server4 diff --git a/maxscale-system-test/session_limits.cpp b/maxscale-system-test/session_limits.cpp index 3ed6574a4..165d2a6e5 100644 --- a/maxscale-system-test/session_limits.cpp +++ b/maxscale-system-test/session_limits.cpp @@ -14,49 +14,40 @@ router_options=max_sescmd_history=10 * - execute one more session commad, excpect failure */ - - -#include #include "testconnections.h" int main(int argc, char *argv[]) { - TestConnections * Test = new TestConnections(argc, argv); - Test->set_timeout(200); - int i; - char sql[256]; + TestConnections test(argc, argv); + int first_sleep = 5; + int second_sleep = 12; - Test->tprintf("Open session and wait 20 seconds\n"); - Test->connect_maxscale(); - sleep(20); - Test->tprintf("Execute query to check session\n"); - Test->try_query(Test->conn_rwsplit, "SELECT 1"); + test.set_timeout(200); - Test->tprintf("Wait 35 seconds more and try quiry again expecting failure\n"); - sleep(35); - if (execute_query(Test->conn_rwsplit, "SELECT 1") == 0) + test.tprintf("Open session, wait %d seconds and execute a query", first_sleep); + test.connect_maxscale(); + sleep(first_sleep); + test.try_query(test.conn_rwsplit, "SELECT 1"); + + test.tprintf("Wait %d seconds and execute query, expecting failure", second_sleep); + sleep(second_sleep); + test.add_result(execute_query(test.conn_rwsplit, "SELECT 1") == 0, + "Session was not closed after %d seconds", + second_sleep); + test.close_maxscale_connections(); + + test.tprintf("Open session and execute 10 session commands"); + test.connect_maxscale(); + for (int i = 0; i < 10; i++) { - Test->add_result(1, "Session was not closed after 40 seconds\n"); + test.try_query(test.conn_rwsplit, "set @test=1"); } - Test->close_maxscale_connections(); - Test->tprintf("Open session and execute 10 session commands\n"); - fflush(stdout); - Test->connect_maxscale(); - for (i = 0; i < 10; i++) - { - sprintf(sql, "set @test=%d", i); - Test->try_query(Test->conn_rwsplit, sql); - } - Test->tprintf("done!\n"); + test.tprintf("Execute one more session command and expect message in error log"); + execute_query(test.conn_rwsplit, "set @test=1"); + sleep(1); + test.check_log_err("Router session exceeded session command history limit", true); + test.close_maxscale_connections(); - Test->tprintf("Execute one more session command and expect message in error log\n"); - execute_query(Test->conn_rwsplit, "set @test=11"); - sleep(5); - Test->check_log_err((char *) "Router session exceeded session command history limit", true); - Test->close_maxscale_connections(); - - int rval = Test->global_result; - delete Test; - return rval; + return test.global_result; }