From cd812d94deb7e03ae9fea5c77df1e6765aac5dbd Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 3 Sep 2020 04:54:50 +0300 Subject: [PATCH] Wait for clickhouse-server to start in stateful tests --- docker/test/stateful/run.sh | 24 +++++++++++++++++---- docker/test/stateful_with_coverage/run.sh | 26 +++++++++++++++++------ 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/docker/test/stateful/run.sh b/docker/test/stateful/run.sh index 5be14970914..431a61d5503 100755 --- a/docker/test/stateful/run.sh +++ b/docker/test/stateful/run.sh @@ -36,10 +36,26 @@ echo "ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-10/bin/llvm-symbolizer" >> /etc/environ echo "UBSAN_SYMBOLIZER_PATH=/usr/lib/llvm-10/bin/llvm-symbolizer" >> /etc/environment echo "LLVM_SYMBOLIZER_PATH=/usr/lib/llvm-10/bin/llvm-symbolizer" >> /etc/environment -service zookeeper start -sleep 5 -service clickhouse-server start -sleep 5 +function start() +{ + counter=0 + until clickhouse-client --query "SELECT 1" + do + if [ "$counter" -gt 120 ] + then + echo "Cannot start clickhouse-server" + cat /var/log/clickhouse-server/stdout.log + tail -n1000 /var/log/clickhouse-server/stderr.log + tail -n1000 /var/log/clickhouse-server/clickhouse-server.log + break + fi + timeout 120 service clickhouse-server start + sleep 0.5 + counter=$(($counter + 1)) + done +} + +start /s3downloader --dataset-names $DATASETS chmod 777 -R /var/lib/clickhouse clickhouse-client --query "SHOW DATABASES" diff --git a/docker/test/stateful_with_coverage/run.sh b/docker/test/stateful_with_coverage/run.sh index 8928fc28f80..c2434b319b9 100755 --- a/docker/test/stateful_with_coverage/run.sh +++ b/docker/test/stateful_with_coverage/run.sh @@ -71,14 +71,26 @@ ln -s /usr/share/clickhouse-test/config/macros.xml /etc/clickhouse-server/config ln -s --backup=simple --suffix=_original.xml \ /usr/share/clickhouse-test/config/query_masking_rules.xml /etc/clickhouse-server/config.d/ +function start() +{ + counter=0 + until clickhouse-client --query "SELECT 1" + do + if [ "$counter" -gt 120 ] + then + echo "Cannot start clickhouse-server" + cat /var/log/clickhouse-server/stdout.log + tail -n1000 /var/log/clickhouse-server/stderr.log + tail -n1000 /var/log/clickhouse-server/clickhouse-server.log + break + fi + timeout 120 service clickhouse-server start + sleep 0.5 + counter=$(($counter + 1)) + done +} -service zookeeper start - -sleep 5 - -start_clickhouse - -sleep 5 +start if ! /s3downloader --dataset-names $DATASETS; then echo "Cannot download datatsets"