ClickHouse/tests/integration/test_log_levels_update/test.py

68 lines
1.7 KiB
Python
Raw Normal View History

2021-10-04 09:25:42 +00:00
import re
2024-09-27 10:19:39 +00:00
import pytest
2021-10-04 09:25:42 +00:00
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
2022-08-24 16:14:30 +00:00
node = cluster.add_instance(
"node", with_zookeeper=False, main_configs=["configs/log.xml"]
)
2021-10-04 09:25:42 +00:00
config = """<clickhouse>
2021-10-04 09:25:42 +00:00
<logger>
2023-03-01 23:35:09 +00:00
<level>debug</level>
2021-10-04 09:25:42 +00:00
<log>/var/log/clickhouse-server/clickhouse-server.log</log>
</logger>
</clickhouse>"""
2021-10-04 09:25:42 +00:00
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def get_log(node):
return node.exec_in_container(
["bash", "-c", "cat /var/log/clickhouse-server/clickhouse-server.log"]
)
2021-10-04 09:25:42 +00:00
def check_it_will_work_slowly(node, log):
it_will_work_slowly = "It will work slowly"
if node.is_built_with_sanitizer() or node.is_debug_build():
# message still in logs
re.search(f"<Warning>.*{it_will_work_slowly}", log)
# but not in system.warnings
query = f"SELECT count() FROM system.warnings WHERE message ILIKE '%{it_will_work_slowly}%'"
assert 0 == int(node.query(query).strip())
2021-10-04 09:25:42 +00:00
def test_log_levels_update(start_cluster):
# Make sure that there are enough log messages for the test
for _ in range(5):
2021-10-04 09:25:42 +00:00
node.query("SELECT 1")
log = get_log(node)
assert re.search("(<Trace>|<Debug>)", log)
check_it_will_work_slowly(node, log)
2021-10-04 09:25:42 +00:00
node.replace_config("/etc/clickhouse-server/config.d/log.xml", config)
node.query("SYSTEM RELOAD CONFIG;")
node.exec_in_container(
["bash", "-c", "> /var/log/clickhouse-server/clickhouse-server.log"]
)
for _ in range(5):
2021-10-04 09:25:42 +00:00
node.query("SELECT 1")
log = get_log(node)
assert len(log) > 0
2023-03-02 14:31:38 +00:00
assert not re.search("<Trace>", log)