2024-07-15 16:28:06 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import logging
|
|
|
|
import time
|
2024-09-27 10:19:39 +00:00
|
|
|
from multiprocessing.dummy import Pool
|
|
|
|
|
2024-07-15 16:28:06 +00:00
|
|
|
import pytest
|
2024-09-27 10:19:39 +00:00
|
|
|
|
2024-07-15 16:28:06 +00:00
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
|
|
|
|
node = cluster.add_instance(
|
|
|
|
"node",
|
|
|
|
main_configs=[
|
|
|
|
"configs/async_metrics_no.xml",
|
|
|
|
],
|
2024-07-15 17:05:23 +00:00
|
|
|
mem_limit="4g",
|
2024-07-15 16:28:06 +00:00
|
|
|
)
|
|
|
|
|
2024-07-15 17:05:23 +00:00
|
|
|
|
2024-07-15 16:28:06 +00:00
|
|
|
@pytest.fixture(scope="module", autouse=True)
|
|
|
|
def start_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
2024-07-15 17:05:23 +00:00
|
|
|
|
2024-07-15 16:28:06 +00:00
|
|
|
def test_multiple_queries():
|
2024-07-16 12:55:14 +00:00
|
|
|
if node.is_built_with_sanitizer():
|
|
|
|
return
|
|
|
|
|
2024-07-15 16:28:06 +00:00
|
|
|
p = Pool(15)
|
|
|
|
|
|
|
|
def run_query(node):
|
|
|
|
try:
|
|
|
|
node.query("SELECT * FROM system.numbers GROUP BY number")
|
|
|
|
except Exception as ex:
|
|
|
|
print("Exception", ex)
|
|
|
|
raise ex
|
|
|
|
|
|
|
|
tasks = []
|
|
|
|
for i in range(30):
|
2024-07-15 17:05:23 +00:00
|
|
|
tasks.append(p.apply_async(run_query, (node,)))
|
2024-07-15 16:28:06 +00:00
|
|
|
time.sleep(i * 0.1)
|
|
|
|
|
|
|
|
for task in tasks:
|
|
|
|
try:
|
|
|
|
task.get()
|
|
|
|
except Exception as ex:
|
|
|
|
print("Exception", ex)
|
|
|
|
|
|
|
|
# test that we didn't kill the server
|
|
|
|
node.query("SELECT 1")
|