2021-12-25 08:52:39 +00:00
|
|
|
# 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__)
|
2021-12-25 08:52:39 +00:00
|
|
|
node = cluster.add_instance('node', main_configs=['configs/config.xml'])
|
2021-07-14 13:17:30 +00:00
|
|
|
|
|
|
|
|
2021-12-25 08:52:39 +00:00
|
|
|
@pytest.fixture(scope='module')
|
2021-07-14 13:17:30 +00:00
|
|
|
def started_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
2021-12-25 08:52:39 +00:00
|
|
|
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):
|
2021-12-25 08:52:39 +00:00
|
|
|
def execute_queries(_):
|
2021-07-14 13:17:30 +00:00
|
|
|
for _ in range(100):
|
2021-12-25 08:52:39 +00:00
|
|
|
node.query('select * from t where number = 0 limit 2', settings={
|
|
|
|
'sleep_in_receive_cancel_ms': int(10e6),
|
|
|
|
'max_execution_time': 5,
|
2021-12-25 08:52:57 +00:00
|
|
|
# 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-12-25 08:52:39 +00:00
|
|
|
})
|
2021-07-14 13:17:30 +00:00
|
|
|
|
2021-12-25 08:52:39 +00:00
|
|
|
any(map(execute_queries, range(10)))
|