Skip to content

Commit

Permalink
Combine regression test suite and main CMake projects
Browse files Browse the repository at this point in the history
Combining the projects makes it easier to use common components. This
fixes the build failure of maxutils due to missing jansson definitions.
  • Loading branch information
markus456 committed Aug 17, 2018
1 parent c7a6d75 commit f09afa2
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 107 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_executable(maxadmin maxadmin.c)
add_dependencies(maxadmin maxutils)
add_dependencies(maxadmin maxbase)

find_library(HIST edit)
if(HIST)
Expand Down
9 changes: 0 additions & 9 deletions cmake/BuildMaxUtils.cmake

This file was deleted.

28 changes: 9 additions & 19 deletions maxscale-system-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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/)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion maxscale-system-test/big_transaction.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef BIG_TRANSACTION_H
#define BIG_TRANSACTION_H

#include <mariadb/mysql.h>
#include <mysql.h>
#include <stdio.h>
#include <stdlib.h>
#include "sql_t1.h"
Expand Down
2 changes: 1 addition & 1 deletion maxscale-system-test/mariadb_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @endverbatim
*/

#include <mariadb/mysql.h>
#include <mysql.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
8 changes: 5 additions & 3 deletions maxscale-system-test/mdbci/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions maxscale-system-test/mdbci/run_test_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
43 changes: 0 additions & 43 deletions maxscale-system-test/utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 "")
22 changes: 0 additions & 22 deletions maxutils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 <string.h>\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)
4 changes: 2 additions & 2 deletions server/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)

Expand Down

0 comments on commit f09afa2

Please sign in to comment.