ClickHouse/tests/queries/0_stateless/02290_client_insert_cancel.sh
Azat Khuzhin 22189b0a5a Properly cancel INSERT queries in clickhouse-client
This will also fix issues like queries left after the test, like in [1].

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/36686/042cf0c76444e8738eb2481ae21a135f05b4c990/stateless_tests__debug__actions__[2/3]/runlog.log

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-04-27 20:00:27 +03:00

19 lines
609 B
Bash
Executable File

#!/usr/bin/env bash
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
yes 1 | $CLICKHOUSE_CLIENT --query_id "$CLICKHOUSE_TEST_UNIQUE_NAME" -q "insert into function null('n Int') format TSV" &
client_pid=$!
# wait for the query
while [ "$($CLICKHOUSE_CLIENT -q "select count() from system.processes where query_id = '$CLICKHOUSE_TEST_UNIQUE_NAME'")" = 0 ]; do
sleep 0.1
done
kill -INT $client_pid
wait $client_pid
# if client does not cancel it properly (i.e. cancel the query), then return code will be 2, otherwise 0
echo $?