2020-01-23 20:50:26 +00:00
|
|
|
# pylint: disable=unused-argument
|
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
from helpers.client import QueryRuntimeException
|
2020-09-16 04:26:10 +00:00
|
|
|
from helpers.cluster import ClickHouseCluster
|
2020-01-23 20:50:26 +00:00
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
|
2020-08-12 08:55:04 +00:00
|
|
|
node = cluster.add_instance("node", main_configs=["configs/config.d/text_log.xml"])
|
2020-01-23 20:50:26 +00:00
|
|
|
|
2020-09-16 04:26:10 +00:00
|
|
|
|
2020-01-23 20:50:26 +00:00
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def start_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
|
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
2020-09-16 04:26:10 +00:00
|
|
|
|
2020-01-23 20:50:26 +00:00
|
|
|
def test_basic(start_cluster):
|
|
|
|
with pytest.raises(QueryRuntimeException):
|
|
|
|
# generates log with "Error" level
|
|
|
|
node.query("SELECT * FROM no_such_table")
|
2022-03-22 16:39:58 +00:00
|
|
|
|
2020-01-23 20:50:26 +00:00
|
|
|
node.query("SYSTEM FLUSH LOGS")
|
2022-03-22 16:39:58 +00:00
|
|
|
|
2020-01-23 20:50:26 +00:00
|
|
|
assert (
|
|
|
|
int(node.query("SELECT count() FROM system.text_log WHERE level = 'Trace'"))
|
|
|
|
== 0
|
2022-03-22 16:39:58 +00:00
|
|
|
)
|
2020-01-23 20:50:26 +00:00
|
|
|
assert (
|
|
|
|
int(node.query("SELECT count() FROM system.text_log WHERE level = 'Debug'"))
|
|
|
|
== 0
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
int(
|
|
|
|
node.query(
|
|
|
|
"SELECT count() FROM system.text_log WHERE level = 'Information'"
|
2022-03-22 16:39:58 +00:00
|
|
|
)
|
|
|
|
)
|
2020-01-23 20:50:26 +00:00
|
|
|
>= 1
|
2022-03-22 16:39:58 +00:00
|
|
|
)
|
2020-01-23 20:50:26 +00:00
|
|
|
assert (
|
|
|
|
int(node.query("SELECT count() FROM system.text_log WHERE level = 'Error'"))
|
|
|
|
>= 1
|
2022-03-22 16:39:58 +00:00
|
|
|
)
|