2020-06-21 14:34:34 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-09-12 12:35:27 +00:00
|
|
|
# Tags: no-replicated-database, no-parallel, no-fasttest
|
|
|
|
# Tag no-fasttest: max_memory_usage_for_user can interfere another queries running concurrently
|
2020-06-21 14:34:34 +00:00
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2020-12-28 11:46:53 +00:00
|
|
|
# shellcheck source=../shell_config.sh
|
2020-08-01 00:51:12 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
2020-06-21 14:34:34 +00:00
|
|
|
|
|
|
|
set -o pipefail
|
|
|
|
|
2024-07-29 11:00:21 +00:00
|
|
|
MISTER_USER="test_01238_http_$RANDOM"
|
|
|
|
# Create another user to check limit on the amount of memory reliabily
|
|
|
|
${CLICKHOUSE_CLIENT} --format Null -q "CREATE USER $MISTER_USER"
|
|
|
|
|
2020-06-21 14:34:34 +00:00
|
|
|
# This is needed to keep at least one running query for user for the time of test.
|
2020-06-21 23:44:13 +00:00
|
|
|
# (1k http queries takes ~1 second, let's run for 5x more to avoid flaps)
|
2024-09-07 16:21:06 +00:00
|
|
|
${CLICKHOUSE_CLIENT} --user ${MISTER_USER} --function_sleep_max_microseconds_per_block 5000000 --format Null <<<'SELECT sleepEachRow(1) FROM numbers(5)' &
|
2020-06-21 14:34:34 +00:00
|
|
|
|
|
|
|
# ignore "yes: standard output: Broken pipe"
|
|
|
|
yes 'SELECT 1' 2>/dev/null | {
|
2020-06-21 23:44:13 +00:00
|
|
|
head -n1000
|
2020-06-21 14:34:34 +00:00
|
|
|
} | {
|
2024-07-29 11:00:21 +00:00
|
|
|
xargs -I{} ${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}&user=${MISTER_USER}&wait_end_of_query=1&max_memory_usage_for_user=$((1<<30))" -d '{}'
|
2020-06-21 14:34:34 +00:00
|
|
|
} | grep -x -c 1
|
|
|
|
|
|
|
|
wait
|
2021-02-03 20:02:37 +00:00
|
|
|
|
|
|
|
# Reset max_memory_usage_for_user, so it will not affect other tests
|
2024-07-29 11:00:21 +00:00
|
|
|
${CLICKHOUSE_CLIENT} --user ${MISTER_USER} --max_memory_usage_for_user=0 -q "SELECT 1 FORMAT Null"
|