Update test.py

This commit is contained in:
Alexey Milovidov 2023-02-26 04:33:56 +03:00 committed by GitHub
parent c58468ce8d
commit 0e01991eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,9 @@ import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance('node', main_configs=["configs/config.xml"], with_zookeeper=True, stay_alive=True)
node = cluster.add_instance(
'node', main_configs=["configs/config.xml"], with_zookeeper=True, stay_alive=True
)
@pytest.fixture(scope="module")
@ -14,13 +16,24 @@ def started_cluster():
finally:
cluster.shutdown()
def replace_substring_to_substr(node):
node.exec_in_container(["bash", "-c", "sed -i 's/substring/substr/g' /var/lib/clickhouse/metadata/default/file.sql"], user="root")
node.exec_in_container((
[
"bash",
"-c",
"sed -i 's/substring/substr/g' /var/lib/clickhouse/metadata/default/file.sql",
],
user="root",
)
def test_attach_substr(started_cluster):
# Initialize
node.query("DROP TABLE IF EXISTS default.file")
node.query("CREATE TABLE default.file(`s` String, `n` UInt8) ENGINE = MergeTree PARTITION BY substring(s, 1, 2) ORDER BY n ")
node.query(
"CREATE TABLE default.file(`s` String, `n` UInt8) ENGINE = MergeTree PARTITION BY substring(s, 1, 2) ORDER BY n "
)
# Detach table file
node.query("DETACH TABLE file")
@ -31,10 +44,13 @@ def test_attach_substr(started_cluster):
# Attach table file
node.query("ATTACH TABLE file")
def test_attach_substr_restart(started_cluster):
# Initialize
node.query("DROP TABLE IF EXISTS default.file")
node.query("CREATE TABLE default.file(`s` String, `n` UInt8) ENGINE = MergeTree PARTITION BY substring(s, 1, 2) ORDER BY n ")
node.query(
"CREATE TABLE default.file(`s` String, `n` UInt8) ENGINE = MergeTree PARTITION BY substring(s, 1, 2) ORDER BY n "
)
# Replace substring to substr
replace_substring_to_substr(node)