ClickHouse/tests/integration/test_log_lz4_streaming/test.py

62 lines
1.4 KiB
Python
Raw Normal View History

2021-10-28 13:24:00 +00:00
import pytest
2021-11-10 21:10:03 +00:00
import time
2021-10-28 13:24:00 +00:00
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance("node", main_configs=["configs/logs.xml"], stay_alive=True)
2021-10-28 13:24:00 +00:00
@pytest.fixture(scope="module")
def started_cluster():
try:
cluster.start()
yield cluster
finally:
2021-11-15 11:27:04 +00:00
cluster.shutdown()
2021-10-28 13:24:00 +00:00
2021-11-10 21:10:03 +00:00
def check_log_file():
2021-12-02 13:25:45 +00:00
assert node.path_exists("/var/log/clickhouse-server/clickhouse-server.log.lz4")
2021-10-28 13:24:00 +00:00
lz4_output = node.exec_in_container(
[
"bash",
"-c",
"lz4 -t /var/log/clickhouse-server/clickhouse-server.log.lz4 2>&1",
],
user="root",
)
assert lz4_output.count("Error") == 0, lz4_output
compressed_size = int(
node.exec_in_container(
[
"bash",
"-c",
"du -b /var/log/clickhouse-server/clickhouse-server.log.lz4 | awk {' print $1 '}",
],
user="root",
)
)
2021-11-10 21:10:03 +00:00
uncompressed_size = int(lz4_output.split()[3])
assert 0 < compressed_size < uncompressed_size, lz4_output
def test_concatenation(started_cluster):
2021-10-28 13:24:00 +00:00
node.stop_clickhouse()
node.start_clickhouse()
node.stop_clickhouse()
2021-11-10 21:10:03 +00:00
check_log_file()
2021-10-28 13:24:00 +00:00
2021-11-10 21:10:03 +00:00
def test_incomplete_rotation(started_cluster):
node.stop_clickhouse(kill=True)
node.start_clickhouse()
node.stop_clickhouse()
check_log_file()