2022-07-15 17:01:30 +00:00
|
|
|
import pytest
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
import json
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
2022-07-29 06:51:59 +00:00
|
|
|
node = cluster.add_instance("node", main_configs=["configs/config_json.xml"])
|
2022-07-15 17:01:30 +00:00
|
|
|
|
2022-08-02 03:48:57 +00:00
|
|
|
|
2022-07-15 17:01:30 +00:00
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def start_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
2022-08-02 03:48:57 +00:00
|
|
|
|
2022-07-15 17:01:30 +00:00
|
|
|
def is_json(log_json):
|
|
|
|
try:
|
|
|
|
json.loads(log_json)
|
|
|
|
except ValueError as e:
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def test_structured_logging_json_format(start_cluster):
|
|
|
|
node.query("SELECT 1")
|
|
|
|
|
2022-08-02 03:48:57 +00:00
|
|
|
logs = node.grep_in_log("").split("\n")
|
2022-08-02 03:21:48 +00:00
|
|
|
length = min(10, len(logs))
|
|
|
|
for i in range(0, length):
|
|
|
|
assert is_json(logs[i])
|