forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ClickHouse#64694 from ClickHouse/fix_ttl_incompati…
…bility Fix backward incompatibility in TTL execution
- Loading branch information
Showing
4 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
36 changes: 36 additions & 0 deletions
36
tests/integration/test_move_ttl_broken_compatibility/configs/storage_conf.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<clickhouse> | ||
<logger> | ||
<level>test</level> | ||
</logger> | ||
|
||
<storage_configuration> | ||
<disks> | ||
<s3> | ||
<type>s3</type> | ||
<endpoint>http://minio1:9001/root/data/</endpoint> | ||
<access_key_id>minio</access_key_id> | ||
<secret_access_key>minio123</secret_access_key> | ||
</s3> | ||
</disks> | ||
<policies> | ||
<default> | ||
<default> | ||
<disk>default</disk> | ||
</default> | ||
</default> | ||
<s3> | ||
<volumes> | ||
<default> | ||
<disk>default</disk> | ||
<perform_ttl_move_on_insert>False</perform_ttl_move_on_insert> | ||
</default> | ||
<main> | ||
<disk>s3</disk> | ||
<perform_ttl_move_on_insert>False</perform_ttl_move_on_insert> | ||
</main> | ||
</volumes> | ||
<move_factor>0.0</move_factor> | ||
</s3> | ||
</policies> | ||
</storage_configuration> | ||
</clickhouse> |
105 changes: 105 additions & 0 deletions
105
tests/integration/test_move_ttl_broken_compatibility/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import logging | ||
import random | ||
import string | ||
import time | ||
|
||
import pytest | ||
from helpers.cluster import ClickHouseCluster | ||
import minio | ||
|
||
|
||
cluster = ClickHouseCluster(__file__) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def started_cluster(): | ||
try: | ||
cluster.add_instance( | ||
"node1", | ||
main_configs=["configs/storage_conf.xml"], | ||
image="clickhouse/clickhouse-server", | ||
with_minio=True, | ||
tag="24.1", | ||
stay_alive=True, | ||
with_installed_binary=True, | ||
) | ||
cluster.start() | ||
|
||
yield cluster | ||
finally: | ||
cluster.shutdown() | ||
|
||
|
||
def test_bc_compatibility(started_cluster): | ||
node1 = cluster.instances["node1"] | ||
node1.query( | ||
""" | ||
CREATE TABLE test_ttl_table ( | ||
generation UInt64, | ||
date_key DateTime, | ||
number UInt64, | ||
text String, | ||
expired DateTime DEFAULT now() | ||
) | ||
ENGINE=MergeTree | ||
ORDER BY (generation, date_key) | ||
PARTITION BY toMonth(date_key) | ||
TTL expired + INTERVAL 20 SECONDS TO DISK 's3' | ||
SETTINGS storage_policy = 's3'; | ||
""" | ||
) | ||
|
||
node1.query( | ||
""" | ||
INSERT INTO test_ttl_table ( | ||
generation, | ||
date_key, | ||
number, | ||
text | ||
) | ||
SELECT | ||
1, | ||
toDateTime('2000-01-01 00:00:00') + rand(number) % 365 * 86400, | ||
number, | ||
toString(number) | ||
FROM numbers(10000); | ||
""" | ||
) | ||
|
||
disks = ( | ||
node1.query( | ||
""" | ||
SELECT distinct disk_name | ||
FROM system.parts | ||
WHERE table = 'test_ttl_table' | ||
""" | ||
) | ||
.strip() | ||
.split("\n") | ||
) | ||
print("Disks before", disks) | ||
|
||
assert len(disks) == 1 | ||
assert disks[0] == "default" | ||
|
||
node1.restart_with_latest_version() | ||
|
||
for _ in range(60): | ||
disks = ( | ||
node1.query( | ||
""" | ||
SELECT distinct disk_name | ||
FROM system.parts | ||
WHERE table = 'test_ttl_table' | ||
""" | ||
) | ||
.strip() | ||
.split("\n") | ||
) | ||
print("Disks after", disks) | ||
if "s3" in disks: | ||
break | ||
time.sleep(1) | ||
assert "s3" in disks |