2021-10-04 09:25:42 +00:00
|
|
|
import pytest
|
|
|
|
import re
|
|
|
|
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__, name="log_quries_probability")
|
2022-03-22 16:39:58 +00:00
|
|
|
node = cluster.add_instance("node", with_zookeeper=False)
|
2021-10-04 09:25:42 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
config = """<clickhouse>
|
2021-10-04 09:25:42 +00:00
|
|
|
<logger>
|
|
|
|
<level>information</level>
|
|
|
|
<log>/var/log/clickhouse-server/clickhouse-server.log</log>
|
|
|
|
</logger>
|
2022-03-22 16:39:58 +00:00
|
|
|
</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):
|
2022-03-22 16:39:58 +00:00
|
|
|
return node.exec_in_container(
|
|
|
|
["bash", "-c", "cat /var/log/clickhouse-server/clickhouse-server.log"]
|
|
|
|
)
|
|
|
|
|
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 i in range(5):
|
|
|
|
node.query("SELECT 1")
|
|
|
|
|
|
|
|
log = get_log(node)
|
|
|
|
assert re.search("(<Trace>|<Debug>)", log)
|
|
|
|
|
|
|
|
node.replace_config("/etc/clickhouse-server/config.d/log.xml", config)
|
|
|
|
node.query("SYSTEM RELOAD CONFIG;")
|
2022-03-22 16:39:58 +00:00
|
|
|
node.exec_in_container(
|
|
|
|
["bash", "-c", "> /var/log/clickhouse-server/clickhouse-server.log"]
|
|
|
|
)
|
|
|
|
|
2021-10-04 09:25:42 +00:00
|
|
|
for i in range(5):
|
|
|
|
node.query("SELECT 1")
|
|
|
|
|
|
|
|
log = get_log(node)
|
|
|
|
assert len(log) > 0
|
|
|
|
assert not re.search("(<Trace>|<Debug>)", log)
|