mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
add functional test for mutations of Replicated tables [#CLICKHOUSE-3747]
This commit is contained in:
parent
84191ecca4
commit
48c48c6c9a
@ -0,0 +1,7 @@
|
||||
2000-01-01 2 b
|
||||
2000-01-01 5 e
|
||||
2000-02-01 2 b
|
||||
2000-02-01 5 e
|
||||
0000000000 DELETE WHERE x = 1 [] [] 0 1
|
||||
0000000001 DELETE WHERE (x % 2) = 1 ['200001','200002'] [2,1] 0 1
|
||||
0000000002 DELETE WHERE s = \'d\' ['200001','200002'] [3,2] 0 1
|
50
dbms/tests/queries/0_stateless/00652_replicated_mutations_zookeeper.sh
Executable file
50
dbms/tests/queries/0_stateless/00652_replicated_mutations_zookeeper.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. $CURDIR/../shell_config.sh
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS test.mutations_r1"
|
||||
${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS test.mutations_r2"
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query="CREATE TABLE test.mutations_r1(d Date, x UInt32, s String) ENGINE ReplicatedMergeTree('/clickhouse/tables/test/mutations', 'r1', d, intDiv(x, 10), 8192)"
|
||||
${CLICKHOUSE_CLIENT} --query="CREATE TABLE test.mutations_r2(d Date, x UInt32, s String) ENGINE ReplicatedMergeTree('/clickhouse/tables/test/mutations', 'r2', d, intDiv(x, 10), 8192)"
|
||||
|
||||
# Test a mutation on empty table
|
||||
${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.mutations_r1 DELETE WHERE x = 1"
|
||||
|
||||
# Insert some data
|
||||
${CLICKHOUSE_CLIENT} --query="INSERT INTO test.mutations_r1 VALUES ('2000-01-01', 1, 'a')"
|
||||
${CLICKHOUSE_CLIENT} --query="INSERT INTO test.mutations_r1 VALUES \
|
||||
('2000-01-01', 2, 'b'), ('2000-01-01', 3, 'c'), ('2000-01-01', 4, 'd') \
|
||||
('2000-02-01', 2, 'b'), ('2000-02-01', 3, 'c'), ('2000-02-01', 4, 'd')"
|
||||
|
||||
# Delete some values
|
||||
${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.mutations_r1 DELETE WHERE x % 2 = 1"
|
||||
${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.mutations_r1 DELETE WHERE s = 'd'"
|
||||
|
||||
# Insert more data
|
||||
${CLICKHOUSE_CLIENT} --query="INSERT INTO test.mutations_r1 VALUES \
|
||||
('2000-01-01', 5, 'e'), ('2000-02-01', 5, 'e')"
|
||||
|
||||
# Wait until all mutations are done.
|
||||
for i in {1..100}
|
||||
do
|
||||
sleep 0.1
|
||||
if [[ $(${CLICKHOUSE_CLIENT} --query="SELECT sum(is_done) FROM system.mutations WHERE table='mutations_r2'") -eq 3 ]]; then
|
||||
break
|
||||
fi
|
||||
|
||||
if [[ $i -eq 100 ]]; then
|
||||
echo "Timed out while waiting for mutations to execute!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Check that the table contains only the data that should not be deleted.
|
||||
${CLICKHOUSE_CLIENT} --query="SELECT * FROM test.mutations_r2 ORDER BY d, x"
|
||||
# Check the contents of the system.mutations table.
|
||||
${CLICKHOUSE_CLIENT} --query="SELECT mutation_id, command, block_numbers.partition_id, block_numbers.number, parts_to_do, is_done \
|
||||
FROM system.mutations WHERE table = 'mutations_r2' ORDER BY mutation_id"
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query="DROP TABLE test.mutations_r1"
|
||||
${CLICKHOUSE_CLIENT} --query="DROP TABLE test.mutations_r2"
|
Loading…
Reference in New Issue
Block a user