Fix 2.2 test results

The changes to object naming and tee filter rewriting caused a number of
changes in the expected outcome of tests and how the tests have to behave.
This commit is contained in:
Markus Mäkelä
2017-06-02 22:30:44 +03:00
parent 3505d26b42
commit d63af9df0b
7 changed files with 66 additions and 520 deletions

View File

@ -591,7 +591,7 @@ add_test_script(ssl sql_queries ssl LABELS maxscale readwritesplit REPL_BACKEND)
#add_test_script(ssl_load load_balancing ssl_load LABELS maxscale readwritesplit REPL_BACKEND) #add_test_script(ssl_load load_balancing ssl_load LABELS maxscale readwritesplit REPL_BACKEND)
# Check load balancing, client ssl is ON, Galera backend # Check load balancing, client ssl is ON, Galera backend
add_test_script(ssl_load_galera load_balancing_galera ssl_load_galera LABELS maxscale readwritesplit GALERA_BACKEND) #add_test_script(ssl_load_galera load_balancing_galera ssl_load_galera LABELS maxscale readwritesplit GALERA_BACKEND)
# Testing slaves who have lost their master and how MaxScale works with them # Testing slaves who have lost their master and how MaxScale works with them
add_test_executable(stale_slaves.cpp stale_slaves replication LABELS mysqlmon REPL_BACKEND) add_test_executable(stale_slaves.cpp stale_slaves replication LABELS mysqlmon REPL_BACKEND)

View File

@ -1,103 +1,17 @@
/** /**
* @file bug643.cpp regression case for bugs 645 ("Tee filter with readwritesplit service hangs MaxScale") * @file bug643.cpp regression case for bugs 645 ("Tee filter with readwritesplit service hangs MaxScale")
* - setup RWSplit in the following way *
* @verbatim * - Try to connect to all services except 4016
[RW_Router] * - Try simple query on all services
type=service * - Check log for presence of "Couldn't find suitable Master from 2 candidates" errors
router=readconnroute
servers=server1
user=skysql
passwd=skysql
version_string=5.1-OLD-Bored-Mysql
filters=DuplicaFilter
[RW_Split]
type=service
router=readwritesplit
servers=server3,server2
user=skysql
passwd=skysql
[DuplicaFilter]
type=filter
module=tee
service=RW_Split
[RW_Listener]
type=listener
service=RW_Router
protocol=MySQLClient
port=4006
[RW_Split_list]
type=listener
service=RW_Split
protocol=MySQLClient
port=4016
[Read Connection Router Slave]
type=service
router=readconnroute
router_options= slave
servers=server1,server2,server3,server4
user=skysql
passwd=skysql
filters=QLA
[Read Connection Router Master]
type=service
router=readconnroute
router_options=master
servers=server1,server2,server3,server4
user=skysql
passwd=skysql
filters=QLA
[Read Connection Listener Slave]
type=listener
service=Read Connection Router Slave
protocol=MySQLClient
port=4009
[Read Connection Listener Master]
type=listener
service=Read Connection Router Master
protocol=MySQLClient
port=4008
@endverbatim
* - try to connect to all services except 4016
* - try simple query
* - check ReadConn is ok
* - check log for presens of "Couldn't find suitable Master from 2 candidates" errors
*/ */
#include <iostream>
#include "testconnections.h" #include "testconnections.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
TestConnections * Test = new TestConnections(argc, argv); TestConnections test(argc, argv);
Test->set_timeout(10); test.check_maxscale_alive();
test.check_log_err( "Couldn't find suitable Master from 2 candidates", true);
Test->connect_maxscale(); return test.global_result;
Test->tprintf("trying query to RWSplit, expecting failure\n");
if (execute_query(Test->conn_rwsplit, (char *) "show processlist") == 0)
{
Test->add_result(1, "Query is ok, but failue is expected\n");
}
Test->tprintf("Trying query to ReadConn router master\n");
Test->try_query(Test->conn_master, (char *) "show processlist");
Test->tprintf("Trying query to ReadConn router slave\n");
Test->try_query(Test->conn_slave, (char *) "show processlist");
Test->close_maxscale_connections();
Test->check_log_err((char *) "Couldn't find suitable Master from 2 candidates", true);
int rval = Test->global_result;
delete Test;
return rval;
} }

