ClickHouse/tests/queries/0_stateless/02104_overcommit_memory.sh
Robert Schulze fe8f84dccc
Exclude slow tests from fasttest profile
99% of all tests in the fasttest profile run in one sec or less. The
excluded tests take 10 sec or more (the slowest being
02271_replace_partition_many_tables with 30 sec).

Estimated savings: 7 min
2022-09-07 15:57:29 +00:00

50 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Tags: no-parallel, no-fasttest
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
$CLICKHOUSE_CLIENT -q 'CREATE USER IF NOT EXISTS u02104 IDENTIFIED WITH no_password'
$CLICKHOUSE_CLIENT -q 'GRANT ALL ON *.* TO u02104'
function overcommited()
{
while true; do
$CLICKHOUSE_CLIENT -u u02104 -q 'SELECT number FROM numbers(130000) GROUP BY number SETTINGS memory_overcommit_ratio_denominator=1,memory_usage_overcommit_max_wait_microseconds=500' 2>&1 \
| grep -F -q "MEMORY_LIMIT_EXCEEDED" && echo "OVERCOMMITED WITH USER LIMIT IS KILLED"
done
}
function expect_execution()
{
while true; do
$CLICKHOUSE_CLIENT -u u02104 -q 'SELECT number FROM numbers(130000) GROUP BY number SETTINGS max_memory_usage_for_user=5000000,memory_overcommit_ratio_denominator=2,memory_usage_overcommit_max_wait_microseconds=500' >/dev/null 2>/dev/null
done
}
export -f overcommited
export -f expect_execution
function user_test()
{
for _ in {1..10};
do
timeout 10 bash -c overcommited &
timeout 10 bash -c expect_execution &
done;
wait
}
output=$(user_test)
if test -z "$output"
then
echo "OVERCOMMITED WITH USER LIMIT WAS NOT KILLED"
else
echo "OVERCOMMITED WITH USER LIMIT WAS KILLED"
fi
$CLICKHOUSE_CLIENT -q 'DROP USER IF EXISTS u02104'