mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Fix flaky ttl_replicated test (remove sleep)
This commit is contained in:
parent
dc0e3bd802
commit
2f06457c44
48
tests/queries/0_stateless/00933_ttl_replicated_zookeeper.sh
Executable file
48
tests/queries/0_stateless/00933_ttl_replicated_zookeeper.sh
Executable file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
function query_with_retry
|
||||
{
|
||||
retry=0
|
||||
until [ $retry -ge 5 ]
|
||||
do
|
||||
result=$($CLICKHOUSE_CLIENT $2 --query="$1" 2>&1)
|
||||
if [ "$?" == 0 ]; then
|
||||
echo -n "$result"
|
||||
return
|
||||
else
|
||||
retry=$(($retry + 1))
|
||||
sleep 3
|
||||
fi
|
||||
done
|
||||
echo "Query '$1' failed with '$result'"
|
||||
}
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS ttl_repl1"
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS ttl_repl2"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="CREATE TABLE ttl_repl1(d Date, x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/{database}/test_00933/ttl_repl', '1') PARTITION BY toDayOfMonth(d) ORDER BY x TTL d + INTERVAL 1 DAY;"
|
||||
$CLICKHOUSE_CLIENT --query="CREATE TABLE ttl_repl2(d Date, x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/{database}/test_00933/ttl_repl', '2') PARTITION BY toDayOfMonth(d) ORDER BY x TTL d + INTERVAL 1 DAY;"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="INSERT INTO TABLE ttl_repl1 VALUES (toDate('2000-10-10 00:00:00'), 100)"
|
||||
$CLICKHOUSE_CLIENT --query="INSERT INTO TABLE ttl_repl1 VALUES (toDate('2100-10-10 00:00:00'), 200)"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="ALTER TABLE ttl_repl1 MODIFY TTL d + INTERVAL 1 DAY"
|
||||
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA ttl_repl2"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="INSERT INTO TABLE ttl_repl1 VALUES (toDate('2000-10-10 00:00:00'), 300)"
|
||||
$CLICKHOUSE_CLIENT --query="INSERT INTO TABLE ttl_repl1 VALUES (toDate('2100-10-10 00:00:00'), 400)"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA ttl_repl2"
|
||||
|
||||
query_with_retry "OPTIMIZE TABLE ttl_repl2 FINAL SETTINGS optimize_throw_if_noop = 1"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="SELECT x FROM ttl_repl2 ORDER BY x"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="SHOW CREATE TABLE ttl_repl2"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE ttl_repl1"
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE ttl_repl2"
|
@ -1,30 +0,0 @@
|
||||
-- Tags: long, replica
|
||||
|
||||
DROP TABLE IF EXISTS ttl_repl1;
|
||||
DROP TABLE IF EXISTS ttl_repl2;
|
||||
|
||||
CREATE TABLE ttl_repl1(d Date, x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/{database}/test_00933/ttl_repl', '1')
|
||||
PARTITION BY toDayOfMonth(d) ORDER BY x TTL d + INTERVAL 1 DAY;
|
||||
CREATE TABLE ttl_repl2(d Date, x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/{database}/test_00933/ttl_repl', '2')
|
||||
PARTITION BY toDayOfMonth(d) ORDER BY x TTL d + INTERVAL 1 DAY;
|
||||
|
||||
INSERT INTO TABLE ttl_repl1 VALUES (toDate('2000-10-10 00:00:00'), 100);
|
||||
INSERT INTO TABLE ttl_repl1 VALUES (toDate('2100-10-10 00:00:00'), 200);
|
||||
|
||||
ALTER TABLE ttl_repl1 MODIFY TTL d + INTERVAL 1 DAY;
|
||||
SYSTEM SYNC REPLICA ttl_repl2;
|
||||
|
||||
INSERT INTO TABLE ttl_repl1 VALUES (toDate('2000-10-10 00:00:00'), 300);
|
||||
INSERT INTO TABLE ttl_repl1 VALUES (toDate('2100-10-10 00:00:00'), 400);
|
||||
|
||||
SYSTEM SYNC REPLICA ttl_repl2;
|
||||
|
||||
SELECT sleep(1) format Null; -- wait for probable merges after inserts
|
||||
|
||||
OPTIMIZE TABLE ttl_repl2 FINAL;
|
||||
SELECT x FROM ttl_repl2 ORDER BY x;
|
||||
|
||||
SHOW CREATE TABLE ttl_repl2;
|
||||
|
||||
DROP TABLE ttl_repl1;
|
||||
DROP TABLE ttl_repl2;
|
Loading…
Reference in New Issue
Block a user