View File

@ -1,81 +1,16 @@
/** /**
* @file bug650.cpp regression case for bug 650 ("Hints, RWSplit: MaxScale goes into infinite loop and crashes") and bug645 * @file bug650.cpp regression case for bug 650 ("Hints, RWSplit: MaxScale goes into infinite loop and crashes") and bug645
* - setup RWSplit in the following way * - try simple query using all services
* @verbatim * - check for errors in the log
[RW_Router]
type=service
router=readconnroute
servers=server1
user=skysql
passwd=skysql
version_string=5.1-OLD-Bored-Mysql
filters=DuplicaFilter
[RW_Split]
type=service
router=readwritesplit
servers=server3,server2
user=skysql
passwd=skysql
[DuplicaFilter]
type=filter
module=tee
service=RW_Split
[RW_Listener]
type=listener
service=RW_Router
protocol=MySQLClient
port=4006
[RW_Split_list]
type=listener
service=RW_Split
protocol=MySQLClient
port=4016
@endverbatim
* - try to connect
* - try simple query using ReadConn router (both, master and slave)
* - check errors in the log
@verbatim
Couldn't find suitable Master from 2 candidates
Failed to create RW_Split session.
Creating client session for Tee filter failed. Terminating session.
Failed to create filter 'DuplicaFilter' for service 'RW_Router'
Setting up filters failed. Terminating session RW_Router
@endverbatim
*/ */
#include <iostream>
#include "testconnections.h" #include "testconnections.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
TestConnections * Test = new TestConnections(argc, argv); TestConnections test(argc, argv);
Test->set_timeout(20); test.check_maxscale_alive();
test.check_log_err( "Couldn't find suitable Master from 2 candidates", true);
Test->connect_maxscale(); test.check_log_err( "Failed to create new router session for service 'RW_Split'", true);
Test->tprintf("Trying query to ReadConn master\n"); return test.global_result;
Test->try_query(Test->conn_master, (char *) "show processlist");
Test->tprintf("Trying query to ReadConn slave\n");
Test->try_query(Test->conn_slave, (char *) "show processlist");
Test->tprintf("Trying query to RWSplit, expecting failure\n");
if (execute_query(Test->conn_rwsplit, (char *) "show processlist") == 0)
{
Test->add_result(1, "Query is ok, but failure is expected\n");
}
Test->close_maxscale_connections();
Test->tprintf("Checking logs\n");
Test->check_log_err((char *) "Couldn't find suitable Master from 2 candidates", true);
Test->check_log_err((char *) "Failed to create new router session for service 'RW_Split'", true);
int rval = Test->global_result;
delete Test;
return rval;
} }

View File

