ClickHouse/tests/integration/test_log_lz4_streaming/test.py

45 lines
1.2 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)
@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():
assert node.file_exists("/var/log/clickhouse-server/clickhouse-server.log.lz4")
2021-10-28 13:24:00 +00:00
2021-11-10 21:10:03 +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'))
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()