mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
allow fast test to run locally
This commit is contained in:
parent
4fd1db73a1
commit
e943a22d28
@ -16,28 +16,55 @@ stage=${stage:-}
|
|||||||
read -ra FASTTEST_CMAKE_FLAGS <<< "${FASTTEST_CMAKE_FLAGS:-}"
|
read -ra FASTTEST_CMAKE_FLAGS <<< "${FASTTEST_CMAKE_FLAGS:-}"
|
||||||
|
|
||||||
|
|
||||||
function kill_clickhouse
|
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}")
|
||||||
|
|
||||||
|
server_pid=none
|
||||||
|
|
||||||
|
function stop_server
|
||||||
{
|
{
|
||||||
|
if ! kill -- "$server_pid"
|
||||||
|
then
|
||||||
|
echo "The server we started ($server_pid) is not present, won't do anything"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
for _ in {1..60}
|
for _ in {1..60}
|
||||||
do
|
do
|
||||||
if ! pkill -f clickhouse-server ; then break ; fi
|
if ! kill -- "$server_pid" ; then break ; fi
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
if pgrep -f clickhouse-server
|
if kill -0 -- "$server_pid"
|
||||||
then
|
then
|
||||||
pstree -apgT
|
pstree -apgT
|
||||||
jobs
|
jobs
|
||||||
echo "Failed to kill the ClickHouse server $(pgrep -f clickhouse-server)"
|
echo "Failed to kill the ClickHouse server pid '$server_pid'"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function wait_for_server_start
|
function start_server
|
||||||
{
|
{
|
||||||
|
set -m # Spawn server in its own process groups
|
||||||
|
clickhouse-server --config-file="$FASTTEST_DATA/config.xml" -- --path "$FASTTEST_DATA" --user_files_path "$FASTTEST_DATA/user_files" &>> "$FASTTEST_OUTPUT/server.log" &
|
||||||
|
server_pid=$!
|
||||||
|
set +m
|
||||||
|
|
||||||
|
if [ "$server_pid" == "0" ]
|
||||||
|
then
|
||||||
|
echo "Failed to start ClickHouse server"
|
||||||
|
# Avoid zero PID because `kill` treats it as our process group PID.
|
||||||
|
server_pid="none"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
for _ in {1..60}
|
for _ in {1..60}
|
||||||
do
|
do
|
||||||
if clickhouse-client --query "select 1" || ! pgrep -f clickhouse-server
|
if clickhouse-client --query "select 1" || ! kill -0 -- "$server_pid"
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -47,20 +74,26 @@ function wait_for_server_start
|
|||||||
if ! clickhouse-client --query "select 1"
|
if ! clickhouse-client --query "select 1"
|
||||||
then
|
then
|
||||||
echo "Failed to wait until ClickHouse server starts."
|
echo "Failed to wait until ClickHouse server starts."
|
||||||
|
server_pid="none"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "ClickHouse server pid '$(pgrep -f clickhouse-server)' started and responded"
|
if ! kill -0 -- "$server_pid"
|
||||||
|
then
|
||||||
|
echo "Wrong clickhouse server started: PID '$server_pid' we started is not running, but '$(pgrep -f clickhouse-server)' is running"
|
||||||
|
server_pid="none"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "ClickHouse server pid '$server_pid' started and responded"
|
||||||
}
|
}
|
||||||
|
|
||||||
function clone_root
|
function clone_root
|
||||||
{
|
{
|
||||||
git clone https://github.com/ClickHouse/ClickHouse.git | ts '%Y-%m-%d %H:%M:%S' | tee /test_output/clone_log.txt
|
git clone https://github.com/ClickHouse/ClickHouse.git -- "$FASTTEST_SOURCE" | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/clone_log.txt"
|
||||||
cd ClickHouse
|
|
||||||
CLICKHOUSE_DIR=$(pwd)
|
|
||||||
export CLICKHOUSE_DIR
|
|
||||||
|
|
||||||
|
|
||||||
|
(
|
||||||
|
cd "$FASTTEST_SOURCE"
|
||||||
if [ "$PULL_REQUEST_NUMBER" != "0" ]; then
|
if [ "$PULL_REQUEST_NUMBER" != "0" ]; then
|
||||||
if git fetch origin "+refs/pull/$PULL_REQUEST_NUMBER/merge"; then
|
if git fetch origin "+refs/pull/$PULL_REQUEST_NUMBER/merge"; then
|
||||||
git checkout FETCH_HEAD
|
git checkout FETCH_HEAD
|
||||||
@ -71,22 +104,37 @@ if [ "$PULL_REQUEST_NUMBER" != "0" ]; then
|
|||||||
echo 'Checked out to commit'
|
echo 'Checked out to commit'
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$COMMIT_SHA" != "" ]; then
|
if [ -v COMMIT_SHA ]; then
|
||||||
git checkout "$COMMIT_SHA"
|
git checkout "$COMMIT_SHA"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function run
|
function clone_submodules
|
||||||
{
|
{
|
||||||
|
(
|
||||||
|
cd "$FASTTEST_SOURCE"
|
||||||
|
|
||||||
SUBMODULES_TO_UPDATE=(contrib/boost contrib/zlib-ng contrib/libxml2 contrib/poco contrib/libunwind contrib/ryu contrib/fmtlib contrib/base64 contrib/cctz contrib/libcpuid contrib/double-conversion contrib/libcxx contrib/libcxxabi contrib/libc-headers contrib/lz4 contrib/zstd contrib/fastops contrib/rapidjson contrib/re2 contrib/sparsehash-c11)
|
SUBMODULES_TO_UPDATE=(contrib/boost contrib/zlib-ng contrib/libxml2 contrib/poco contrib/libunwind contrib/ryu contrib/fmtlib contrib/base64 contrib/cctz contrib/libcpuid contrib/double-conversion contrib/libcxx contrib/libcxxabi contrib/libc-headers contrib/lz4 contrib/zstd contrib/fastops contrib/rapidjson contrib/re2 contrib/sparsehash-c11)
|
||||||
|
|
||||||
git submodule update --init --recursive "${SUBMODULES_TO_UPDATE[@]}" | ts '%Y-%m-%d %H:%M:%S' | tee /test_output/submodule_log.txt
|
git submodule sync
|
||||||
|
git submodule update --init --recursive "${SUBMODULES_TO_UPDATE[@]}"
|
||||||
|
git submodule foreach git reset --hard
|
||||||
|
git submodule foreach git checkout @ -f
|
||||||
|
git submodule foreach git clean -xfd
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function build
|
||||||
|
{
|
||||||
CMAKE_LIBS_CONFIG=(-DENABLE_LIBRARIES=0 -DENABLE_TESTS=0 -DENABLE_UTILS=0 -DENABLE_EMBEDDED_COMPILER=0 -DENABLE_THINLTO=0 -DUSE_UNWIND=1)
|
CMAKE_LIBS_CONFIG=(-DENABLE_LIBRARIES=0 -DENABLE_TESTS=0 -DENABLE_UTILS=0 -DENABLE_EMBEDDED_COMPILER=0 -DENABLE_THINLTO=0 -DUSE_UNWIND=1)
|
||||||
|
|
||||||
export CCACHE_DIR=/ccache
|
# TODO remove this? we don't use ccache anyway. An option would be to download it
|
||||||
export CCACHE_BASEDIR=/ClickHouse
|
# from S3 simultaneously with cloning.
|
||||||
|
export CCACHE_DIR="$FASTTEST_WORKSPACE/ccache"
|
||||||
|
export CCACHE_BASEDIR="$FASTTEST_SOURCE"
|
||||||
export CCACHE_NOHASHDIR=true
|
export CCACHE_NOHASHDIR=true
|
||||||
export CCACHE_COMPILERCHECK=content
|
export CCACHE_COMPILERCHECK=content
|
||||||
export CCACHE_MAXSIZE=15G
|
export CCACHE_MAXSIZE=15G
|
||||||
@ -94,34 +142,40 @@ export CCACHE_MAXSIZE=15G
|
|||||||
ccache --show-stats ||:
|
ccache --show-stats ||:
|
||||||
ccache --zero-stats ||:
|
ccache --zero-stats ||:
|
||||||
|
|
||||||
mkdir build
|
mkdir "$FASTTEST_BUILD" ||:
|
||||||
cd build
|
(
|
||||||
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_C_COMPILER=clang-10 "${CMAKE_LIBS_CONFIG[@]}" "${FASTTEST_CMAKE_FLAGS[@]}" | ts '%Y-%m-%d %H:%M:%S' | tee /test_output/cmake_log.txt
|
cd "$FASTTEST_BUILD"
|
||||||
time ninja clickhouse-bundle | ts '%Y-%m-%d %H:%M:%S' | tee /test_output/build_log.txt
|
cmake "$FASTTEST_SOURCE" -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_C_COMPILER=clang-10 "${CMAKE_LIBS_CONFIG[@]}" "${FASTTEST_CMAKE_FLAGS[@]}" | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/cmake_log.txt"
|
||||||
ninja install | ts '%Y-%m-%d %H:%M:%S' | tee /test_output/install_log.txt
|
time ninja clickhouse-bundle | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/build_log.txt"
|
||||||
|
)
|
||||||
|
|
||||||
ccache --show-stats ||:
|
ccache --show-stats ||:
|
||||||
|
}
|
||||||
|
|
||||||
mkdir -p /etc/clickhouse-server
|
function configure
|
||||||
mkdir -p /etc/clickhouse-client
|
{
|
||||||
mkdir -p /etc/clickhouse-server/config.d
|
export PATH="$FASTTEST_BUILD/programs:$FASTTEST_SOURCE/tests:$PATH"
|
||||||
mkdir -p /etc/clickhouse-server/users.d
|
|
||||||
ln -s /test_output /var/log/clickhouse-server
|
|
||||||
cp "$CLICKHOUSE_DIR/programs/server/config.xml" /etc/clickhouse-server/
|
|
||||||
cp "$CLICKHOUSE_DIR/programs/server/users.xml" /etc/clickhouse-server/
|
|
||||||
|
|
||||||
# install tests config
|
clickhouse-client --version
|
||||||
$CLICKHOUSE_DIR/tests/config/install.sh
|
clickhouse-test --help
|
||||||
|
|
||||||
|
mkdir -p "$FASTTEST_DATA"{,/client-config}
|
||||||
|
cp -a "$FASTTEST_SOURCE/programs/server/"{config,users}.xml "$FASTTEST_DATA"
|
||||||
|
cp -a "$FASTTEST_SOURCE/programs/server/"{config,users}.xml "$FASTTEST_DATA"
|
||||||
|
"$FASTTEST_SOURCE/tests/config/install.sh" "$FASTTEST_DATA" "$FASTTEST_DATA/client-config"
|
||||||
# doesn't support SSL
|
# doesn't support SSL
|
||||||
rm -f /etc/clickhouse-server/config.d/secure_ports.xml
|
rm -f "$FASTTEST_DATA/config.d/secure_ports.xml"
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_tests
|
||||||
|
{
|
||||||
|
clickhouse-server --version
|
||||||
|
clickhouse-test --help
|
||||||
|
|
||||||
# Kill the server in case we are running locally and not in docker
|
# Kill the server in case we are running locally and not in docker
|
||||||
kill_clickhouse
|
stop_server ||:
|
||||||
|
|
||||||
clickhouse-server --config /etc/clickhouse-server/config.xml --daemon
|
start_server
|
||||||
|
|
||||||
wait_for_server_start
|
|
||||||
|
|
||||||
TESTS_TO_SKIP=(
|
TESTS_TO_SKIP=(
|
||||||
parquet
|
parquet
|
||||||
@ -191,11 +245,10 @@ TESTS_TO_SKIP=(
|
|||||||
01460_DistributedFilesToInsert
|
01460_DistributedFilesToInsert
|
||||||
)
|
)
|
||||||
|
|
||||||
time clickhouse-test -j 8 --no-long --testname --shard --zookeeper --skip "${TESTS_TO_SKIP[@]}" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee /test_output/test_log.txt
|
time clickhouse-test -j 8 --no-long --testname --shard --zookeeper --skip "${TESTS_TO_SKIP[@]}" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/test_log.txt"
|
||||||
|
|
||||||
|
|
||||||
# substr is to remove semicolon after test name
|
# substr is to remove semicolon after test name
|
||||||
readarray -t FAILED_TESTS < <(awk '/FAIL|TIMEOUT|ERROR/ { print substr($3, 1, length($3)-1) }' /test_output/test_log.txt | tee /test_output/failed-parallel-tests.txt)
|
readarray -t FAILED_TESTS < <(awk '/FAIL|TIMEOUT|ERROR/ { print substr($3, 1, length($3)-1) }' "$FASTTEST_OUTPUT/test_log.txt" | tee "$FASTTEST_OUTPUT/failed-parallel-tests.txt")
|
||||||
|
|
||||||
# We will rerun sequentially any tests that have failed during parallel run.
|
# We will rerun sequentially any tests that have failed during parallel run.
|
||||||
# They might have failed because there was some interference from other tests
|
# They might have failed because there was some interference from other tests
|
||||||
@ -206,19 +259,16 @@ readarray -t FAILED_TESTS < <(awk '/FAIL|TIMEOUT|ERROR/ { print substr($3, 1, le
|
|||||||
# explicit instead of guessing.
|
# explicit instead of guessing.
|
||||||
if [[ -n "${FAILED_TESTS[*]}" ]]
|
if [[ -n "${FAILED_TESTS[*]}" ]]
|
||||||
then
|
then
|
||||||
kill_clickhouse
|
stop_server ||:
|
||||||
|
|
||||||
# Clean the data so that there is no interference from the previous test run.
|
# Clean the data so that there is no interference from the previous test run.
|
||||||
rm -rf /var/lib/clickhouse ||:
|
rm -rf "$FASTTEST_DATA"/{meta,}data ||:
|
||||||
mkdir /var/lib/clickhouse
|
|
||||||
|
|
||||||
clickhouse-server --config /etc/clickhouse-server/config.xml --daemon
|
start_server
|
||||||
|
|
||||||
wait_for_server_start
|
|
||||||
|
|
||||||
echo "Going to run again: ${FAILED_TESTS[*]}"
|
echo "Going to run again: ${FAILED_TESTS[*]}"
|
||||||
|
|
||||||
clickhouse-test --no-long --testname --shard --zookeeper "${FAILED_TESTS[@]}" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee -a /test_output/test_log.txt
|
clickhouse-test --no-long --testname --shard --zookeeper "${FAILED_TESTS[@]}" 2>&1 | ts '%Y-%m-%d %H:%M:%S' | tee -a "$FASTTEST_OUTPUT/test_log.txt"
|
||||||
else
|
else
|
||||||
echo "No failed tests"
|
echo "No failed tests"
|
||||||
fi
|
fi
|
||||||
@ -228,20 +278,33 @@ case "$stage" in
|
|||||||
"")
|
"")
|
||||||
ls -la
|
ls -la
|
||||||
;&
|
;&
|
||||||
|
|
||||||
"clone_root")
|
"clone_root")
|
||||||
clone_root
|
clone_root
|
||||||
|
|
||||||
# Pass control to the script from cloned sources, unless asked otherwise.
|
# Pass control to the script from cloned sources, unless asked otherwise.
|
||||||
if ! [ -v FASTTEST_LOCAL_SCRIPT ]
|
if ! [ -v FASTTEST_LOCAL_SCRIPT ]
|
||||||
then
|
then
|
||||||
stage=run "$CLICKHOUSE_DIR/docker/test/fasttest/run.sh"
|
# 'run' is deprecated, used for compatibility with old scripts.
|
||||||
|
# Replace with 'clone_submodules' after Nov 1, 2020.
|
||||||
|
stage=run "$FASTTEST_SOURCE/docker/test/fasttest/run.sh"
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
;&
|
;&
|
||||||
|
|
||||||
"run")
|
"run")
|
||||||
run
|
# A deprecated stage that is called by old script and equivalent to everything
|
||||||
|
# after cloning root, starting with cloning submodules.
|
||||||
|
;&
|
||||||
|
"clone_submodules")
|
||||||
|
clone_submodules | ts '%Y-%m-%d %H:%M:%S' | tee "$FASTTEST_OUTPUT/submodule_log.txt"
|
||||||
|
;&
|
||||||
|
"build")
|
||||||
|
build
|
||||||
|
;&
|
||||||
|
"configure")
|
||||||
|
configure
|
||||||
|
;&
|
||||||
|
"run_tests")
|
||||||
|
run_tests
|
||||||
;&
|
;&
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user