@ -1,316 +1,17 @@
/** /**
* @file bug664.cpp bug664 regression case ("Core: Access of freed memory in gw_send_authentication_to_backend") * @file bug664.cpp Tee filter branch session failure test
* *
* - Maxscale.cnf contains: * - Configure MaxScale so that the branched session will always fail
* @verbatim * - Execute query on the main service and check that MaxScale is alive
[RW_Router] * - An error should be logged about the failed branch session
type=service
router=readconnroute
servers=server1
user=maxuser
passwd=maxpwd
version_string=5.1-OLD-Bored-Mysql
filters=DuplicaFilter
[RW_Split]
type=service
router=readwritesplit
servers=server3,server2
user=maxuser
passwd=maxpwd
[DuplicaFilter]
type=filter
module=tee
service=RW_Split
[RW_Listener]
type=listener
service=RW_Router
protocol=MySQLClient
port=4006
[RW_Split_list]
type=listener
service=RW_Split
protocol=MySQLClient
port=4016
[Read Connection Router Slave]
type=service
router=readconnroute
router_options= slave
servers=server1,server2,server3,server4
user=maxuser
passwd=maxpwd
filters=QLA
[Read Connection Router Master]
type=service
router=readconnroute
router_options=master
servers=server1,server2,server3,server4
user=maxuser
passwd=maxpwd
filters=QLA
[Read Connection Listener Slave]
type=listener
service=Read Connection Router Slave
protocol=MySQLClient
port=4009
[Read Connection Listener Master]
type=listener
service=Read Connection Router Master
protocol=MySQLClient
port=4008
@endverbatim
* - warning is expected in the log, but not an error. All Maxscale services should be alive.
* - Check MaxScale is alive
*/ */
/*
Vilho Raatikka 2014-12-29 18:12:23 UTC
All these cases are due to accessing freed dcb->data (MYSQL_session *):
==12419== Invalid read of size 1
==12419== at 0x1B1434BA: gw_send_authentication_to_backend (mysql_common.c:544)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x18690285 is 149 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 1
==12419== at 0x1B1434D6: gw_send_authentication_to_backend (mysql_common.c:547)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x186901f0 is 0 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 8
==12419== at 0x1B1435FC: gw_send_authentication_to_backend (mysql_common.c:572)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x186901f0 is 0 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 8
==12419== at 0x1B143606: gw_send_authentication_to_backend (mysql_common.c:572)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x186901f8 is 8 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 4
==12419== at 0x1B143611: gw_send_authentication_to_backend (mysql_common.c:572)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x18690200 is 16 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 1
==12419== at 0x4C2CCA2: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x1B143719: gw_send_authentication_to_backend (mysql_common.c:604)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x18690204 is 20 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 1
==12419== at 0x4C2CCB4: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x1B143719: gw_send_authentication_to_backend (mysql_common.c:604)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x18690205 is 21 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 1
==12419== at 0x4C2CCA2: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x1B143893: gw_send_authentication_to_backend (mysql_common.c:660)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x18690204 is 20 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 1
==12419== at 0x4C2CCB4: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x1B143893: gw_send_authentication_to_backend (mysql_common.c:660)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x18690205 is 21 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 1
==12419== at 0x4C2DE21: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x1B1438AF: gw_send_authentication_to_backend (mysql_common.c:660)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x1869020a is 26 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 2
==12419== at 0x4C2DEA0: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x1B1438AF: gw_send_authentication_to_backend (mysql_common.c:660)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x18690206 is 22 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 1
==12419== at 0x4C2CCA2: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x1B1438BE: gw_send_authentication_to_backend (mysql_common.c:661)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x18690204 is 20 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419==
==12419== Invalid read of size 1
==12419== at 0x4C2CCB4: strlen (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x1B1438BE: gw_send_authentication_to_backend (mysql_common.c:661)
==12419== by 0x1B13F90E: gw_read_backend_event (mysql_backend.c:228)
==12419== by 0x588CA2: process_pollq (poll.c:858)
==12419== by 0x58854B: poll_waitevents (poll.c:608)
==12419== by 0x57C11B: main (gateway.c:1792)
==12419== Address 0x18690205 is 21 bytes inside a block of size 278 free'd
==12419== at 0x4C2AF6C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12419== by 0x57D806: dcb_final_free (dcb.c:406)
==12419== by 0x57DDE6: dcb_process_zombies (dcb.c:603)
==12419== by 0x588598: poll_waitevents (poll.c:613)
==12419== by 0x57C11B: main (gateway.c:1792)
Comment 1 Vilho Raatikka 2014-12-29 18:29:11 UTC
dcb_final_free:don't free dcb->data, it is either freed in session_alloc if session creation fails or in session_free only.
mysql_client.c:gw_mysql_do_authentication:if anything fails, and session_alloc won't be called, free dcb->data.
mysql_common.c:gw_send_authentication_to_backend:if session is already closing then return with error.
Comment 2 Markus Mäkelä 2014-12-30 08:58:59 UTC
Created attachment 170 [details]
failing configuration
The attached configuration currently crashes into a debug assert in handleError in readconnroute.c when connecting to port 4006. If this is removed, the next point of failure is in dcb_final_free when the session->data object is freed.
Comment 3 Vilho Raatikka 2014-12-30 10:14:43 UTC
(In reply to comment #2)
> Created attachment 170 [details]
> failing configuration
>
> The attached configuration currently crashes into a debug assert in
> handleError in readconnroute.c when connecting to port 4006. If this is
> removed, the next point of failure is in dcb_final_free when the
> session->data object is freed.
Should this be open or closed based on the information provided?
Comment 4 Markus Mäkelä 2014-12-30 10:17:55 UTC
My apologies, I thought I did reopen it.
Comment 5 Vilho Raatikka 2014-12-30 10:27:32 UTC
Fixed double freeing dcb->data if authentication phase fails.
Comment 6 Vilho Raatikka 2014-12-30 10:30:12 UTC
Reopen due to crash. Another double free somewhere.
Comment 7 Vilho Raatikka 2014-12-30 11:36:38 UTC
Cloned session was freeing the shared 'data' dcb->data/session->data. Now only session_free for the non-clone session is allowed to free the data.
*/
#include <iostream>
#include <unistd.h>
#include "testconnections.h" #include "testconnections.h"
using namespace std;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
TestConnections test(argc, argv);
TestConnections * Test = new TestConnections(argc, argv); test.check_maxscale_alive();
Test->set_timeout(20); test.check_log_err("Failed to create new router session for service 'RW_Split'", true);
return test.global_result;
Test->connect_maxscale();
Test->tprintf("Trying query to ReadConn master\n");
fflush(stdout);
Test->try_query(Test->conn_master, "show processlist;");
Test->tprintf("Trying query to ReadConn slave\n");
Test->try_query(Test->conn_slave, "show processlist;");
Test->close_maxscale_connections();
Test->check_log_err((char *) "Creating client session for Tee filter failed. Terminating session.", true);
Test->check_log_err((char *) "Failed to create filter 'DuplicaFilter' for service 'RW_Router'", true);
int rval = Test->global_result;
delete Test;
return rval;
} }

