Add test for SYSTEM UNFREEZE with zero_copy

This commit is contained in:
Joe Lynch 2024-09-10 17:22:19 +02:00
parent 1c6976d7a5
commit 35df5ff28e
No known key found for this signature in database
4 changed files with 101 additions and 1 deletions

View File

@ -350,7 +350,8 @@ public:
return delegate;
}
UInt32 getRefCount(const String & path) const override {
UInt32 getRefCount(const String & path) const override
{
auto wrapped_path = wrappedPath(path);
return delegate->getRefCount(wrapped_path);
}

View File

@ -0,0 +1,42 @@
<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>
<encrypted>
<type>encrypted</type>
<disk>s3</disk>
<key_hex>9bb21f41535d8e89098f3f23a62c661e</key_hex>
</encrypted>
</disks>
<policies>
<encrypted>
<volumes>
<main>
<disk>s3</disk>
</main>
</volumes>
</encrypted>
<s3>
<volumes>
<main>
<disk>s3</disk>
</main>
</volumes>
</s3>
</policies>
</storage_configuration>
<merge_tree>
<allow_remote_fs_zero_copy_replication>true</allow_remote_fs_zero_copy_replication>
<disable_freeze_partition_for_zero_copy_replication>false</disable_freeze_partition_for_zero_copy_replication>
</merge_tree>
<enable_system_unfreeze>true</enable_system_unfreeze>
</clickhouse>

View File

@ -0,0 +1,57 @@
from collections.abc import Iterable
import pytest
from helpers.cluster import ClickHouseCluster, ClickHouseInstance
cluster = ClickHouseCluster(__file__)
@pytest.fixture(scope="module")
def started_cluster() -> Iterable[ClickHouseCluster]:
try:
cluster.add_instance(
"node1",
main_configs=["configs/storage_conf.xml"],
with_minio=True,
with_zookeeper=True,
)
cluster.start()
yield cluster
finally:
cluster.shutdown()
@pytest.mark.parametrize("storage_policy", ["s3", "encrypted"])
def test_unfreeze(storage_policy: str, started_cluster: ClickHouseCluster) -> None:
node1: ClickHouseInstance = started_cluster.instances["node1"]
node1.query(
f"""\
CREATE TABLE test1 (a Int)
ENGINE = ReplicatedMergeTree('/clickhouse-tables/test1/{storage_policy}', 'r1')
ORDER BY a
SETTINGS storage_policy = '{storage_policy}'
"""
)
node1.query(
"""\
INSERT INTO test1
SELECT *
FROM system.numbers
LIMIT 20
"""
)
node1.query("ALTER TABLE test1 FREEZE WITH NAME 'test'")
node1.query("SYSTEM UNFREEZE WITH NAME 'test'")
uuid = node1.query("SELECT uuid FROM system.tables WHERE name = 'test1'").strip()
# ensure that zero copy lock parent still exists
kazoo = started_cluster.get_kazoo_client("zoo1")
part_path = f"/clickhouse/zero_copy/zero_copy_s3/{uuid}/all_0_0_0/"
children: list[str] = kazoo.get_children(part_path)
assert len(children) == 1
part_name = children[0]
assert len(kazoo.get_children(part_path + part_name)) == 1
assert node1.query("SELECT count() FROM test1").strip() == "20"
node1.query("DROP TABLE test1")