ClickHouse/tests/integration/test_fetch_partition_from_auxiliary_zookeeper/test.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.8 KiB
Python
Raw Normal View History

import pytest
from helpers.client import QueryRuntimeException
from helpers.cluster import ClickHouseCluster
2020-08-28 11:12:51 +00:00
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance(
"node", main_configs=["configs/zookeeper_config.xml"], with_zookeeper=True
)
2020-08-28 11:12:51 +00:00
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
2020-08-28 11:12:51 +00:00
yield cluster
finally:
cluster.shutdown()
2020-08-28 11:12:51 +00:00
@pytest.mark.parametrize(
2021-04-14 12:04:59 +00:00
("part", "date", "part_name"),
[
2021-04-14 12:04:59 +00:00
("PARTITION", "2020-08-27", "2020-08-27"),
2021-04-14 13:15:53 +00:00
("PART", "2020-08-28", "20200828_0_0_0"),
],
)
2021-04-14 12:04:59 +00:00
def test_fetch_part_from_allowed_zookeeper(start_cluster, part, date, part_name):
2020-08-28 11:12:51 +00:00
node.query(
2021-04-14 12:04:59 +00:00
"CREATE TABLE IF NOT EXISTS simple (date Date, id UInt32) ENGINE = ReplicatedMergeTree('/clickhouse/tables/0/simple', 'node') ORDER BY tuple() PARTITION BY date;"
2020-08-28 11:12:51 +00:00
)
2021-04-14 12:04:59 +00:00
node.query("""INSERT INTO simple VALUES ('{date}', 1)""".format(date=date))
2020-08-28 11:12:51 +00:00
node.query(
2021-04-14 12:04:59 +00:00
"CREATE TABLE IF NOT EXISTS simple2 (date Date, id UInt32) ENGINE = ReplicatedMergeTree('/clickhouse/tables/1/simple', 'node') ORDER BY tuple() PARTITION BY date;"
2020-08-28 11:12:51 +00:00
)
2020-08-28 11:12:51 +00:00
node.query(
"""ALTER TABLE simple2 FETCH {part} '{part_name}' FROM 'zookeeper2:/clickhouse/tables/0/simple';""".format(
part=part, part_name=part_name
)
)
2021-04-14 12:04:59 +00:00
node.query(
"""ALTER TABLE simple2 ATTACH {part} '{part_name}';""".format(
part=part, part_name=part_name
)
)
2020-08-28 11:12:51 +00:00
with pytest.raises(QueryRuntimeException):
node.query(
"""ALTER TABLE simple2 FETCH {part} '{part_name}' FROM 'zookeeper:/clickhouse/tables/0/simple';""".format(
part=part, part_name=part_name
)
)
2021-04-14 12:04:59 +00:00
assert (
node.query(
"""SELECT id FROM simple2 where date = '{date}'""".format(date=date)
).strip()
== "1"
)