Merge pull request #58560 from vitlibar/fix-test-02932_kill_query_sleep

Fix test 02932_kill_query_sleep
This commit is contained in:
Alexey Milovidov 2024-01-06 21:59:16 +01:00 committed by GitHub
commit ef1e50091d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,18 +8,31 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
function wait_query_started()
{
local query_id="$1"
$CLICKHOUSE_CLIENT --query "SYSTEM FLUSH LOGS"
while [[ $($CLICKHOUSE_CLIENT --query="SELECT count() FROM system.query_log WHERE query_id='$query_id' AND current_database = currentDatabase()") == 0 ]]; do
sleep 0.1;
$CLICKHOUSE_CLIENT --query "SYSTEM FLUSH LOGS;"
timeout=60
start=$EPOCHSECONDS
while [[ $($CLICKHOUSE_CLIENT --query="SELECT count() FROM system.processes WHERE query_id='$query_id'") == 0 ]]; do
if ((EPOCHSECONDS-start > timeout )); then
echo "Timeout while waiting for query $query_id to start"
exit 1
fi
sleep 0.1
done
}
function kill_query()
{
local query_id="$1"
$CLICKHOUSE_CLIENT --query "KILL QUERY WHERE query_id='$query_id'" >/dev/null
while [[ $($CLICKHOUSE_CLIENT --query="SELECT count() FROM system.processes WHERE query_id='$query_id'") != 0 ]]; do sleep 0.1; done
timeout=60
start=$EPOCHSECONDS
while [[ $($CLICKHOUSE_CLIENT --query="SELECT count() FROM system.processes WHERE query_id='$query_id'") != 0 ]]; do
if ((EPOCHSECONDS-start > timeout )); then
echo "Timeout while waiting for query $query_id to cancel"
exit 1
fi
sleep 0.1
done
}