Merge branch 'develop' into firewall

Conflicts:
	server/modules/filter/test/CMakeLists.txt
	server/modules/filter/test/harness_common.c
This commit is contained in:
Markus Makela
2014-11-18 05:02:12 +02:00
17 changed files with 180 additions and 201 deletions

View File

@ -8,9 +8,9 @@ endforeach()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(harness_ui harness_ui.c harness_common.c)
add_executable(harness harness_util.c harness_common.c ${CORE})
target_link_libraries(harness_ui fullcore log_manager utils ${EMBEDDED_LIB})
target_link_libraries(harness fullcore ${EMBEDDED_LIB})
file(COPY ${ERRMSG} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fwtest.cnf.in ${CMAKE_CURRENT_BINARY_DIR}/fwtest.cnf @ONLY)
target_link_libraries(harness_ui fullcore log_manager utils)
target_link_libraries(harness fullcore)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${ERRMSG} ${CMAKE_CURRENT_BINARY_DIR})
add_test(TestHintfilter /bin/sh -c "MAXSCALE_HOME=\"${CMAKE_BINARY_DIR}\" ${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.input -o ${CMAKE_CURRENT_BINARY_DIR}/hint_testing.output -c ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.cnf -t 1 -s 1 -e ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.expected")
add_test(TestFwfilter /bin/sh -c "MAXSCALE_HOME=\"${CMAKE_BINARY_DIR}\" ${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/fwtest.input -o ${CMAKE_CURRENT_BINARY_DIR}/fwtest.output -c ${CMAKE_CURRENT_SOURCE_DIR}/fwtest.cnf -t 1 -s 1 -e ${CMAKE_CURRENT_SOURCE_DIR}/fwtest.expected")
add_test(TestRegexfilter /bin/sh -c "MAXSCALE_HOME=\"${CMAKE_BINARY_DIR}\" ${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/regextest.input -o ${CMAKE_CURRENT_BINARY_DIR}/regextest.output -c ${CMAKE_CURRENT_SOURCE_DIR}/regextest.cnf -t 1 -s 1 -e ${CMAKE_CURRENT_SOURCE_DIR}/regextest.expected")

View File

@ -11,6 +11,12 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){
int i = 0;
MYSQL_session* mysqlsess;
DCB* dcb;
char cwd[1024];
char tmp[2048];
char** optstr;
if(!(argc == 2 && strcmp(argv[1],"-h") == 0)){
skygw_logmanager_init(0,NULL);
}
@ -32,8 +38,8 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){
instance.last_ind = -1;
instance.sess_ind = -1;
instance.session = calloc(1,sizeof(SESSION));
MYSQL_session* mysqlsess = calloc(1,sizeof(MYSQL_session));
DCB* dcb = calloc(1,sizeof(DCB));
dcb = calloc(1,sizeof(DCB));
mysqlsess = calloc(1,sizeof(MYSQL_session));
sprintf(mysqlsess->user,"dummyuser");
sprintf(mysqlsess->db,"dummydb");
@ -43,6 +49,17 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){
instance.session->client = (void*)dcb;
instance.session->data = (void*)mysqlsess;
getcwd(cwd,sizeof(cwd));
sprintf(tmp,"%s",cwd);
optstr = (char**)malloc(sizeof(char*)*4);
optstr[0] = strdup("log_manager");
optstr[1] = strdup("-j");
optstr[2] = strdup(tmp);
optstr[3] = NULL;
skygw_logmanager_init( 3, optstr);
free(optstr);
process_opts(argc,argv);
if(!(instance.thrpool = malloc(instance.thrcount * sizeof(pthread_t)))){
@ -849,6 +866,8 @@ void route_buffers()
while(instance.buff_ind < instance.buffer_count){
pthread_mutex_unlock(&instance.work_mtx);
while(instance.last_ind < instance.session_count){
struct timespec ts1;
ts1.tv_sec = 0;
tprg = ((bprg + (float)instance.last_ind)/fin);
if(!instance.verbose){
@ -857,7 +876,8 @@ void route_buffers()
trig += step;
}
}
usleep(100);
ts1.tv_nsec = 100*1000000;
nanosleep(&ts1, NULL);
}
pthread_mutex_lock(&instance.work_mtx);
instance.buff_ind++;
@ -892,7 +912,11 @@ void work_buffer(void* thr_num)
index < instance.session_count &&
instance.buff_ind < instance.buffer_count)
{
struct timespec ts1;
ts1.tv_sec = 0;
if(instance.head->instance->routeQuery(instance.head->filter,
instance.head->session[index],
instance.buffer[instance.buff_ind]) == 0){
if(instance.outfile > 0){
@ -906,7 +930,8 @@ void work_buffer(void* thr_num)
fake_ok);
}
atomic_add(&instance.last_ind,1);
usleep(1000*instance.rt_delay);
ts1.tv_nsec = 1000*instance.rt_delay*1000000;
nanosleep(&ts1, NULL);
}
}

