ClickHouse/tests/integration/test_memory_limit/test.py

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

52 lines
1.1 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
import logging
import time
import pytest
from helpers.cluster import ClickHouseCluster
from multiprocessing.dummy import Pool
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",
env_variables={"MALLOC_CONF": "dirty_decay_ms:0"},
)
2024-07-15 17:05:23 +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
def test_multiple_queries():
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,)))
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")