ClickHouse/tests/integration/test_parallel_replicas_no_replicas/test.py

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

55 lines
1.7 KiB
Python
Raw Normal View History

2024-06-24 11:58:32 +00:00
import pytest
from helpers.cluster import ClickHouseCluster
from helpers.client import QueryRuntimeException
cluster = ClickHouseCluster(__file__)
initiator = cluster.add_instance(
"initiator", main_configs=["configs/remote_servers.xml"], with_zookeeper=True
)
2024-06-24 12:07:31 +00:00
2024-06-24 11:58:32 +00:00
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def create_tables(cluster, table_name):
initiator.query(f"DROP TABLE IF EXISTS {table_name} SYNC")
initiator.query(
f"CREATE TABLE IF NOT EXISTS {table_name} (key Int64, value String) Engine=ReplicatedMergeTree('/test_parallel_replicas/shard1/{table_name}', 'r1') ORDER BY (key)"
)
# populate data
initiator.query(
f"INSERT INTO {table_name} SELECT number % 4, number FROM numbers(1000)"
)
@pytest.mark.parametrize("skip_unavailable_shards", [1, 0])
@pytest.mark.parametrize("max_parallel_replicas", [2, 3, 100])
2024-07-25 01:55:23 +00:00
def test_skip_all_replicas(
start_cluster, skip_unavailable_shards, max_parallel_replicas
):
2024-06-24 11:58:32 +00:00
cluster_name = "test_1_shard_3_unavaliable_replicas"
table_name = "tt"
create_tables(cluster_name, table_name)
with pytest.raises(QueryRuntimeException):
initiator.query(
f"SELECT key, count() FROM {table_name} GROUP BY key ORDER BY key",
2024-06-24 12:07:31 +00:00
settings={
2024-06-24 11:58:32 +00:00
"allow_experimental_parallel_reading_from_replicas": 2,
"max_parallel_replicas": max_parallel_replicas,
2024-06-24 11:58:32 +00:00
"cluster_for_parallel_replicas": cluster_name,
"skip_unavailable_shards": skip_unavailable_shards,
2024-06-26 10:12:09 +00:00
"parallel_replicas_local_plan": 0,
2024-06-24 12:07:31 +00:00
},
2024-06-24 11:58:32 +00:00
)