View File

@ -1,165 +1,3 @@
#
# Example MaxScale.cnf configuration file
#
#
#
# Number of server threads
# Valid options are:
# threads=<number of threads>
[maxscale]
threads=1
# Define a monitor that can be used to determine the state and role of
# the servers.
#
# Valid options are:
#
# module=<name of module to load>
# servers=<server name>,<server name>,...
# user =<user name - must have slave replication and
# slave client privileges>
# passwd=<password of the above user, plain text currently>
# monitor_interval=<sampling interval in milliseconds,
# default value is 10000>
[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1,server2,server3,server4
user=maxuser
passwd=maxpwd
# A series of service definition
#
# Valid options are:
#
# router=<name of router module>
# servers=<server name>,<server name>,...
# user=<User to fetch password inforamtion with>
# passwd=<Password of the user, plain text currently>
# enable_root_user=<0 or 1, default is 0>
# version_string=<specific string for server handshake,
# default is the MariaDB embedded library version>
#
# Valid router modules currently are:
# readwritesplit, readconnroute and debugcli
[RW Split Router]
type=service
router=readwritesplit
servers=server1,server2,server3,server4
max_slave_connections=90%
user=maxuser
passwd=maxpwd
#filters=MQ
[RW Split Hint Router]
type=service
router=readwritesplit
servers=server1,server2,server3,server4
max_slave_connections=90%
user=maxuser
passwd=maxpwd
filters=Hint
[Read Connection Router]
type=service
router=readconnroute
router_options=master
servers=server1
user=maxuser
passwd=maxpwd
[HTTPD Router]
type=service
router=testroute
servers=server1,server2,server3
[Debug Interface]
type=service
router=debugcli
[Hint]
type=filter
module=hintfilter
#[MQ]
#type=filter
#module=mqfilter
#exchange=x1
#key=k1
#queue=q1
#port=5673
# Listener definitions for the services
#
# Valid options are:
#
# service=<name of service defined elsewhere>
# protocol=<name of protocol module with which to listen>
# port=<Listening port>
# address=<Address to bind to>
# socket=<Listening socket>
[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
[RW Split Hint Listener]
type=listener
service=RW Split Hint Router
protocol=MySQLClient
port=4009
[Read Connection Listener]
type=listener
service=Read Connection Router
protocol=MySQLClient
port=4008
#socket=/tmp/readconn.sock
[Debug Listener]
type=listener
service=Debug Interface
protocol=telnetd
port=4442
#address=127.0.0.1
[HTTPD Listener]
type=listener
service=HTTPD Router
protocol=HTTPD
port=6444
# Definition of the servers
[server1]
type=server
address=127.0.0.1
port=3000
protocol=MySQLBackend
[server2]
type=server
address=127.0.0.1
port=3001
protocol=MySQLBackend
[server3]
type=server
address=127.0.0.1
port=3002
protocol=MySQLBackend
[server4]
type=server
address=127.0.0.1
port=3003
protocol=MySQLBackend

View File

@ -0,0 +1,5 @@
[Regex]
type=filter
module=regexfilter
match=wrong
replace=right

View File

@ -0,0 +1,3 @@
select * from mysql.right;
select right from test.table;
select * from test.table where name='right';

View File

@ -0,0 +1,3 @@
select * from mysql.wrong;
select wrong from test.table;
select * from test.table where name='wrong';

View File

@ -1111,7 +1111,7 @@ int gw_MySQLAccept(DCB *listener)
int sendbuf = GW_BACKEND_SO_SNDBUF;
socklen_t optlen = sizeof(sendbuf);
int eno = 0;
int syseno = 0;
int syseno = 0;
int i = 0;
CHK_DCB(listener);
@ -1151,6 +1151,8 @@ int gw_MySQLAccept(DCB *listener)
}
else if (eno == ENFILE || eno == EMFILE)
{
struct timespec ts1;
ts1.tv_sec = 0;
/**
* Exceeded system's (ENFILE) or processes
* (EMFILE) max. number of files limit.
@ -1173,8 +1175,9 @@ int gw_MySQLAccept(DCB *listener)
strerror(eno))));
}
i++;
usleep(100*i*i);
ts1.tv_nsec = 100*i*i*1000000;
nanosleep(&ts1, NULL);
if (i<10) {
goto retry_accept;
}

View File

@ -1847,7 +1847,7 @@ void protocol_add_srv_command(
MySQLProtocol* p,
mysql_server_cmd_t cmd)
{
#if defined(SS_DEBUG)
#if defined(EXTRA_SS_DEBUG)
server_command_t* c;
#endif
spinlock_acquire(&p->protocol_lock);