mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
a more stable test
This commit is contained in:
parent
2259387f0c
commit
852ee7e26a
@ -1 +1 @@
|
||||
138
|
||||
OK
|
||||
|
@ -6,17 +6,36 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
function wait_for_query_to_start()
|
||||
{
|
||||
while [[ $($CLICKHOUSE_CLIENT --query "SELECT count() FROM system.processes WHERE query_id = '$1' and current_database = currentDatabase()") == 0 ]]; do sleep 0.1; done
|
||||
}
|
||||
|
||||
# Run a test query that takes very long to run.
|
||||
query_id="01572_kill_window_function"
|
||||
$CLICKHOUSE_CLIENT --query_id="$query_id" --query "SELECT count(1048575) OVER (PARTITION BY intDiv(NULL, number) ORDER BY number DESC NULLS FIRST ROWS BETWEEN CURRENT ROW AND 1048575 FOLLOWING) FROM numbers(255, 1048575)" >/dev/null 2>&1 &
|
||||
client_pid=$!
|
||||
wait_for_query_to_start "$query_id"
|
||||
$CLICKHOUSE_CLIENT --query "kill query where query_id = '$query_id' and current_database = currentDatabase() format Null"
|
||||
wait $client_pid || echo $?
|
||||
|
||||
# First check that clickhouse-client is still alive, and then use one query to
|
||||
# both kill the test query and verify that it has started.
|
||||
# If we try to kill it before it starts, the test will fail.
|
||||
# If it finishes after we check it started, the test will fail.
|
||||
# That's why it is better to check and kill with the same call.
|
||||
while kill -0 $client_pid \
|
||||
&& [ -z "$(CLICKHOUSE_CLIENT --query "kill query where query_id = '$query_id' and current_database = currentDatabase()")" ]
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Wait for the client to terminate.
|
||||
client_exit_code=0
|
||||
wait $client_pid || client_exit_code=$?
|
||||
|
||||
# Note that we still have to check for normal termination, because the test query
|
||||
# might have completed even before we first tried to kill it. This shouldn't
|
||||
# really happen because it's very long, but our CI infractructure is known to
|
||||
# introduce the most unexpected delays.
|
||||
if [ $client_exit_code -eq 0 ] || [ $client_exit_code -eq 138 ]
|
||||
then
|
||||
echo "OK"
|
||||
else
|
||||
echo "Got unexpected client exit code $client_exit_code"
|
||||
fi
|
||||
|
||||
# We have tested for Ctrl+C.
|
||||
# The following client flags don't cancel, but should: --max_execution_time,
|
||||
|
Loading…
Reference in New Issue
Block a user