ClickHouse/tests/queries/0_stateless/02015_async_inserts_stress_long.sh
Azat Khuzhin d28963d695 tests: do not leave any queries after finish
This should fix issues like [1], where because one query from the
previous test was left the next fails, in this particular report the
problem was that 01281_group_by_limit_memory_tracking fails due to the
query from 01301_aggregate_state_exception_memory_leak was running in
background.

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/34919/311f884d3d4215f7f82c2dd66ea51d071d313241/stateless_tests__thread__actions__[2/3].html

v2: wait for queries in 01249_flush_interactive
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-03-09 17:29:33 +03:00

80 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Tags: no-random-settings
set -e
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
function insert1()
{
url="${CLICKHOUSE_URL}&async_insert=1&wait_for_async_insert=0"
while true; do
${CLICKHOUSE_CURL} -sS "$url" -d 'INSERT INTO async_inserts FORMAT CSV
1,"a"
2,"b"
'
done
}
function insert2()
{
url="${CLICKHOUSE_URL}&async_insert=1&wait_for_async_insert=0"
while true; do
${CLICKHOUSE_CURL} -sS "$url" -d 'INSERT INTO async_inserts FORMAT JSONEachRow {"id": 5, "s": "e"} {"id": 6, "s": "f"}'
done
}
function insert3()
{
url="${CLICKHOUSE_URL}&async_insert=1&wait_for_async_insert=0"
while true; do
${CLICKHOUSE_CURL} -sS "$url" -d "INSERT INTO FUNCTION remote('127.0.0.1', $CLICKHOUSE_DATABASE, async_inserts) VALUES (7, 'g') (8, 'h')"
done
}
function select1()
{
${CLICKHOUSE_CLIENT} -q "SELECT * FROM async_inserts FORMAT Null"
}
function select2()
{
${CLICKHOUSE_CLIENT} -q "SELECT * FROM system.asynchronous_inserts FORMAT Null"
}
function truncate1()
{
sleep 0.1
${CLICKHOUSE_CLIENT} -q "TRUNCATE TABLE async_inserts"
}
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS async_inserts"
${CLICKHOUSE_CLIENT} -q "CREATE TABLE async_inserts (id UInt32, s String) ENGINE = MergeTree ORDER BY id"
TIMEOUT=10
export -f insert1
export -f insert2
export -f insert3
export -f select1
export -f select2
export -f truncate1
for _ in {1..5}; do
timeout $TIMEOUT bash -c insert1 &
timeout $TIMEOUT bash -c insert2 &
timeout $TIMEOUT bash -c insert3 &
done
clickhouse_client_loop_timeout $TIMEOUT select1 &
clickhouse_client_loop_timeout $TIMEOUT select2 &
clickhouse_client_loop_timeout $TIMEOUT truncate1 &
wait
echo "OK"
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS async_inserts";