Use system.text_log in test

This commit is contained in:
Amos Bird 2021-10-11 18:07:00 +08:00
parent ebfb013ea1
commit a07ce98121
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4

View File

@ -4,8 +4,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
function wait_for_query_to_start()
{
function wait_for_query_to_start() {
while [[ $($CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL" -d "SELECT sum(read_rows) FROM system.processes WHERE query_id = '$1'") == 0 ]]; do sleep 0.1; done
}
@ -21,14 +20,14 @@ insert into simple select number, number + 100 from numbers(5000);
query_id="long_running_query-$CLICKHOUSE_DATABASE"
echo "Spin up a long running query"
${CLICKHOUSE_CLIENT} --query "select sleepEachRow(0.1) from simple settings max_block_size = 1 format Null" --query_id "$query_id" > /dev/null 2>&1 &
${CLICKHOUSE_CLIENT} --query "select sleepEachRow(0.1) from simple settings max_block_size = 1 format Null" --query_id "$query_id" >/dev/null 2>&1 &
wait_for_query_to_start "$query_id"
# query which reads marks >= min_marks_to_honor_max_concurrent_queries is throttled
echo "Check if another query with some marks to read is throttled"
${CLICKHOUSE_CLIENT} --query "select * from simple" 2> /dev/null;
${CLICKHOUSE_CLIENT} --query "select * from simple" 2>/dev/null
CODE=$?
[ "$CODE" -ne "202" ] && echo "Expected error code: 202 but got: $CODE" && exit 1;
[ "$CODE" -ne "202" ] && echo "Expected error code: 202 but got: $CODE" && exit 1
echo "yes"
# query which reads marks less than min_marks_to_honor_max_concurrent_queries is allowed
@ -41,9 +40,9 @@ ${CLICKHOUSE_CLIENT} --query "alter table simple modify setting min_marks_to_hon
# Now smaller queries are also throttled
echo "Check if another query with less marks to read is throttled"
${CLICKHOUSE_CLIENT} --query "select * from simple where i = 0" 2> /dev/null;
${CLICKHOUSE_CLIENT} --query "select * from simple where i = 0" 2>/dev/null
CODE=$?
[ "$CODE" -ne "202" ] && echo "Expected error code: 202 but got: $CODE" && exit 1;
[ "$CODE" -ne "202" ] && echo "Expected error code: 202 but got: $CODE" && exit 1
echo "yes"
echo "Modify max_concurrent_queries to 2"
@ -58,9 +57,9 @@ ${CLICKHOUSE_CLIENT} --query "alter table simple modify setting max_concurrent_q
# Now queries are throttled again
echo "Check if another query with less marks to read is throttled"
${CLICKHOUSE_CLIENT} --query "select * from simple where i = 0" 2> /dev/null;
${CLICKHOUSE_CLIENT} --query "select * from simple where i = 0" 2>/dev/null
CODE=$?
[ "$CODE" -ne "202" ] && echo "Expected error code: 202 but got: $CODE" && exit 1;
[ "$CODE" -ne "202" ] && echo "Expected error code: 202 but got: $CODE" && exit 1
echo "yes"
${CLICKHOUSE_CLIENT} --query "KILL QUERY WHERE query_id = '$query_id' SYNC FORMAT Null"
@ -70,10 +69,9 @@ wait
query_id=max_concurrent_queries_$RANDOM
${CLICKHOUSE_CLIENT} --query_id "$query_id" --query "select i from simple where j in (select i from simple where i < 10)"
# We have to grep the server's error log because the following warning message
# We have to search the server's error log because the following warning message
# is generated during pipeline destruction and thus is not sent to the client.
grep -E -q "{$query_id} <Warning>.*We have query_id removed but it's not recorded. This is a bug" /var/log/clickhouse-server/clickhouse-server.err.log && exit 1
${CLICKHOUSE_CLIENT} --query "system flush logs"
if [[ $(${CLICKHOUSE_CLIENT} --query "select count() > 0 from system.text_log where query_id = '$query_id' and level = 'Warning' and message like '%We have query_id removed but it\'s not recorded. This is a bug%' format TSVRaw") == 1 ]]; then echo "We have query_id removed but it's not recorded. This is a bug." >&2; exit 1; fi
${CLICKHOUSE_CLIENT} --multiline --multiquery --query "
drop table simple
"
${CLICKHOUSE_CLIENT} --query "drop table simple"