2020-07-08 13:06:35 +00:00
|
|
|
#!/bin/bash
|
2020-08-18 10:24:37 +00:00
|
|
|
set -xeu
|
|
|
|
set -o pipefail
|
|
|
|
trap "exit" INT TERM
|
|
|
|
trap 'kill $(jobs -pr) ||:' EXIT
|
|
|
|
|
|
|
|
# This script is separated into two stages, cloning and everything else, so
|
2020-09-07 10:19:01 +00:00
|
|
|
# that we can run the "everything else" stage from the cloned source.
|
2020-08-18 10:24:37 +00:00
|
|
|
stage=${stage:-}
|
|
|
|
|
2021-04-01 18:05:09 +00:00
|
|
|
# Compiler version, normally set by Dockerfile
|
2023-08-24 18:03:22 +00:00
|
|
|
export LLVM_VERSION=${LLVM_VERSION:-17}
|
2021-04-01 18:05:09 +00:00
|
|
|
|
2020-08-18 10:24:37 +00:00
|
|
|
# A variable to pass additional flags to CMake.
|
|
|
|
# Here we explicitly default it to nothing so that bash doesn't complain about
|
2020-09-07 06:40:01 +00:00
|
|
|
# it being undefined. Also read it as array so that we can pass an empty list
|
2020-08-18 10:24:37 +00:00
|
|
|
# of additional variable to cmake properly, and it doesn't generate an extra
|
|
|
|
# empty parameter.
|
2023-03-27 13:35:51 +00:00
|
|
|
# Read it as CMAKE_FLAGS to not lose exported FASTTEST_CMAKE_FLAGS on subsequential launch
|
|
|
|
read -ra CMAKE_FLAGS <<< "${FASTTEST_CMAKE_FLAGS:-}"
|
2020-07-08 13:06:35 +00:00
|
|
|
|
2020-10-30 17:11:13 +00:00
|
|
|
# Run only matching tests.
|
|
|
|
FASTTEST_FOCUS=${FASTTEST_FOCUS:-""}
|
|
|
|
|
2020-09-29 18:01:49 +00:00
|
|
|
FASTTEST_WORKSPACE=$(readlink -f "${FASTTEST_WORKSPACE:-.}")
|
|
|
|
FASTTEST_SOURCE=$(readlink -f "${FASTTEST_SOURCE:-$FASTTEST_WORKSPACE/ch}")
|
|
|
|
FASTTEST_BUILD=$(readlink -f "${FASTTEST_BUILD:-${BUILD:-$FASTTEST_WORKSPACE/build}}")
|
|
|
|
FASTTEST_DATA=$(readlink -f "${FASTTEST_DATA:-$FASTTEST_WORKSPACE/db-fasttest}")
|
|
|
|
FASTTEST_OUTPUT=$(readlink -f "${FASTTEST_OUTPUT:-$FASTTEST_WORKSPACE}")
|
2020-10-22 17:30:50 +00:00
|
|
|
PATH="$FASTTEST_BUILD/programs:$FASTTEST_SOURCE/tests:$PATH"
|
2023-09-20 17:07:42 +00:00
|
|
|
# Work around for non-existent user
|
|
|
|
if [ "$HOME" == "/" ]; then
|
|
|
|
HOME="$FASTTEST_WORKSPACE/user-home"
|
|
|
|
mkdir -p "$HOME"
|
|
|
|
export HOME
|
|
|
|
fi
|
2020-09-29 18:01:49 +00:00
|
|
|
|
2020-09-30 17:39:38 +00:00
|
|
|
# Export these variables, so that all subsequent invocations of the script
|
|
|
|
# use them, and not try to guess them anew, which leads to weird effects.
|
|
|
|
export FASTTEST_WORKSPACE
|
|
|
|
export FASTTEST_SOURCE
|
|
|
|
export FASTTEST_BUILD
|
|
|
|
export FASTTEST_DATA
|
|
|
|
export FASTTEST_OUT
|
2020-10-22 17:30:50 +00:00
|
|
|
export PATH
|
2020-09-30 17:39:38 +00:00
|
|
|
|
2023-02-09 15:43:24 +00:00
|
|
|
function ccache_status
|
|
|
|
{
|
|
|
|
ccache --show-config ||:
|
|
|
|
ccache --show-stats ||:
|
|
|
|
SCCACHE_NO_DAEMON=1 sccache --show-stats ||:
|
|
|
|
}
|
|
|
|
|
2020-09-29 18:01:49 +00:00
|
|
|
function start_server
|
2020-08-18 10:24:37 +00:00
|
|
|
{
|
2020-09-29 18:01:49 +00:00
|
|
|
set -m # Spawn server in its own process groups
|
2022-05-26 10:19:17 +00:00
|
|
|
|
2020-12-08 20:58:27 +00:00
|
|
|
local opts=(
|
2020-12-28 11:46:53 +00:00
|
|
|
--config-file "$FASTTEST_DATA/config.xml"
|
2022-05-26 10:19:17 +00:00
|
|
|
--pid-file "$FASTTEST_DATA/clickhouse-server.pid"
|
2020-12-08 20:58:27 +00:00
|
|
|
--
|
|
|
|
--path "$FASTTEST_DATA"
|
|
|
|
--user_files_path "$FASTTEST_DATA/user_files"
|
|
|
|
--top_level_domains_path "$FASTTEST_DATA/top_level_domains"
|
2021-05-12 20:00:28 +00:00
|
|
|
--keeper_server.storage_path "$FASTTEST_DATA/coordination"
|
2020-12-08 20:58:27 +00:00
|
|
|
)
|
|
|
|
clickhouse-server "${opts[@]}" &>> "$FASTTEST_OUTPUT/server.log" &
|
2020-09-29 18:01:49 +00:00
|
|
|
set +m
|
|
|
|
|
2022-05-26 10:19:17 +00:00
|
|
|
for _ in {1..60}; do
|
|
|
|
if clickhouse-client --query "select 1"; then
|
2020-08-18 10:24:37 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2022-05-26 10:19:17 +00:00
|
|
|
if ! clickhouse-client --query "select 1"; then
|
2020-08-18 10:24:37 +00:00
|
|
|
echo "Failed to wait until ClickHouse server starts."
|
2020-09-29 18:01:49 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2022-05-26 10:19:17 +00:00
|
|
|
local server_pid
|
|
|
|
server_pid="$(cat "$FASTTEST_DATA/clickhouse-server.pid")"
|
2020-09-29 18:01:49 +00:00
|
|
|
echo "ClickHouse server pid '$server_pid' started and responded"
|
2020-08-18 10:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function clone_root
|
|
|
|
{
|
2023-06-19 20:26:27 +00:00
|
|
|
[ "$UID" -eq 0 ] && git config --global --add safe.directory "$FASTTEST_SOURCE"
|
2021-04-01 21:04:59 +00:00
|
|
|
git clone --depth 1 https://github.com/ClickHouse/ClickHouse.git -- "$FASTTEST_SOURCE" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/clone_log.txt"
|
2020-11-22 21:27:40 +00:00
|
|
|
|
|
|
|
(
|
|
|
|
cd "$FASTTEST_SOURCE"
|
|
|
|
if [ "$PULL_REQUEST_NUMBER" != "0" ]; then
|
2021-04-01 18:44:43 +00:00
|
|
|
if git fetch --depth 1 origin "+refs/pull/$PULL_REQUEST_NUMBER/merge"; then
|
2020-11-22 21:27:40 +00:00
|
|
|
git checkout FETCH_HEAD
|
2021-04-01 20:28:53 +00:00
|
|
|
echo "Checked out pull/$PULL_REQUEST_NUMBER/merge ($(git rev-parse FETCH_HEAD))"
|
2020-11-22 21:27:40 +00:00
|
|
|
else
|
2021-04-01 18:44:43 +00:00
|
|
|
git fetch --depth 1 origin "+refs/pull/$PULL_REQUEST_NUMBER/head"
|
2020-11-22 21:27:40 +00:00
|
|
|
git checkout "$COMMIT_SHA"
|
2021-04-01 20:28:53 +00:00
|
|
|
echo "Checked out nominal SHA $COMMIT_SHA for PR $PULL_REQUEST_NUMBER"
|
2020-11-22 21:27:40 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -v COMMIT_SHA ]; then
|
2021-04-01 18:44:43 +00:00
|
|
|
git fetch --depth 1 origin "$COMMIT_SHA"
|
2020-11-22 21:27:40 +00:00
|
|
|
git checkout "$COMMIT_SHA"
|
2021-04-01 20:28:53 +00:00
|
|
|
echo "Checked out nominal SHA $COMMIT_SHA for master"
|
|
|
|
else
|
|
|
|
echo "Using default repository head $(git rev-parse HEAD)"
|
2020-11-22 21:27:40 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
)
|
2020-08-18 10:24:37 +00:00
|
|
|
}
|
2020-07-08 16:02:19 +00:00
|
|
|
|
2020-09-29 18:01:49 +00:00
|
|
|
function clone_submodules
|
2020-08-18 10:24:37 +00:00
|
|
|
{
|
2020-11-22 21:27:40 +00:00
|
|
|
(
|
|
|
|
cd "$FASTTEST_SOURCE"
|
2020-07-08 16:02:19 +00:00
|
|
|
|
2020-11-22 21:27:40 +00:00
|
|
|
SUBMODULES_TO_UPDATE=(
|
2021-10-12 00:34:07 +00:00
|
|
|
contrib/sysroot
|
2021-09-06 15:59:46 +00:00
|
|
|
contrib/magic_enum
|
2021-02-27 18:02:44 +00:00
|
|
|
contrib/abseil-cpp
|
2020-11-22 21:27:40 +00:00
|
|
|
contrib/boost
|
|
|
|
contrib/zlib-ng
|
|
|
|
contrib/libxml2
|
|
|
|
contrib/libunwind
|
|
|
|
contrib/fmtlib
|
2023-08-31 12:28:39 +00:00
|
|
|
contrib/aklomp-base64
|
2020-11-22 21:27:40 +00:00
|
|
|
contrib/cctz
|
|
|
|
contrib/libcpuid
|
2022-12-11 18:57:30 +00:00
|
|
|
contrib/libdivide
|
2020-11-22 21:27:40 +00:00
|
|
|
contrib/double-conversion
|
2022-10-30 13:04:22 +00:00
|
|
|
contrib/llvm-project
|
2020-11-22 21:27:40 +00:00
|
|
|
contrib/lz4
|
|
|
|
contrib/zstd
|
|
|
|
contrib/fastops
|
|
|
|
contrib/rapidjson
|
|
|
|
contrib/re2
|
|
|
|
contrib/sparsehash-c11
|
|
|
|
contrib/croaring
|
|
|
|
contrib/miniselect
|
|
|
|
contrib/xz
|
2020-12-05 21:32:03 +00:00
|
|
|
contrib/dragonbox
|
2020-12-05 17:09:12 +00:00
|
|
|
contrib/fast_float
|
2021-01-25 15:32:59 +00:00
|
|
|
contrib/NuRaft
|
2021-12-17 19:09:05 +00:00
|
|
|
contrib/jemalloc
|
|
|
|
contrib/replxx
|
2022-04-21 16:36:47 +00:00
|
|
|
contrib/wyhash
|
2022-07-11 15:43:56 +00:00
|
|
|
contrib/c-ares
|
2022-09-25 17:58:00 +00:00
|
|
|
contrib/morton-nd
|
2022-11-25 23:14:08 +00:00
|
|
|
contrib/xxHash
|
2023-01-27 08:07:44 +00:00
|
|
|
contrib/simdjson
|
2022-06-27 08:38:00 +00:00
|
|
|
contrib/liburing
|
2023-05-10 11:56:17 +00:00
|
|
|
contrib/libfiu
|
2023-07-23 15:30:23 +00:00
|
|
|
contrib/incbin
|
2023-08-06 00:52:36 +00:00
|
|
|
contrib/yaml-cpp
|
2020-11-22 21:27:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
git submodule sync
|
2023-09-20 16:10:50 +00:00
|
|
|
git submodule init
|
|
|
|
# --jobs does not work as fast as real parallel running
|
|
|
|
printf '%s\0' "${SUBMODULES_TO_UPDATE[@]}" | \
|
|
|
|
xargs --max-procs=100 --null --no-run-if-empty --max-args=1 \
|
|
|
|
git submodule update --depth 1 --single-branch
|
2020-11-22 21:27:40 +00:00
|
|
|
git submodule foreach git reset --hard
|
|
|
|
git submodule foreach git checkout @ -f
|
|
|
|
git submodule foreach git clean -xfd
|
|
|
|
)
|
2020-09-29 18:01:49 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 18:55:06 +00:00
|
|
|
function run_cmake
|
2020-09-29 18:01:49 +00:00
|
|
|
{
|
2020-11-22 21:27:40 +00:00
|
|
|
CMAKE_LIBS_CONFIG=(
|
|
|
|
"-DENABLE_LIBRARIES=0"
|
|
|
|
"-DENABLE_TESTS=0"
|
|
|
|
"-DENABLE_UTILS=0"
|
|
|
|
"-DENABLE_THINLTO=0"
|
2021-01-25 15:53:13 +00:00
|
|
|
"-DENABLE_NURAFT=1"
|
2023-01-27 08:07:44 +00:00
|
|
|
"-DENABLE_SIMDJSON=1"
|
2021-12-17 19:09:05 +00:00
|
|
|
"-DENABLE_JEMALLOC=1"
|
2022-06-27 08:38:00 +00:00
|
|
|
"-DENABLE_LIBURING=1"
|
2023-08-06 00:52:36 +00:00
|
|
|
"-DENABLE_YAML_CPP=1"
|
2020-11-22 21:27:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
export CCACHE_DIR="$FASTTEST_WORKSPACE/ccache"
|
2022-07-29 22:47:12 +00:00
|
|
|
export CCACHE_COMPRESSLEVEL=5
|
2020-11-22 21:27:40 +00:00
|
|
|
export CCACHE_BASEDIR="$FASTTEST_SOURCE"
|
|
|
|
export CCACHE_NOHASHDIR=true
|
|
|
|
export CCACHE_COMPILERCHECK=content
|
|
|
|
export CCACHE_MAXSIZE=15G
|
|
|
|
|
2023-02-09 15:43:24 +00:00
|
|
|
ccache_status
|
2020-11-22 21:27:40 +00:00
|
|
|
ccache --zero-stats ||:
|
|
|
|
|
|
|
|
mkdir "$FASTTEST_BUILD" ||:
|
|
|
|
|
|
|
|
(
|
|
|
|
cd "$FASTTEST_BUILD"
|
2023-03-27 13:35:51 +00:00
|
|
|
cmake "$FASTTEST_SOURCE" -DCMAKE_CXX_COMPILER="clang++-${LLVM_VERSION}" -DCMAKE_C_COMPILER="clang-${LLVM_VERSION}" "${CMAKE_LIBS_CONFIG[@]}" "${CMAKE_FLAGS[@]}" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/cmake_log.txt"
|
2020-11-22 21:27:40 +00:00
|
|
|
)
|
2020-09-29 18:55:06 +00:00
|
|
|
}
|
2020-07-08 13:06:35 +00:00
|
|
|
|
2020-09-29 18:55:06 +00:00
|
|
|
function build
|
|
|
|
{
|
2020-11-22 21:27:40 +00:00
|
|
|
(
|
|
|
|
cd "$FASTTEST_BUILD"
|
2023-04-19 10:48:02 +00:00
|
|
|
TIMEFORMAT=$'\nreal\t%3R\nuser\t%3U\nsys\t%3S'
|
|
|
|
( time ninja clickhouse-bundle) |& ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/build_log.txt"
|
|
|
|
BUILD_SECONDS_ELAPSED=$(awk '/^....-..-.. ..:..:.. real\t[0-9]/ {print $4}' < "$FASTTEST_OUTPUT/build_log.txt")
|
|
|
|
echo "build_clickhouse_fasttest_binary: [ OK ] $BUILD_SECONDS_ELAPSED sec." \
|
|
|
|
| ts '%Y-%m-%d %H:%M:%S' \
|
|
|
|
| tee "$FASTTEST_OUTPUT/test_result.txt"
|
2020-11-22 21:27:40 +00:00
|
|
|
if [ "$COPY_CLICKHOUSE_BINARY_TO_OUTPUT" -eq "1" ]; then
|
2023-06-19 20:26:27 +00:00
|
|
|
mkdir -p "$FASTTEST_OUTPUT/binaries/"
|
|
|
|
cp programs/clickhouse "$FASTTEST_OUTPUT/binaries/clickhouse"
|
2021-12-01 07:14:45 +00:00
|
|
|
|
2023-06-19 20:26:27 +00:00
|
|
|
strip programs/clickhouse -o programs/clickhouse-stripped
|
|
|
|
zstd --threads=0 programs/clickhouse-stripped -o "$FASTTEST_OUTPUT/binaries/clickhouse-stripped.zst"
|
2020-11-22 21:27:40 +00:00
|
|
|
fi
|
2023-02-09 15:43:24 +00:00
|
|
|
ccache_status
|
2022-07-29 22:47:12 +00:00
|
|
|
ccache --evict-older-than 1d ||:
|
2020-11-22 21:27:40 +00:00
|
|
|
)
|
2020-09-29 18:01:49 +00:00
|
|
|
}
|
2020-07-08 13:06:35 +00:00
|
|
|
|
2020-09-29 18:01:49 +00:00
|
|
|
function configure
|
|
|
|
{
|
2020-11-22 21:27:40 +00:00
|
|
|
clickhouse-client --version
|
|
|
|
clickhouse-test --help
|
|
|
|
|
|
|
|
mkdir -p "$FASTTEST_DATA"{,/client-config}
|
|
|
|
cp -a "$FASTTEST_SOURCE/programs/server/"{config,users}.xml "$FASTTEST_DATA"
|
|
|
|
"$FASTTEST_SOURCE/tests/config/install.sh" "$FASTTEST_DATA" "$FASTTEST_DATA/client-config"
|
|
|
|
cp -a "$FASTTEST_SOURCE/programs/server/config.d/log_to_console.xml" "$FASTTEST_DATA/config.d"
|
|
|
|
# doesn't support SSL
|
|
|
|
rm -f "$FASTTEST_DATA/config.d/secure_ports.xml"
|
2020-09-29 18:01:49 +00:00
|
|
|
}
|
2020-08-05 12:14:20 +00:00
|
|
|
|
2020-09-29 18:01:49 +00:00
|
|
|
function run_tests
|
|
|
|
{
|
2020-11-22 21:27:40 +00:00
|
|
|
clickhouse-server --version
|
|
|
|
clickhouse-test --help
|
2020-07-28 11:16:06 +00:00
|
|
|
|
2020-09-29 18:01:49 +00:00
|
|
|
start_server
|
2020-07-29 11:39:08 +00:00
|
|
|
|
2021-10-06 20:07:30 +00:00
|
|
|
set +e
|
2021-12-16 14:15:37 +00:00
|
|
|
local NPROC
|
|
|
|
NPROC=$(nproc)
|
|
|
|
NPROC=$((NPROC / 2))
|
|
|
|
if [[ $NPROC == 0 ]]; then
|
|
|
|
NPROC=1
|
|
|
|
fi
|
2022-03-03 12:42:29 +00:00
|
|
|
|
|
|
|
local test_opts=(
|
|
|
|
--hung-check
|
|
|
|
--fast-tests-only
|
2022-03-28 12:56:23 +00:00
|
|
|
--no-random-settings
|
2022-10-28 23:26:06 +00:00
|
|
|
--no-random-merge-tree-settings
|
2022-03-03 12:42:29 +00:00
|
|
|
--no-long
|
|
|
|
--testname
|
|
|
|
--shard
|
|
|
|
--zookeeper
|
|
|
|
--check-zookeeper-session
|
|
|
|
--order random
|
2022-03-03 12:42:53 +00:00
|
|
|
--print-time
|
2023-01-25 15:06:40 +00:00
|
|
|
--report-logs-stats
|
2022-03-03 12:42:29 +00:00
|
|
|
--jobs "${NPROC}"
|
|
|
|
)
|
|
|
|
time clickhouse-test "${test_opts[@]}" -- "$FASTTEST_FOCUS" 2>&1 \
|
2021-05-20 12:31:33 +00:00
|
|
|
| ts '%Y-%m-%d %H:%M:%S' \
|
2023-04-19 10:48:02 +00:00
|
|
|
| tee -a "$FASTTEST_OUTPUT/test_result.txt"
|
2021-10-06 20:07:30 +00:00
|
|
|
set -e
|
2022-05-26 10:19:17 +00:00
|
|
|
|
|
|
|
clickhouse stop --pid-path "$FASTTEST_DATA"
|
2020-08-18 10:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$stage" in
|
|
|
|
"")
|
2020-09-07 10:19:01 +00:00
|
|
|
ls -la
|
2020-08-18 10:24:37 +00:00
|
|
|
;&
|
|
|
|
"clone_root")
|
|
|
|
clone_root
|
2020-09-29 18:01:49 +00:00
|
|
|
;&
|
|
|
|
"clone_submodules")
|
2021-04-01 21:02:35 +00:00
|
|
|
clone_submodules 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/submodule_log.txt"
|
2020-09-29 18:01:49 +00:00
|
|
|
;&
|
2020-09-29 18:55:06 +00:00
|
|
|
"run_cmake")
|
2023-09-20 16:02:59 +00:00
|
|
|
cd "$FASTTEST_WORKSPACE"
|
2020-09-29 18:55:06 +00:00
|
|
|
run_cmake
|
|
|
|
;&
|
2020-09-29 18:01:49 +00:00
|
|
|
"build")
|
|
|
|
build
|
|
|
|
;&
|
|
|
|
"configure")
|
2020-09-29 20:09:52 +00:00
|
|
|
# The `install_log.txt` is also needed for compatibility with old CI task --
|
|
|
|
# if there is no log, it will decide that build failed.
|
2021-04-01 21:02:35 +00:00
|
|
|
configure 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/install_log.txt"
|
2020-09-29 18:01:49 +00:00
|
|
|
;&
|
|
|
|
"run_tests")
|
|
|
|
run_tests
|
2021-09-28 17:38:41 +00:00
|
|
|
/process_functional_tests_result.py --in-results-dir "$FASTTEST_OUTPUT/" \
|
|
|
|
--out-results-file "$FASTTEST_OUTPUT/test_results.tsv" \
|
|
|
|
--out-status-file "$FASTTEST_OUTPUT/check_status.tsv" || echo -e "failure\tCannot parse results" > "$FASTTEST_OUTPUT/check_status.tsv"
|
2020-10-14 14:12:04 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown test stage '$stage'"
|
|
|
|
exit 1
|
2020-08-18 10:24:37 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
pstree -apgT
|
|
|
|
jobs
|