mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Better tests (#1785)
* Make separate libs Common/ZooKeeper and Common/ConfigProcessor renamed: dbms/src/Common/StringUtils.h -> dbms/src/Common/StringUtils/StringUtils.h * Fix space * Fix data in system.build_options * merge * merge * Travis optimize * optimize * Fix clickhouse-test --no-long * no long * Split too long test * Better tests * missing file * Fix includes * Added draft [#CLICKHOUSE-2]. * fix * fix * fix * Fix test 281 under asan
This commit is contained in:
parent
0b8d2a2024
commit
76cf0ba5d0
3
contrib/CMakeLists.txt
vendored
3
contrib/CMakeLists.txt
vendored
@ -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 ()
|
||||
|
@ -19,7 +19,7 @@ using namespace DB;
|
||||
|
||||
TEST(Common, RWLockFIFO_1)
|
||||
{
|
||||
constexpr int cycles = 10000;
|
||||
constexpr int cycles = 1000;
|
||||
const std::vector<size_t> pool_sizes{1, 2, 4, 8};
|
||||
|
||||
static std::atomic<int> 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<size_t> pool_sizes{1, 2, 4, 8};
|
||||
|
||||
static auto fifo_lock = RWLockFIFO::create();
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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 ()
|
||||
|
4
dbms/tests/CTestCustom.cmake
Normal file
4
dbms/tests/CTestCustom.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
set(CTEST_CUSTOM_TESTS_IGNORE
|
||||
example
|
||||
example64
|
||||
)
|
@ -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', '<zookeeper', '/etc/clickhouse-server/config-preprocessed.xml'])
|
||||
args.zookeeper = True
|
||||
except CalledProcessError:
|
||||
args.zookeeper = False
|
||||
|
||||
if args.shard is None:
|
||||
try:
|
||||
check_call(['grep', '-qE', '"127.0.0.2|<listen_host>::</listen_host>"', '/etc/clickhouse-server/config-preprocessed.xml'])
|
||||
args.shard = True
|
||||
except CalledProcessError:
|
||||
# TODO: false here after setting <listen_host>::1</listen_host>
|
||||
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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
3
debian/pbuilder-hooks/B90test-server
vendored
3
debian/pbuilder-hooks/B90test-server
vendored
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 ()
|
||||
|
Loading…
Reference in New Issue
Block a user