diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.replication.one_slave b/maxscale-system-test/cnf/maxscale.cnf.template.replication.one_slave index 1692d72eb..8b8adc4a3 100755 --- a/maxscale-system-test/cnf/maxscale.cnf.template.replication.one_slave +++ b/maxscale-system-test/cnf/maxscale.cnf.template.replication.one_slave @@ -17,6 +17,7 @@ max_slave_connections=1 servers=server1,server2,server3,server4 user=maxskysql passwd=skysql +router_options=disable_sescmd_history=false [Read Connection Router Slave] type=service diff --git a/maxscale-system-test/mariadb_func.cpp b/maxscale-system-test/mariadb_func.cpp index 8a83fb711..0a1ef7882 100644 --- a/maxscale-system-test/mariadb_func.cpp +++ b/maxscale-system-test/mariadb_func.cpp @@ -461,14 +461,14 @@ int get_conn_num(MYSQL *conn, char * ip, char *hostname, char * db) MYSQL_RES *res; MYSQL_ROW row; unsigned long long int num_fields; - //unsigned long long int row_i=0; unsigned long long int rows; unsigned long long int i; unsigned int conn_num = 0; - char * hostname_internal; + const char * hostname_internal; + if (strcmp(ip, "127.0.0.1") == 0) { - hostname_internal = (char*) "localhost"; + hostname_internal = "localhost"; } else { @@ -516,9 +516,9 @@ int get_conn_num(MYSQL *conn, char * ip, char *hostname, char * db) } if (strcmp(ip, "127.0.0.1") == 0) { - // one extra connection i svisible in the processlist + // one extra connection is visible in the process list // output in case of local test - // (when maxscale is on the same machine as backends) + // (when MaxScale is on the same machine as backends) conn_num--; } return conn_num; diff --git a/maxscale-system-test/slave_failover.cpp b/maxscale-system-test/slave_failover.cpp index ecad48b09..901bc7c05 100644 --- a/maxscale-system-test/slave_failover.cpp +++ b/maxscale-system-test/slave_failover.cpp @@ -16,59 +16,37 @@ int main(int argc, char *argv[]) { - TestConnections * Test = new TestConnections(argc, argv); - Test->set_timeout(20); + TestConnections test(argc, argv); + printf("Connecting to RWSplit"); + test.set_timeout(60); + test.add_result(test.connect_rwsplit(), "Error connection to RWSplit! Exiting"); + sleep(5); + + test.tprintf("Checking current slave"); int res = 0; + int old_slave = test.find_connected_slave(&res); + test.add_result(res, "no current slave"); - unsigned int current_slave; - unsigned int old_slave; + test.tprintf("Setup firewall to block mysql on old slave (oldslave is node %d)", old_slave); - printf("Connecting to RWSplit %s\n", Test->maxscale_IP); - if (Test->connect_rwsplit() != 0) - { - Test->add_result(1, "Error connection to RWSplit! Exiting\n"); - } - else - { + test.add_result((old_slave < 0) || (old_slave >= test.repl->N), "Active slave is not found"); + test.repl->block_node(old_slave); - Test->tprintf("Checking current slave\n"); - old_slave = Test->find_connected_slave( &res); + test.tprintf("Waiting for MaxScale to find a new slave"); + test.stop_timeout(); + sleep(10); - Test->add_result(res, "no current slave\n"); + test.set_timeout(20); + int current_slave = test.find_connected_slave(&res); + test.add_result((current_slave == old_slave) || (current_slave < 0), "No failover happened"); - Test->tprintf("Setup firewall to block mysql on old slave (oldslave is node %d)\n", old_slave); - if ((old_slave < 0) || (old_slave >= Test->repl->N)) - { - Test->add_result(1, "Active slave is not found\n"); - } - else - { - Test->repl->block_node(old_slave); + test.tprintf("Unblock old node"); + test.repl->unblock_node(old_slave); + test.close_rwsplit(); - Test->tprintf("Sleeping 60 seconds to let MaxScale to find new slave\n"); - Test->stop_timeout(); - sleep(60); - Test->set_timeout(20); + test.check_maxscale_alive(); + test.stop_timeout(); + test.repl->fix_replication(); - current_slave = Test->find_connected_slave(&res); - if ((current_slave == old_slave) || (current_slave < 0)) - { - Test->add_result(1, "No failover happened\n"); - } - - Test->tprintf("Setup firewall back to allow mysql\n"); - Test->repl->unblock_node(old_slave); - - Test->close_rwsplit(); - - Test->check_maxscale_alive(); - Test->set_timeout(20); - } - Test->set_timeout(200); - Test->repl->start_replication(); - } - - int rval = Test->global_result; - delete Test; - return rval; + return test.global_result; }