Fix bad tests

This commit is contained in:
Alexey Milovidov 2020-05-13 02:55:16 +03:00
parent c57210736b
commit 1b42a6ccdc
2 changed files with 50 additions and 60 deletions

View File

@ -5,8 +5,6 @@ set -e
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
trap 'kill -9 $(jobs -p)' EXIT
$CLICKHOUSE_CLIENT --multiquery <<EOF
DROP TABLE IF EXISTS src;
DROP TABLE IF EXISTS mv;
@ -41,22 +39,15 @@ function alter_thread()
done
}
alter_thread &
alter_pid=$!
export -f alter_thread;
timeout 10 bash -c alter_thread &
for i in $(seq 1 100); do
(
for i in {1..100}; do
# Retry (hopefully retriable (deadlock avoided)) errors.
until false; do
while true; do
$CLICKHOUSE_CLIENT -q "INSERT INTO src VALUES (1);" 2>/dev/null && break
done
)
done
# Enough alters.
kill -INT $alter_pid
wait
# This was a fun ride.
$CLICKHOUSE_CLIENT -q "SELECT count() FROM mv;"
wait

View File

@ -5,8 +5,6 @@ set -e
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
trap 'kill -9 $(jobs -p)' EXIT
$CLICKHOUSE_CLIENT --multiquery <<EOF
DROP TABLE IF EXISTS src_a;
DROP TABLE IF EXISTS src_b;
@ -34,11 +32,10 @@ function insert_thread() {
while true; do
# trigger 100 concurrent inserts at a time
for i in $(seq 1 100); do
for i in {0..100}; do
# ignore `Possible deadlock avoided. Client should retry`
$CLICKHOUSE_CLIENT -q "${INSERT[$RANDOM % 2]}" 2>/dev/null &
done
wait
done
}
@ -56,12 +53,13 @@ function alter_thread() {
done
}
insert_thread &
insert_thread_pid=$!
export -f insert_thread;
export -f alter_thread;
alter_thread &
alter_thread_pid=$!
timeout 30 bash -c insert_thread &
timeout 30 bash -c alter_thread &
function check_thread() {
while true; do
is_done=$($CLICKHOUSE_CLIENT -q "SELECT countIf(case = 1) > 0 AND countIf(case = 2) > 0 FROM mv;")
@ -69,9 +67,10 @@ while true; do
break
fi
done
}
kill -INT $insert_thread_pid
kill -INT $alter_thread_pid
export -f check_thread
timeout 30 bash -c check_thread
wait