2020-05-01 18:47:41 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Sandbox does not provide CAP_NET_ADMIN capability but does have ProcFS mounted at /proc
|
|
|
|
# This ensures that OS metrics can be collected
|
|
|
|
|
|
|
|
|
|
|
|
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-05-01 18:47:41 +00:00
|
|
|
|
|
|
|
function read_numbers_func()
|
|
|
|
{
|
|
|
|
$CLICKHOUSE_CLIENT -q "
|
|
|
|
SELECT * FROM numbers(600000000) FORMAT Null SETTINGS max_threads = 1
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function show_processes_func()
|
|
|
|
{
|
2020-06-08 23:55:53 +00:00
|
|
|
while true; do
|
|
|
|
sleep 0.1;
|
|
|
|
|
|
|
|
# These two system metrics for the generating query above are guaranteed to be nonzero when ProcFS is mounted at /proc
|
|
|
|
$CLICKHOUSE_CLIENT -q "
|
|
|
|
SELECT count() > 0 FROM system.processes\
|
2021-01-21 05:08:40 +00:00
|
|
|
WHERE ProfileEvents['OSCPUVirtualTimeMicroseconds'] > 0 AND ProfileEvents['OSReadChars'] > 0 \
|
2020-06-08 23:55:53 +00:00
|
|
|
SETTINGS max_threads = 1
|
|
|
|
" | grep '1' && break;
|
|
|
|
done
|
2020-05-01 18:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export -f read_numbers_func;
|
|
|
|
export -f show_processes_func;
|
|
|
|
|
|
|
|
TIMEOUT=3
|
|
|
|
|
|
|
|
timeout $TIMEOUT bash -c read_numbers_func &
|
|
|
|
timeout $TIMEOUT bash -c show_processes_func &
|
|
|
|
|
|
|
|
wait
|
|
|
|
|
2022-03-28 13:29:13 +00:00
|
|
|
# otherwise it can be alive after test
|
2022-03-28 13:39:02 +00:00
|
|
|
query_alive=$($CLICKHOUSE_CLIENT --query "SELECT count() FROM system.processes WHERE query ILIKE 'SELECT * FROM numbers(600000000)%'")
|
|
|
|
while [[ $query_alive != 0 ]]
|
|
|
|
do
|
|
|
|
$CLICKHOUSE_CLIENT -q "KILL QUERY WHERE query ilike '%SELECT * FROM numbers(600000000)%'" 2> /dev/null 1> /dev/null
|
|
|
|
sleep 0.5
|
|
|
|
query_alive=$($CLICKHOUSE_CLIENT --query "SELECT count() FROM system.processes WHERE query ILIKE 'SELECT * FROM numbers(600000000)%'")
|
|
|
|
done
|
2022-03-28 13:29:13 +00:00
|
|
|
|
2020-05-01 18:47:41 +00:00
|
|
|
echo "Test OK"
|