View File

@ -1,9 +1,10 @@
/** /**
* @file bug673.cpp regression case for bug673 ("MaxScale crashes if "Users table data" is empty and "show dbusers" is executed in maxadmin") * @file bug673.cpp regression case for bug673 ("MaxScale crashes if "Users table data" is empty and "show dbusers" is executed in maxadmin")
* *
* - configure wrong IP for all backends * - Configure wrong IP for all backends
* - execute maxadmin command show dbusers "RW Split Router" * - Execute maxadmin command show dbusers "RW Split Router"
* - check MaxScale is alive by executing maxadmin again * - Check MaxScale is alive by executing maxadmin again
* - Check that only new style object names in maxadmin commands are accepted
*/ */
#include "testconnections.h" #include "testconnections.h"
@ -11,20 +12,17 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char result[1024]; TestConnections test(argc, argv);
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(20);
test.set_timeout(60);
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
Test->tprintf("Trying show dbusers \"RW Split Router\"\n"); char result[1024];
Test->add_result(Test->get_maxadmin_param((char *) "show dbusers \"RW Split Router\"", (char *) "User names:", test.add_result(test.get_maxadmin_param("show dbusers \"RW Split Router\"", "User names:", result) == 0,
result), "Maxadmin failed\n"); "Old style objects in maxadmin commands should fail");
Test->tprintf("result %s\n", result); test.add_result(test.get_maxadmin_param("show dbusers RW-Split-Router", "User names:", result),
"New style objects in maxadmin commands should succeed");
} }
int rval = Test->global_result; return test.global_result;
delete Test;
return rval;
} }

View File

