From 0e53cd26a0d514bc2b1b6b59d2a9574d851cbc30 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 4 Sep 2020 02:28:44 +0300 Subject: [PATCH] Simplify tests for mutations --- .../00652_mutations_alter_update.sh | 20 +++++----------- .../00652_mutations_default_database.sh | 6 +---- .../0_stateless/00682_empty_parts_merge.sh | 24 ++++++------------- .../00699_materialized_view_mutations.sh | 15 +++--------- .../queries/0_stateless/00942_mutate_index.sh | 6 +---- .../00944_clear_index_in_partition.sh | 9 ++----- ...01031_mutations_interpreter_and_context.sh | 6 +---- .../01035_lc_empty_part_bug.reference | 2 +- .../0_stateless/01035_lc_empty_part_bug.sh | 9 +++---- 9 files changed, 25 insertions(+), 72 deletions(-) diff --git a/tests/queries/0_stateless/00652_mutations_alter_update.sh b/tests/queries/0_stateless/00652_mutations_alter_update.sh index f551872da6c..83a5e18d4ae 100755 --- a/tests/queries/0_stateless/00652_mutations_alter_update.sh +++ b/tests/queries/0_stateless/00652_mutations_alter_update.sh @@ -3,8 +3,6 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh -. "$CURDIR"/mergetree_mutations.lib - ${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS alter_update" ${CLICKHOUSE_CLIENT} --query="CREATE TABLE alter_update \ @@ -26,8 +24,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES \ ('2000-01-01', 123, 'abc', 1), \ ('2000-01-01', 234, 'cde', 2)" -${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update UPDATE value1 = 'aaa', value2 = value2 + 100 WHERE key < 200" -wait_for_mutation "alter_update" "mutation_2.txt" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update UPDATE value1 = 'aaa', value2 = value2 + 100 WHERE key < 200" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key" @@ -40,8 +37,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES ('2000-01-01', 123 ${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \ UPDATE value2 = (value2 + 1) / 2 WHERE 1, \ - UPDATE value2 = value2 + 1 WHERE 1" -wait_for_mutation "alter_update" "mutation_4.txt" + UPDATE value2 = value2 + 1 WHERE 1" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key" @@ -59,8 +55,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES \ ${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \ DELETE WHERE key IN (SELECT toUInt32(arrayJoin([121, 122, 123]))), \ UPDATE value1 = concat(value1, 'ccc') WHERE value2 IN (20, 30), \ - UPDATE value1 = 'iii' WHERE value2 IN (SELECT toUInt64(40))" -wait_for_mutation "alter_update" "mutation_6.txt" + UPDATE value1 = 'iii' WHERE value2 IN (SELECT toUInt64(40))" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key" @@ -75,8 +70,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES \ ${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \ UPDATE value2 = value2 + 10 WHERE 1, \ - DELETE WHERE value2 = 20" -wait_for_mutation "alter_update" "mutation_8.txt" + DELETE WHERE value2 = 20" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key" @@ -96,8 +90,7 @@ ${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \ UPDATE value2 = value2 + 10 WHERE value2 <= 10, \ DELETE WHERE length(value1) + value2 = 23, \ DELETE WHERE materialized_value = 'materialized_37', \ - UPDATE value1 = concat(value1, '_', materialized_value) WHERE key = 456" -wait_for_mutation "alter_update" "mutation_10.txt" + UPDATE value1 = concat(value1, '_', materialized_value) WHERE key = 456" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key" @@ -123,8 +116,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES \ ('2000-01-01', 456, 'ijk', 40)" ${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \ - UPDATE value2 = value2 + 7 WHERE value2 <= 20" -wait_for_mutation "alter_update" "mutation_12.txt" + UPDATE value2 = value2 + 7 WHERE value2 <= 20" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="SELECT value2, materialized_value FROM alter_update ORDER BY key" diff --git a/tests/queries/0_stateless/00652_mutations_default_database.sh b/tests/queries/0_stateless/00652_mutations_default_database.sh index c5b406b8c8e..78aa0e88c36 100755 --- a/tests/queries/0_stateless/00652_mutations_default_database.sh +++ b/tests/queries/0_stateless/00652_mutations_default_database.sh @@ -3,9 +3,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh -. "$CURDIR"/mergetree_mutations.lib - -${CLICKHOUSE_CLIENT} --multiquery << EOF +${CLICKHOUSE_CLIENT} --multiquery --mutations_sync=1 << EOF DROP TABLE IF EXISTS mutations; DROP TABLE IF EXISTS for_subquery; @@ -19,8 +17,6 @@ ALTER TABLE mutations UPDATE y = y + 1 WHERE x IN for_subquery; ALTER TABLE mutations UPDATE y = y + 1 WHERE x IN (SELECT x FROM for_subquery); EOF -wait_for_mutation "mutations" "mutation_3.txt" - ${CLICKHOUSE_CLIENT} --query="SELECT * FROM mutations" ${CLICKHOUSE_CLIENT} --query="DROP TABLE mutations" diff --git a/tests/queries/0_stateless/00682_empty_parts_merge.sh b/tests/queries/0_stateless/00682_empty_parts_merge.sh index ce9e0ab95eb..03915e3f5e4 100755 --- a/tests/queries/0_stateless/00682_empty_parts_merge.sh +++ b/tests/queries/0_stateless/00682_empty_parts_merge.sh @@ -3,17 +3,13 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh -. "$CURDIR"/mergetree_mutations.lib - - ${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS ordinary_00682" ${CLICKHOUSE_CLIENT} --query="CREATE TABLE ordinary_00682(k UInt32) ENGINE MergeTree ORDER BY k" ${CLICKHOUSE_CLIENT} --query="INSERT INTO ordinary_00682(k) VALUES (1)" ${CLICKHOUSE_CLIENT} --query="INSERT INTO ordinary_00682(k) VALUES (1)" -${CLICKHOUSE_CLIENT} --query="ALTER TABLE ordinary_00682 DELETE WHERE k = 1" -wait_for_mutation "ordinary_00682" "mutation_3.txt" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE ordinary_00682 DELETE WHERE k = 1" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE ordinary_00682 PARTITION tuple() FINAL" ${CLICKHOUSE_CLIENT} --query="SELECT * FROM ordinary_00682" @@ -32,8 +28,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE vertical_00682(k UInt32, v UInt32) EN ${CLICKHOUSE_CLIENT} --query="INSERT INTO vertical_00682(k, v) VALUES (1, 1)" ${CLICKHOUSE_CLIENT} --query="INSERT INTO vertical_00682(k, v) VALUES (2, 2)" -${CLICKHOUSE_CLIENT} --query="ALTER TABLE vertical_00682 DELETE WHERE k = 1" -wait_for_mutation "vertical_00682" "mutation_3.txt" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE vertical_00682 DELETE WHERE k = 1" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE vertical_00682 PARTITION tuple() FINAL" ${CLICKHOUSE_CLIENT} --query="SELECT * FROM vertical_00682" @@ -47,8 +42,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE summing_00682(k UInt32, v UInt32) ENG ${CLICKHOUSE_CLIENT} --query="INSERT INTO summing_00682(k, v) VALUES (1, 1)" ${CLICKHOUSE_CLIENT} --query="INSERT INTO summing_00682(k, v) VALUES (1, 2)" -${CLICKHOUSE_CLIENT} --query="ALTER TABLE summing_00682 DELETE WHERE k = 1" -wait_for_mutation "summing_00682" "mutation_3.txt" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE summing_00682 DELETE WHERE k = 1" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE summing_00682 PARTITION tuple() FINAL" ${CLICKHOUSE_CLIENT} --query="SELECT * FROM summing_00682" @@ -62,8 +56,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE aggregating_00682(k UInt32, v Aggrega ${CLICKHOUSE_CLIENT} --query="INSERT INTO aggregating_00682(k) VALUES (1)" ${CLICKHOUSE_CLIENT} --query="INSERT INTO aggregating_00682(k) VALUES (1)" -${CLICKHOUSE_CLIENT} --query="ALTER TABLE aggregating_00682 DELETE WHERE k = 1" -wait_for_mutation "aggregating_00682" "mutation_3.txt" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE aggregating_00682 DELETE WHERE k = 1" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE aggregating_00682 PARTITION tuple() FINAL" ${CLICKHOUSE_CLIENT} --query="SELECT * FROM aggregating_00682" @@ -77,8 +70,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE replacing_00682(k UInt32, v String) E ${CLICKHOUSE_CLIENT} --query="INSERT INTO replacing_00682(k, v) VALUES (1, 'a')" ${CLICKHOUSE_CLIENT} --query="INSERT INTO replacing_00682(k, v) VALUES (1, 'b')" -${CLICKHOUSE_CLIENT} --query="ALTER TABLE replacing_00682 DELETE WHERE k = 1" -wait_for_mutation "replacing_00682" "mutation_3.txt" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE replacing_00682 DELETE WHERE k = 1" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE replacing_00682 PARTITION tuple() FINAL" ${CLICKHOUSE_CLIENT} --query="SELECT * FROM replacing_00682" @@ -92,8 +84,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE collapsing_00682(k UInt32, v String, ${CLICKHOUSE_CLIENT} --query="INSERT INTO collapsing_00682(k, v, s) VALUES (1, 'a', 1)" ${CLICKHOUSE_CLIENT} --query="INSERT INTO collapsing_00682(k, v, s) VALUES (2, 'b', 1)" -${CLICKHOUSE_CLIENT} --query="ALTER TABLE collapsing_00682 DELETE WHERE k IN (1, 2)" -wait_for_mutation "collapsing_00682" "mutation_3.txt" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE collapsing_00682 DELETE WHERE k IN (1, 2)" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE collapsing_00682 PARTITION tuple() FINAL" ${CLICKHOUSE_CLIENT} --query="SELECT * FROM collapsing_00682" @@ -107,8 +98,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE versioned_collapsing_00682(k UInt32, ${CLICKHOUSE_CLIENT} --query="INSERT INTO versioned_collapsing_00682(k, val, ver, s) VALUES (1, 'a', 0, 1)" ${CLICKHOUSE_CLIENT} --query="INSERT INTO versioned_collapsing_00682(k, val, ver, s) VALUES (2, 'b', 0, 1)" -${CLICKHOUSE_CLIENT} --query="ALTER TABLE versioned_collapsing_00682 DELETE WHERE k IN (1, 2)" -wait_for_mutation "versioned_collapsing_00682" "mutation_3.txt" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE versioned_collapsing_00682 DELETE WHERE k IN (1, 2)" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE versioned_collapsing_00682 PARTITION tuple() FINAL" ${CLICKHOUSE_CLIENT} --query="SELECT * FROM versioned_collapsing_00682" diff --git a/tests/queries/0_stateless/00699_materialized_view_mutations.sh b/tests/queries/0_stateless/00699_materialized_view_mutations.sh index 0356c24b863..a8166ca29c0 100755 --- a/tests/queries/0_stateless/00699_materialized_view_mutations.sh +++ b/tests/queries/0_stateless/00699_materialized_view_mutations.sh @@ -4,8 +4,6 @@ set -e CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh -. "$CURDIR"/mergetree_mutations.lib - ${CLICKHOUSE_CLIENT} --multiquery --query=" DROP TABLE IF EXISTS view_00699; @@ -18,18 +16,14 @@ INSERT INTO null_00699 SELECT * FROM numbers(100); SELECT count(), min(x), max(x) FROM null_00699; SELECT count(), min(x), max(x) FROM view_00699; -ALTER TABLE null_00699 DELETE WHERE x % 2 = 0;" - -wait_for_mutation null_00699 mutation_2.txt +ALTER TABLE null_00699 DELETE WHERE x % 2 = 0;" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --multiquery --query=" SELECT count(), min(x), max(x) FROM null_00699; SELECT count(), min(x), max(x) FROM view_00699; ALTER TABLE view_00699 DELETE WHERE x % 2 = 0; -" - -wait_for_mutation .inner.view_00699 mutation_2.txt +" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --multiquery --query=" SELECT count(), min(x), max(x) FROM null_00699; @@ -37,10 +31,7 @@ SELECT count(), min(x), max(x) FROM view_00699; ALTER TABLE null_00699 DELETE WHERE x % 2 = 1; ALTER TABLE view_00699 DELETE WHERE x % 2 = 1; -" - -wait_for_mutation null_00699 mutation_3.txt -wait_for_mutation .inner.view_00699 mutation_3.txt +" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --multiquery --query=" SELECT count(), min(x), max(x) FROM null_00699; diff --git a/tests/queries/0_stateless/00942_mutate_index.sh b/tests/queries/0_stateless/00942_mutate_index.sh index 783ebbecd37..df02361af78 100755 --- a/tests/queries/0_stateless/00942_mutate_index.sh +++ b/tests/queries/0_stateless/00942_mutate_index.sh @@ -2,11 +2,9 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh -. "$CURDIR"/mergetree_mutations.lib $CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS minmax_idx;" - $CLICKHOUSE_CLIENT -n --query=" CREATE TABLE minmax_idx ( @@ -18,7 +16,6 @@ CREATE TABLE minmax_idx ORDER BY u64 SETTINGS index_granularity = 2;" - $CLICKHOUSE_CLIENT --query="INSERT INTO minmax_idx VALUES (0, 1, 1), (1, 1, 2), @@ -34,8 +31,7 @@ $CLICKHOUSE_CLIENT --query="INSERT INTO minmax_idx VALUES $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 1;" $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 5;" -$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx UPDATE i64 = 5 WHERE i64 = 1;" -wait_for_mutation "minmax_idx" "mutation_2.txt" "$CLICKHOUSE_DATABASE" +$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx UPDATE i64 = 5 WHERE i64 = 1;" --mutations_sync=1 $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 1;" $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 5;" diff --git a/tests/queries/0_stateless/00944_clear_index_in_partition.sh b/tests/queries/0_stateless/00944_clear_index_in_partition.sh index ea27e148bbd..8687e2044f0 100755 --- a/tests/queries/0_stateless/00944_clear_index_in_partition.sh +++ b/tests/queries/0_stateless/00944_clear_index_in_partition.sh @@ -2,7 +2,6 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh -. "$CURDIR"/mergetree_mutations.lib $CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS minmax_idx;" @@ -35,16 +34,12 @@ $CLICKHOUSE_CLIENT --query="INSERT INTO minmax_idx VALUES $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2;" $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" # Returns 4 -# First two numbers are for inserted blocks in two partitions -# And this will be mutation number 3: -$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx CLEAR INDEX idx IN PARTITION 1;" --replication_alter_partitions_sync=2 +$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx CLEAR INDEX idx IN PARTITION 1;" --mutations_sync=1 $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2;" $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" # Returns 6 -# And this will be mutation number 4: -$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx MATERIALIZE INDEX idx IN PARTITION 1;" -wait_for_mutation "minmax_idx" "mutation_4.txt" "$CLICKHOUSE_DATABASE" +$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx MATERIALIZE INDEX idx IN PARTITION 1;" --mutations_sync=1 $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2;" $CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" # Returns 4 diff --git a/tests/queries/0_stateless/01031_mutations_interpreter_and_context.sh b/tests/queries/0_stateless/01031_mutations_interpreter_and_context.sh index 56c95754611..7e77d58a6eb 100755 --- a/tests/queries/0_stateless/01031_mutations_interpreter_and_context.sh +++ b/tests/queries/0_stateless/01031_mutations_interpreter_and_context.sh @@ -3,8 +3,6 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh -. "$CURDIR"/mergetree_mutations.lib - ${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS json_test" @@ -14,9 +12,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO json_test VALUES (1, '{\"date\": \"201 ${CLICKHOUSE_CLIENT} --query="SELECT COUNT() FROM json_test" -${CLICKHOUSE_CLIENT} --query="ALTER TABLE json_test DELETE WHERE JSONExtractString(metadata, 'date') = '2018-01-01'" - -wait_for_mutation "json_test" "mutation_2.txt" +${CLICKHOUSE_CLIENT} --query="ALTER TABLE json_test DELETE WHERE JSONExtractString(metadata, 'date') = '2018-01-01'" --mutations_sync=1 ${CLICKHOUSE_CLIENT} --query="SELECT COUNT() FROM json_test" diff --git a/tests/queries/0_stateless/01035_lc_empty_part_bug.reference b/tests/queries/0_stateless/01035_lc_empty_part_bug.reference index 1ca0ea26354..e29f51890e2 100644 --- a/tests/queries/0_stateless/01035_lc_empty_part_bug.reference +++ b/tests/queries/0_stateless/01035_lc_empty_part_bug.reference @@ -1,3 +1,3 @@ -Waiting for mutation to finish +Waited for mutation to finish still alive 100 diff --git a/tests/queries/0_stateless/01035_lc_empty_part_bug.sh b/tests/queries/0_stateless/01035_lc_empty_part_bug.sh index f40ec14dfa8..e5bf2197157 100755 --- a/tests/queries/0_stateless/01035_lc_empty_part_bug.sh +++ b/tests/queries/0_stateless/01035_lc_empty_part_bug.sh @@ -2,7 +2,6 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../shell_config.sh -. "$CURDIR"/mergetree_mutations.lib # that test is failing on versions <= 19.11.12 @@ -11,11 +10,9 @@ ${CLICKHOUSE_CLIENT} --multiquery --query=" create table lc_empty_part_bug (id UInt64, s String) Engine=MergeTree ORDER BY id; insert into lc_empty_part_bug select number as id, toString(rand()) from numbers(100); alter table lc_empty_part_bug delete where id < 100; -" +" --mutations_sync=1 -wait_for_mutation 'lc_empty_part_bug' 'mutation_2.txt' - -echo 'Waiting for mutation to finish' +echo 'Waited for mutation to finish' ${CLICKHOUSE_CLIENT} --multiquery --query=" alter table lc_empty_part_bug modify column s LowCardinality(String); @@ -23,4 +20,4 @@ ${CLICKHOUSE_CLIENT} --multiquery --query=" insert into lc_empty_part_bug select number+100 as id, toString(rand()) from numbers(100); SELECT count() FROM lc_empty_part_bug WHERE not ignore(*); DROP TABLE lc_empty_part_bug; -" +" --mutations_sync=1