From 180055b577bda453830518c6dbbe44a95ea2005d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mar=C3=ADn?= Date: Mon, 6 Dec 2021 12:50:46 +0100 Subject: [PATCH] Test that scalar queries can be killed --- .../02132_kill_scalar_queries.reference | 4 ++++ .../0_stateless/02132_kill_scalar_queries.sh | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/queries/0_stateless/02132_kill_scalar_queries.reference create mode 100755 tests/queries/0_stateless/02132_kill_scalar_queries.sh diff --git a/tests/queries/0_stateless/02132_kill_scalar_queries.reference b/tests/queries/0_stateless/02132_kill_scalar_queries.reference new file mode 100644 index 00000000000..7d0d98e85f0 --- /dev/null +++ b/tests/queries/0_stateless/02132_kill_scalar_queries.reference @@ -0,0 +1,4 @@ +OK +finished default_TEST02132KILL_QUERY1 default select (SELECT max(number) from system.numbers) + 1; +OK +finished default_TEST02132KILL_QUERY2 default SELECT (SELECT number FROM system.numbers WHERE number = 1000000000000); diff --git a/tests/queries/0_stateless/02132_kill_scalar_queries.sh b/tests/queries/0_stateless/02132_kill_scalar_queries.sh new file mode 100755 index 00000000000..ae7348a1f0b --- /dev/null +++ b/tests/queries/0_stateless/02132_kill_scalar_queries.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Ref: https://github.com/ClickHouse/ClickHouse/issues/1576 +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +function wait_for_query_to_start() +{ + while [[ $($CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL" -d "SELECT count() FROM system.processes WHERE query_id = '$1'") == 0 ]]; do sleep 0.1; done +} + +QUERY_1_ID="${CLICKHOUSE_DATABASE}_TEST02132KILL_QUERY1" +(${CLICKHOUSE_CLIENT} --query_id="${QUERY_1_ID}" --query='select (SELECT max(number) from system.numbers) + 1;' 2>&1 | grep -q "Code: 394." && echo 'OK' || echo 'FAIL' ||: ) & +wait_for_query_to_start "${QUERY_1_ID}" +${CLICKHOUSE_CLIENT} --query="KILL QUERY WHERE query_id='${QUERY_1_ID}' SYNC" + +QUERY_2_ID="${CLICKHOUSE_DATABASE}_TEST02132KILL_QUERY2" +(${CLICKHOUSE_CLIENT} --query_id="${QUERY_2_ID}" --query='SELECT (SELECT number FROM system.numbers WHERE number = 1000000000000);' 2>&1 | grep -q "Code: 394." && echo 'OK' || echo 'FAIL' ||: ) & +wait_for_query_to_start "${QUERY_2_ID}" +${CLICKHOUSE_CLIENT} --query="KILL QUERY WHERE query_id='${QUERY_2_ID}' SYNC" +