ClickHouse/tests/integration/test_async_drain_connection/test.py

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

42 lines
1.2 KiB
Python
Raw Normal View History

# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
2021-07-14 13:17:30 +00:00
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance("node", main_configs=["configs/config.xml"])
2021-07-14 13:17:30 +00:00
@pytest.fixture(scope="module")
2021-07-14 13:17:30 +00:00
def started_cluster():
try:
cluster.start()
node.query(
"""
create table t (number UInt64)
engine = Distributed(test_cluster_two_shards, system, numbers)
"""
)
2021-07-14 13:17:30 +00:00
yield cluster
finally:
cluster.shutdown()
def test_filled_async_drain_connection_pool(started_cluster):
def execute_queries(_):
2021-07-14 13:17:30 +00:00
for _ in range(100):
node.query(
"select * from t where number = 0 limit 2",
settings={
"sleep_in_receive_cancel_ms": int(10e6),
"max_execution_time": 5,
# decrease drain_timeout to make test more stable
# (another way is to increase max_execution_time, but this will make test slower)
"drain_timeout": 1,
},
)
2021-07-14 13:17:30 +00:00
any(map(execute_queries, range(10)))