@ -100,7 +100,7 @@ int main(int argc, char *argv[])
copy_rules(Test, (char *) "rules_syntax_error", rules_dir); copy_rules(Test, (char *) "rules_syntax_error", rules_dir);
char *output = Test->ssh_maxscale_output(true, char *output = Test->ssh_maxscale_output(true,
"maxadmin call command dbfwfilter rules/reload \"Database Firewall\""); "maxadmin call command dbfwfilter rules/reload Database-Firewall");
Test->add_result(strcasestr(output, "Failed") == NULL, "Reloading rules should fail with syntax errors"); Test->add_result(strcasestr(output, "Failed") == NULL, "Reloading rules should fail with syntax errors");
Test->check_maxscale_processes(1); Test->check_maxscale_processes(1);

View File

@ -18,37 +18,37 @@ using namespace std;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
TestConnections * Test = new TestConnections(argc, argv); TestConnections test(argc, argv);
Test->set_timeout(10); test.set_timeout(10);
Test->connect_maxscale(); test.connect_maxscale();
Test->set_timeout(10); test.set_timeout(10);
Test->try_query(Test->conn_rwsplit, (char *) "SET @a=1"); test.try_query(test.conn_rwsplit, (char *) "SET @a=1");
Test->stop_timeout(); test.stop_timeout();
sleep(1); sleep(1);
Test->set_timeout(20); test.set_timeout(20);
Test->tprintf("Blocking first slave\n"); test.tprintf("Blocking first slave\n");
Test->repl->block_node(1); test.repl->block_node(1);
Test->stop_timeout(); test.stop_timeout();
sleep(5); sleep(5);
Test->set_timeout(10); test.set_timeout(10);
Test->tprintf("Unblocking first slave and blocking second slave\n"); test.tprintf("Unblocking first slave and blocking second slave\n");
Test->repl->unblock_node(1); test.repl->unblock_node(1);
Test->stop_timeout(); test.stop_timeout();
sleep(5); sleep(5);
Test->repl->block_node(2); test.repl->block_node(2);
Test->stop_timeout(); test.stop_timeout();
sleep(5); sleep(5);
Test->set_timeout(20); test.set_timeout(20);
int retries; int retries;
for (retries = 0; retries < 10; retries++) for (retries = 0; retries < 10; retries++)
{ {
char server1_status[256]; char server1_status[256];
Test->get_maxadmin_param((char *) "show server server2", (char *) "Status", server1_status); test.get_maxadmin_param((char *) "show server server2", (char *) "Status", server1_status);
if (strstr(server1_status, "Running")) if (strstr(server1_status, "Running"))
{ {
break; break;
@ -56,28 +56,26 @@ int main(int argc, char *argv[])
sleep(1); sleep(1);
} }
Test->add_result(retries == 10, "Slave is not recovered, slave status is not Running\n"); test.add_result(retries == 10, "Slave is not recovered, slave status is not Running\n");
Test->repl->connect(); test.repl->connect();
int real_id = Test->repl->get_server_id(1); int real_id = test.repl->get_server_id(1);
char server_id[200] = ""; char server_id[200] = "";
find_field(Test->conn_rwsplit, "SELECT @@server_id", "@@server_id", server_id); find_field(test.conn_rwsplit, "SELECT @@server_id", "@@server_id", server_id);
int queried_id = atoi(server_id); int queried_id = atoi(server_id);
Test->add_result(queried_id != real_id, "The query server ID '%d' does not match the one from server '%d'. " test.add_result(queried_id != real_id, "The query server ID '%d' does not match the one from server '%d'. "
"Slave was not recovered.", queried_id, real_id); "Slave was not recovered.", queried_id, real_id);
char userval[200] = ""; char userval[200] = "";
find_field(Test->conn_rwsplit, "SELECT @a", "@a", userval); find_field(test.conn_rwsplit, "SELECT @a", "@a", userval);
Test->add_result(atoi(userval) != 1, "User variable @a is not 1, it is '%s'", userval); test.add_result(atoi(userval) != 1, "User variable @a is not 1, it is '%s'", userval);
Test->tprintf("Unblocking second slave\n"); test.tprintf("Unblocking second slave\n");
Test->repl->unblock_node(2); test.repl->unblock_node(2);
Test->check_maxscale_alive(); test.check_maxscale_alive();
int rval = Test->global_result; return test.global_result;
delete Test;
return rval;
} }