fix style

This commit is contained in:
Han Fei 2024-03-13 06:40:47 +01:00
parent c7c64636d0
commit 044eed8d82

View File

@ -7,9 +7,10 @@ from helpers.cluster import ClickHouseCluster, run_and_check
cluster = ClickHouseCluster(__file__) cluster = ClickHouseCluster(__file__)
node1 = cluster.add_instance( node1 = cluster.add_instance(
"node1", main_configs=["config/text_log.xml"], mem_limit = "5g" "node1", main_configs=["config/text_log.xml"], mem_limit="5g"
) )
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def started_cluster(): def started_cluster():
try: try:
@ -20,16 +21,19 @@ def started_cluster():
finally: finally:
cluster.shutdown() cluster.shutdown()
def get_latest_mem_limit(): def get_latest_mem_limit():
for _ in range(10): for _ in range(10):
try: try:
mem_limit = float(node1.query( mem_limit = float(
''' node1.query(
"""
select extract(message, '\\d+\\.\\d+') from system.text_log select extract(message, '\\d+\\.\\d+') from system.text_log
where message like '%Setting max_server_memory_usage was set to%' and where message like '%Setting max_server_memory_usage was set to%' and
message not like '%like%' order by event_time desc limit 1 message not like '%like%' order by event_time desc limit 1
''' """
).strip()) ).strip()
)
return mem_limit return mem_limit
except Exception as e: except Exception as e:
time.sleep(1) time.sleep(1)
@ -37,12 +41,8 @@ def get_latest_mem_limit():
def test_observe_memory_limit(started_cluster): def test_observe_memory_limit(started_cluster):
original_max_mem = get_latest_mem_limit() original_max_mem = get_latest_mem_limit()
#container_id = cluster.get_container_id('node1')
#cmd = "docker update --memory=10g {}".format(node1.docker_id)
logging.debug(f"get original memory limit {original_max_mem}") logging.debug(f"get original memory limit {original_max_mem}")
run_and_check([ run_and_check(['docker', 'update', '--memory=10g', node1.docker_id])
'docker', 'update', '--memory=10g', node1.docker_id
])
for _ in range(30): for _ in range(30):
time.sleep(10) time.sleep(10)
new_max_mem = get_latest_mem_limit() new_max_mem = get_latest_mem_limit()