diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 3371066edda..bede3c62c6b 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -56,10 +56,11 @@ if (USE_INTERNAL_ZLIB_LIBRARY) endif () set_target_properties(example PROPERTIES EXCLUDE_FROM_ALL 1) - set_target_properties(minigzip PROPERTIES EXCLUDE_FROM_ALL 1) if (TARGET example64) set_target_properties(example64 PROPERTIES EXCLUDE_FROM_ALL 1) endif () + + set_target_properties(minigzip PROPERTIES EXCLUDE_FROM_ALL 1) if (TARGET minigzip64) set_target_properties(minigzip64 PROPERTIES EXCLUDE_FROM_ALL 1) endif () diff --git a/dbms/src/Common/tests/gtest_rw_lock_fifo.cpp.cpp b/dbms/src/Common/tests/gtest_rw_lock_fifo.cpp.cpp index 3334dccabc6..9d1eda9178c 100644 --- a/dbms/src/Common/tests/gtest_rw_lock_fifo.cpp.cpp +++ b/dbms/src/Common/tests/gtest_rw_lock_fifo.cpp.cpp @@ -19,7 +19,7 @@ using namespace DB; TEST(Common, RWLockFIFO_1) { - constexpr int cycles = 10000; + constexpr int cycles = 1000; const std::vector pool_sizes{1, 2, 4, 8}; static std::atomic readers{0}; @@ -128,7 +128,7 @@ TEST(Common, RWLockFIFO_Recursive) TEST(Common, RWLockFIFO_PerfTest_Readers) { - constexpr int cycles = 1000000; // 1 mln + constexpr int cycles = 100000; // 100k const std::vector pool_sizes{1, 2, 4, 8}; static auto fifo_lock = RWLockFIFO::create(); diff --git a/dbms/src/Interpreters/tests/in_join_subqueries_preprocessor.cpp b/dbms/src/Interpreters/tests/in_join_subqueries_preprocessor.cpp index 4b2a174071c..3a2f6453dbb 100644 --- a/dbms/src/Interpreters/tests/in_join_subqueries_preprocessor.cpp +++ b/dbms/src/Interpreters/tests/in_join_subqueries_preprocessor.cpp @@ -1163,11 +1163,12 @@ bool run() return performTests(entries); } +static DB::Context context = DB::Context::createGlobal(); + TestResult check(const TestEntry & entry) { try { - DB::Context context = DB::Context::createGlobal(); auto storage_distributed_visits = StorageDistributedFake::create("remote_db", "remote_visits", entry.shard_count); auto storage_distributed_hits = StorageDistributedFake::create("distant_db", "distant_hits", entry.shard_count); @@ -1218,10 +1219,12 @@ TestResult check(const TestEntry & entry) bool res = equals(ast_input, ast_expected); std::string output = DB::queryToString(ast_input); + context.detachDatabase("test"); return TestResult(res, output); } catch (DB::Exception & e) { + context.detachDatabase("test"); return TestResult(false, e.displayText()); } } diff --git a/dbms/tests/CMakeLists.txt b/dbms/tests/CMakeLists.txt index 9aa36a26687..d079f8287bd 100644 --- a/dbms/tests/CMakeLists.txt +++ b/dbms/tests/CMakeLists.txt @@ -18,3 +18,10 @@ install ( ) add_subdirectory (external_dictionaries) + +if (ENABLE_TESTS) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}) + + # maybe add --no-long ? + add_test(NAME with_server COMMAND bash -c "env BUILD_DIR=${ClickHouse_BINARY_DIR} TEST_OPT='--skip 00281' ${CMAKE_CURRENT_SOURCE_DIR}/server_wrapper.sh") +endif () diff --git a/dbms/tests/CTestCustom.cmake b/dbms/tests/CTestCustom.cmake new file mode 100644 index 00000000000..13359d886fe --- /dev/null +++ b/dbms/tests/CTestCustom.cmake @@ -0,0 +1,4 @@ +set(CTEST_CUSTOM_TESTS_IGNORE + example + example64 +) diff --git a/dbms/tests/clickhouse-test b/dbms/tests/clickhouse-test index 75eec3ce913..4e9886f8b70 100755 --- a/dbms/tests/clickhouse-test +++ b/dbms/tests/clickhouse-test @@ -19,6 +19,7 @@ from time import sleep from errno import ESRCH from termcolor import colored from random import random +import commands OP_SQUARE_BRACKET = colored("[", attrs=['bold']) @@ -69,34 +70,33 @@ def main(args): report_root.append(report_suite) report_file.write(et.tostring(report_root, encoding = "UTF-8", xml_declaration=True, pretty_print=True)) - - if args.zookeeper is None: - try: - check_call(['grep', '-q', '::"', '/etc/clickhouse-server/config-preprocessed.xml']) - args.shard = True - except CalledProcessError: - # TODO: false here after setting ::1 - args.shard = True - base_dir = os.path.abspath(args.queries) tmp_dir = os.path.abspath(args.tmp) - passed_total = 0 - skipped_total = 0 - failures_total = 0 - # Keep same default values as in queries/0_stateless/00000_sh_lib.sh os.environ.setdefault("CLICKHOUSE_BINARY", args.binary) os.environ.setdefault("CLICKHOUSE_CLIENT", args.client) os.environ.setdefault("CLICKHOUSE_TMP", tmp_dir) + # TODO ! use clickhouse-extract-from-config here: + if args.zookeeper is None: + code, out = commands.getstatusoutput(args.binary + "-extract-from-config --try --config " + args.configserver + ' --key zookeeper | grep . | wc -l') + if int(out) > 0: + args.zookeeper = True + else: + args.zookeeper = False + + if args.shard is None: + code, out = commands.getstatusoutput(args.binary + "-extract-from-config --try --config " + args.configserver + ' --key listen_host | grep -E "127.0.0.2|::"') + if out: + args.shard = True + else: + args.shard = False + + passed_total = 0 + skipped_total = 0 + failures_total = 0 + for suite in sorted(os.listdir(base_dir)): if SERVER_DIED: break @@ -319,7 +319,8 @@ if __name__ == '__main__': parser.add_argument('--tmp', help = 'Path to tmp dir') parser.add_argument('-b', '--binary', default = 'clickhouse', help = 'Main clickhouse binary') parser.add_argument('-c', '--client', help = 'Client program') - parser.add_argument('--clientconfig', help = 'Client config (if you use not default ports)') + parser.add_argument('--configclient', help = 'Client config (if you use not default ports)') + parser.add_argument('--configserver', default= '/etc/clickhouse-server/config.xml', help = 'Preprocessed server config') parser.add_argument('-o', '--output', help = 'Output xUnit compliant test report directory') parser.add_argument('-t', '--timeout', type = int, default = 600, help = 'Timeout for each test case in seconds') parser.add_argument('test', nargs = '?', help = 'Optional test case name regex') @@ -350,6 +351,6 @@ if __name__ == '__main__': if args.client is None: args.client = args.binary + '-client' - if args.clientconfig: - args.client += ' -c' + args.clientconfig + if args.configclient: + args.client += ' -c' + args.configclient main(args) diff --git a/dbms/tests/queries/shell_config.sh b/dbms/tests/queries/shell_config.sh index 31ec03e2579..780e19ca598 100644 --- a/dbms/tests/queries/shell_config.sh +++ b/dbms/tests/queries/shell_config.sh @@ -5,6 +5,7 @@ export CLICKHOUSE_LOCAL=${CLICKHOUSE_LOCAL:="${CLICKHOUSE_BINARY}-local"} export CLICKHOUSE_CONFIG=${CLICKHOUSE_CONFIG:="/etc/clickhouse-server/config.xml"} export CLICKHOUSE_EXTRACT_CONFIG=${CLICKHOUSE_EXTRACT_CONFIG:="$CLICKHOUSE_BINARY-extract-from-config -c $CLICKHOUSE_CONFIG"} +export CLICKHOUSE_CONFIG_GREP=${CLICKHOUSE_CONFIG_GREP:="/etc/clickhouse-server/config-preprocessed.xml"} export CLICKHOUSE_HOST=${CLICKHOUSE_HOST:="localhost"} export CLICKHOUSE_PORT_TCP=${CLICKHOUSE_PORT_TCP:=`${CLICKHOUSE_EXTRACT_CONFIG} --try --key=tcp_port 2>/dev/null`} 2>/dev/null diff --git a/dbms/tests/server_wrapper.sh b/dbms/tests/server_wrapper.sh index 6213f631bca..ba1597eff50 100755 --- a/dbms/tests/server_wrapper.sh +++ b/dbms/tests/server_wrapper.sh @@ -1,20 +1,21 @@ -#!/bin/bash +#!/usr/bin/env bash set -o errexit set -o pipefail -CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -ROOTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../.. && pwd) -DATADIR=${DATADIR:=/tmp/clickhouse} -LOGDIR=${LOGDIR:=$DATADIR/log} +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../.. && pwd) +DATA_DIR=${DATA_DIR:=/tmp/clickhouse} +LOG_DIR=${LOG_DIR:=$DATA_DIR/log} +BUILD_DIR=${BUILD_DIR:="$ROOT_DIR/build${BUILD_TYPE}"} -rm -rf $DATADIR +rm -rf $DATA_DIR -mkdir -p $LOGDIR +mkdir -p $LOG_DIR # Start a local clickhouse server which will be used to run tests -#PATH=$PATH:$ROOTDIR/build${BUILD_TYPE}/dbms/src/Server \ - $ROOTDIR/build${BUILD_TYPE}/dbms/src/Server/clickhouse-server --config-file=$CURDIR/server-test.xml > $LOGDIR/stdout 2>&1 & +#PATH=$PATH:$BUILD_DIR/dbms/src/Server \ + $BUILD_DIR/dbms/src/Server/clickhouse-server --config-file=$CUR_DIR/server-test.xml > $LOG_DIR/stdout 2>&1 & CH_PID=$! sleep 3 @@ -22,18 +23,18 @@ sleep 3 function finish { kill $CH_PID || true wait - tail -n 50 $LOGDIR/stdout - rm -rf $DATADIR + tail -n 50 $LOG_DIR/stdout + rm -rf $DATA_DIR } trap finish EXIT # Do tests -export CLICKHOUSE_CONFIG=${CLICKHOUSE_CONFIG:=$CURDIR/server-test.xml} -#cd $CURDIR +export CLICKHOUSE_CONFIG=${CLICKHOUSE_CONFIG:=$CUR_DIR/server-test.xml} +#cd $CUR_DIR if [ -n "$*" ]; then $* else - $ROOTDIR/build${BUILD_TYPE}/dbms/src/Server/clickhouse-client --config $CURDIR/client-test.xml -q 'SELECT * from system.build_options;' - PATH=$PATH:$ROOTDIR/build${BUILD_TYPE}/dbms/src/Server \ - $CURDIR/clickhouse-test --binary $ROOTDIR/build${BUILD_TYPE}/dbms/src/Server/clickhouse --clientconfig $CURDIR/client-test.xml --tmp $DATADIR/tmp --queries $CURDIR/queries $TEST_OPT + $BUILD_DIR/dbms/src/Server/clickhouse-client --config $CUR_DIR/client-test.xml -q 'SELECT * from system.build_options;' + PATH=$PATH:$BUILD_DIR/dbms/src/Server \ + $CUR_DIR/clickhouse-test --binary $BUILD_DIR/dbms/src/Server/clickhouse --configclient $CUR_DIR/client-test.xml --configserver $CUR_DIR/server-test.xml --tmp $DATA_DIR/tmp --queries $CUR_DIR/queries $TEST_OPT fi diff --git a/debian/pbuilder-hooks/B90test-server b/debian/pbuilder-hooks/B90test-server index a2c2da63cc3..9afd82950c9 100755 --- a/debian/pbuilder-hooks/B90test-server +++ b/debian/pbuilder-hooks/B90test-server @@ -29,8 +29,7 @@ clickhouse-client -q "SELECT toDateTime(1);" TEST_TRUE=${TEST_TRUE:=true} -# --no-shard because default server listen only :: and 127.0.0.1 -[ -n "$TEST_RUN" ] && clickhouse-test --no-shard --queries /usr/share/clickhouse-test/queries --tmp /tmp/clickhouse-test/ $TEST_OPT || $TEST_TRUE +[ -n "$TEST_RUN" ] && clickhouse-test --queries /usr/share/clickhouse-test/queries --tmp /tmp/clickhouse-test/ $TEST_OPT || $TEST_TRUE service clickhouse-server stop diff --git a/libs/libcommon/CMakeLists.txt b/libs/libcommon/CMakeLists.txt index 7c254a73658..6f4be1c7b5c 100644 --- a/libs/libcommon/CMakeLists.txt +++ b/libs/libcommon/CMakeLists.txt @@ -98,6 +98,10 @@ target_include_directories (common BEFORE PRIVATE ${CCTZ_INCLUDE_DIR}) target_include_directories (common BEFORE PUBLIC ${CITYHASH_INCLUDE_DIR}) target_include_directories (common PUBLIC ${COMMON_INCLUDE_DIR}) +if (NOT USE_INTERNAL_BOOST_LIBRARY) + target_include_directories (common BEFORE PUBLIC ${Boost_INCLUDE_DIRS}) +endif () + target_link_libraries ( common pocoext diff --git a/utils/compressor/CMakeLists.txt b/utils/compressor/CMakeLists.txt index aff97c839db..ae4333337db 100644 --- a/utils/compressor/CMakeLists.txt +++ b/utils/compressor/CMakeLists.txt @@ -8,3 +8,6 @@ set_target_properties(util-clickhouse-compressor PROPERTIES OUTPUT_NAME "clickho add_executable (zstd_test zstd_test.cpp) target_link_libraries (zstd_test ${ZSTD_LIBRARY} Threads::Threads) +if (NOT USE_INTERNAL_ZSTD_LIBRARY) + target_include_directories (zstd_test BEFORE PRIVATE ${ZSTD_INCLUDE_DIR}) +endif ()