ClickHouse/tests/queries/0_stateless/02015_async_inserts_stress_long.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
1.9 KiB
Bash
Raw Normal View History

2021-09-09 17:17:19 +00:00
#!/usr/bin/env bash
# Tags: no-random-settings, no-fasttest
2022-03-05 16:17:08 +00:00
2021-09-09 17:17:19 +00:00
set -e
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
2022-03-05 16:17:08 +00:00
2021-09-09 17:17:19 +00:00
function insert1()
{
2021-09-16 17:18:34 +00:00
url="${CLICKHOUSE_URL}&async_insert=1&wait_for_async_insert=0"
2021-09-09 17:17:19 +00:00
while true; do
${CLICKHOUSE_CURL} -sS "$url" -d 'INSERT INTO async_inserts FORMAT CSV
1,"a"
2,"b"
'
done
}
function insert2()
{
2021-09-16 17:18:34 +00:00
url="${CLICKHOUSE_URL}&async_insert=1&wait_for_async_insert=0"
2021-09-09 17:17:19 +00:00
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
}
2021-09-09 17:17:19 +00:00
function select1()
{
while true; do
${CLICKHOUSE_CLIENT} -q "SELECT * FROM async_inserts FORMAT Null"
done
2021-09-09 17:17:19 +00:00
}
function select2()
{
while true; do
${CLICKHOUSE_CLIENT} -q "SELECT * FROM system.asynchronous_inserts FORMAT Null"
done
2021-09-09 17:17:19 +00:00
}
function truncate1()
{
while true; do
sleep 0.1
${CLICKHOUSE_CLIENT} -q "TRUNCATE TABLE async_inserts"
done
2021-09-09 17:17:19 +00:00
}
${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
2021-09-09 17:17:19 +00:00
export -f select1
export -f select2
export -f truncate1
2021-09-09 17:17:19 +00:00
for _ in {1..5}; do
timeout $TIMEOUT bash -c insert1 &
timeout $TIMEOUT bash -c insert2 &
timeout $TIMEOUT bash -c insert3 &
2021-09-09 17:17:19 +00:00
done
timeout $TIMEOUT bash -c select1 &
timeout $TIMEOUT bash -c select2 &
timeout $TIMEOUT bash -c truncate1 &
2021-09-09 17:17:19 +00:00
wait
echo "OK"
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS async_inserts";