2020-10-02 16:54:07 +00:00
|
|
|
|
2020-08-27 14:19:18 +00:00
|
|
|
|
2020-09-16 04:26:10 +00:00
|
|
|
import pytest
|
|
|
|
from helpers.client import QueryRuntimeException
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
2020-08-27 14:19:18 +00:00
|
|
|
|
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-27 14:19:18 +00:00
|
|
|
|
2020-08-28 11:12:51 +00:00
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def start_cluster():
|
2020-08-27 14:19:18 +00:00
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
|
2020-08-28 11:12:51 +00:00
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
2020-08-27 14:19:18 +00:00
|
|
|
|
2020-08-28 11:12:51 +00:00
|
|
|
|
2020-08-28 13:03:42 +00:00
|
|
|
def test_fetch_part_from_allowed_zookeeper(start_cluster):
|
2020-08-28 11:12:51 +00:00
|
|
|
node.query(
|
|
|
|
"CREATE TABLE simple (date Date, id UInt32) ENGINE = ReplicatedMergeTree('/clickhouse/tables/0/simple', 'node') ORDER BY tuple() PARTITION BY date;"
|
|
|
|
)
|
|
|
|
node.query("INSERT INTO simple VALUES ('2020-08-27', 1)")
|
|
|
|
|
|
|
|
node.query(
|
|
|
|
"CREATE TABLE simple2 (date Date, id UInt32) ENGINE = ReplicatedMergeTree('/clickhouse/tables/1/simple', 'node') ORDER BY tuple() PARTITION BY date;"
|
|
|
|
)
|
|
|
|
node.query(
|
|
|
|
"ALTER TABLE simple2 FETCH PARTITION '2020-08-27' FROM 'zookeeper2:/clickhouse/tables/0/simple';"
|
|
|
|
)
|
|
|
|
node.query("ALTER TABLE simple2 ATTACH PARTITION '2020-08-27';")
|
|
|
|
|
|
|
|
with pytest.raises(QueryRuntimeException):
|
2020-08-27 14:19:18 +00:00
|
|
|
node.query(
|
2020-08-28 11:12:51 +00:00
|
|
|
"ALTER TABLE simple2 FETCH PARTITION '2020-08-27' FROM 'zookeeper:/clickhouse/tables/0/simple';"
|
2020-08-27 14:19:18 +00:00
|
|
|
)
|
|
|
|
|
2020-08-28 11:12:51 +00:00
|
|
|
assert node.query("SELECT id FROM simple2").strip() == "1"
|