ClickHouse/tests/queries/0_stateless/02888_replicated_merge_tree_creation.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
2.5 KiB
Bash
Raw Normal View History

2023-10-26 03:17:30 +00:00
#!/usr/bin/env bash
2023-11-16 01:38:42 +00:00
# Tags: zookeeper, no-parallel, no-ordinary-database
2023-10-26 03:17:30 +00:00
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS test_exception_replicated SYNC"
UUID=$(${CLICKHOUSE_CLIENT} --query "SELECT reinterpretAsUUID(currentDatabase())")
2023-10-26 03:17:30 +00:00
#### 1 - There is only one replica
2023-11-02 00:42:57 +00:00
${CLICKHOUSE_CLIENT} --create_replicated_merge_tree_fault_injection_probability=1 \
-q "CREATE TABLE test_exception_replicated UUID '$UUID' (date Date) ENGINE=ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/recreate', 'r1') ORDER BY date" 2>&1 | grep -cm1 "Fault injected"
2023-10-26 03:17:30 +00:00
2023-11-02 00:42:57 +00:00
# We will see that the replica is empty and throw the same 'Fault injected' exception as before
${CLICKHOUSE_CLIENT} --create_replicated_merge_tree_fault_injection_probability=1 \
-q "CREATE TABLE test_exception_replicated UUID '$UUID' (date Date) ENGINE=ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/recreate', 'r1') ORDER BY date" 2>&1 | grep -cm1 "Fault injected"
2023-10-26 03:17:30 +00:00
# We will succeed
${CLICKHOUSE_CLIENT} \
-q "CREATE TABLE test_exception_replicated UUID '$UUID' (date Date) ENGINE=ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/recreate', 'r1') ORDER BY date"
2023-10-26 03:17:30 +00:00
${CLICKHOUSE_CLIENT} -q "DROP TABLE test_exception_replicated SYNC"
#### 2 - There are two replicas
2023-11-02 00:42:57 +00:00
${CLICKHOUSE_CLIENT} --create_replicated_merge_tree_fault_injection_probability=1 \
-q "CREATE TABLE test_exception_replicated UUID '$UUID' (date Date) ENGINE=ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/recreate', 'r1') ORDER BY date" 2>&1 | grep -cm1 "Fault injected"
2023-11-02 00:42:57 +00:00
${CLICKHOUSE_CLIENT} --create_replicated_merge_tree_fault_injection_probability=1 \
-q "CREATE TABLE test_exception_replicated_2 (date Date) ENGINE=ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/recreate', 'r2') ORDER BY date" 2>&1 | grep -cm1 "Fault injected"
2023-10-26 03:17:30 +00:00
# We will succeed
${CLICKHOUSE_CLIENT} \
-q "CREATE TABLE test_exception_replicated UUID '$UUID' (date Date) ENGINE=ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/recreate', 'r1') ORDER BY date"
# The trash from the second replica creation will not prevent us from dropping the table fully, so we delete it separately
${CLICKHOUSE_CLIENT} -q "SYSTEM DROP REPLICA 'r2' FROM TABLE test_exception_replicated"
2023-10-26 03:17:30 +00:00
${CLICKHOUSE_CLIENT} -q "DROP TABLE test_exception_replicated SYNC"