ClickHouse/tests/integration/test_async_drain_connection/test.py
Azat Khuzhin 42ab02a810 Fix test_async_drain_connection flakiness
Sometimes [1] 5 seconds is not enough, since drain_timeout is 3 seconds,
and 2 seconds sometimes is not enough to do other things, especially
under sanitizers:

    E           Code: 159. DB::Exception: Received from 172.16.1.2:9000. DB::Exception: Timeout exceeded: elapsed 5.019254094 seconds, maximum: 5. Stack trace:

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/0/826f7cb0f53e20e67ef52800cb735bb88a6de658/integration_tests__thread__actions__[4/4].html
2021-12-25 11:55:57 +03:00

37 lines
1.1 KiB
Python

# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance('node', main_configs=['configs/config.xml'])
@pytest.fixture(scope='module')
def started_cluster():
try:
cluster.start()
node.query("""
create table t (number UInt64)
engine = Distributed(test_cluster_two_shards, system, numbers)
""")
yield cluster
finally:
cluster.shutdown()
def test_filled_async_drain_connection_pool(started_cluster):
def execute_queries(_):
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,
})
any(map(execute_queries, range(10)))