Merge branch 'cmake_build' into merge_cmake
This commit is contained in:
commit
0b3b86ad1c
136
CMakeLists.txt
Normal file
136
CMakeLists.txt
Normal file
@ -0,0 +1,136 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
include(macros.cmake)
|
||||
|
||||
enable_testing()
|
||||
set_variables()
|
||||
set_maxscale_version()
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories." FORCE)
|
||||
|
||||
project(MaxScale)
|
||||
|
||||
check_deps()
|
||||
check_dirs()
|
||||
|
||||
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/modules)
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_SOURCE_DIR}/server/include/version.h)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/maxscale.conf.in ${CMAKE_SOURCE_DIR}/maxscale.conf @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/init.d/maxscale.in ${CMAKE_SOURCE_DIR}/etc/init.d/maxscale @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.in ${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale @ONLY)
|
||||
|
||||
|
||||
set(CMAKE_C_FLAGS "-Wall -fPIC")
|
||||
set(CMAKE_CXX_FLAGS "-Wall -fPIC")
|
||||
|
||||
if(BUILD_TYPE MATCHES Debug)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -pthread -pipe -DSS_DEBUG -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -pthread -pipe -DSS_DEBUG -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4")
|
||||
message(STATUS "Generating debugging symbols")
|
||||
elseif(BUILD_TYPE MATCHES Optimized)
|
||||
if(NOT (DEFINED OLEVEL))
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
message(STATUS "Optimization level at: 2")
|
||||
endif()
|
||||
else()
|
||||
|
||||
endif()
|
||||
|
||||
if(DEFINED OLEVEL )
|
||||
if((OLEVEL GREATER -1) AND (OLEVEL LESS 4) )
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O${OLEVEL}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O${OLEVEL}")
|
||||
message(STATUS "Optimization level at: ${OLEVEL}")
|
||||
else()
|
||||
message(WARNING "Optimization level was set to a bad value, ignoring it. (Valid values are 0-3)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(GCOV)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
|
||||
endif()
|
||||
|
||||
|
||||
include_directories(${MYSQL_DIR})
|
||||
include_directories(${MYSQL_DIR}/private)
|
||||
include_directories(${MYSQL_DIR}/extra)
|
||||
include_directories(${MYSQL_DIR}/..)
|
||||
include_directories(utils)
|
||||
include_directories(log_manager)
|
||||
include_directories(query_classifier)
|
||||
include_directories(server/include)
|
||||
include_directories(server/inih)
|
||||
include_directories(server/modules/include)
|
||||
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(log_manager)
|
||||
add_subdirectory(query_classifier)
|
||||
add_subdirectory(server)
|
||||
add_subdirectory(client)
|
||||
|
||||
|
||||
# Install startup scripts and ldconfig files
|
||||
if( NOT ( (DEFINED INSTALL_SYSTEM_FILES) AND ( NOT ( INSTALL_SYSTEM_FILES ) ) ) )
|
||||
install(FILES maxscale.conf DESTINATION /etc/ld.so.conf.d/ PERMISSIONS WORLD_EXECUTE WORLD_READ)
|
||||
if(DEB_BASED)
|
||||
install(FILES etc/ubuntu/init.d/maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE)
|
||||
else()
|
||||
install(FILES etc/init.d/maxscale DESTINATION /etc/init.d/ PERMISSIONS WORLD_EXECUTE)
|
||||
endif()
|
||||
message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d")
|
||||
message(STATUS "Installing startup scripts to: /etc/init.d")
|
||||
endif()
|
||||
|
||||
file(GLOB DOCS Documentation/*.pdf)
|
||||
message(STATUS "Installing MaxScale to: ${CMAKE_INSTALL_PREFIX}/")
|
||||
|
||||
install(FILES server/MaxScale_template.cnf DESTINATION etc)
|
||||
install(FILES ${ERRMSG} DESTINATION mysql)
|
||||
install(FILES ${DOCS} DESTINATION Documentation)
|
||||
|
||||
# See if we are on a RPM-capable or DEB-capable system
|
||||
find_program(RPMBUILD rpmbuild)
|
||||
find_program(DEBBUILD dpkg-buildpackage)
|
||||
|
||||
if(NOT ( ${RPMBUILD} STREQUAL "RPMBUILD-NOTFOUND" ) )
|
||||
message(STATUS "Generating RPM packages")
|
||||
set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
|
||||
endif()
|
||||
|
||||
if(NOT ( ${DEBBUILD} STREQUAL "DEBBUILD-NOTFOUND" ) )
|
||||
set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
|
||||
execute_process(COMMAND dpgk --print-architecture OUTPUT_VARIABLE DEB_ARCHITECTURE)
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DEB_ARCHITECTURE})
|
||||
message(STATUS "Generating DEB packages for ${DEB_ARCHITECTURE}")
|
||||
endif()
|
||||
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MaxScale")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${MAXSCALE_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${MAXSCALE_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${MAXSCALE_VERSION_PATCH}")
|
||||
set(CPACK_PACKAGE_CONTACT "SkySQL Ab")
|
||||
set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}")
|
||||
set(CPACK_PACKAGE_NAME "maxscale")
|
||||
set(CPACK_PACKAGE_VENDOR "SkySQL Ab")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/README)
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
set(CPACK_RPM_SPEC_INSTALL_POST "/sbin/ldconfig")
|
||||
set(CPACK_RPM_PACKAGE_NAME "maxscale")
|
||||
set(CPACK_RPM_PACKAGE_VENDOR "SkySQL Ab")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQPROV " no")
|
||||
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/etc /etc/ld.so.conf.d /etc/init.d /etc/rc.d/init.d")
|
||||
set(CPACK_RPM_SPEC_MORE_DEFINE "%define ignore \#")
|
||||
set(CPACK_RPM_USER_FILELIST "%ignore /etc/init.d")
|
||||
set(CPACK_RPM_USER_FILELIST "%ignore /etc/ld.so.conf.d")
|
||||
set(CPACK_RPM_USER_FILELIST "%ignore /etc")
|
||||
include(CPack)
|
||||
add_custom_target(testall
|
||||
COMMAND ${CMAKE_COMMAND} -DDEPS_OK=Y -DBUILD_TESTS=Y -DBUILD_TYPE=Debug -DINSTALL_DIR=${CMAKE_BINARY_DIR} -DINSTALL_SYSTEM_FILES=N ${CMAKE_SOURCE_DIR}
|
||||
COMMAND make install
|
||||
COMMAND make test
|
||||
COMMENT "Running full test suite")
|
65
README
65
README
@ -152,6 +152,71 @@ max_connections=4096
|
||||
|
||||
Please check errmsg.sys is found in the MaxScale install_dir DEST/MaxScale/mysql
|
||||
|
||||
\section Building Building MaxScale with CMake
|
||||
|
||||
You can also build MaxScale with CMake which makes the build process a bit more simple.
|
||||
|
||||
All the same dependencies are required as with the normal MaxScale build with the addition of CMake
|
||||
version 2.6 for regular builds and 2.8.12 or newer if you wish to generate packages.
|
||||
|
||||
CMake tries to find all the required directories and files on its own but if it can't find them or you wish to
|
||||
explicitly state the locations you can pass additional options to CMake by using the -D flag. To confirm the variable
|
||||
values, you can run CMake in interactive mode by using the -i flag or use a CMake GUI (for example, ccmake for command line).
|
||||
|
||||
It is highly recommended to make a separate build directory to build into. This keeps the source and build trees clean and
|
||||
makes it easy to get rid of everything you built by simply deleting the build directory.
|
||||
|
||||
To build MaxScale using CMake:
|
||||
|
||||
cd <path to MaxScale source>
|
||||
|
||||
mkdir build
|
||||
|
||||
cd build
|
||||
|
||||
cmake ..
|
||||
|
||||
make
|
||||
|
||||
make install
|
||||
|
||||
This generates the required makefiles in the current directory, compiles and links all the programs and installs
|
||||
all the required files in their right places.
|
||||
|
||||
If you have your headers and libraries in non-standard locations, you can define those locations at configuration time as such:
|
||||
|
||||
cmake -D<variable>=<value>
|
||||
|
||||
By default, MaxScale installs to '/usr/local/skysql/maxscale' and places init.d scripts and ldconfig files into their folders. Change the INSTALL_DIR
|
||||
variable to your desired installation directory and set INSTALL_SYSTEM_FILES=N to prevent the init.d script and ldconfig file installation.
|
||||
|
||||
If you run into any trouble while configuring CMake, you can always remove the 'CMakeCache.txt' file to clear CMake's
|
||||
internal cache. This resets all values to their defaults and can be used to fix a 'stuck' configuration of CMake. This
|
||||
is also a good reason why you should always build into a separate directory, because you can safely wipe the build directory clean without the
|
||||
danger of deleting important files when something goes wrong.
|
||||
|
||||
The default values that CMake uses can be found in the 'macros.cmake' file. If you wish to change these, edit the 'macros.cmake' file
|
||||
or define the variables manually at configuration time.
|
||||
|
||||
All the variables that control the CMake build process:
|
||||
|
||||
INSTALL_DIR=<path> Installation directory
|
||||
BUILD_TYPE=[None|Debug|Release] Type of the build, defaults to Release (optimized)
|
||||
INSTALL_SYSTEM_FILES=[Y|N] Install startup scripts and ld configuration files
|
||||
EMBEDDED_LIB=<path> Path to the embedded library location (libmysqld.a for static and libmysqld.so for dynamic)
|
||||
MYSQL_DIR=<path> Path to MySQL headers
|
||||
ERRMSG=<path> Path to errmsg.sys file
|
||||
STATIC_EMBEDDED=[Y|N] Whether to link the static or the dynamic verson of the library
|
||||
GCOV=[Y|N] Generate gcov output
|
||||
OLEVEL=<0-3> Level of optimization
|
||||
BUILD_TESTS=[Y|N] Build tests
|
||||
DEPS_OK=[Y|N] Check dependencies, use N when you want to force a recheck of values
|
||||
DEBUG_OUTPUT=[Y|N] Produce debugging output when configuring CMake
|
||||
RABBITMQ_LIB=<path> Path to RabbitMQ-C libraries
|
||||
RABBITMQ_HEADERS=<path> Path to RabbitMQ-C headers
|
||||
MYSQL_CLIENT_LIB=<path> Path to MySQL client libraries
|
||||
MYSQL_CLIENT_HEADERS=<path> Path to MySQL client headers
|
||||
|
||||
\section Running Running MaxScale
|
||||
|
||||
MaxScale consists of a core executable and a number of modules that implement
|
||||
|
7
client/CMakeLists.txt
Normal file
7
client/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
add_executable(maxadmin maxadmin.c)
|
||||
find_library(HIST edit)
|
||||
if(HIST)
|
||||
add_definitions(-DHISTORY)
|
||||
target_link_libraries(maxadmin ${HIST})
|
||||
endif()
|
||||
install(TARGETS maxadmin DESTINATION bin)
|
157
etc/init.d/maxscale.in
Executable file
157
etc/init.d/maxscale.in
Executable file
@ -0,0 +1,157 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# maxscale: The SkySQL MaxScale database proxy
|
||||
#
|
||||
# description: MaxScale provides database specific proxy functionality
|
||||
#
|
||||
# processname: maxscale
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: maxscale
|
||||
# Required-Start: $syslog $local_fs
|
||||
# Required-Stop: $syslog $local_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: The maxscale database proxy
|
||||
# Description: MaxScale is a database proxy server that can be used to front end
|
||||
# database clusters offering different routing, filtering and protocol choices
|
||||
### END INIT INFO
|
||||
|
||||
#############################################
|
||||
# MaxScale HOME, PIDFILE, LIB
|
||||
#############################################
|
||||
|
||||
export MAXSCALE_HOME=@INSTALL_DIR@
|
||||
export MAXSCALE_PIDFILE=$MAXSCALE_HOME/log/maxscale.pid
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MAXSCALE_HOME/lib
|
||||
|
||||
###############################
|
||||
# LSB Exit codes (non-Status)
|
||||
###############################
|
||||
_RETVAL_GENERIC=1
|
||||
_RETVAL_NOT_INSTALLED=5
|
||||
_RETVAL_NOT_RUNNING=7
|
||||
|
||||
###############################
|
||||
# LSB Status action Exit codes
|
||||
###############################
|
||||
_RETVAL_STATUS_OK=0
|
||||
_RETVAL_STATUS_NOT_RUNNING=3
|
||||
|
||||
# Sanity checks.
|
||||
[ -x $MAXSCALE_HOME/bin/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
# we can rearrange this easily
|
||||
processname=maxscale
|
||||
servicename=maxscale
|
||||
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
echo -n $"Starting MaxScale: "
|
||||
my_check=`status -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale`
|
||||
CHECK_RET=$?
|
||||
[ $CHECK_RET -eq 0 ] && echo -n " found $my_check" && success && CHECK_RET=0
|
||||
|
||||
daemon --pidfile $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale >& /dev/null
|
||||
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
|
||||
|
||||
if [ $CHECK_RET -ne 0 ]; then
|
||||
sleep 2
|
||||
my_check=`status -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale`
|
||||
CHECK_RET=$?
|
||||
[ $CHECK_RET -eq 0 ] && echo -n $my_check && success || failure
|
||||
fi
|
||||
|
||||
# Return rigth code
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
failure
|
||||
RETVAL=$_RETVAL_NOT_RUNNING
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping MaxScale: "
|
||||
killproc -p $MAXSCALE_PIDFILE -TERM
|
||||
|
||||
RETVAL=$?
|
||||
|
||||
echo
|
||||
|
||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$servicename
|
||||
|
||||
# Return rigth code
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
RETVAL=$_RETVAL_NOT_RUNNING
|
||||
fi
|
||||
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo -n $"Reloading MaxScale: "
|
||||
|
||||
killproc -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale -HUP
|
||||
RETVAL=$?
|
||||
echo
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
# return 0 on success
|
||||
# return 3 on any error
|
||||
|
||||
echo -n $"Checking MaxScale status: "
|
||||
status -p $MAXSCALE_PIDFILE 'MaxScale'
|
||||
RETVAL=$?
|
||||
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
echo -ne "\033[1A"
|
||||
[ $RETVAL -eq 1 ] && warning || failure
|
||||
echo -ne "\033[1B"
|
||||
|
||||
RETVAL=$_RETVAL_STATUS_NOT_RUNNING
|
||||
else
|
||||
echo -ne "\033[1A"
|
||||
success
|
||||
echo -ne "\033[1B"
|
||||
RETVAL=$_RETVAL_STATUS_OK
|
||||
fi
|
||||
|
||||
exit $RETVAL
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
condrestart)
|
||||
if [ -f /var/lock/subsys/$servicename ]; then
|
||||
stop
|
||||
start
|
||||
fi
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
|
||||
;;
|
||||
esac
|
||||
exit $RETVAL
|
145
etc/ubuntu/init.d/maxscale.in
Normal file
145
etc/ubuntu/init.d/maxscale.in
Normal file
@ -0,0 +1,145 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# maxscale: The SkySQL MaxScale database proxy
|
||||
#
|
||||
# description: MaxScale provides database specific proxy functionality
|
||||
#
|
||||
# processname: maxscale
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: maxscale
|
||||
# Required-Start: $syslog $local_fs
|
||||
# Required-Stop: $syslog $local_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: The maxscale database proxy
|
||||
# Description: MaxScale is a database proxy server that can be used to front end
|
||||
# database clusters offering different routing, filtering and protocol choices
|
||||
### END INIT INFO
|
||||
|
||||
#############################################
|
||||
# MaxScale HOME, PIDFILE, LIB
|
||||
#############################################
|
||||
|
||||
export MAXSCALE_HOME=@INSTALL_DIR@
|
||||
export MAXSCALE_PIDFILE=$MAXSCALE_HOME/log/maxscale.pid
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MAXSCALE_HOME/lib
|
||||
|
||||
###############################
|
||||
# LSB Exit codes (non-Status)
|
||||
###############################
|
||||
_RETVAL_GENERIC=1
|
||||
_RETVAL_NOT_INSTALLED=5
|
||||
_RETVAL_NOT_RUNNING=7
|
||||
|
||||
###############################
|
||||
# LSB Status action Exit codes
|
||||
###############################
|
||||
_RETVAL_STATUS_OK=0
|
||||
_RETVAL_STATUS_NOT_RUNNING=3
|
||||
|
||||
# Sanity checks.
|
||||
[ -x $MAXSCALE_HOME/bin/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
|
||||
#################################
|
||||
# stop/start/status related vars
|
||||
#################################
|
||||
NAME=maxscale
|
||||
DAEMON=$MAXSCALE_HOME/bin/maxscale
|
||||
|
||||
# Source function library.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
# we can rearrange this easily
|
||||
processname=maxscale
|
||||
servicename=maxscale
|
||||
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
log_daemon_msg "Starting MaxScale"
|
||||
start_daemon -p $MAXSCALE_PIDFILE $DAEMON 2> /dev/null
|
||||
|
||||
sleep 2
|
||||
|
||||
status_of_proc -p $MAXSCALE_PIDFILE $DAEMON $NAME
|
||||
|
||||
log_end_msg $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
log_daemon_msg "Stopping MaxScale"
|
||||
killproc -p $PIDFILE $DAEMON 2>&1 /dev/null
|
||||
|
||||
maxscale_wait_stop
|
||||
|
||||
log_end_msg $?
|
||||
}
|
||||
|
||||
reload() {
|
||||
log_daemon_msg "Reloading MaxScale"
|
||||
|
||||
killproc -p $MAXSCALE_PIDFILE $DAEMON 1
|
||||
|
||||
log_end_msg $?
|
||||
}
|
||||
|
||||
maxscale_wait_stop() {
|
||||
PIDTMP=$(pidofproc -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale)
|
||||
kill -TERM "${PIDTMP:-}" 2> /dev/null;
|
||||
if [ -n "${PIDTMP:-}" ] && kill -0 "${PIDTMP:-}" 2> /dev/null; then
|
||||
local i=0
|
||||
while kill -0 "${PIDTMP:-}" 2> /dev/null; do
|
||||
if [ $i = '60' ]; then
|
||||
break
|
||||
STATUS=2
|
||||
fi
|
||||
[ "$VERBOSE" != no ] && log_progress_msg "."
|
||||
sleep 1
|
||||
i=$(($i+1))
|
||||
done
|
||||
return $STATUS
|
||||
else
|
||||
return $STATUS
|
||||
fi
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
# return 0 on success
|
||||
# return 3 on any error
|
||||
|
||||
log_daemon_msg "Checking MaxScale"
|
||||
status_of_proc -p $MAXSCALE_PIDFILE $DAEMON $NAME
|
||||
RETVAL=$?
|
||||
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
[ $RETVAL -eq 1 ]
|
||||
|
||||
RETVAL=$_RETVAL_STATUS_NOT_RUNNING
|
||||
else
|
||||
RETVAL=$_RETVAL_STATUS_OK
|
||||
fi
|
||||
|
||||
log_end_msg $RETVAL
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|reload}"
|
||||
;;
|
||||
esac
|
||||
exit $RETVAL
|
6
log_manager/CMakeLists.txt
Normal file
6
log_manager/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
add_library(log_manager SHARED log_manager.cc)
|
||||
target_link_libraries(log_manager pthread aio stdc++)
|
||||
install(TARGETS log_manager DESTINATION lib)
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
5
log_manager/test/CMakeLists.txt
Normal file
5
log_manager/test/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
add_executable(testlog testlog.c)
|
||||
add_executable(testorder testorder.c)
|
||||
target_link_libraries(testlog pthread log_manager utils)
|
||||
target_link_libraries(testorder pthread log_manager utils)
|
||||
add_test(NAME TestLogOrder COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/logorder.sh ${CMAKE_CURRENT_BINARY_DIR}/test.log 500 0 500 ${CMAKE_CURRENT_BINARY_DIR})
|
@ -2,24 +2,33 @@
|
||||
|
||||
if [[ $# -lt 4 ]]
|
||||
then
|
||||
echo "Usage: logorder.sh <iterations> <frequency of flushes> <message size>"
|
||||
echo "Usage: logorder.sh <iterations> <frequency of flushes> <message size> <log file>"
|
||||
echo "To disable log flushing, use 0 for flush frequency"
|
||||
exit
|
||||
fi
|
||||
|
||||
rm *.log
|
||||
|
||||
if [ $# -eq 5 ]
|
||||
then
|
||||
TDIR=$5
|
||||
else
|
||||
TDIR=$PWD
|
||||
fi
|
||||
|
||||
#Create large messages
|
||||
$PWD/testorder $1 $2 $3
|
||||
|
||||
$TDIR/testorder $1 $2 $3
|
||||
|
||||
TESTLOG=$4
|
||||
MCOUNT=$1
|
||||
|
||||
BLOCKS=`cat skygw_err1.log |tr -s ' '|grep -o 'block:[[:digit:]]\+'|cut -d ':' -f 2`
|
||||
MESSAGES=`cat skygw_err1.log |tr -s ' '|grep -o 'message|[[:digit:]]\+'|cut -d '|' -f 2`
|
||||
BLOCKS=`cat $TDIR/skygw_err1.log |tr -s ' '|grep -o 'block:[[:digit:]]\+'|cut -d ':' -f 2`
|
||||
MESSAGES=`cat $TDIR/skygw_err1.log |tr -s ' '|grep -o 'message|[[:digit:]]\+'|cut -d '|' -f 2`
|
||||
|
||||
prev=0
|
||||
error=0
|
||||
all_errors=0
|
||||
|
||||
for i in $BLOCKS
|
||||
do
|
||||
@ -27,6 +36,7 @@ do
|
||||
if [[ $i -le $prev ]]
|
||||
then
|
||||
error=1
|
||||
all_errors=1
|
||||
echo "block mismatch: $i was after $prev." >> $TESTLOG
|
||||
fi
|
||||
prev=$i
|
||||
@ -48,6 +58,7 @@ do
|
||||
if [[ $i -ne $(( prev + 1 )) ]]
|
||||
then
|
||||
error=1
|
||||
all_errors=1
|
||||
echo "message mismatch: $i was after $prev." >> $TESTLOG
|
||||
fi
|
||||
prev=$i
|
||||
@ -59,3 +70,9 @@ then
|
||||
else
|
||||
echo "Error: block buffer messages were written in the wrong order" >> $TESTLOG
|
||||
fi
|
||||
|
||||
if [ $# -eq 5 ]
|
||||
then
|
||||
cat $TESTLOG
|
||||
exit $all_errors
|
||||
fi
|
||||
|
210
macros.cmake
Normal file
210
macros.cmake
Normal file
@ -0,0 +1,210 @@
|
||||
macro(set_maxscale_version)
|
||||
|
||||
#MaxScale version number
|
||||
set(MAXSCALE_VERSION_MAJOR "1")
|
||||
set(MAXSCALE_VERSION_MINOR "0")
|
||||
set(MAXSCALE_VERSION_PATCH "0")
|
||||
set(MAXSCALE_VERSION "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}-beta")
|
||||
|
||||
endmacro()
|
||||
|
||||
macro(set_variables)
|
||||
|
||||
# Installation directory
|
||||
set(INSTALL_DIR "/usr/local/skysql/maxscale/" CACHE PATH "MaxScale installation directory.")
|
||||
|
||||
# Build type
|
||||
set(BUILD_TYPE "None" CACHE STRING "Build type, possible values are:None, Debug, Optimized.")
|
||||
|
||||
# hostname or IP address of MaxScale's host
|
||||
set(TEST_HOST "127.0.0.1" CACHE STRING "hostname or IP address of MaxScale's host")
|
||||
|
||||
# port of read connection router module
|
||||
set(TEST_PORT_RW "4008" CACHE STRING "port of read connection router module")
|
||||
|
||||
# port of read/write split router module
|
||||
set(TEST_PORT_RW "4006" CACHE STRING "port of read/write split router module")
|
||||
|
||||
# port of read/write split router module with hints
|
||||
set(TEST_PORT_RW_HINT "4006" CACHE STRING "port of read/write split router module with hints")
|
||||
|
||||
# master test server server_id
|
||||
set(TEST_MASTER_ID "3000" CACHE STRING "master test server server_id")
|
||||
|
||||
# username of MaxScale user
|
||||
set(TEST_USER "maxuser" CACHE STRING "username of MaxScale user")
|
||||
|
||||
# password of MaxScale user
|
||||
set(TEST_PASSWORD "maxpwd" CACHE STRING "password of MaxScale user")
|
||||
|
||||
# Use static version of libmysqld
|
||||
set(STATIC_EMBEDDED TRUE CACHE BOOL "Use static version of libmysqld")
|
||||
|
||||
# Build RabbitMQ components
|
||||
set(BUILD_RABBITMQ FALSE CACHE BOOL "Build RabbitMQ components")
|
||||
|
||||
# Use gcov build flags
|
||||
set(GCOV FALSE CACHE BOOL "Use gcov build flags")
|
||||
|
||||
# Install init.d scripts and ldconf configuration files
|
||||
set(INSTALL_SYSTEM_FILES TRUE CACHE BOOL "Install init.d scripts and ldconf configuration files")
|
||||
|
||||
# Build tests
|
||||
set(BUILD_TESTS TRUE CACHE BOOL "Build tests")
|
||||
|
||||
endmacro()
|
||||
|
||||
macro(check_deps)
|
||||
|
||||
# Check for libraries MaxScale depends on
|
||||
set(MAXSCALE_DEPS aio ssl crypt crypto z m dl rt pthread)
|
||||
foreach(lib ${MAXSCALE_DEPS})
|
||||
find_library(lib${lib} ${lib})
|
||||
if((DEFINED lib${lib}) AND (${lib${lib}} STREQUAL "lib${lib}-NOTFOUND"))
|
||||
set(DEPS_ERROR TRUE)
|
||||
set(FAILED_DEPS "${FAILED_DEPS} lib${lib}")
|
||||
elseif(DEBUG_OUTPUT)
|
||||
message(STATUS "Library was found at: ${lib${lib}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(DEPS_ERROR)
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Cannot find dependencies: ${FAILED_DEPS}")
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
||||
macro(check_dirs)
|
||||
|
||||
# This variable is used to prevent redundant checking of dependencies
|
||||
set(DEPS_OK TRUE CACHE BOOL "If all the dependencies were found.")
|
||||
|
||||
# Find the MySQL headers if they were not defined
|
||||
if(DEFINED MYSQL_DIR)
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Searching for MySQL headers at: ${MYSQL_DIR}")
|
||||
endif()
|
||||
find_path(MYSQL_DIR_LOC mysql.h PATHS ${MYSQL_DIR} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
||||
endif()
|
||||
find_path(MYSQL_DIR_LOC mysql.h PATH_SUFFIXES mysql mariadb)
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Search returned: ${MYSQL_DIR_LOC}")
|
||||
endif()
|
||||
if(${MYSQL_DIR_LOC} STREQUAL "MYSQL_DIR_LOC-NOTFOUND")
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Fatal Error: MySQL headers were not found.")
|
||||
else()
|
||||
message(STATUS "Using MySQL headers found at: ${MYSQL_DIR}")
|
||||
set(MYSQL_DIR ${MYSQL_DIR_LOC} CACHE PATH "Path to MySQL headers" FORCE)
|
||||
endif()
|
||||
set(MYSQL_DIR_LOC "" INTERNAL)
|
||||
|
||||
# Find the errmsg.sys file if it was not defied
|
||||
if( DEFINED ERRMSG )
|
||||
find_file(ERRMSG_FILE errmsg.sys PATHS ${ERRMSG} NO_DEFAULT_PATH)
|
||||
endif()
|
||||
find_file(ERRMSG_FILE errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english)
|
||||
if(${ERRMSG_FILE} MATCHES "ERRMSG_FILE-NOTFOUND")
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found, please define the path to it by using -DERRMSG=<path>")
|
||||
else()
|
||||
message(STATUS "Using errmsg.sys found at: ${ERRMSG_FILE}")
|
||||
endif()
|
||||
set(ERRMSG ${ERRMSG_FILE} CACHE FILEPATH "Path to the errmsg.sys file." FORCE)
|
||||
set(ERRMSG_FILE "" INTERNAL)
|
||||
|
||||
# Find the embedded mysql library
|
||||
if(STATIC_EMBEDDED)
|
||||
|
||||
set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
if (DEFINED EMBEDDED_LIB)
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Searching for libmysqld.a at: ${EMBEDDED_LIB}")
|
||||
endif()
|
||||
find_library(EMBEDDED_LIB_STATIC libmysqld.a PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_library(EMBEDDED_LIB_STATIC libmysqld.a PATH_SUFFIXES mysql mariadb)
|
||||
endif()
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Search returned: ${EMBEDDED_LIB_STATIC}")
|
||||
endif()
|
||||
set(EMBEDDED_LIB ${EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
|
||||
set(OLD_SUFFIXES "" INTERNAL)
|
||||
|
||||
else()
|
||||
if (DEFINED EMBEDDED_LIB)
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Searching for libmysqld.so at: ${EMBEDDED_LIB}")
|
||||
endif()
|
||||
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb)
|
||||
endif()
|
||||
if(DEBUG_OUTPUT)
|
||||
message(STATUS "Search returned: ${EMBEDDED_LIB_DYNAMIC}")
|
||||
endif()
|
||||
set(EMBEDDED_LIB ${EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
||||
|
||||
endif()
|
||||
set(EMBEDDED_LIB_DYNAMIC "" INTERNAL)
|
||||
set(EMBEDDED_LIB_STATIC "" INTERNAL)
|
||||
|
||||
# Inform the user about the embedded library
|
||||
if( (${EMBEDDED_LIB} STREQUAL "EMBEDDED_LIB_STATIC-NOTFOUND") OR (${EMBEDDED_LIB} STREQUAL "EMBEDDED_LIB_DYNAMIC-NOTFOUND"))
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Library not found: libmysqld. If your install of MySQL is in a non-default location, please provide the location with -DEMBEDDED_LIB=<path to library>")
|
||||
else()
|
||||
get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} REALPATH)
|
||||
message(STATUS "Using embedded library: ${EMBEDDED_LIB}")
|
||||
endif()
|
||||
|
||||
|
||||
# Check which init.d script to install
|
||||
find_file(RPM_FNC functions PATHS /etc/rc.d/init.d)
|
||||
if(${RPM_FNC} MATCHES "RPM_FNC-NOTFOUND")
|
||||
find_file(DEB_FNC init-functions PATHS /lib/lsb)
|
||||
if(${DEB_FNC} MATCHES "DEB_FNC-NOTFOUND")
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Cannot find required init-functions in /lib/lsb/ or /etc/rc.d/init.d/, please confirm that your system files are OK.")
|
||||
else()
|
||||
set(DEB_BASED TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
|
||||
endif()
|
||||
else()
|
||||
set(DEB_BASED FALSE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
|
||||
endif()
|
||||
set(DEB_FNC "" INTERNAL)
|
||||
set(RPM_FNC "" INTERNAL)
|
||||
|
||||
#Check RabbitMQ headers and libraries
|
||||
if(BUILD_RABBITMQ)
|
||||
|
||||
if(DEFINED RABBITMQ_LIB)
|
||||
find_library(RMQ_LIB rabbitmq PATHS ${RABBITMQ_LIB} NO_DEFAULT_PATH)
|
||||
endif()
|
||||
find_library(RMQ_LIB rabbitmq)
|
||||
if(RMQ_LIB STREQUAL "RMQ_LIB-NOTFOUND")
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Cannot find RabbitMQ libraries, please define the path to the libraries with -DRABBITMQ_LIB=<path>")
|
||||
else()
|
||||
set(RABBITMQ_LIB ${RMQ_LIB} CACHE PATH "Path to RabbitMQ libraries" FORCE)
|
||||
message(STATUS "Using RabbitMQ libraries found at: ${RABBITMQ_LIB}")
|
||||
endif()
|
||||
|
||||
if(DEFINED RABBITMQ_HEADERS)
|
||||
find_file(RMQ_HEADERS amqp.h PATHS ${RABBITMQ_HEADERS} NO_DEFAULT_PATH)
|
||||
endif()
|
||||
find_file(RMQ_HEADERS amqp.h)
|
||||
if(RMQ_HEADERS STREQUAL "RMQ_HEADERS-NOTFOUND")
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Cannot find RabbitMQ headers, please define the path to the headers with -DRABBITMQ_HEADERS=<path>")
|
||||
else()
|
||||
set(RABBITMQ_HEADERS ${RMQ_HEADERS} CACHE PATH "Path to RabbitMQ headers" FORCE)
|
||||
message(STATUS "Using RabbitMQ headers found at: ${RABBITMQ_HEADERS}")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
endmacro()
|
2
maxscale.conf.in
Normal file
2
maxscale.conf.in
Normal file
@ -0,0 +1,2 @@
|
||||
@INSTALL_DIR@/modules
|
||||
@INSTALL_DIR@/lib
|
6
query_classifier/CMakeLists.txt
Normal file
6
query_classifier/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
add_library(query_classifier SHARED query_classifier.cc)
|
||||
target_link_libraries(query_classifier ${EMBEDDED_LIB})
|
||||
install(TARGETS query_classifier DESTINATION lib)
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
1
query_classifier/test/CMakeLists.txt
Normal file
1
query_classifier/test/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(canonical_tests)
|
12
query_classifier/test/canonical_tests/CMakeLists.txt
Normal file
12
query_classifier/test/canonical_tests/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
file(COPY ${ERRMSG} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
if(${ERRMSG} MATCHES "ERRMSG-NOTFOUND")
|
||||
message(FATAL_ERROR "The errmsg.sys file was not found, please define the path with -DERRMSG=<path>")
|
||||
endif()
|
||||
add_executable(canonizer canonizer.c)
|
||||
target_link_libraries(canonizer pthread query_classifier z dl ssl aio crypt crypto rt m ${EMBEDDED_LIB} fullcore stdc++)
|
||||
add_test(NAME TestCanonicalQuery COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test.log
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/input.sql
|
||||
${CMAKE_CURRENT_BINARY_DIR}/output.sql
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/expected.sql
|
||||
$<TARGET_FILE:canonizer>)
|
@ -1,5 +1,5 @@
|
||||
#! /bin/sh
|
||||
if [[ $# -ne 4 ]]
|
||||
if [[ $# -lt 4 ]]
|
||||
then
|
||||
echo "Usage: canontest.sh <logfile name> <input file> <output file> <expected output>"
|
||||
exit 0
|
||||
@ -9,13 +9,29 @@ INPUT=$2
|
||||
OUTPUT=$3
|
||||
EXPECTED=$4
|
||||
DIFFLOG=diff.out
|
||||
$PWD/canonizer $INPUT $OUTPUT
|
||||
|
||||
if [ $# -eq 5 ]
|
||||
then
|
||||
EXECUTABLE=$5
|
||||
else
|
||||
EXECUTABLE=$PWD/canonizer
|
||||
fi
|
||||
|
||||
$EXECUTABLE $INPUT $OUTPUT
|
||||
diff $OUTPUT $EXPECTED > $DIFFLOG
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "PASSED" >> $TESTLOG
|
||||
exval=0
|
||||
else
|
||||
echo "FAILED" >> $TESTLOG
|
||||
echo "Diff output: " >> $TESTLOG
|
||||
cat $DIFFLOG >> $TESTLOG
|
||||
exval=1
|
||||
fi
|
||||
|
||||
if [ $# -eq 5 ]
|
||||
then
|
||||
cat $TESTLOG
|
||||
exit $exval
|
||||
fi
|
||||
|
@ -1,7 +1,7 @@
|
||||
select md5(?) =?, sleep(?), rand(?);
|
||||
select * from my1 where md5(?) =?;
|
||||
select md5(?) =?;
|
||||
select * from my1 where md5(?) =?;
|
||||
select md5("?") =?, sleep(?), rand(?)
|
||||
select * from my1 where md5("?") =?
|
||||
select md5("?") =?
|
||||
select * from my1 where md5("?") =?
|
||||
select sleep(?)
|
||||
select * from tst where lname='?'
|
||||
select ?,?,?,?,?,? from tst
|
||||
@ -13,5 +13,5 @@ create table tst(fname varchar(30), lname varchar(30))
|
||||
update tst set lname="?" where fname like '?' or lname like '?'
|
||||
delete from tst where lname like '?' and fname like '?'
|
||||
select ? from tst where fname='?' or lname like '?'
|
||||
select ?,?,?,? from tst where name='?' or name='?' or name='?'
|
||||
select ?,?,?,? from tst where name='?' or name='?' or name='?' or name='?'
|
||||
select count(?),count(?),count(?),count(?),count (?),count(?) from tst
|
||||
|
@ -1,44 +1,21 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
if (NOT ( DEFINED MYSQL_CLIENT_LIB ) )
|
||||
find_library(MYSQL_CLIENT_LIB NAMES mysqlclient PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb)
|
||||
endif()
|
||||
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 /usr/lib/mariadb /usr/lib64/mariadb)
|
||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /usr/include /usr/local/include /usr/include/mysql /usr/local/include/mysql /usr/include/mariadb /usr/local/include/mariadb)
|
||||
if (NOT ( DEFINED MYSQL_CLIENT_HEADERS ) )
|
||||
find_path(MYSQL_CLIENT_HEADERS NAMES mysql.h PATH_SUFFIXES mysql mariadb)
|
||||
endif()
|
||||
|
||||
include(InstallRequiredSystemLibraries)
|
||||
|
||||
project (consumer)
|
||||
|
||||
find_path(MYSQL_INCLUDE_DIRS mysql.h)
|
||||
find_library(MYSQL_LIBRARIES NAMES mysqlclient)
|
||||
find_library(RABBITMQ_C_LIBRARIES NAMES rabbitmq)
|
||||
|
||||
include_directories(${MYSQL_INCLUDE_DIRS})
|
||||
include_directories(${RABBITMQ_C_INCLUDE_DIRS})
|
||||
include_directories(${CMAKE_SOURCE_DIR}/inih)
|
||||
|
||||
add_subdirectory (inih)
|
||||
link_directories(${CMAKE_SOURCE_DIR}/inih)
|
||||
|
||||
if(RABBITMQ_C_LIBRARIES AND MYSQL_LIBRARIES AND MYSQL_INCLUDE_DIRS)
|
||||
|
||||
add_executable (consumer consumer.c ${MYSQL_LIBRARIES} ${RABBITMQ_C_LIBRARIES})
|
||||
target_link_libraries(consumer mysqlclient)
|
||||
target_link_libraries(consumer rabbitmq)
|
||||
target_link_libraries(consumer inih)
|
||||
install(TARGETS consumer DESTINATION bin)
|
||||
install(FILES consumer.cnf DESTINATION share/consumer)
|
||||
if( ( RABBITMQ_LIB AND RABBITMQ_HEADERS ) AND ( NOT ( ${MYSQL_CLIENT_LIB} STREQUAL "MYSQL_CLIENT_LIB-NOTFOUND" ) ) AND ( NOT ( ${MYSQL_CLIENT_HEADERS} STREQUAL "MYSQL_CLIENT_HEADERS-NOTFOUND" ) ) )
|
||||
include_directories(${MYSQL_CLIENT_HEADERS})
|
||||
add_executable (consumer consumer.c)
|
||||
target_link_libraries(consumer ${MYSQL_CLIENT_LIB} rabbitmq inih)
|
||||
install(TARGETS consumer DESTINATION bin)
|
||||
install(FILES consumer.cnf DESTINATION etc)
|
||||
|
||||
|
||||
else(RABBITMQ_C_LIBRARIES AND MYSQL_LIBRARIES AND MYSQL_INCLUDE_DIRS)
|
||||
message(FATAL_ERROR "Error: Can not find requred libraries: libmysqld, librabbitmq.")
|
||||
else()
|
||||
|
||||
endif(RABBITMQ_C_LIBRARIES AND MYSQL_LIBRARIES AND MYSQL_INCLUDE_DIRS)
|
||||
message(FATAL_ERROR "Error: Can not find requred libraries and headers: librabbitmq libmysqlclient")
|
||||
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "RabbitMQ Consumer Client")
|
||||
set(CPACK_PACKAGE_NAME "RabbitMQ Consumer")
|
||||
set(CPACK_GENERATOR "RPM")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||
set(CPACK_RPM_PACKAGE_NAME "rabbitmq-consumer")
|
||||
set(CPACK_RPM_PACKAGE_VENDOR "SkySQL Ab")
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQPROV " no")
|
||||
include(CPack)
|
||||
endif()
|
||||
|
6
server/CMakeLists.txt
Normal file
6
server/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(modules)
|
||||
add_subdirectory(inih)
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
22
server/core/CMakeLists.txt
Normal file
22
server/core/CMakeLists.txt
Normal file
@ -0,0 +1,22 @@
|
||||
file(GLOB FULLCORE_SRC *.c)
|
||||
add_library(fullcore STATIC ${FULLCORE_SRC})
|
||||
target_link_libraries(fullcore log_manager utils pthread ${EMBEDDED_LIB} ssl aio rt crypt dl crypto inih z m stdc++)
|
||||
|
||||
add_executable(maxscale atomic.c buffer.c spinlock.c gateway.c
|
||||
gw_utils.c utils.c dcb.c load_utils.c session.c service.c server.c
|
||||
poll.c config.c users.c hashtable.c dbusers.c thread.c gwbitmask.c
|
||||
monitor.c adminusers.c secrets.c filter.c modutil.c hint.c housekeeper.c)
|
||||
target_link_libraries(maxscale ${EMBEDDED_LIB} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++)
|
||||
install(TARGETS maxscale DESTINATION bin)
|
||||
|
||||
add_executable(maxkeys maxkeys.c secrets.c utils.c)
|
||||
target_link_libraries(maxkeys log_manager utils pthread crypt crypto)
|
||||
install(TARGETS maxkeys DESTINATION bin)
|
||||
|
||||
add_executable(maxpasswd maxpasswd.c secrets.c utils.c)
|
||||
target_link_libraries(maxpasswd log_manager utils pthread crypt crypto)
|
||||
install(TARGETS maxpasswd DESTINATION bin)
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
13
server/core/test/CMakeLists.txt
Normal file
13
server/core/test/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
add_executable(test_hash testhash.c)
|
||||
add_executable(test_spinlock testspinlock.c)
|
||||
add_executable(test_filter testfilter.c)
|
||||
add_executable(test_adminusers testadminusers.c)
|
||||
target_link_libraries(test_hash fullcore)
|
||||
target_link_libraries(test_spinlock fullcore)
|
||||
target_link_libraries(test_filter fullcore)
|
||||
target_link_libraries(test_adminusers fullcore)
|
||||
add_test(TestHash test_hash)
|
||||
add_test(TestSpinlock test_spinlock)
|
||||
add_test(TestFilter test_filter)
|
||||
add_test(TestAdminUsers test_adminusers)
|
||||
|
1
server/include/version.h.in
Normal file
1
server/include/version.h.in
Normal file
@ -0,0 +1 @@
|
||||
#define MAXSCALE_VERSION "@MAXSCALE_VERSION@"
|
1
server/inih/CMakeLists.txt
Normal file
1
server/inih/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_library(inih ini.c)
|
5
server/modules/CMakeLists.txt
Normal file
5
server/modules/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
include_directories(monitor)
|
||||
add_subdirectory(routing)
|
||||
add_subdirectory(protocol)
|
||||
add_subdirectory(monitor)
|
||||
add_subdirectory(filter)
|
27
server/modules/filter/CMakeLists.txt
Normal file
27
server/modules/filter/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
||||
if(BUILD_RABBITMQ)
|
||||
add_library(mqfilter SHARED mqfilter.c)
|
||||
target_link_libraries(mqfilter query_classifier log_manager utils rabbitmq)
|
||||
install(TARGETS mqfilter DESTINATION modules)
|
||||
endif()
|
||||
|
||||
add_library(regexfilter SHARED regexfilter.c)
|
||||
target_link_libraries(regexfilter log_manager utils)
|
||||
install(TARGETS regexfilter DESTINATION modules)
|
||||
|
||||
add_library(testfilter SHARED testfilter.c)
|
||||
target_link_libraries(testfilter log_manager utils)
|
||||
install(TARGETS testfilter DESTINATION modules)
|
||||
|
||||
add_library(qlafilter SHARED qlafilter.c)
|
||||
target_link_libraries(qlafilter log_manager utils)
|
||||
install(TARGETS qlafilter DESTINATION modules)
|
||||
|
||||
add_library(tee SHARED tee.c)
|
||||
target_link_libraries(tee log_manager utils)
|
||||
install(TARGETS tee DESTINATION modules)
|
||||
|
||||
add_library(topfilter SHARED topfilter.c)
|
||||
target_link_libraries(topfilter log_manager utils)
|
||||
install(TARGETS topfilter DESTINATION modules)
|
||||
|
||||
add_subdirectory(hint)
|
4
server/modules/filter/hint/CMakeLists.txt
Normal file
4
server/modules/filter/hint/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
add_library(hintfilter SHARED hintfilter.c hintparser.c)
|
||||
set_target_properties(hintfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
|
||||
target_link_libraries(hintfilter ssl log_manager utils)
|
||||
install(TARGETS hintfilter DESTINATION modules)
|
11
server/modules/monitor/CMakeLists.txt
Normal file
11
server/modules/monitor/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
add_library(mysqlmon SHARED mysql_mon.c)
|
||||
target_link_libraries(mysqlmon log_manager utils ${EMBEDDED_LIB})
|
||||
install(TARGETS mysqlmon DESTINATION modules)
|
||||
|
||||
add_library(galeramon SHARED galera_mon.c)
|
||||
target_link_libraries(galeramon log_manager utils ${EMBEDDED_LIB})
|
||||
install(TARGETS galeramon DESTINATION modules)
|
||||
|
||||
add_library(ndbclustermon SHARED ndbcluster_mon.c)
|
||||
target_link_libraries(ndbclustermon log_manager utils ${EMBEDDED_LIB})
|
||||
install(TARGETS ndbclustermon DESTINATION modules)
|
24
server/modules/protocol/CMakeLists.txt
Normal file
24
server/modules/protocol/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
add_library(MySQLClient SHARED mysql_client.c mysql_common.c)
|
||||
target_link_libraries(MySQLClient log_manager utils)
|
||||
install(TARGETS MySQLClient DESTINATION modules)
|
||||
|
||||
add_library(MySQLBackend SHARED mysql_backend.c mysql_common.c)
|
||||
target_link_libraries(MySQLBackend log_manager utils)
|
||||
install(TARGETS MySQLBackend DESTINATION modules)
|
||||
|
||||
add_library(telnetd SHARED telnetd.c)
|
||||
target_link_libraries(telnetd log_manager utils)
|
||||
install(TARGETS telnetd DESTINATION modules)
|
||||
|
||||
add_library(HTTPD SHARED httpd.c)
|
||||
target_link_libraries(HTTPD log_manager utils)
|
||||
install(TARGETS HTTPD DESTINATION modules)
|
||||
|
||||
add_library(maxscaled SHARED maxscaled.c)
|
||||
target_link_libraries(maxscaled log_manager utils)
|
||||
install(TARGETS maxscaled DESTINATION modules)
|
||||
|
||||
|
||||
|
||||
|
||||
|
18
server/modules/routing/CMakeLists.txt
Normal file
18
server/modules/routing/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
||||
add_library(testroute SHARED testroute.c)
|
||||
target_link_libraries(testroute log_manager utils)
|
||||
install(TARGETS testroute DESTINATION modules)
|
||||
|
||||
add_library(readconnroute SHARED readconnroute.c)
|
||||
target_link_libraries(readconnroute log_manager utils)
|
||||
install(TARGETS readconnroute DESTINATION modules)
|
||||
|
||||
add_library(debugcli SHARED debugcli.c debugcmd.c)
|
||||
target_link_libraries(debugcli log_manager utils)
|
||||
install(TARGETS debugcli DESTINATION modules)
|
||||
|
||||
add_library(cli SHARED cli.c debugcmd.c)
|
||||
target_link_libraries(cli log_manager utils)
|
||||
install(TARGETS cli DESTINATION modules)
|
||||
|
||||
add_subdirectory(readwritesplit)
|
||||
add_subdirectory(binlog)
|
4
server/modules/routing/binlog/CMakeLists.txt
Normal file
4
server/modules/routing/binlog/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
add_library(binlogrouter SHARED blr.c blr_master.c blr_cache.c blr_slave.c blr_file.c)
|
||||
set_target_properties(binlogrouter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
|
||||
target_link_libraries(binlogrouter ssl pthread log_manager ${EMBEDDED_LIB})
|
||||
install(TARGETS binlogrouter DESTINATION modules)
|
6
server/modules/routing/readwritesplit/CMakeLists.txt
Normal file
6
server/modules/routing/readwritesplit/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
add_library(readwritesplit SHARED readwritesplit.c)
|
||||
target_link_libraries(readwritesplit ssl pthread log_manager utils query_classifier ${EMBEDDED_LIB})
|
||||
install(TARGETS readwritesplit DESTINATION modules)
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
@ -0,0 +1,3 @@
|
||||
add_test(NAME ReadWriteSplitTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit.sh testrwsplit.log ${TEST_HOST} ${TEST_PORT_RW} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_tests_properties(ReadWriteSplitTest PROPERTIES DEPENDS RunExecutable)
|
||||
add_subdirectory(test_hints)
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
NARGS=6
|
||||
NARGS=7
|
||||
TLOG=$1
|
||||
THOST=$2
|
||||
TPORT=$3
|
||||
@ -7,10 +7,10 @@ TMASTER_ID=$4
|
||||
TUSER=$5
|
||||
TPWD=$6
|
||||
|
||||
if [ $# != $NARGS ] ;
|
||||
if [ $# -lt $(( NARGS - 1 )) ] ;
|
||||
then
|
||||
echo""
|
||||
echo "Wrong number of arguments, gave "$#" but "$NARGS" is required"
|
||||
echo "Wrong number of arguments, gave "$#" but "$(( NARGS - 1 ))" is required"
|
||||
echo ""
|
||||
echo "Usage :"
|
||||
echo " rwsplit.sh <log filename> <host> <port> <master id> <user> <password>"
|
||||
@ -18,12 +18,20 @@ echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$#" == "$NARGS" ]
|
||||
then
|
||||
echo "CTest mode"
|
||||
TDIR=$7 #this is only used by CMake
|
||||
echo "Test directory is: $TDIR"
|
||||
else
|
||||
TDIR=.
|
||||
fi
|
||||
|
||||
RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ --silent
|
||||
|
||||
TINPUT=test_transaction_routing2.sql
|
||||
TRETVAL=0
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -32,7 +40,7 @@ fi
|
||||
|
||||
TINPUT=test_transaction_routing2b.sql
|
||||
TRETVAL=0
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -41,7 +49,7 @@ fi
|
||||
|
||||
TINPUT=test_transaction_routing3.sql
|
||||
TRETVAL=2
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" = "$TMASTER_ID" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when one of the slave IDs was expected">>$TLOG;
|
||||
else
|
||||
@ -50,7 +58,7 @@ fi
|
||||
|
||||
TINPUT=test_transaction_routing3b.sql
|
||||
TRETVAL=2
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" = "$TMASTER_ID" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when one of the slave IDs was expected">>$TLOG;
|
||||
else
|
||||
@ -60,7 +68,7 @@ fi
|
||||
# test implicit transaction, that is, not started explicitly, autocommit=0
|
||||
TINPUT=test_transaction_routing4.sql
|
||||
TRETVAL=0
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -69,7 +77,7 @@ fi
|
||||
|
||||
TINPUT=test_transaction_routing4b.sql
|
||||
TRETVAL=0
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -80,7 +88,7 @@ fi
|
||||
TINPUT=select_for_var_set.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -90,7 +98,7 @@ fi
|
||||
TINPUT=test_implicit_commit1.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" = "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG;
|
||||
else
|
||||
@ -99,7 +107,7 @@ fi
|
||||
|
||||
TINPUT=test_implicit_commit2.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" = "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG;
|
||||
else
|
||||
@ -108,7 +116,7 @@ fi
|
||||
|
||||
TINPUT=test_implicit_commit3.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" = "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG;
|
||||
else
|
||||
@ -117,7 +125,7 @@ fi
|
||||
|
||||
TINPUT=test_implicit_commit4.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -126,7 +134,7 @@ fi
|
||||
|
||||
TINPUT=test_implicit_commit5.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" = "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG;
|
||||
else
|
||||
@ -135,7 +143,7 @@ fi
|
||||
|
||||
TINPUT=test_implicit_commit6.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" = "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG;
|
||||
else
|
||||
@ -144,7 +152,7 @@ fi
|
||||
|
||||
TINPUT=test_implicit_commit7.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" = "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG;
|
||||
else
|
||||
@ -153,7 +161,7 @@ fi
|
||||
|
||||
TINPUT=test_autocommit_disabled1.sql
|
||||
TRETVAL=1
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -162,7 +170,7 @@ fi
|
||||
|
||||
TINPUT=test_autocommit_disabled1b.sql
|
||||
TRETVAL=1
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -173,7 +181,7 @@ fi
|
||||
# it is again enabled.
|
||||
TINPUT=test_autocommit_disabled2.sql
|
||||
TRETVAL=1
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -181,10 +189,10 @@ else
|
||||
fi
|
||||
|
||||
TINPUT=set_autocommit_disabled.sql
|
||||
`$RUNCMD < ./$TINPUT`
|
||||
`$RUNCMD < $TDIR/$TINPUT`
|
||||
TINPUT=test_after_autocommit_disabled.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" = "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG;
|
||||
else
|
||||
@ -194,37 +202,37 @@ fi
|
||||
|
||||
TINPUT=test_sescmd.sql
|
||||
TRETVAL=2
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
echo "$TINPUT PASSED">>$TLOG ;
|
||||
fi
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
echo "$TINPUT PASSED">>$TLOG ;
|
||||
fi
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
echo "$TINPUT PASSED">>$TLOG ;
|
||||
fi
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
echo "$TINPUT PASSED">>$TLOG ;
|
||||
fi
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
echo "$TINPUT PASSED">>$TLOG ;
|
||||
fi
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
else
|
||||
@ -232,7 +240,7 @@ else
|
||||
fi
|
||||
|
||||
TINPUT=test_temporary_table.sql
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT`
|
||||
TRETVAL=1
|
||||
if [ "$a" != "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG;
|
||||
@ -252,7 +260,7 @@ do
|
||||
then
|
||||
printf "."
|
||||
fi
|
||||
a=`$RUNCMD < $TINPUT 2>&1`
|
||||
a=`$RUNCMD < $TDIR/$TINPUT 2>&1`
|
||||
if [[ "`echo "$a"|grep -i 'error'`" != "" ]]
|
||||
then
|
||||
err=`echo "$a" | grep -i error`
|
||||
@ -278,7 +286,7 @@ do
|
||||
then
|
||||
printf "."
|
||||
fi
|
||||
b=`$RUNCMD < $TINPUT 2>&1`
|
||||
b=`$RUNCMD < $TDIR/$TINPUT 2>&1`
|
||||
if [[ "`echo "$b"|grep -i 'null\|error'`" != "" ]]
|
||||
then
|
||||
err=`echo "$b" | grep -i null\|error`
|
||||
@ -292,3 +300,8 @@ else
|
||||
echo "Test FAILED at iteration $((j+1))" >> $TLOG
|
||||
fi
|
||||
echo "" >> $TLOG
|
||||
|
||||
if [ $# -eq $NARGS ]
|
||||
then
|
||||
cat $TLOG
|
||||
fi
|
||||
|
@ -0,0 +1,3 @@
|
||||
add_test(NAME SimpleHintTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit_hints.sh hints.log ${TEST_HOST} ${TEST_PORT_RW_HINT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} simple_tests ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_test(NAME ComplexHintTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit_hints.sh hints.log ${TEST_HOST} ${TEST_PORT_RW_HINT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} complex_tests ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_test(NAME StackHintTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit_hints.sh hints.log ${TEST_HOST} ${TEST_PORT_RW_HINT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} stack_tests ${CMAKE_CURRENT_SOURCE_DIR})
|
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
NARGS=7
|
||||
NARGS=8
|
||||
TLOG=$1
|
||||
THOST=$2
|
||||
TPORT=$3
|
||||
@ -8,10 +8,10 @@ TUSER=$5
|
||||
TPWD=$6
|
||||
TESTINPUT=$7
|
||||
|
||||
if [ $# != $NARGS ] ;
|
||||
if [ $# -lt $(( NARGS - 1 )) ] ;
|
||||
then
|
||||
echo""
|
||||
echo "Wrong number of arguments, gave "$#" but "$NARGS" is required"
|
||||
echo "Wrong number of arguments, gave "$#" but "$(( NARGS - 1 ))" is required"
|
||||
echo ""
|
||||
echo "Usage :"
|
||||
echo " rwsplit_hints.sh <log filename> <host> <port> <master id> <user> <password> <test file>"
|
||||
@ -19,6 +19,14 @@ echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -eq $NARGS ]
|
||||
then
|
||||
TDIR=$8
|
||||
else
|
||||
TDIR=.
|
||||
fi
|
||||
|
||||
TESTINPUT=$TDIR/$TESTINPUT
|
||||
|
||||
RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ --silent\ --comment
|
||||
i=0
|
||||
@ -63,3 +71,8 @@ then
|
||||
else
|
||||
echo "Test set: FAILED">>$TLOG;
|
||||
fi
|
||||
|
||||
if [ $# -eq $NARGS ]
|
||||
then
|
||||
cat $TLOG
|
||||
fi
|
||||
|
7
server/test/CMakeLists.txt
Normal file
7
server/test/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
file(COPY MaxScale_test.cnf DESTINATION ${CMAKE_BINARY_DIR}/etc)
|
||||
file(RENAME ${CMAKE_BINARY_DIR}/etc/MaxScale_test.cnf ${CMAKE_BINARY_DIR}/etc/MaxScale.cnf)
|
||||
add_test(NAME RunExecutable COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/startmaxscale.sh "${CMAKE_BINARY_DIR}/bin/" "-c ${CMAKE_BINARY_DIR}")
|
||||
set_tests_properties(RunExecutable PROPERTIES TIMEOUT 2)
|
||||
|
||||
add_test(NAME KillExecutable COMMAND killall -KILL maxscale)
|
||||
set_tests_properties(KillExecutable PROPERTIES DEPENDS StackHintTest ) #this needs to be the last test that requires a running maxscale
|
5
server/test/startmaxscale.sh
Executable file
5
server/test/startmaxscale.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
killall -KILL maxscale
|
||||
sleep 1
|
||||
setsid $1/maxscale $2
|
||||
exit 0
|
2
utils/CMakeLists.txt
Normal file
2
utils/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
add_library(utils skygw_utils.cc)
|
||||
target_link_libraries(utils stdc++)
|
Loading…
x
Reference in New Issue
Block a user