mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Fix bad tests
This commit is contained in:
parent
c57210736b
commit
1b42a6ccdc
@ -5,14 +5,12 @@ 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;
|
||||
|
||||
CREATE TABLE src(v UInt64) ENGINE = Null;
|
||||
CREATE MATERIALIZED VIEW mv(v UInt8) Engine = MergeTree() ORDER BY v AS SELECT v FROM src;
|
||||
CREATE TABLE src (v UInt64) ENGINE = Null;
|
||||
CREATE MATERIALIZED VIEW mv (v UInt8) Engine = MergeTree() ORDER BY v AS SELECT v FROM src;
|
||||
EOF
|
||||
|
||||
# Test that ALTER doesn't cause data loss or duplication.
|
||||
@ -30,33 +28,26 @@ EOF
|
||||
|
||||
function alter_thread()
|
||||
{
|
||||
trap 'exit' INT
|
||||
trap 'exit' INT
|
||||
|
||||
ALTERS[0]="ALTER TABLE mv MODIFY QUERY SELECT v FROM src;"
|
||||
ALTERS[1]="ALTER TABLE mv MODIFY QUERY SELECT v * 2 as v FROM src;"
|
||||
ALTERS[0]="ALTER TABLE mv MODIFY QUERY SELECT v FROM src;"
|
||||
ALTERS[1]="ALTER TABLE mv MODIFY QUERY SELECT v * 2 as v FROM src;"
|
||||
|
||||
while true; do
|
||||
$CLICKHOUSE_CLIENT --allow_experimental_alter_materialized_view_structure=1 -q "${ALTERS[$RANDOM % 2]}"
|
||||
sleep `echo 0.$RANDOM`;
|
||||
done
|
||||
while true; do
|
||||
$CLICKHOUSE_CLIENT --allow_experimental_alter_materialized_view_structure=1 -q "${ALTERS[$RANDOM % 2]}"
|
||||
sleep `echo 0.$RANDOM`;
|
||||
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
|
||||
|
@ -5,18 +5,16 @@ 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;
|
||||
|
||||
DROP TABLE IF EXISTS mv;
|
||||
|
||||
CREATE TABLE src_a(v UInt64) ENGINE = Null;
|
||||
CREATE TABLE src_b(v UInt64) ENGINE = Null;
|
||||
CREATE TABLE src_a (v UInt64) ENGINE = Null;
|
||||
CREATE TABLE src_b (v UInt64) ENGINE = Null;
|
||||
|
||||
CREATE MATERIALIZED VIEW mv(test UInt8, case UInt8)
|
||||
CREATE MATERIALIZED VIEW mv (test UInt8, case UInt8)
|
||||
Engine = MergeTree()
|
||||
ORDER BY test AS
|
||||
SELECT v == 1 as test, v as case FROM src_a;
|
||||
@ -26,52 +24,53 @@ EOF
|
||||
# Also, helps detect data races.
|
||||
|
||||
function insert_thread() {
|
||||
# Always wait for all background INSERTs to finish to catch stuck queries.
|
||||
trap 'wait; exit;' INT
|
||||
# Always wait for all background INSERTs to finish to catch stuck queries.
|
||||
trap 'wait; exit;' INT
|
||||
|
||||
INSERT[0]="INSERT INTO TABLE src_a VALUES (1);"
|
||||
INSERT[1]="INSERT INTO TABLE src_b VALUES (2);"
|
||||
INSERT[0]="INSERT INTO TABLE src_a VALUES (1);"
|
||||
INSERT[1]="INSERT INTO TABLE src_b VALUES (2);"
|
||||
|
||||
while true; do
|
||||
# trigger 100 concurrent inserts at a time
|
||||
for i in $(seq 1 100); do
|
||||
# ignore `Possible deadlock avoided. Client should retry`
|
||||
$CLICKHOUSE_CLIENT -q "${INSERT[$RANDOM % 2]}" 2>/dev/null &
|
||||
while true; do
|
||||
# trigger 100 concurrent inserts at a time
|
||||
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
|
||||
|
||||
wait
|
||||
done
|
||||
}
|
||||
|
||||
function alter_thread() {
|
||||
trap 'exit' INT
|
||||
trap 'exit' INT
|
||||
|
||||
ALTER[0]="ALTER TABLE mv MODIFY QUERY SELECT v == 1 as test, v as case FROM src_a;"
|
||||
ALTER[1]="ALTER TABLE mv MODIFY QUERY SELECT v == 2 as test, v as case FROM src_b;"
|
||||
ALTER[0]="ALTER TABLE mv MODIFY QUERY SELECT v == 1 as test, v as case FROM src_a;"
|
||||
ALTER[1]="ALTER TABLE mv MODIFY QUERY SELECT v == 2 as test, v as case FROM src_b;"
|
||||
|
||||
while true; do
|
||||
$CLICKHOUSE_CLIENT --allow_experimental_alter_materialized_view_structure=1 \
|
||||
-q "${ALTER[$RANDOM % 2]}"
|
||||
sleep "0.0$RANDOM"
|
||||
done
|
||||
while true; do
|
||||
$CLICKHOUSE_CLIENT --allow_experimental_alter_materialized_view_structure=1 \
|
||||
-q "${ALTER[$RANDOM % 2]}"
|
||||
sleep "0.0$RANDOM"
|
||||
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 &
|
||||
|
||||
while true; do
|
||||
is_done=$($CLICKHOUSE_CLIENT -q "SELECT countIf(case = 1) > 0 AND countIf(case = 2) > 0 FROM mv;")
|
||||
function check_thread() {
|
||||
while true; do
|
||||
is_done=$($CLICKHOUSE_CLIENT -q "SELECT countIf(case = 1) > 0 AND countIf(case = 2) > 0 FROM mv;")
|
||||
|
||||
if [ "$is_done" -eq "1" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$is_done" -eq "1" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
kill -INT $insert_thread_pid
|
||||
kill -INT $alter_thread_pid
|
||||
export -f check_thread
|
||||
timeout 30 bash -c check_thread
|
||||
|
||||
wait
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user