From e5c8c8ca022015025a7cdef1a67322fccc15b446 Mon Sep 17 00:00:00 2001 From: alesapin Date: Thu, 14 May 2020 15:45:42 +0300 Subject: [PATCH] Fix test --- ...ter_materialized_view_consistent.reference | 1 + ...1019_alter_materialized_view_consistent.sh | 35 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/queries/0_stateless/01019_alter_materialized_view_consistent.reference b/tests/queries/0_stateless/01019_alter_materialized_view_consistent.reference index 726246fba3f..a7bb9e4c153 100755 --- a/tests/queries/0_stateless/01019_alter_materialized_view_consistent.reference +++ b/tests/queries/0_stateless/01019_alter_materialized_view_consistent.reference @@ -1 +1,2 @@ +1 inconsistencies 0 diff --git a/tests/queries/0_stateless/01019_alter_materialized_view_consistent.sh b/tests/queries/0_stateless/01019_alter_materialized_view_consistent.sh index a4256499469..f3a272d091b 100755 --- a/tests/queries/0_stateless/01019_alter_materialized_view_consistent.sh +++ b/tests/queries/0_stateless/01019_alter_materialized_view_consistent.sh @@ -31,12 +31,18 @@ function insert_thread() { INSERT[1]="INSERT INTO TABLE src_b VALUES (2);" while true; do - # trigger 100 concurrent inserts at a time - for i in {0..100}; do + # trigger 50 concurrent inserts at a time + for i in {0..50}; do # ignore `Possible deadlock avoided. Client should retry` $CLICKHOUSE_CLIENT -q "${INSERT[$RANDOM % 2]}" 2>/dev/null & done wait + + 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 } @@ -50,28 +56,23 @@ function alter_thread() { $CLICKHOUSE_CLIENT --allow_experimental_alter_materialized_view_structure=1 \ -q "${ALTER[$RANDOM % 2]}" sleep "0.0$RANDOM" + + 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 } export -f insert_thread; export -f alter_thread; -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;") - - if [ "$is_done" -eq "1" ]; then - break - fi - done -} - -export -f check_thread -timeout 30 bash -c check_thread +# finishes much faster with all builds, except debug with coverage +timeout 120 bash -c insert_thread & +timeout 120 bash -c alter_thread & wait +$CLICKHOUSE_CLIENT -q "SELECT countIf(case = 1) > 0 AND countIf(case = 2) > 0 FROM mv LIMIT 1;" $CLICKHOUSE_CLIENT -q "SELECT 'inconsistencies', count() FROM mv WHERE test == 0;"