From 1de7dbafd9fbebfdfade44d2069c8073f26442a2 Mon Sep 17 00:00:00 2001 From: Alexandra Latysheva Date: Wed, 7 Oct 2020 14:54:41 +0000 Subject: [PATCH] added 3 functional tests for parallel quorum inserts --- ...eck_many_parallel_quorum_inserts.reference | 10 +++++ ...1509_check_many_parallel_quorum_inserts.sh | 38 +++++++++++++++++ ...09_check_parallel_quorum_inserts.reference | 2 + .../01509_check_parallel_quorum_inserts.sh | 37 ++++++++++++++++ ...rallel_quorum_inserts_with_merge.reference | 2 + ...heck_parallel_quorum_inserts_with_merge.sh | 42 +++++++++++++++++++ 6 files changed, 131 insertions(+) create mode 100644 tests/queries/0_stateless/01509_check_many_parallel_quorum_inserts.reference create mode 100755 tests/queries/0_stateless/01509_check_many_parallel_quorum_inserts.sh create mode 100644 tests/queries/0_stateless/01509_check_parallel_quorum_inserts.reference create mode 100755 tests/queries/0_stateless/01509_check_parallel_quorum_inserts.sh create mode 100644 tests/queries/0_stateless/01509_check_parallel_quorum_inserts_with_merge.reference create mode 100755 tests/queries/0_stateless/01509_check_parallel_quorum_inserts_with_merge.sh diff --git a/tests/queries/0_stateless/01509_check_many_parallel_quorum_inserts.reference b/tests/queries/0_stateless/01509_check_many_parallel_quorum_inserts.reference new file mode 100644 index 00000000000..52dea650ebc --- /dev/null +++ b/tests/queries/0_stateless/01509_check_many_parallel_quorum_inserts.reference @@ -0,0 +1,10 @@ +100 0 99 4950 +100 0 99 4950 +100 0 99 4950 +100 0 99 4950 +100 0 99 4950 +100 0 99 4950 +100 0 99 4950 +100 0 99 4950 +100 0 99 4950 +100 0 99 4950 diff --git a/tests/queries/0_stateless/01509_check_many_parallel_quorum_inserts.sh b/tests/queries/0_stateless/01509_check_many_parallel_quorum_inserts.sh new file mode 100755 index 00000000000..f04ce0306e4 --- /dev/null +++ b/tests/queries/0_stateless/01509_check_many_parallel_quorum_inserts.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -e + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + +NUM_REPLICAS=10 + +for i in $(seq 1 $NUM_REPLICAS); do + $CLICKHOUSE_CLIENT -n -q " + DROP TABLE IF EXISTS r$i; + CREATE TABLE r$i (x UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_01509/parallel_quorum_many', 'r$i') ORDER BY x; + " +done + +$CLICKHOUSE_CLIENT -n -q "SYSTEM STOP REPLICATION QUEUES quorum2;" + +function thread { + for j in {0..9}; do + a=$((($1 - 1) * 10 + $j)) + $CLICKHOUSE_CLIENT --insert_quorum 5 --insert_quorum_parallel 1 --query "INSERT INTO r$1 SELECT $a" + done +} + +for i in $(seq 1 $NUM_REPLICAS); do + thread $i & +done + +wait + +for i in $(seq 1 $NUM_REPLICAS); do + $CLICKHOUSE_CLIENT -n -q " + SYSTEM SYNC REPLICA r$i; + SELECT count(), min(x), max(x), sum(x) FROM r$i; + DROP TABLE IF EXISTS r$i; +" +done diff --git a/tests/queries/0_stateless/01509_check_parallel_quorum_inserts.reference b/tests/queries/0_stateless/01509_check_parallel_quorum_inserts.reference new file mode 100644 index 00000000000..103d5e37094 --- /dev/null +++ b/tests/queries/0_stateless/01509_check_parallel_quorum_inserts.reference @@ -0,0 +1,2 @@ +5 1 5 15 +5 1 5 15 diff --git a/tests/queries/0_stateless/01509_check_parallel_quorum_inserts.sh b/tests/queries/0_stateless/01509_check_parallel_quorum_inserts.sh new file mode 100755 index 00000000000..a3f7af8e9ca --- /dev/null +++ b/tests/queries/0_stateless/01509_check_parallel_quorum_inserts.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + +NUM_REPLICAS=2 +NUM_INSERTS=5 + +for i in $(seq 1 $NUM_REPLICAS); do + $CLICKHOUSE_CLIENT -n -q " + DROP TABLE IF EXISTS r$i; + CREATE TABLE r$i (x UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_01509/parallel_quorum', 'r$i') ORDER BY x; + " +done + +$CLICKHOUSE_CLIENT -n -q "SYSTEM STOP REPLICATION QUEUES quorum2;" + +function thread { + $CLICKHOUSE_CLIENT --insert_quorum 2 --insert_quorum_parallel 1 --query "INSERT INTO r1 SELECT $1" +} + +for i in $(seq 1 $NUM_INSERTS); do + thread $i & +done + +$CLICKHOUSE_CLIENT -n -q "SYSTEM START REPLICATION QUEUES quorum2;" + +wait + +for i in $(seq 1 $NUM_REPLICAS); do + $CLICKHOUSE_CLIENT -n -q " + SELECT count(), min(x), max(x), sum(x) FROM r$i; + DROP TABLE IF EXISTS r$i; +" +done diff --git a/tests/queries/0_stateless/01509_check_parallel_quorum_inserts_with_merge.reference b/tests/queries/0_stateless/01509_check_parallel_quorum_inserts_with_merge.reference new file mode 100644 index 00000000000..103d5e37094 --- /dev/null +++ b/tests/queries/0_stateless/01509_check_parallel_quorum_inserts_with_merge.reference @@ -0,0 +1,2 @@ +5 1 5 15 +5 1 5 15 diff --git a/tests/queries/0_stateless/01509_check_parallel_quorum_inserts_with_merge.sh b/tests/queries/0_stateless/01509_check_parallel_quorum_inserts_with_merge.sh new file mode 100755 index 00000000000..ea07c5c410b --- /dev/null +++ b/tests/queries/0_stateless/01509_check_parallel_quorum_inserts_with_merge.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +set -e + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + +NUM_REPLICAS=2 + +for i in $(seq 1 $NUM_REPLICAS); do + $CLICKHOUSE_CLIENT -n -q " + DROP TABLE IF EXISTS r$i; + CREATE TABLE r$i (x UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_01509/parallel_quorum_merge', 'r$i') ORDER BY x; + " +done + +$CLICKHOUSE_CLIENT -n -q " + SYSTEM STOP REPLICATION QUEUES quorum2; +" + +function thread { + $CLICKHOUSE_CLIENT --insert_quorum 2 --insert_quorum_parallel 1 --query "INSERT INTO r1 SELECT $1" +} + +for i in {1..5}; do + thread $i & +done + + +$CLICKHOUSE_CLIENT -n -q " + OPTIMIZE TABLE r1 FINAL; + SYSTEM START REPLICATION QUEUES quorum2; +" + +wait + +for i in $(seq 1 $NUM_REPLICAS); do + $CLICKHOUSE_CLIENT -n -q " + SELECT count(), min(x), max(x), sum(x) FROM r$i; + DROP TABLE IF EXISTS r$i; +" +done