mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 06:01:57 +00:00
51 lines
1.7 KiB
Bash
Executable File
51 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
# shellcheck source=../shell_config.sh
|
|
. "$CURDIR"/../shell_config.sh
|
|
|
|
$CLICKHOUSE_CLIENT -q 'SELECT number FROM numbers(10000000) GROUP BY number SETTINGS max_memory_usage_for_user = 1' 2>&1 | grep -F -q "MEMORY_LIMIT_EXCEEDED" && echo 'OK' || echo 'FAIL'
|
|
$CLICKHOUSE_CLIENT -q 'SELECT number FROM numbers(10000000) GROUP BY number SETTINGS max_guaranteed_memory_usage_for_user = 1' 2>&1 | grep -F -q "MEMORY_LIMIT_EXCEEDED" && echo 'FAIL' || echo 'OK'
|
|
|
|
$CLICKHOUSE_CLIENT -q 'CREATE USER IF NOT EXISTS u1 IDENTIFIED WITH no_password'
|
|
$CLICKHOUSE_CLIENT -q 'GRANT ALL ON *.* TO u1'
|
|
|
|
function overcommited()
|
|
{
|
|
while true; do
|
|
$CLICKHOUSE_CLIENT -u u1 -q 'SELECT number FROM numbers(130000) GROUP BY number SETTINGS max_guaranteed_memory_usage=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 u1 -q 'SELECT number FROM numbers(130000) GROUP BY number SETTINGS max_memory_usage_for_user=5000000,max_guaranteed_memory_usage=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 3 bash -c overcommited &
|
|
timeout 3 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 u1'
|