From f09afa29671548051b10bbe233fab230ca98fa25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 17 Aug 2018 13:44:55 +0300 Subject: [PATCH] Combine regression test suite and main CMake projects Combining the projects makes it easier to use common components. This fixes the build failure of maxutils due to missing jansson definitions. --- CMakeLists.txt | 10 +++-- client/CMakeLists.txt | 2 +- cmake/BuildMaxUtils.cmake | 9 ---- maxscale-system-test/CMakeLists.txt | 28 ++++-------- maxscale-system-test/big_transaction.h | 2 +- maxscale-system-test/mariadb_func.h | 2 +- maxscale-system-test/mdbci/run_test.sh | 8 ++-- .../mdbci/run_test_snapshot.sh | 6 ++- maxscale-system-test/utilities.cmake | 43 ------------------- maxutils/CMakeLists.txt | 22 ---------- server/core/CMakeLists.txt | 4 +- 11 files changed, 29 insertions(+), 107 deletions(-) delete mode 100644 cmake/BuildMaxUtils.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e293a9e881..127872f5d58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,10 +58,6 @@ include_directories(BEFORE ${MARIADB_CONNECTOR_INCLUDE_DIR}) include(cmake/BuildJansson.cmake) include(cmake/BuildMicroHttpd.cmake) -# Build the MaxUtils libraries -include(cmake/BuildMaxUtils.cmake) -include_directories(${MAXUTILS_INCLUDE_DIR}) - include_directories(${JANSSON_INCLUDE_DIR}) if(NOT OPENSSL_FOUND) @@ -179,12 +175,14 @@ include_directories(server/inih) include_directories(server/modules/include) include_directories(${CMAKE_BINARY_DIR}/include) include_directories(${CURL_INCLUDE_DIRS}) +include_directories(maxutils/maxbase/include) if (BUILD_CDC) include_directories(avro) add_subdirectory(avro) endif() +add_subdirectory(maxutils) add_subdirectory(plugins) add_subdirectory(query_classifier) add_subdirectory(server) @@ -198,6 +196,10 @@ if(BUILD_TESTS) add_subdirectory(examples) endif() +if(BUILD_SYSTEM_TESTS) + add_subdirectory(maxscale-system-test) +endif() + # Generate text versions of some documents execute_process(COMMAND perl ${CMAKE_SOURCE_DIR}/Documentation/format.pl ${CMAKE_SOURCE_DIR}/Documentation/Changelog.md diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 5dc9cfb2317..70393ceca6e 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(maxadmin maxadmin.c) -add_dependencies(maxadmin maxutils) +add_dependencies(maxadmin maxbase) find_library(HIST edit) if(HIST) diff --git a/cmake/BuildMaxUtils.cmake b/cmake/BuildMaxUtils.cmake deleted file mode 100644 index a6f13a45266..00000000000 --- a/cmake/BuildMaxUtils.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# Build the maxutils library - -ExternalProject_Add(maxutils - SOURCE_DIR ${CMAKE_SOURCE_DIR}/maxutils - BINARY_DIR ${CMAKE_BINARY_DIR}/maxutils - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/maxutils/install) - -set(MAXUTILS_INCLUDE_DIR ${CMAKE_BINARY_DIR}/maxutils/install/include CACHE INTERNAL "") -set(MAXUTILS_LIBRARIES ${CMAKE_BINARY_DIR}/maxutils/install/lib/libmaxbase.a CACHE INTERNAL "") diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 74364993042..87d39d20bfb 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -11,27 +11,19 @@ # EXTERN_BACKEND # BREAKS_REPL # BREAKS_GALERA - -project(maxscale_system_test) -cmake_minimum_required(VERSION 2.8) set(CTEST_BUILD_NAME "${BUILDNAME}") -set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of -build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug -Release RelWithDebInfo MinSizeRel.") - set(CMAKE_CXX_FLAGS "-std=c++11 -ggdb -Wall -Wextra -Werror -Wno-format-overflow -Wno-unused-function -Wno-unused-parameter -Werror=format-security") set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function") set(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function") -enable_testing() - # utilities.cmake contains all helper functions and extra tools include(utilities.cmake) -include_directories(${CMAKE_SOURCE_DIR}) -include_directories(${MAXUTILS_INCLUDE_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_SOURCE_DIR}/connectors/cdc-connector) # The core library include_directories(${CMAKE_BINARY_DIR}) @@ -41,10 +33,10 @@ add_library(testcore SHARED testconnections.cpp nodes.cpp mariadb_nodes.cpp maxs different_size.cpp fw_copy_rules maxinfo_func.cpp config_operations.cpp rds_vpc.cpp execute_cmd.cpp blob_test.cpp keepalived_func.cpp tcp_connection.cpp base/stopwatch.cpp # Include the CDC connector in the core library - ${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/cdc_connector.cpp) -target_link_libraries(testcore ${MYSQL_CLIENT} ${JANSSON_LIBRARIES} ${MAXUTILS_LIBRARIES} z m pthread ssl dl rt crypto crypt) + ${CMAKE_SOURCE_DIR}/connectors/cdc-connector/cdc_connector.cpp) +target_link_libraries(testcore ${MARIADB_CONNECTOR_LIBRARIES} ${JANSSON_LIBRARIES} z m pthread ssl dl rt crypto crypt maxbase) install(TARGETS testcore DESTINATION system-test) -add_dependencies(testcore connector-c jansson maxutils) +add_dependencies(testcore connector-c jansson maxbase) # Include the CDC connector headers include_directories(${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/) @@ -217,7 +209,7 @@ add_test_executable(bug730.cpp bug730 bug730 LABELS regexfilter REPL_BACKEND) add_test_executable(bulk_insert.cpp bulk_insert bulk_insert LABELS MySQLProtocol REPL_BACKEND 10.2) # Tests for the CCRFilter module -add_test_executable(ccrfilter.cpp ccrfilter ccrfilter LABELS ccrfilter LIGHT REPL_BACKEND) +add_test_executable(ccrfilter.cpp ccrfilter_test ccrfilter LABELS ccrfilter LIGHT REPL_BACKEND) # Tries to reconfigure replication setup to use another node as a Master add_test_executable(change_master_during_session.cpp change_master_during_session replication LABELS readwritesplit mysqlmon REPL_BACKEND) @@ -743,7 +735,7 @@ add_test_executable(mxs1896_load_data_infile.cpp mxs1896_load_data_infile replic add_test_executable(mxs1899_generated_cnf.cpp mxs1899_generated_cnf replication LABELS REPL_BACKEND) # 'namedserverfilter' test -add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND) +add_test_executable(namedserverfilter.cpp namedserverfilter_test namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND) # Authentication error testing add_test_executable(no_password.cpp no_password replication LABELS MySQLAuth LIGHT REPL_BACKEND) @@ -1059,6 +1051,4 @@ add_test_executable(mxs1985_kill_hang.cpp mxs1985_kill_hang replication LABELS R add_test_executable(mxs1113_schemarouter_ps.cpp mxs1113_schemarouter_ps mxs1113_schemarouter_ps LABELS schemarouter BREAKS_REPL) -configure_file(templates.h.in templates.h @ONLY) - -include(CTest) +configure_file(templates.h.in ${CMAKE_CURRENT_BINARY_DIR}/templates.h @ONLY) diff --git a/maxscale-system-test/big_transaction.h b/maxscale-system-test/big_transaction.h index d5be98e0155..d5f4fe02f12 100644 --- a/maxscale-system-test/big_transaction.h +++ b/maxscale-system-test/big_transaction.h @@ -1,7 +1,7 @@ #ifndef BIG_TRANSACTION_H #define BIG_TRANSACTION_H -#include +#include #include #include #include "sql_t1.h" diff --git a/maxscale-system-test/mariadb_func.h b/maxscale-system-test/mariadb_func.h index 795e8f9501e..134aa6d4816 100644 --- a/maxscale-system-test/mariadb_func.h +++ b/maxscale-system-test/mariadb_func.h @@ -14,7 +14,7 @@ * @endverbatim */ -#include +#include #include #include #include diff --git a/maxscale-system-test/mdbci/run_test.sh b/maxscale-system-test/mdbci/run_test.sh index db081eb8b17..63fbc1f5312 100755 --- a/maxscale-system-test/mdbci/run_test.sh +++ b/maxscale-system-test/mdbci/run_test.sh @@ -64,9 +64,11 @@ res=$? ulimit -c unlimited if [ $res == 0 ] ; then . ${script_dir}/set_env.sh $name - cd ${script_dir}/.. + cd ${script_dir}/../../ + mkdir build && cd build - cmake .. -DBUILDNAME=$name -DCMAKE_BUILD_TYPE=Debug + cmake ../../ -DWITH_SYSTEM_TESTS -DBUILDNAME=$name -DCMAKE_BUILD_TYPE=Debug + cd maxscale-system-test make if [ ! -z "${named_test}" ] ; then @@ -82,7 +84,7 @@ if [ $res == 0 ] ; then exit 1 fi ${mdbci_dir}/mdbci snapshot take --path-to-nodes $name --snapshot-name clean - ctest -VV -D Nightly ${test_set} + ctest -VV ${test_set} fi cp core.* ${logs_publish_dir} ${script_dir}/copy_logs.sh diff --git a/maxscale-system-test/mdbci/run_test_snapshot.sh b/maxscale-system-test/mdbci/run_test_snapshot.sh index a3e6c643d05..5f6cd9cf382 100755 --- a/maxscale-system-test/mdbci/run_test_snapshot.sh +++ b/maxscale-system-test/mdbci/run_test_snapshot.sh @@ -69,15 +69,17 @@ checkExitStatus $? "Error installing Maxscale" $snapshot_lock_file cd ${script_dir}/.. rm -rf build + mkdir build && cd build -cmake .. -DBUILDNAME=$JOB_NAME-$BUILD_NUMBER-$target +cmake ../../ -DBUILDNAME=$JOB_NAME-$BUILD_NUMBER-$target -DBUILD_SYSTEM_TESTS=Y +cd maxscale-system-test make ./check_backend --restart-galera checkExitStatus $? "Failed to check backends" $snapshot_lock_file ulimit -c unlimited -ctest $test_set -VV -D Nightly +ctest $test_set -VV cp core.* ${logs_publish_dir} ${script_dir}/copy_logs.sh diff --git a/maxscale-system-test/utilities.cmake b/maxscale-system-test/utilities.cmake index a79a8e18c42..6ec3f058970 100644 --- a/maxscale-system-test/utilities.cmake +++ b/maxscale-system-test/utilities.cmake @@ -105,20 +105,6 @@ add_test_executable_notest(binlog_big_transaction.cpp binlog_big_transaction set add_test_executable_notest(avro_long.cpp avro_long avro) add_test_executable_notest(sysbench_example.cpp sysbench_example replication) -# Build the MariaDB Connector/C 3.0 - -set(CONNECTOR_C_VERSION "v3.0.2" CACHE STRING "The Connector-C version to use") - -include(ExternalProject) -ExternalProject_Add(connector-c - GIT_REPOSITORY "https://github.com/MariaDB/mariadb-connector-c.git" - GIT_TAG ${CONNECTOR_C_VERSION} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} - UPDATE_COMMAND "") - -include_directories(${CMAKE_BINARY_DIR}/include) -set(MYSQL_CLIENT ${CMAKE_BINARY_DIR}/lib/mariadb/libmariadbclient.a CACHE INTERNAL "") - # # Check that all required components are present. To build even without them, # add e.g. -DHAVE_PHP=Y to the CMake invocation @@ -133,32 +119,3 @@ find_program(HAVE_PHP php) if (NOT HAVE_PHP) message(FATAL_ERROR "Could not find php.") endif() - -# Build the Jansson library from source -set(JANSSON_REPO "https://github.com/akheron/jansson.git" CACHE STRING "Jansson Git repository") - -# Release 2.9 of Jansson -set(JANSSON_TAG "v2.9" CACHE STRING "Jansson Git tag") - -ExternalProject_Add(jansson - GIT_REPOSITORY ${JANSSON_REPO} - GIT_TAG ${JANSSON_TAG} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/jansson/install -DCMAKE_C_FLAGS=-fPIC -DJANSSON_BUILD_DOCS=OFF - BINARY_DIR ${CMAKE_BINARY_DIR}/jansson - INSTALL_DIR ${CMAKE_BINARY_DIR}/jansson/install - UPDATE_COMMAND "") - -set(JANSSON_FOUND TRUE CACHE INTERNAL "") -set(JANSSON_STATIC_FOUND TRUE CACHE INTERNAL "") -set(JANSSON_INCLUDE_DIR ${CMAKE_BINARY_DIR}/jansson/install/include CACHE INTERNAL "") -set(JANSSON_STATIC_LIBRARIES ${CMAKE_BINARY_DIR}/jansson/install/lib/libjansson.a CACHE INTERNAL "") -set(JANSSON_LIBRARIES ${JANSSON_STATIC_LIBRARIES} CACHE INTERNAL "") - -# Build the maxutils library -ExternalProject_Add(maxutils - SOURCE_DIR ${CMAKE_SOURCE_DIR}/../maxutils/ - BINARY_DIR ${CMAKE_BINARY_DIR}/maxutils - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/maxutils/install) - -set(MAXUTILS_INCLUDE_DIR ${CMAKE_BINARY_DIR}/maxutils/install/include CACHE INTERNAL "") -set(MAXUTILS_LIBRARIES ${CMAKE_BINARY_DIR}/maxutils/install/lib/libmaxbase.a CACHE INTERNAL "") diff --git a/maxutils/CMakeLists.txt b/maxutils/CMakeLists.txt index aeb148e9315..911b44033f3 100644 --- a/maxutils/CMakeLists.txt +++ b/maxutils/CMakeLists.txt @@ -1,23 +1 @@ -enable_testing() - -project(maxutils) -cmake_minimum_required(VERSION 2.8) -set(CMAKE_CXX_FLAGS "-fPIC -std=c++11 -ggdb -Wall -Werror -Wno-unused-function") - -# Check for GLIBC. The XSI version of strerror_r return an int and the GNU version a -# char*. Depending on this check, we make assumptions about the system. -include(CheckCXXSourceCompiles) -check_cxx_source_compiles(" - #define _GNU_SOURCE 1 - #include \n - int main(){\n - char errbuf[200];\n - return strerror_r(13, errbuf, sizeof(errbuf)) == errbuf;\n - }\n" - HAVE_GLIBC) - -if(HAVE_GLIBC) - add_definitions(-DHAVE_GLIBC=1) -endif() - add_subdirectory(maxbase) diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 97cbbc27ce6..8f175ba89fc 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -61,8 +61,8 @@ elseif(WITH_TCMALLOC) endif() target_link_libraries(maxscale-common + maxbase ${MARIADB_CONNECTOR_LIBRARIES} - ${MAXUTILS_LIBRARIES} ${LZMA_LINK_FLAGS} ${PCRE2_LIBRARIES} ${JANSSON_LIBRARIES} @@ -88,7 +88,7 @@ if (HAVE_LIBDL) target_link_libraries(maxscale-common dl) endif() -add_dependencies(maxscale-common pcre2 connector-c libmicrohttpd jansson maxutils) +add_dependencies(maxscale-common pcre2 connector-c libmicrohttpd jansson maxbase) set_target_properties(maxscale-common PROPERTIES VERSION "1.0.0") install_module(maxscale-common core)