From b3ce9710209429ab2a15aa010fdf1f956bc99539 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 11 Sep 2014 18:24:41 +0300 Subject: [PATCH 001/125] initial implementation of the CMake build system --- CMakeLists.txt | 42 +++++++++++++++++++ client/CMakeLists.txt | 8 ++++ log_manager/CMakeLists.txt | 5 +++ query_classifier/CMakeLists.txt | 3 ++ server/CMakeLists.txt | 3 ++ server/core/CMakeLists.txt | 19 +++++++++ server/inih/CMakeLists.txt | 1 + server/modules/CMakeLists.txt | 5 +++ server/modules/filter/CMakeLists.txt | 33 +++++++++++++++ server/modules/filter/hint/CMakeLists.txt | 4 ++ server/modules/monitor/CMakeLists.txt | 14 +++++++ server/modules/protocol/CMakeLists.txt | 29 +++++++++++++ server/modules/routing/CMakeLists.txt | 22 ++++++++++ server/modules/routing/binlog/CMakeLists.txt | 4 ++ .../routing/readwritesplit/CMakeLists.txt | 4 ++ utils/CMakeLists.txt | 3 ++ 16 files changed, 199 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 client/CMakeLists.txt create mode 100644 log_manager/CMakeLists.txt create mode 100644 query_classifier/CMakeLists.txt create mode 100644 server/CMakeLists.txt create mode 100644 server/core/CMakeLists.txt create mode 100644 server/inih/CMakeLists.txt create mode 100644 server/modules/CMakeLists.txt create mode 100644 server/modules/filter/CMakeLists.txt create mode 100644 server/modules/filter/hint/CMakeLists.txt create mode 100644 server/modules/monitor/CMakeLists.txt create mode 100644 server/modules/protocol/CMakeLists.txt create mode 100644 server/modules/routing/CMakeLists.txt create mode 100644 server/modules/routing/binlog/CMakeLists.txt create mode 100644 server/modules/routing/readwritesplit/CMakeLists.txt create mode 100644 utils/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..3a884cc5a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 2.6) +project(MaxScale) + +find_path(MYSQL_DIR mysql.h PATH_SUFFIXES mysql mariadb) +find_file(ERRMSG errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english) + +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fPIC) +set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC) +message(STATUS "cflags: ${CMAKE_C_FLAGS}") +if(NOT EMBEDDED_LIB) + find_library(EMBEDDED_LIB libmysqld.a PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql) + if(EMBEDDED_LIB_NOT_FOUND) + message(ERROR "Library not found: libmysqld. If your install of MySQL is in a non-default location, please provide the location with -DEMBEDDED_LIB=") + endif(EMBEDDED_LIB_NOT_FOUND) +endif(NOT EMBEDDED_LIB) + +include_directories(${MYSQL_DIR}) +include_directories(${MYSQL_DIR}/private) +include_directories(${MYSQL_DIR}/extra) +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) + +if(BUILD_RABBITMQ) +add_subdirectory(rabbitmq_consumer) +endif(BUILD_RABBITMQ) + +file(GLOB DOCS Documentation/*.pdf) + +install(FILES server/test/MaxScale_test.cnf RENAME MaxScale.cnf DESTINATION etc) +install(FILES ${ERRMSG} DESTINATION mysql) +install(FILES ${EMBEDDED_LIB} DESTINATION lib) +install(FILES ${DOCS} DESTINATION Documentation) \ No newline at end of file diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt new file mode 100644 index 000000000..496c59127 --- /dev/null +++ b/client/CMakeLists.txt @@ -0,0 +1,8 @@ +add_executable(maxadmin maxadmin.c) +find_library(HIST edit) +#if(HIST) +# add_definitions(-DHISTORY) +# set(LIBS ${LIBS} {HIST}) +#endif(HIST) +set_target_properties(maxadmin PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +install(TARGETS maxadmin DESTINATION bin) \ No newline at end of file diff --git a/log_manager/CMakeLists.txt b/log_manager/CMakeLists.txt new file mode 100644 index 000000000..a5966c5c0 --- /dev/null +++ b/log_manager/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.6) +set(LOG_MANAGER_HEADERS log_manager.h) +add_library(log_manager SHARED log_manager.cc) +target_link_libraries(log_manager utils) +install(TARGETS log_manager DESTINATION lib) \ No newline at end of file diff --git a/query_classifier/CMakeLists.txt b/query_classifier/CMakeLists.txt new file mode 100644 index 000000000..3253e910b --- /dev/null +++ b/query_classifier/CMakeLists.txt @@ -0,0 +1,3 @@ +set(QUERY_CLASSIFIER_HEADERS query_classifier.h) +add_library(query_classifier SHARED query_classifier.cc ${MYSQL_HEADERS}) +install(TARGETS query_classifier DESTINATION lib) \ No newline at end of file diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt new file mode 100644 index 000000000..83404086e --- /dev/null +++ b/server/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(core) +add_subdirectory(modules) +add_subdirectory(inih) \ No newline at end of file diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt new file mode 100644 index 000000000..5a8972093 --- /dev/null +++ b/server/core/CMakeLists.txt @@ -0,0 +1,19 @@ +#file(GLOB FULLCORE_SRC *.c) #Not used, might be useful somewhere +#add_library(fullcore ${FULLCORE_SRC}) +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) +set_target_properties(maxscale PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(maxscale utils log_manager aio pthread crypt dl mysqld crypto inih) +install(TARGETS maxscale DESTINATION bin) + +add_executable(maxkeys maxkeys.c secrets.c utils.c) +set_target_properties(maxkeys PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(maxkeys utils log_manager aio pthread crypt dl mysqld crypto inih) +install(TARGETS maxkeys DESTINATION bin) + +add_executable(maxpasswd maxpasswd.c secrets.c utils.c) +set_target_properties(maxpasswd PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(maxpasswd utils log_manager aio pthread crypt dl mysqld crypto inih) +install(TARGETS maxpasswd DESTINATION bin) \ No newline at end of file diff --git a/server/inih/CMakeLists.txt b/server/inih/CMakeLists.txt new file mode 100644 index 000000000..24393e05d --- /dev/null +++ b/server/inih/CMakeLists.txt @@ -0,0 +1 @@ +add_library(inih ini.c) \ No newline at end of file diff --git a/server/modules/CMakeLists.txt b/server/modules/CMakeLists.txt new file mode 100644 index 000000000..f2d746ded --- /dev/null +++ b/server/modules/CMakeLists.txt @@ -0,0 +1,5 @@ +include_directories(monitor) +add_subdirectory(routing) +add_subdirectory(protocol) +add_subdirectory(monitor) +add_subdirectory(filter) \ No newline at end of file diff --git a/server/modules/filter/CMakeLists.txt b/server/modules/filter/CMakeLists.txt new file mode 100644 index 000000000..8343f6ca5 --- /dev/null +++ b/server/modules/filter/CMakeLists.txt @@ -0,0 +1,33 @@ +if(BUILD_RABBITMQ) + add_library(mqfilter SHARED mqfilter.c) + set_target_properties(mqfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) + target_link_libraries(mqfilter utils query_classifier log_manager rabbitmq) + install(TARGETS DESTINATION modules) +endif(BUILD_RABBITMQ) + +add_library(regexfilter SHARED regexfilter.c) +set_target_properties(regexfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(regexfilter utils log_manager) +install(TARGETS regexfilter DESTINATION modules) + +add_library(testfilter SHARED testfilter.c) +set_target_properties(testfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(testfilter utils log_manager) +install(TARGETS testfilter DESTINATION modules) + +add_library(qlafilter SHARED qlafilter.c) +set_target_properties(qlafilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(qlafilter utils log_manager) +install(TARGETS qlafilter DESTINATION modules) + +add_library(tee SHARED tee.c) +set_target_properties(tee PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(tee utils log_manager) +install(TARGETS tee DESTINATION modules) + +add_library(topfilter SHARED topfilter.c) +set_target_properties(topfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(topfilter utils log_manager) +install(TARGETS topfilter DESTINATION modules) + +add_subdirectory(hint) \ No newline at end of file diff --git a/server/modules/filter/hint/CMakeLists.txt b/server/modules/filter/hint/CMakeLists.txt new file mode 100644 index 000000000..62d2e9ee2 --- /dev/null +++ b/server/modules/filter/hint/CMakeLists.txt @@ -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 utils ssl log_manager) +install(TARGETS hintfilter DESTINATION modules) \ No newline at end of file diff --git a/server/modules/monitor/CMakeLists.txt b/server/modules/monitor/CMakeLists.txt new file mode 100644 index 000000000..947536b75 --- /dev/null +++ b/server/modules/monitor/CMakeLists.txt @@ -0,0 +1,14 @@ +add_library(mysqlmon SHARED mysql_mon.c) +set_target_properties(mysqlmon PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(mysqlmon utils log_manager mysqld) +install(TARGETS mysqlmon DESTINATION modules) + +add_library(galeramon SHARED galera_mon.c) +set_target_properties(galeramon PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(galeramon utils log_manager mysqld) +install(TARGETS galeramon DESTINATION modules) + +add_library(ndbclustermon SHARED ndbcluster_mon.c) +set_target_properties(ndbclustermon PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(ndbclustermon utils log_manager mysqld) +install(TARGETS ndbclustermon DESTINATION modules) \ No newline at end of file diff --git a/server/modules/protocol/CMakeLists.txt b/server/modules/protocol/CMakeLists.txt new file mode 100644 index 000000000..074c6f748 --- /dev/null +++ b/server/modules/protocol/CMakeLists.txt @@ -0,0 +1,29 @@ +add_library(MySQLClient SHARED mysql_client.c mysql_common.c) +set_target_properties(MySQLClient PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(MySQLClient utils log_manager) +install(TARGETS MySQLClient DESTINATION modules) + +add_library(MySQLBackend SHARED mysql_backend.c mysql_common.c) +set_target_properties(MySQLBackend PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(MySQLBackend utils log_manager) +install(TARGETS MySQLBackend DESTINATION modules) + +add_library(telnetd SHARED telnetd.c) +set_target_properties(telnetd PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(telnetd utils log_manager) +install(TARGETS telnetd DESTINATION modules) + +add_library(HTTPD SHARED httpd.c) +set_target_properties(HTTPD PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(HTTPD utils log_manager) +install(TARGETS HTTPD DESTINATION modules) + +add_library(maxscaled SHARED maxscaled.c) +set_target_properties(maxscaled PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(maxscaled utils log_manager) +install(TARGETS maxscaled DESTINATION modules) + + + + + diff --git a/server/modules/routing/CMakeLists.txt b/server/modules/routing/CMakeLists.txt new file mode 100644 index 000000000..7159471b1 --- /dev/null +++ b/server/modules/routing/CMakeLists.txt @@ -0,0 +1,22 @@ +add_library(testroute SHARED testroute.c) +set_target_properties(testroute PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(testroute utils log_manager) +install(TARGETS testroute DESTINATION modules) + +add_library(readconnroute SHARED readconnroute.c) +set_target_properties(readconnroute PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(readconnroute utils log_manager) +install(TARGETS readconnroute DESTINATION modules) + +add_library(debugcli SHARED debugcli.c debugcmd.c) +set_target_properties(debugcli PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(debugcli utils log_manager) +install(TARGETS debugcli DESTINATION modules) + +add_library(cli SHARED cli.c debugcmd.c) +set_target_properties(cli PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(cli utils log_manager) +install(TARGETS cli DESTINATION modules) + +add_subdirectory(readwritesplit) +add_subdirectory(binlog) \ No newline at end of file diff --git a/server/modules/routing/binlog/CMakeLists.txt b/server/modules/routing/binlog/CMakeLists.txt new file mode 100644 index 000000000..a36324eb1 --- /dev/null +++ b/server/modules/routing/binlog/CMakeLists.txt @@ -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 mysqld) +install(TARGETS binlogrouter DESTINATION modules) diff --git a/server/modules/routing/readwritesplit/CMakeLists.txt b/server/modules/routing/readwritesplit/CMakeLists.txt new file mode 100644 index 000000000..9c4f3e7e3 --- /dev/null +++ b/server/modules/routing/readwritesplit/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(readwritesplit SHARED readwritesplit.c) +set_target_properties(readwritesplit PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) +target_link_libraries(readwritesplit utils ssl pthread log_manager query_classifier mysqld) +install(TARGETS readwritesplit DESTINATION modules) \ No newline at end of file diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 000000000..a0a932353 --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.6) +set(UTILS_HEADERS skygw_debug.h skygw_types.h skygw_utils.h) +add_library(utils skygw_utils.cc ${UTILS_HEADERS}) \ No newline at end of file From 19ca28d8bd8c45456b0b1a69e8f5baadf7a70c61 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 11 Sep 2014 18:58:03 +0300 Subject: [PATCH 002/125] added preliminary testing framework --- CMakeLists.txt | 1 + server/CMakeLists.txt | 3 ++- server/test/CMakeLists.txt | 0 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 server/test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a884cc5a..3044a355c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 2.6) +enable_testing() project(MaxScale) find_path(MYSQL_DIR mysql.h PATH_SUFFIXES mysql mariadb) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 83404086e..883541d53 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(core) add_subdirectory(modules) -add_subdirectory(inih) \ No newline at end of file +add_subdirectory(inih) +add_subdirectory(test) \ No newline at end of file diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb From 7a069ecdf76ddd6e6f98b00a15afad5ce293d3e2 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 11 Sep 2014 20:08:28 +0300 Subject: [PATCH 003/125] added core tests to cmake --- CMakeLists.txt | 16 +++++++++++++++- server/core/CMakeLists.txt | 9 ++++++--- server/core/test/CMakeLists.txt | 12 ++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 server/core/test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 3044a355c..c07f4fda2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,26 @@ cmake_minimum_required(VERSION 2.6) enable_testing() project(MaxScale) +set(MAXSCALE_VERSION_MAJOR "1") +set(MAXSCALE_VERSION_MINOR "0.0-beta") +set(MAXSCALE_VERSION "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}") + +configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_SOURCE_DIR}/server/include/version.h) + find_path(MYSQL_DIR mysql.h PATH_SUFFIXES mysql mariadb) +if(MYSQL_DIR_NOT_FOUND) +message(FATAL_ERROR "Fatal Error: MySQL headers were not found.") +endif(MYSQL_DIR_NOT_FOUND) + + find_file(ERRMSG errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english) +if(ERRMSG_NOT_FOUND) +message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found.") +endif(ERRMSG_NOT_FOUND) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fPIC) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC) -message(STATUS "cflags: ${CMAKE_C_FLAGS}") + if(NOT EMBEDDED_LIB) find_library(EMBEDDED_LIB libmysqld.a PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql) if(EMBEDDED_LIB_NOT_FOUND) diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 5a8972093..b10d476da 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -1,5 +1,6 @@ -#file(GLOB FULLCORE_SRC *.c) #Not used, might be useful somewhere -#add_library(fullcore ${FULLCORE_SRC}) +file(GLOB FULLCORE_SRC *.c) +add_library(fullcore STATIC ${FULLCORE_SRC}) +target_link_libraries(fullcore utils log_manager aio pthread crypt dl mysqld crypto inih) 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 @@ -16,4 +17,6 @@ install(TARGETS maxkeys DESTINATION bin) add_executable(maxpasswd maxpasswd.c secrets.c utils.c) set_target_properties(maxpasswd PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) target_link_libraries(maxpasswd utils log_manager aio pthread crypt dl mysqld crypto inih) -install(TARGETS maxpasswd DESTINATION bin) \ No newline at end of file +install(TARGETS maxpasswd DESTINATION bin) + +add_subdirectory(test) \ No newline at end of file diff --git a/server/core/test/CMakeLists.txt b/server/core/test/CMakeLists.txt new file mode 100644 index 000000000..5e68f24ea --- /dev/null +++ b/server/core/test/CMakeLists.txt @@ -0,0 +1,12 @@ +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 crypto ssl pthread log_manager fullcore) +target_link_libraries(test_spinlock crypto ssl pthread log_manager fullcore) +target_link_libraries(test_filter crypto ssl pthread log_manager fullcore) +target_link_libraries(test_adminusers crypto crypt mysqld ssl fullcore) +add_test(TestHash test_hash) +add_test(TestSpinlock test_spinlock) +add_test(TestFilter test_filter) +add_test(TestAdminUsers test_adminusers) From 00449dfd4811ff8690f028cc5894b35468597d7f Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 11 Sep 2014 20:19:10 +0300 Subject: [PATCH 004/125] added the missing version.h template file --- server/include/version.h.in | 1 + 1 file changed, 1 insertion(+) create mode 100644 server/include/version.h.in diff --git a/server/include/version.h.in b/server/include/version.h.in new file mode 100644 index 000000000..5aced69a5 --- /dev/null +++ b/server/include/version.h.in @@ -0,0 +1 @@ +#define MAXSCALE_VERSION "@MAXSCALE_VERSION@" From dc92dbd37425c85131d9ac1d68b53a18030868b5 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 11 Sep 2014 20:30:49 +0300 Subject: [PATCH 005/125] added CPack and RPM packaging --- CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c07f4fda2..639549f3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,4 +54,16 @@ file(GLOB DOCS Documentation/*.pdf) install(FILES server/test/MaxScale_test.cnf RENAME MaxScale.cnf DESTINATION etc) install(FILES ${ERRMSG} DESTINATION mysql) install(FILES ${EMBEDDED_LIB} DESTINATION lib) -install(FILES ${DOCS} DESTINATION Documentation) \ No newline at end of file +install(FILES ${DOCS} DESTINATION Documentation) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MaxScale") +set(CPACK_PACKAGE_NAME "MaxScale") +set(CPACK_GENERATOR "RPM") +set(CPACK_PACKAGE_VERSION_MAJOR "1") +set(CPACK_PACKAGE_VERSION_MINOR "0") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}") +set(CPACK_RPM_PACKAGE_NAME "maxscale-${MAXSCALE_VERSION}") +set(CPACK_RPM_PACKAGE_VENDOR "SkySQL Ab") +set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") +include(CPack) \ No newline at end of file From 11a7c0d6b66e82df69763f2ae5ceb89e5a4eb3f9 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 11 Sep 2014 21:50:59 +0300 Subject: [PATCH 006/125] added gcov and static embedded library flags --- CMakeLists.txt | 27 +++++++++++++++++++++------ server/core/CMakeLists.txt | 3 ++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 639549f3c..964010454 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,12 +22,24 @@ endif(ERRMSG_NOT_FOUND) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fPIC) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC) -if(NOT EMBEDDED_LIB) - find_library(EMBEDDED_LIB libmysqld.a PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql) - if(EMBEDDED_LIB_NOT_FOUND) - message(ERROR "Library not found: libmysqld. If your install of MySQL is in a non-default location, please provide the location with -DEMBEDDED_LIB=") - endif(EMBEDDED_LIB_NOT_FOUND) -endif(NOT EMBEDDED_LIB) +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(GCOV) + + +if(STATIC_EMBEDDED) + find_file(EMBEDDED_LIB libmysqld.a PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) + message(STATUS "Using static embedded library.") +elseif( NOT STATIC_EMBEDDED) + find_library(EMBEDDED_LIB mysqld PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) + message(STATUS "Using dynamic embedded library.") +endif(STATIC_EMBEDDED) + +if(EMBEDDED_LIB_NOT_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=") +endif(EMBEDDED_LIB_NOT_FOUND) include_directories(${MYSQL_DIR}) include_directories(${MYSQL_DIR}/private) @@ -52,6 +64,8 @@ endif(BUILD_RABBITMQ) file(GLOB DOCS Documentation/*.pdf) install(FILES server/test/MaxScale_test.cnf RENAME MaxScale.cnf DESTINATION etc) +install(FILES maxscale.conf DESTINATION etc/ld.so.conf.d) +install(FILES etc/init.d/maxscale DESTINATION etc/init.d) install(FILES ${ERRMSG} DESTINATION mysql) install(FILES ${EMBEDDED_LIB} DESTINATION lib) install(FILES ${DOCS} DESTINATION Documentation) @@ -62,6 +76,7 @@ set(CPACK_GENERATOR "RPM") set(CPACK_PACKAGE_VERSION_MAJOR "1") set(CPACK_PACKAGE_VERSION_MINOR "0") set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_CONTACT "SkySQL Ab") set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}") set(CPACK_RPM_PACKAGE_NAME "maxscale-${MAXSCALE_VERSION}") set(CPACK_RPM_PACKAGE_VENDOR "SkySQL Ab") diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index b10d476da..f0e48aa08 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -1,12 +1,13 @@ file(GLOB FULLCORE_SRC *.c) add_library(fullcore STATIC ${FULLCORE_SRC}) target_link_libraries(fullcore utils log_manager aio pthread crypt dl mysqld crypto inih) + 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) set_target_properties(maxscale PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) -target_link_libraries(maxscale utils log_manager aio pthread crypt dl mysqld crypto inih) +target_link_libraries(maxscale utils log_manager ssl aio pthread crypt dl ${EMBEDDED_LIB} crypto inih z) install(TARGETS maxscale DESTINATION bin) add_executable(maxkeys maxkeys.c secrets.c utils.c) From 8962fec0cf3cb5a9b45d6317a469ccbbff548b63 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 11 Sep 2014 22:04:57 +0300 Subject: [PATCH 007/125] added post install ldconfig call --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 964010454..fab7a11fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ set(CPACK_PACKAGE_VERSION_MINOR "0") set(CPACK_PACKAGE_VERSION_PATCH "0") set(CPACK_PACKAGE_CONTACT "SkySQL Ab") set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}") +set(CPACK_RPM_SPEC_INSTALL_POST "/sbin/ldconfig") set(CPACK_RPM_PACKAGE_NAME "maxscale-${MAXSCALE_VERSION}") set(CPACK_RPM_PACKAGE_VENDOR "SkySQL Ab") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") From 8697b9761709d79e4e88a13243ae41fc3b73786e Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 11 Sep 2014 22:14:17 +0300 Subject: [PATCH 008/125] added missing linker flags --- server/core/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index f0e48aa08..91dd5878b 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -7,17 +7,17 @@ add_executable(maxscale atomic.c buffer.c spinlock.c gateway.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) set_target_properties(maxscale PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) -target_link_libraries(maxscale utils log_manager ssl aio pthread crypt dl ${EMBEDDED_LIB} crypto inih z) +target_link_libraries(maxscale utils log_manager ssl aio pthread crypt dl ${EMBEDDED_LIB} crypto inih z rt m) install(TARGETS maxscale DESTINATION bin) add_executable(maxkeys maxkeys.c secrets.c utils.c) set_target_properties(maxkeys PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) -target_link_libraries(maxkeys utils log_manager aio pthread crypt dl mysqld crypto inih) +target_link_libraries(maxkeys utils log_manager ssl aio pthread crypt dl ${EMBEDDED_LIB} crypto inih z rt m) install(TARGETS maxkeys DESTINATION bin) add_executable(maxpasswd maxpasswd.c secrets.c utils.c) set_target_properties(maxpasswd PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) -target_link_libraries(maxpasswd utils log_manager aio pthread crypt dl mysqld crypto inih) +target_link_libraries(maxpasswd utils log_manager ssl aio pthread crypt dl ${EMBEDDED_LIB} crypto inih z rt m) install(TARGETS maxpasswd DESTINATION bin) add_subdirectory(test) \ No newline at end of file From d8c34aabadb9e88554a2a8411f0b08b0ea90692e Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 12 Sep 2014 06:06:11 +0300 Subject: [PATCH 009/125] added log manager and query classifier tests --- log_manager/CMakeLists.txt | 5 +++-- log_manager/test/CMakeLists.txt | 5 +++++ query_classifier/CMakeLists.txt | 3 ++- query_classifier/test/CMakeLists.txt | 1 + query_classifier/test/canonical_tests/CMakeLists.txt | 4 ++++ 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 log_manager/test/CMakeLists.txt create mode 100644 query_classifier/test/CMakeLists.txt create mode 100644 query_classifier/test/canonical_tests/CMakeLists.txt diff --git a/log_manager/CMakeLists.txt b/log_manager/CMakeLists.txt index a5966c5c0..c451500b5 100644 --- a/log_manager/CMakeLists.txt +++ b/log_manager/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 2.6) -set(LOG_MANAGER_HEADERS log_manager.h) add_library(log_manager SHARED log_manager.cc) target_link_libraries(log_manager utils) -install(TARGETS log_manager DESTINATION lib) \ No newline at end of file +install(TARGETS log_manager DESTINATION lib) + +add_subdirectory(test) \ No newline at end of file diff --git a/log_manager/test/CMakeLists.txt b/log_manager/test/CMakeLists.txt new file mode 100644 index 000000000..d378bdc7c --- /dev/null +++ b/log_manager/test/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(testlog testlog.c) +add_executable(testorder testorder.c) +target_link_libraries(testlog utils pthread log_manager) +target_link_libraries(testorder utils pthread log_manager) +add_test(NAME TestLogOrder COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/logorder.sh 500 0 500 logtest.log) \ No newline at end of file diff --git a/query_classifier/CMakeLists.txt b/query_classifier/CMakeLists.txt index 3253e910b..87c67ef62 100644 --- a/query_classifier/CMakeLists.txt +++ b/query_classifier/CMakeLists.txt @@ -1,3 +1,4 @@ set(QUERY_CLASSIFIER_HEADERS query_classifier.h) add_library(query_classifier SHARED query_classifier.cc ${MYSQL_HEADERS}) -install(TARGETS query_classifier DESTINATION lib) \ No newline at end of file +install(TARGETS query_classifier DESTINATION lib) +add_subdirectory(test) \ No newline at end of file diff --git a/query_classifier/test/CMakeLists.txt b/query_classifier/test/CMakeLists.txt new file mode 100644 index 000000000..ceaad8110 --- /dev/null +++ b/query_classifier/test/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(canonical_tests) \ No newline at end of file diff --git a/query_classifier/test/canonical_tests/CMakeLists.txt b/query_classifier/test/canonical_tests/CMakeLists.txt new file mode 100644 index 000000000..4695d8045 --- /dev/null +++ b/query_classifier/test/canonical_tests/CMakeLists.txt @@ -0,0 +1,4 @@ +file(COPY ${ERRMSG} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +add_executable(canonizer canonizer.c) +target_link_libraries(canonizer pthread query_classifier z dl ssl aio crypt crypto rt m ${EMBEDDED_LIB} fullcore) +add_test(NAME TestCanonicalQuery COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh testcanon.log input.sql output.sql expected.sql) \ No newline at end of file From f0641dc39e006bd0897a9a9dc976849867244b63 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 12 Sep 2014 07:30:25 +0300 Subject: [PATCH 010/125] added readwritesplit tests --- CMakeLists.txt | 28 ++++++++++--------- .../routing/readwritesplit/CMakeLists.txt | 3 +- .../readwritesplit/test/CMakeLists.txt | 2 ++ server/test/CMakeLists.txt | 5 ++++ 4 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 server/modules/routing/readwritesplit/test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index fab7a11fb..956f5c993 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,31 +1,32 @@ cmake_minimum_required(VERSION 2.6) + +include(macros.cmake) enable_testing() project(MaxScale) -set(MAXSCALE_VERSION_MAJOR "1") -set(MAXSCALE_VERSION_MINOR "0.0-beta") -set(MAXSCALE_VERSION "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}") +set_maxscale_version() +set_testing_variables() configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_SOURCE_DIR}/server/include/version.h) find_path(MYSQL_DIR mysql.h PATH_SUFFIXES mysql mariadb) if(MYSQL_DIR_NOT_FOUND) -message(FATAL_ERROR "Fatal Error: MySQL headers were not found.") + message(FATAL_ERROR "Fatal Error: MySQL headers were not found.") endif(MYSQL_DIR_NOT_FOUND) find_file(ERRMSG errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english) if(ERRMSG_NOT_FOUND) -message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found.") + message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found.") endif(ERRMSG_NOT_FOUND) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fPIC) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC) 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") + 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(GCOV) @@ -58,7 +59,7 @@ add_subdirectory(server) add_subdirectory(client) if(BUILD_RABBITMQ) -add_subdirectory(rabbitmq_consumer) + add_subdirectory(rabbitmq_consumer) endif(BUILD_RABBITMQ) file(GLOB DOCS Documentation/*.pdf) @@ -73,13 +74,14 @@ install(FILES ${DOCS} DESTINATION Documentation) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MaxScale") set(CPACK_PACKAGE_NAME "MaxScale") set(CPACK_GENERATOR "RPM") -set(CPACK_PACKAGE_VERSION_MAJOR "1") -set(CPACK_PACKAGE_VERSION_MINOR "0") -set(CPACK_PACKAGE_VERSION_PATCH "0") +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_RPM_SPEC_INSTALL_POST "/sbin/ldconfig") set(CPACK_RPM_PACKAGE_NAME "maxscale-${MAXSCALE_VERSION}") set(CPACK_RPM_PACKAGE_VENDOR "SkySQL Ab") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") -include(CPack) \ No newline at end of file +include(CPack) + diff --git a/server/modules/routing/readwritesplit/CMakeLists.txt b/server/modules/routing/readwritesplit/CMakeLists.txt index 9c4f3e7e3..1deb361d3 100644 --- a/server/modules/routing/readwritesplit/CMakeLists.txt +++ b/server/modules/routing/readwritesplit/CMakeLists.txt @@ -1,4 +1,5 @@ add_library(readwritesplit SHARED readwritesplit.c) set_target_properties(readwritesplit PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) target_link_libraries(readwritesplit utils ssl pthread log_manager query_classifier mysqld) -install(TARGETS readwritesplit DESTINATION modules) \ No newline at end of file +install(TARGETS readwritesplit DESTINATION modules) +add_subdirectory(test) \ No newline at end of file diff --git a/server/modules/routing/readwritesplit/test/CMakeLists.txt b/server/modules/routing/readwritesplit/test/CMakeLists.txt new file mode 100644 index 000000000..607fbe6d0 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/CMakeLists.txt @@ -0,0 +1,2 @@ +add_test(NAME ReadWriteSplitTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit.sh test.log ${TEST_HOST} ${TEST_PORT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD}) +set_tests_properties(ReadWriteSplitTest PROPERTIES DEPENDS ExecutableTest) \ No newline at end of file diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt index e69de29bb..3a07ab1ee 100644 --- a/server/test/CMakeLists.txt +++ b/server/test/CMakeLists.txt @@ -0,0 +1,5 @@ +add_test(NAME ExecutableTest COMMAND maxscale) +add_test(NAME WaitForExecutable COMMAND sleep 5) +add_test(NAME KillExecutable COMMAND killall maxscale) +set_tests_properties(WaitForExecutable PROPERTIES DEPENDS ExecutableTest) +set_tests_properties(KillExecutable PROPERTIES DEPENDS ReadWriteSplitTest DEPENDS WaitForExecutable) From 175b387eb71f13091395ae0daaea904402f222b7 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 12 Sep 2014 11:18:44 +0300 Subject: [PATCH 011/125] added the macro file --- macros.cmake | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 macros.cmake diff --git a/macros.cmake b/macros.cmake new file mode 100644 index 000000000..1283d9b1b --- /dev/null +++ b/macros.cmake @@ -0,0 +1,36 @@ +macro(set_maxscale_version) + + 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}") + +endmacro() + +macro(set_testing_variables) + + if(NOT TEST_LOG) + set(TEST_LOG "test.log") + endif() + + if(NOT TEST_HOST) + set(TEST_HOST "127.0.0.1") + endif() + + if(NOT TEST_PORT) + set(TEST_PORT "4006") + endif() + + if(NOT TEST_MASTER_ID) + set(TEST_MASTER_ID "3000") + endif() + + if(NOT TEST_USER) + set(TEST_USER "maxuser") + endif() + + if(NOT TEST_PASSWORD) + set(TEST_PASSWORD "maxpwd") + endif() + +endmacro() \ No newline at end of file From ba9a31497ee0d5552e23415ad7042bc693d441e2 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 12 Sep 2014 11:21:05 +0300 Subject: [PATCH 012/125] cleaning up of main CMakeListst.txt --- CMakeLists.txt | 62 +++++++++++++++++++++++++++++++++----------------- macros.cmake | 2 +- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 956f5c993..a6f75130f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,38 +9,51 @@ set_testing_variables() configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_SOURCE_DIR}/server/include/version.h) -find_path(MYSQL_DIR mysql.h PATH_SUFFIXES mysql mariadb) -if(MYSQL_DIR_NOT_FOUND) - message(FATAL_ERROR "Fatal Error: MySQL headers were not found.") -endif(MYSQL_DIR_NOT_FOUND) +if(NOT MYSQL_DIR) + find_path(MYSQL_DIR mysql.h PATH_SUFFIXES mysql mariadb) + if(MYSQL_DIR_NOT_FOUND) + message(FATAL_ERROR "Fatal Error: MySQL headers were not found.") + endif(MYSQL_DIR_NOT_FOUND) +endif() +if(NOT ERRMSG) + find_file(ERRMSG errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql ${CUSTOM_ERRMSG} PATH_SUFFIXES english) + if(ERRMSG_NOT_FOUND) + message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found.") + endif(ERRMSG_NOT_FOUND) +endif() -find_file(ERRMSG errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english) -if(ERRMSG_NOT_FOUND) - message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found.") -endif(ERRMSG_NOT_FOUND) - -set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fPIC) -set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") 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_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") -endif(GCOV) - +endif() if(STATIC_EMBEDDED) + find_file(EMBEDDED_LIB libmysqld.a PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) - message(STATUS "Using static embedded library.") + + if(EMBEDDED_LIB_NOT_FOUND) + message(WARNING "Warning: Static library not found, looking for dynamic version") + find_library(EMBEDDED_LIB mysqld PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) + get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} REALPATH) + endif() + elseif( NOT STATIC_EMBEDDED) + find_library(EMBEDDED_LIB mysqld PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) - message(STATUS "Using dynamic embedded library.") -endif(STATIC_EMBEDDED) + get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} REALPATH) + +endif() if(EMBEDDED_LIB_NOT_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=") -endif(EMBEDDED_LIB_NOT_FOUND) +else() + message(STATUS "Using embedded library: ${EMBEDDED_LIB}") +endif() include_directories(${MYSQL_DIR}) include_directories(${MYSQL_DIR}/private) @@ -64,9 +77,16 @@ endif(BUILD_RABBITMQ) file(GLOB DOCS Documentation/*.pdf) -install(FILES server/test/MaxScale_test.cnf RENAME MaxScale.cnf DESTINATION etc) -install(FILES maxscale.conf DESTINATION etc/ld.so.conf.d) -install(FILES etc/init.d/maxscale DESTINATION etc/init.d) + +if(NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug")) + message(STATUS "Will install system files") + install(FILES server/test/MaxScale_test.cnf RENAME MaxScale.cnf DESTINATION /etc) + install(FILES maxscale.conf DESTINATION /etc/ld.so.conf.d) + install(FILES etc/init.d/maxscale DESTINATION /etc/init.d) +else() + install(FILES server/test/MaxScale_test.cnf RENAME MaxScale.cnf DESTINATION etc) +endif() + install(FILES ${ERRMSG} DESTINATION mysql) install(FILES ${EMBEDDED_LIB} DESTINATION lib) install(FILES ${DOCS} DESTINATION Documentation) diff --git a/macros.cmake b/macros.cmake index 1283d9b1b..4965e3640 100644 --- a/macros.cmake +++ b/macros.cmake @@ -10,7 +10,7 @@ endmacro() macro(set_testing_variables) if(NOT TEST_LOG) - set(TEST_LOG "test.log") + set(TEST_LOG "${CMAKE_SOURCE_DIR}/test/test_maxscale.log") endif() if(NOT TEST_HOST) From 32b72ce474e7094fb0eea9e6764bf556e59abcb4 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 12 Sep 2014 16:48:21 +0300 Subject: [PATCH 013/125] more configuration options, README update and tests --- CMakeLists.txt | 2 +- README | 31 +++ log_manager/test/CMakeLists.txt | 2 +- log_manager/test/logorder.sh | 20 +- macros.cmake | 26 +- .../test/canonical_tests/CMakeLists.txt | 6 +- .../test/canonical_tests/canontest.sh | 18 +- server/core/test/CMakeLists.txt | 1 + .../readwritesplit/test/CMakeLists.txt | 4 +- .../routing/readwritesplit/test/rwsplit.sh | 231 +++++++++--------- server/test/CMakeLists.txt | 6 +- 11 files changed, 199 insertions(+), 148 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6f75130f..83e246e87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ if(GCOV) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") endif() -if(STATIC_EMBEDDED) +if((NOT EMBEDDED_LIB) AND STATIC_EMBEDDED) find_file(EMBEDDED_LIB libmysqld.a PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) diff --git a/README b/README index cdc9b35ac..5a0e2eb23 100644 --- a/README +++ b/README @@ -152,6 +152,37 @@ 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 or newer for package generation. + +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 the ccmake GUI. + +For example, to build MaxScale using CMake with a custom install location: + + cmake -DCMAKE_INSTALL_PREFIX=/usr/local/skysql + + 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. + +Variables controlling the CMake build process: + +CMAKE_INSTALL_PREFIX= Install destination prefix, same as DEST +CMAKE_BUILD_TYPE=[Debug|Release] Type of the build +EMBEDDED_LIB= Path to the embedded library, filename included +MYSQL_DIR= Path to MySQL headers +STATIC_EMBEDDED=[Y|N] Link the static or the dynamic verson of the library +GCOV=[Y|N] Generate gcov output + \section Running Running MaxScale MaxScale consists of a core executable and a number of modules that implement diff --git a/log_manager/test/CMakeLists.txt b/log_manager/test/CMakeLists.txt index d378bdc7c..eb529ba0b 100644 --- a/log_manager/test/CMakeLists.txt +++ b/log_manager/test/CMakeLists.txt @@ -2,4 +2,4 @@ add_executable(testlog testlog.c) add_executable(testorder testorder.c) target_link_libraries(testlog utils pthread log_manager) target_link_libraries(testorder utils pthread log_manager) -add_test(NAME TestLogOrder COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/logorder.sh 500 0 500 logtest.log) \ No newline at end of file +add_test(NAME TestLogOrder COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/logorder.sh 500 0 500) \ No newline at end of file diff --git a/log_manager/test/logorder.sh b/log_manager/test/logorder.sh index bbdcaf0f7..aaad7ffd7 100755 --- a/log_manager/test/logorder.sh +++ b/log_manager/test/logorder.sh @@ -1,6 +1,6 @@ #! /bin/bash -if [[ $# -lt 4 ]] +if [[ $# -lt 3 ]] then echo "Usage: logorder.sh " echo "To disable log flushing, use 0 for flush frequency" @@ -12,7 +12,6 @@ rm *.log #Create large messages $PWD/testorder $1 $2 $3 -TESTLOG=$4 MCOUNT=$1 BLOCKS=`cat skygw_err1.log |tr -s ' '|grep -o 'block:[[:digit:]]\+'|cut -d ':' -f 2` @@ -20,23 +19,24 @@ MESSAGES=`cat skygw_err1.log |tr -s ' '|grep -o 'message|[[:digit:]]\+'|cut -d ' prev=0 error=0 - +all_errors=0 for i in $BLOCKS do if [[ $i -le $prev ]] then error=1 - echo "block mismatch: $i was after $prev." >> $TESTLOG + all_errors=1 + echo "block mismatch: $i was after $prev." fi prev=$i done if [[ error -eq 0 ]] then - echo "Block buffers were in order" >> $TESTLOG + echo "Block buffers were in order" else - echo "Error: block buffers were written in the wrong order" >> $TESTLOG + echo "Error: block buffers were written in the wrong order" fi prev=0 @@ -48,14 +48,16 @@ do if [[ $i -ne $(( prev + 1 )) ]] then error=1 - echo "message mismatch: $i was after $prev." >> $TESTLOG + all_errors=1 + echo "message mismatch: $i was after $prev." fi prev=$i done if [[ error -eq 0 ]] then - echo "Block buffer messages were in order" >> $TESTLOG + echo "Block buffer messages were in order" else - echo "Error: block buffer messages were written in the wrong order" >> $TESTLOG + echo "Error: block buffer messages were written in the wrong order" fi +exit $all_errors diff --git a/macros.cmake b/macros.cmake index 4965e3640..9dccf34cb 100644 --- a/macros.cmake +++ b/macros.cmake @@ -1,34 +1,46 @@ 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}") + set(MAXSCALE_VERSION "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}-beta") endmacro() macro(set_testing_variables) - if(NOT TEST_LOG) - set(TEST_LOG "${CMAKE_SOURCE_DIR}/test/test_maxscale.log") - endif() - + # hostname or IP address of MaxScale's host if(NOT TEST_HOST) set(TEST_HOST "127.0.0.1") endif() - if(NOT TEST_PORT) - set(TEST_PORT "4006") + # port of read connection router module + if(NOT TEST_PORT_RW) + set(TEST_PORT_RW "4008") endif() + # port of read/write split router module + if(NOT TEST_PORT_RW) + set(TEST_PORT_RW "4006") + endif() + + # port of read/write split router module with hints + if(NOT TEST_PORT_RW_HINT) + set(TEST_PORT_RW_HINT "4006") + endif() + + # master's server_id if(NOT TEST_MASTER_ID) set(TEST_MASTER_ID "3000") endif() + # username of MaxScale user if(NOT TEST_USER) set(TEST_USER "maxuser") endif() + # password of MaxScale user if(NOT TEST_PASSWORD) set(TEST_PASSWORD "maxpwd") endif() diff --git a/query_classifier/test/canonical_tests/CMakeLists.txt b/query_classifier/test/canonical_tests/CMakeLists.txt index 4695d8045..c5ec3bf2d 100644 --- a/query_classifier/test/canonical_tests/CMakeLists.txt +++ b/query_classifier/test/canonical_tests/CMakeLists.txt @@ -1,4 +1,8 @@ file(COPY ${ERRMSG} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) add_executable(canonizer canonizer.c) target_link_libraries(canonizer pthread query_classifier z dl ssl aio crypt crypto rt m ${EMBEDDED_LIB} fullcore) -add_test(NAME TestCanonicalQuery COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh testcanon.log input.sql output.sql expected.sql) \ No newline at end of file +add_test(NAME TestCanonicalQuery COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/canontest.sh + $ + ${CMAKE_CURRENT_SOURCE_DIR}/input.sql + ${CMAKE_CURRENT_BINARY_DIR}/output.sql + ${CMAKE_CURRENT_SOURCE_DIR}/expected.sql) \ No newline at end of file diff --git a/query_classifier/test/canonical_tests/canontest.sh b/query_classifier/test/canonical_tests/canontest.sh index 8382103c1..dd9342fc1 100755 --- a/query_classifier/test/canonical_tests/canontest.sh +++ b/query_classifier/test/canonical_tests/canontest.sh @@ -1,21 +1,23 @@ #! /bin/sh -if [[ $# -ne 4 ]] +if [[ $# -lt 4 ]] then - echo "Usage: canontest.sh " + echo "Usage: canontest.sh " exit 0 fi -TESTLOG=$1 +EXECUTABLE=$1 INPUT=$2 OUTPUT=$3 EXPECTED=$4 DIFFLOG=diff.out -$PWD/canonizer $INPUT $OUTPUT +$EXECUTABLE $INPUT $OUTPUT diff $OUTPUT $EXPECTED > $DIFFLOG if [ $? -eq 0 ] then - echo "PASSED" >> $TESTLOG + echo "PASSED" else - echo "FAILED" >> $TESTLOG - echo "Diff output: " >> $TESTLOG - cat $DIFFLOG >> $TESTLOG + echo "FAILED" + echo "Diff output: " + cat $DIFFLOG + exit 1; fi +exit 0; diff --git a/server/core/test/CMakeLists.txt b/server/core/test/CMakeLists.txt index 5e68f24ea..8e0f54661 100644 --- a/server/core/test/CMakeLists.txt +++ b/server/core/test/CMakeLists.txt @@ -10,3 +10,4 @@ add_test(TestHash test_hash) add_test(TestSpinlock test_spinlock) add_test(TestFilter test_filter) add_test(TestAdminUsers test_adminusers) + diff --git a/server/modules/routing/readwritesplit/test/CMakeLists.txt b/server/modules/routing/readwritesplit/test/CMakeLists.txt index 607fbe6d0..cf5806ff1 100644 --- a/server/modules/routing/readwritesplit/test/CMakeLists.txt +++ b/server/modules/routing/readwritesplit/test/CMakeLists.txt @@ -1,2 +1,2 @@ -add_test(NAME ReadWriteSplitTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit.sh test.log ${TEST_HOST} ${TEST_PORT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD}) -set_tests_properties(ReadWriteSplitTest PROPERTIES DEPENDS ExecutableTest) \ No newline at end of file +add_test(NAME ReadWriteSplitTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit.sh ${TEST_HOST} ${TEST_PORT_RW} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD}) +set_tests_properties(ReadWriteSplitTest PROPERTIES DEPENDS WaitForExecutable) \ No newline at end of file diff --git a/server/modules/routing/readwritesplit/test/rwsplit.sh b/server/modules/routing/readwritesplit/test/rwsplit.sh index 6fefd8801..8d4d64234 100755 --- a/server/modules/routing/readwritesplit/test/rwsplit.sh +++ b/server/modules/routing/readwritesplit/test/rwsplit.sh @@ -1,11 +1,10 @@ #!/bin/sh -NARGS=6 -TLOG=$1 -THOST=$2 -TPORT=$3 -TMASTER_ID=$4 -TUSER=$5 -TPWD=$6 +NARGS=5 +THOST=$1 +TPORT=$2 +TMASTER_ID=$3 +TUSER=$4 +TPWD=$5 if [ $# != $NARGS ] ; then @@ -21,231 +20,231 @@ fi RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ --silent -TINPUT=test_transaction_routing2.sql +TINPUT=$PWD/test_transaction_routing2.sql TRETVAL=0 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_transaction_routing2b.sql +TINPUT=$PWD/test_transaction_routing2b.sql TRETVAL=0 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_transaction_routing3.sql +TINPUT=$PWD/test_transaction_routing3.sql TRETVAL=2 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" = "$TMASTER_ID" ]; then - echo "$TINPUT FAILED, return value $a when one of the slave IDs was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when one of the slave IDs was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_transaction_routing3b.sql +TINPUT=$PWD/test_transaction_routing3b.sql TRETVAL=2 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" = "$TMASTER_ID" ]; then - echo "$TINPUT FAILED, return value $a when one of the slave IDs was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when one of the slave IDs was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi # test implicit transaction, that is, not started explicitly, autocommit=0 -TINPUT=test_transaction_routing4.sql +TINPUT=$PWD/test_transaction_routing4.sql TRETVAL=0 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_transaction_routing4b.sql +TINPUT=$PWD/test_transaction_routing4b.sql TRETVAL=0 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi # set a var via SELECT INTO @, get data from master, returning server-id: put master server-id value in TRETVAL -TINPUT=select_for_var_set.sql +TINPUT=$PWD/select_for_var_set.sql TRETVAL=$TMASTER_ID -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_implicit_commit1.sql +TINPUT=$PWD/test_implicit_commit1.sql TRETVAL=$TMASTER_ID -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; + echo "$TINPUT FAILED, return value $a when it was not accetable"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_implicit_commit2.sql +TINPUT=$PWD/test_implicit_commit2.sql TRETVAL=$TMASTER_ID -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; + echo "$TINPUT FAILED, return value $a when it was not accetable"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_implicit_commit3.sql +TINPUT=$PWD/test_implicit_commit3.sql TRETVAL=$TMASTER_ID -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; + echo "$TINPUT FAILED, return value $a when it was not accetable"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_implicit_commit4.sql +TINPUT=$PWD/test_implicit_commit4.sql TRETVAL=$TMASTER_ID -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi TINPUT=test_implicit_commit5.sql TRETVAL=$TMASTER_ID -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; + echo "$TINPUT FAILED, return value $a when it was not accetable"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_implicit_commit6.sql +TINPUT=$PWD/test_implicit_commit6.sql TRETVAL=$TMASTER_ID -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; + echo "$TINPUT FAILED, return value $a when it was not accetable"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_implicit_commit7.sql +TINPUT=$PWD/test_implicit_commit7.sql TRETVAL=$TMASTER_ID -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; + echo "$TINPUT FAILED, return value $a when it was not accetable"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_autocommit_disabled1.sql +TINPUT=$PWD/test_autocommit_disabled1.sql TRETVAL=1 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_autocommit_disabled1b.sql +TINPUT=$PWD/test_autocommit_disabled1b.sql TRETVAL=1 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi # Disable autocommit in the first session and then test in new session that # it is again enabled. -TINPUT=test_autocommit_disabled2.sql +TINPUT=$PWD/test_autocommit_disabled2.sql TRETVAL=1 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=set_autocommit_disabled.sql -`$RUNCMD < ./$TINPUT` +TINPUT=$PWD/set_autocommit_disabled.sql +`$RUNCMD < $TINPUT` TINPUT=test_after_autocommit_disabled.sql TRETVAL=$TMASTER_ID -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; + echo "$TINPUT FAILED, return value $a when it was not accetable"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_sescmd.sql +TINPUT=$PWD/test_sescmd.sql TRETVAL=2 -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -a=`$RUNCMD < ./$TINPUT` +a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -TINPUT=test_temporary_table.sql -a=`$RUNCMD < ./$TINPUT` +TINPUT=$PWD/test_temporary_table.sql +a=`$RUNCMD < $TINPUT` TRETVAL=1 if [ "$a" != "$TRETVAL" ]; then - echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected"; else - echo "$TINPUT PASSED">>$TLOG ; + echo "$TINPUT PASSED" ; fi -echo "-----------------------------------" >> $TLOG -echo "Session variables: Stress Test 1" >> $TLOG -echo "-----------------------------------" >> $TLOG +echo "-----------------------------------" +echo "Session variables: Stress Test 1" +echo "-----------------------------------" RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ -q\ -r -TINPUT=test_sescmd2.sql +TINPUT=$PWD/test_sescmd2.sql for ((i = 0;i<1000;i++)) do if [[ $(( i % 50 )) -eq 0 ]] @@ -261,17 +260,17 @@ do done if [[ "$err" == "" ]] then - echo "TEST PASSED" >> $TLOG + echo "TEST PASSED" else - echo "$err" >> $TLOG - echo "Test FAILED at iteration $((i+1))" >> $TLOG + echo "$err" + echo "Test FAILED at iteration $((i+1))" fi -echo "-----------------------------------" >> $TLOG -echo "Session variables: Stress Test 2" >> $TLOG -echo "-----------------------------------" >> $TLOG +echo "-----------------------------------" +echo "Session variables: Stress Test 2" +echo "-----------------------------------" echo "" err="" -TINPUT=test_sescmd3.sql +TINPUT=$PWD/test_sescmd3.sql for ((j = 0;j<1000;j++)) do if [[ $(( j % 50 )) -eq 0 ]] @@ -287,8 +286,8 @@ do done if [[ "$err" == "" ]] then - echo "TEST PASSED" >> $TLOG + echo "TEST PASSED" else - echo "Test FAILED at iteration $((j+1))" >> $TLOG + echo "Test FAILED at iteration $((j+1))" fi -echo "" >> $TLOG +echo "" diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt index 3a07ab1ee..94e589032 100644 --- a/server/test/CMakeLists.txt +++ b/server/test/CMakeLists.txt @@ -1,5 +1,5 @@ -add_test(NAME ExecutableTest COMMAND maxscale) +add_test(NAME RunExecutable COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/startmaxscale.sh $ "-c ${CMAKE_BINARY_DIR}/") add_test(NAME WaitForExecutable COMMAND sleep 5) add_test(NAME KillExecutable COMMAND killall maxscale) -set_tests_properties(WaitForExecutable PROPERTIES DEPENDS ExecutableTest) -set_tests_properties(KillExecutable PROPERTIES DEPENDS ReadWriteSplitTest DEPENDS WaitForExecutable) +set_tests_properties(WaitForExecutable PROPERTIES DEPENDS RunExecutable) +set_tests_properties(KillExecutable PROPERTIES DEPENDS ReadWriteSplitTest) From bc49b6a901580769859173e56c17c557c02ae8b8 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Sat, 13 Sep 2014 04:13:25 +0300 Subject: [PATCH 014/125] CPack configurations updated to better match expected values --- CMakeLists.txt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83e246e87..c259a5c5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,16 +11,16 @@ configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_SOURCE_DI if(NOT MYSQL_DIR) find_path(MYSQL_DIR mysql.h PATH_SUFFIXES mysql mariadb) - if(MYSQL_DIR_NOT_FOUND) + if(MYSQL_DIR-NOTFOUND) message(FATAL_ERROR "Fatal Error: MySQL headers were not found.") - endif(MYSQL_DIR_NOT_FOUND) + endif(MYSQL_DIR-NOTFOUND) endif() if(NOT ERRMSG) find_file(ERRMSG errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql ${CUSTOM_ERRMSG} PATH_SUFFIXES english) - if(ERRMSG_NOT_FOUND) + if(ERRMSG-NOTFOUND) message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found.") - endif(ERRMSG_NOT_FOUND) + endif(ERRMSG-NOTFOUND) endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") @@ -36,7 +36,7 @@ if((NOT EMBEDDED_LIB) AND STATIC_EMBEDDED) find_file(EMBEDDED_LIB libmysqld.a PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) - if(EMBEDDED_LIB_NOT_FOUND) + if(EMBEDDED_LIB-NOTFOUND) message(WARNING "Warning: Static library not found, looking for dynamic version") find_library(EMBEDDED_LIB mysqld PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} REALPATH) @@ -49,7 +49,7 @@ elseif( NOT STATIC_EMBEDDED) endif() -if(EMBEDDED_LIB_NOT_FOUND) +if(EMBEDDED_LIB-NOTFOUND) 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=") else() message(STATUS "Using embedded library: ${EMBEDDED_LIB}") @@ -99,8 +99,12 @@ 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 "/") set(CPACK_RPM_SPEC_INSTALL_POST "/sbin/ldconfig") -set(CPACK_RPM_PACKAGE_NAME "maxscale-${MAXSCALE_VERSION}") +set(CPACK_RPM_PACKAGE_NAME "maxscale") set(CPACK_RPM_PACKAGE_VENDOR "SkySQL Ab") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") include(CPack) From 155efe0dc53604a855866e61698274d942028867 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Sat, 13 Sep 2014 14:57:17 +0300 Subject: [PATCH 015/125] Added more status messages to configuration and a switch to control system file installing --- CMakeLists.txt | 12 ++++++------ README | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c259a5c5b..f05c1e2e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,21 +72,21 @@ add_subdirectory(server) add_subdirectory(client) if(BUILD_RABBITMQ) + message(STATUS "Building RabbitMQ components") add_subdirectory(rabbitmq_consumer) endif(BUILD_RABBITMQ) file(GLOB DOCS Documentation/*.pdf) - -if(NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug")) - message(STATUS "Will install system files") - install(FILES server/test/MaxScale_test.cnf RENAME MaxScale.cnf DESTINATION /etc) +if( NOT ( (DEFINED INSTALL_SYSTEM_FILES) AND ( ${INSTALL_SYSTEM_FILES} MATCHES "N" ) ) ) install(FILES maxscale.conf DESTINATION /etc/ld.so.conf.d) install(FILES etc/init.d/maxscale DESTINATION /etc/init.d) -else() - install(FILES server/test/MaxScale_test.cnf RENAME MaxScale.cnf DESTINATION etc) + message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d") + message(STATUS "Installing startup scripts to: /etc/init.d") endif() +message(STATUS "Installing MaxScale to: ${CMAKE_INSTALL_PREFIX}/") +install(FILES server/test/MaxScale_test.cnf RENAME MaxScale.cnf DESTINATION etc) install(FILES ${ERRMSG} DESTINATION mysql) install(FILES ${EMBEDDED_LIB} DESTINATION lib) install(FILES ${DOCS} DESTINATION Documentation) diff --git a/README b/README index 5a0e2eb23..aba2ceb4c 100644 --- a/README +++ b/README @@ -178,6 +178,7 @@ Variables controlling the CMake build process: CMAKE_INSTALL_PREFIX= Install destination prefix, same as DEST CMAKE_BUILD_TYPE=[Debug|Release] Type of the build +INSTALL_SYSTEM_FILES=[Y|N] Install startup scripts and ld configuration files EMBEDDED_LIB= Path to the embedded library, filename included MYSQL_DIR= Path to MySQL headers STATIC_EMBEDDED=[Y|N] Link the static or the dynamic verson of the library From df7590c167ebad5e2c2e586b0ab4a693bf647d7e Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Sat, 13 Sep 2014 15:04:10 +0300 Subject: [PATCH 016/125] Fixed INSTALL_SYSTEM_FILES failing if it was set to some other false value than 'N' --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f05c1e2e8..336727757 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,7 @@ endif(BUILD_RABBITMQ) file(GLOB DOCS Documentation/*.pdf) -if( NOT ( (DEFINED INSTALL_SYSTEM_FILES) AND ( ${INSTALL_SYSTEM_FILES} MATCHES "N" ) ) ) +if( NOT ( (DEFINED INSTALL_SYSTEM_FILES) AND ( NOT ( INSTALL_SYSTEM_FILES ) ) ) ) install(FILES maxscale.conf DESTINATION /etc/ld.so.conf.d) install(FILES etc/init.d/maxscale DESTINATION /etc/init.d) message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d") From 5d26cf6fd592af1fd5b3ad490d59b779fd1fb054 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Sun, 14 Sep 2014 07:30:41 +0300 Subject: [PATCH 017/125] Added optional RabbitMQ component configuration Changed all the configuration variables to cached Fixed some errors in tests --- CMakeLists.txt | 2 +- macros.cmake | 43 ++++++++++----------- rabbitmq_consumer/CMakeLists.txt | 57 ++++++++++++---------------- server/modules/filter/CMakeLists.txt | 2 +- server/test/startmaxscale.sh | 2 + 5 files changed, 48 insertions(+), 58 deletions(-) create mode 100644 server/test/startmaxscale.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 336727757..43caf1cea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ enable_testing() project(MaxScale) set_maxscale_version() -set_testing_variables() +set_variables() configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_SOURCE_DIR}/server/include/version.h) diff --git a/macros.cmake b/macros.cmake index 9dccf34cb..0a422262d 100644 --- a/macros.cmake +++ b/macros.cmake @@ -8,41 +8,38 @@ macro(set_maxscale_version) endmacro() -macro(set_testing_variables) +macro(set_variables) # hostname or IP address of MaxScale's host - if(NOT TEST_HOST) - set(TEST_HOST "127.0.0.1") - endif() + set(TEST_HOST "127.0.0.1" CACHE STRING "hostname or IP address of MaxScale's host") # port of read connection router module - if(NOT TEST_PORT_RW) - set(TEST_PORT_RW "4008") - endif() + set(TEST_PORT_RW "4008" CACHE STRING "port of read connection router module") # port of read/write split router module - if(NOT TEST_PORT_RW) - set(TEST_PORT_RW "4006") - endif() + set(TEST_PORT_RW "4006" CACHE STRING "port of read/write split router module") # port of read/write split router module with hints - if(NOT TEST_PORT_RW_HINT) - set(TEST_PORT_RW_HINT "4006") - endif() + set(TEST_PORT_RW_HINT "4006" CACHE STRING "port of read/write split router module with hints") - # master's server_id - if(NOT TEST_MASTER_ID) - set(TEST_MASTER_ID "3000") - endif() + # master test server server_id + set(TEST_MASTER_ID "3000" CACHE STRING "master test server server_id") # username of MaxScale user - if(NOT TEST_USER) - set(TEST_USER "maxuser") - endif() + set(TEST_USER "maxuser" CACHE STRING "username of MaxScale user") # password of MaxScale user - if(NOT TEST_PASSWORD) - set(TEST_PASSWORD "maxpwd") - endif() + set(TEST_PASSWORD "maxpwd" CACHE STRING "password of MaxScale user") + + # Use static version of libmysqld + set(STATIC_EMBEDDED FALSE 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") endmacro() \ No newline at end of file diff --git a/rabbitmq_consumer/CMakeLists.txt b/rabbitmq_consumer/CMakeLists.txt index 30d16d630..e57f715a7 100644 --- a/rabbitmq_consumer/CMakeLists.txt +++ b/rabbitmq_consumer/CMakeLists.txt @@ -1,44 +1,35 @@ cmake_minimum_required (VERSION 2.6) -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) - -include(InstallRequiredSystemLibraries) - project (consumer) -find_path(MYSQL_INCLUDE_DIRS mysql.h) -find_library(MYSQL_LIBRARIES NAMES mysqlclient) -find_library(RABBITMQ_C_LIBRARIES NAMES rabbitmq) +find_path(RABBITMQ_C_DIRS amqp.h) +find_library(RABBITMQ_C_LIB NAMES rabbitmq) +find_library(MYSQL_CLIENT_LIB NAMES mysqlclient PATHS /usr/lib /usr/lib64 PATH_SUFFIXES mysql mariadb) -include_directories(${MYSQL_INCLUDE_DIRS}) -include_directories(${RABBITMQ_C_INCLUDE_DIRS}) -include_directories(${CMAKE_SOURCE_DIR}/inih) +include_directories(${RABBITMQ_C_DIRS}) -add_subdirectory (inih) -link_directories(${CMAKE_SOURCE_DIR}/inih) +if( ( RABBITMQ_C_LIB AND RABBITMQ_C_DIRS ) AND MYSQL_CLIENT_LIB ) -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) + add_executable (consumer consumer.c ${MYSQL_CLIENT_LIB} ${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 etc) -else(RABBITMQ_C_LIBRARIES AND MYSQL_LIBRARIES AND MYSQL_INCLUDE_DIRS) -message(FATAL_ERROR "Error: Can not find requred libraries: libmysqld, librabbitmq.") +else() + message(FATAL_ERROR "Error: Can not find requred libraries.") +endif() -endif(RABBITMQ_C_LIBRARIES AND MYSQL_LIBRARIES AND MYSQL_INCLUDE_DIRS) +# Packaging of RabbitMQ disabled for now -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) \ No newline at end of file +#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) \ No newline at end of file diff --git a/server/modules/filter/CMakeLists.txt b/server/modules/filter/CMakeLists.txt index 8343f6ca5..1655aec4f 100644 --- a/server/modules/filter/CMakeLists.txt +++ b/server/modules/filter/CMakeLists.txt @@ -2,7 +2,7 @@ if(BUILD_RABBITMQ) add_library(mqfilter SHARED mqfilter.c) set_target_properties(mqfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib) target_link_libraries(mqfilter utils query_classifier log_manager rabbitmq) - install(TARGETS DESTINATION modules) + install(TARGETS mqfilter DESTINATION modules) endif(BUILD_RABBITMQ) add_library(regexfilter SHARED regexfilter.c) diff --git a/server/test/startmaxscale.sh b/server/test/startmaxscale.sh new file mode 100644 index 000000000..c16f2b9bc --- /dev/null +++ b/server/test/startmaxscale.sh @@ -0,0 +1,2 @@ +#!/bin/sh +$1 $2 & From 0f07c9f08cb4b7902e09921a1958d6e2042c32b9 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 15 Sep 2014 09:27:47 +0300 Subject: [PATCH 018/125] Added hint tests Fixed readwritesplit tests looking for test input in the wrong directory Updated the canonical query test expected output --- macros.cmake | 1 + .../test/canonical_tests/expected.sql | 10 ++-- .../readwritesplit/test/CMakeLists.txt | 5 +- .../routing/readwritesplit/test/rwsplit.sh | 53 ++++++++----------- .../test/test_hints/CMakeLists.txt | 3 ++ .../test/test_hints/rwsplit_hints.sh | 26 ++++----- server/test/CMakeLists.txt | 10 ++-- server/test/startmaxscale.sh | 6 ++- 8 files changed, 59 insertions(+), 55 deletions(-) create mode 100644 server/modules/routing/readwritesplit/test/test_hints/CMakeLists.txt mode change 100644 => 100755 server/test/startmaxscale.sh diff --git a/macros.cmake b/macros.cmake index 0a422262d..2311d00c1 100644 --- a/macros.cmake +++ b/macros.cmake @@ -42,4 +42,5 @@ macro(set_variables) # Install init.d scripts and ldconf configuration files set(INSTALL_SYSTEM_FILES TRUE CACHE BOOL "Install init.d scripts and ldconf configuration files") + endmacro() \ No newline at end of file diff --git a/query_classifier/test/canonical_tests/expected.sql b/query_classifier/test/canonical_tests/expected.sql index fabb27dc7..1126f6016 100755 --- a/query_classifier/test/canonical_tests/expected.sql +++ b/query_classifier/test/canonical_tests/expected.sql @@ -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 diff --git a/server/modules/routing/readwritesplit/test/CMakeLists.txt b/server/modules/routing/readwritesplit/test/CMakeLists.txt index cf5806ff1..e114a890f 100644 --- a/server/modules/routing/readwritesplit/test/CMakeLists.txt +++ b/server/modules/routing/readwritesplit/test/CMakeLists.txt @@ -1,2 +1,3 @@ -add_test(NAME ReadWriteSplitTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit.sh ${TEST_HOST} ${TEST_PORT_RW} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD}) -set_tests_properties(ReadWriteSplitTest PROPERTIES DEPENDS WaitForExecutable) \ No newline at end of file +add_test(NAME ReadWriteSplitTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit.sh ${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) \ No newline at end of file diff --git a/server/modules/routing/readwritesplit/test/rwsplit.sh b/server/modules/routing/readwritesplit/test/rwsplit.sh index 8d4d64234..d68d14283 100755 --- a/server/modules/routing/readwritesplit/test/rwsplit.sh +++ b/server/modules/routing/readwritesplit/test/rwsplit.sh @@ -1,10 +1,11 @@ #!/bin/sh -NARGS=5 +NARGS=6 THOST=$1 TPORT=$2 TMASTER_ID=$3 TUSER=$4 TPWD=$5 +DIR=$6 if [ $# != $NARGS ] ; then @@ -20,7 +21,7 @@ fi RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ --silent -TINPUT=$PWD/test_transaction_routing2.sql +TINPUT=$DIR/test_transaction_routing2.sql TRETVAL=0 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -29,7 +30,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_transaction_routing2b.sql +TINPUT=$DIR/test_transaction_routing2b.sql TRETVAL=0 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -38,7 +39,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_transaction_routing3.sql +TINPUT=$DIR/test_transaction_routing3.sql TRETVAL=2 a=`$RUNCMD < $TINPUT` if [ "$a" = "$TMASTER_ID" ]; then @@ -47,7 +48,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_transaction_routing3b.sql +TINPUT=$DIR/test_transaction_routing3b.sql TRETVAL=2 a=`$RUNCMD < $TINPUT` if [ "$a" = "$TMASTER_ID" ]; then @@ -57,7 +58,7 @@ else fi # test implicit transaction, that is, not started explicitly, autocommit=0 -TINPUT=$PWD/test_transaction_routing4.sql +TINPUT=$DIR/test_transaction_routing4.sql TRETVAL=0 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -66,7 +67,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_transaction_routing4b.sql +TINPUT=$DIR/test_transaction_routing4b.sql TRETVAL=0 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -76,7 +77,7 @@ else fi # set a var via SELECT INTO @, get data from master, returning server-id: put master server-id value in TRETVAL -TINPUT=$PWD/select_for_var_set.sql +TINPUT=$DIR/select_for_var_set.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` @@ -86,7 +87,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit1.sql +TINPUT=$DIR/test_implicit_commit1.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` @@ -96,7 +97,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit2.sql +TINPUT=$DIR/test_implicit_commit2.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then @@ -105,7 +106,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit3.sql +TINPUT=$DIR/test_implicit_commit3.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then @@ -114,7 +115,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit4.sql +TINPUT=$DIR/test_implicit_commit4.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -132,7 +133,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit6.sql +TINPUT=$DIR/test_implicit_commit6.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then @@ -141,7 +142,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit7.sql +TINPUT=$DIR/test_implicit_commit7.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then @@ -150,7 +151,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_autocommit_disabled1.sql +TINPUT=$DIR/test_autocommit_disabled1.sql TRETVAL=1 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -159,7 +160,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_autocommit_disabled1b.sql +TINPUT=$DIR/test_autocommit_disabled1b.sql TRETVAL=1 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -170,7 +171,7 @@ fi # Disable autocommit in the first session and then test in new session that # it is again enabled. -TINPUT=$PWD/test_autocommit_disabled2.sql +TINPUT=$DIR/test_autocommit_disabled2.sql TRETVAL=1 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -179,7 +180,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/set_autocommit_disabled.sql +TINPUT=$DIR/set_autocommit_disabled.sql `$RUNCMD < $TINPUT` TINPUT=test_after_autocommit_disabled.sql TRETVAL=$TMASTER_ID @@ -191,7 +192,7 @@ else fi -TINPUT=$PWD/test_sescmd.sql +TINPUT=$DIR/test_sescmd.sql TRETVAL=2 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -230,7 +231,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_temporary_table.sql +TINPUT=$DIR/test_temporary_table.sql a=`$RUNCMD < $TINPUT` TRETVAL=1 if [ "$a" != "$TRETVAL" ]; then @@ -244,13 +245,9 @@ echo "Session variables: Stress Test 1" echo "-----------------------------------" RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ -q\ -r -TINPUT=$PWD/test_sescmd2.sql +TINPUT=$DIR/test_sescmd2.sql for ((i = 0;i<1000;i++)) do - if [[ $(( i % 50 )) -eq 0 ]] - then - printf "." - fi a=`$RUNCMD < $TINPUT 2>&1` if [[ "`echo "$a"|grep -i 'error'`" != "" ]] then @@ -270,13 +267,9 @@ echo "Session variables: Stress Test 2" echo "-----------------------------------" echo "" err="" -TINPUT=$PWD/test_sescmd3.sql +TINPUT=$DIR/test_sescmd3.sql for ((j = 0;j<1000;j++)) do - if [[ $(( j % 50 )) -eq 0 ]] - then - printf "." - fi b=`$RUNCMD < $TINPUT 2>&1` if [[ "`echo "$b"|grep -i 'null\|error'`" != "" ]] then diff --git a/server/modules/routing/readwritesplit/test/test_hints/CMakeLists.txt b/server/modules/routing/readwritesplit/test/test_hints/CMakeLists.txt new file mode 100644 index 000000000..410a9fad6 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_hints/CMakeLists.txt @@ -0,0 +1,3 @@ +add_test(NAME SimpleHintTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit_hints.sh ${TEST_HOST} ${TEST_PORT_RW_HINT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} ${CMAKE_CURRENT_SOURCE_DIR}/simple_tests ${CMAKE_CURRENT_SOURCE_DIR}) +add_test(NAME ComplexHintTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit_hints.sh ${TEST_HOST} ${TEST_PORT_RW_HINT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} ${CMAKE_CURRENT_SOURCE_DIR}/complex_tests ${CMAKE_CURRENT_SOURCE_DIR}) +add_test(NAME StackHintTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit_hints.sh ${TEST_HOST} ${TEST_PORT_RW_HINT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} ${CMAKE_CURRENT_SOURCE_DIR}/stack_tests ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/server/modules/routing/readwritesplit/test/test_hints/rwsplit_hints.sh b/server/modules/routing/readwritesplit/test/test_hints/rwsplit_hints.sh index cdbfb335b..8db83cafa 100755 --- a/server/modules/routing/readwritesplit/test/test_hints/rwsplit_hints.sh +++ b/server/modules/routing/readwritesplit/test/test_hints/rwsplit_hints.sh @@ -1,12 +1,12 @@ #!/bin/bash NARGS=7 -TLOG=$1 -THOST=$2 -TPORT=$3 -TMASTER_ID=$4 -TUSER=$5 -TPWD=$6 -TESTINPUT=$7 +THOST=$1 +TPORT=$2 +TMASTER_ID=$3 +TUSER=$4 +TPWD=$5 +TESTINPUT=$6 +DIR=$7 if [ $# != $NARGS ] ; then @@ -14,7 +14,7 @@ echo"" echo "Wrong number of arguments, gave "$#" but "$NARGS" is required" echo "" echo "Usage :" -echo " rwsplit_hints.sh " +echo " rwsplit_hints.sh