mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
a6f89c0546
* Added suggestions for mistyped names for db and tables with different scenarios commented * fixed bugs * fixed style check * fixed errors * fixed errors * fixed error with exceptions * fixed exceptions * fixed exceptions * fixed exceptions * added test and fixed bugs * fixed style check * fixed style check * fixed style check * fixed check black * Update test.py * Fixed server crash * Fixed server crash and style check * Fixed style check * Fixed style check * Fixed style check * Fixed bugs with drop_db * fixed fast test * added tests * fixed style check * fixed style check * fixed bug with lock_db * fixed bug with lock_db and fixed reviews * fixed bug with lock_db and fixed reviews * fixed style check * fixed fast test * fixed fast test * revert tofd582a2
* revert tofd582a2
* Removed unused parameters Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Remove unused parameters Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * resolved arguments issue in assertDatabaseExists * fixing fast test * fixed fast test * fixed stateless test for default db * Update src/Interpreters/DatabaseCatalog.cpp Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Update src/Interpreters/DatabaseCatalog.cpp Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Update src/Interpreters/DatabaseCatalog.cpp Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Fixing tests. * resolved problem with mutex * Fixed mutex in assertDatabaseExists * changes about assertDatabaseExists * fixed bugs with file types * fixed string types * fixed fast test * fixed mutex * fixed mutex * fixed style check * Update src/Interpreters/DatabaseCatalog.cpp Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Update src/Interpreters/DatabaseCatalog.cpp Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Update src/Interpreters/DatabaseCatalog.cpp Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Update src/Interpreters/DatabaseCatalog.cpp Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Update src/Interpreters/DatabaseCatalog.cpp Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Update src/Interpreters/DatabaseCatalog.cpp Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * fixed build * added -unlocked versions of functions * Revert "fixed build" This reverts commit8ce961be21
. * Revert "fixed build" This reverts commit8ce961be21
. * changed usage of assertDatabaseExistsUnlocked() * fixed style check * style check * style check * Revert "style check" This reverts commit28a9ee85a0
. * Merge branch 'master' into hints-for-wrong-db-or-table-name * Changed AssertDatabaseExists and unified exception output * resolved proposed changes and modified tests * Revert "resolved proposed changes and modified tests" This reverts commitd45337d65c
. * resolved requested changes * fixed tests * fixed tests * fixed check black * Update include brackets Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com> * Update suggested changes * Update suggested changes * Fixed style check * Added test to analyzer_integration_broken * Update DatabaseCatalog.cpp * Update test.py * fixed test * Revert "fixed test" This reverts commitca6d4c17c8
. * fixed test * Revert "fixed test" This reverts commitfe6d0d9c86
, reversing changes made to22f4496704
. * Update test.py * fixed black check * Update test.py * fixed long_log_tinylog_deadlock_race * Update DatabaseCatalog.cpp * Update test.py * style * Update DatabaseCatalog.cpp * Fixed test * implemented for IDatabase * Style check * removed const_cast * Update DatabaseCatalog.h * Update DatabaseCatalog.h * Update DatabaseCatalog.cpp * Update DatabaseCatalog.cpp * Added db name to hints * Update 00002_log_and_exception_messages_formatting.sql * Update 00002_log_and_exception_messages_formatting.sql --------- Co-authored-by: Yakov Olkhovskiy <99031427+yakov-olkhovskiy@users.noreply.github.com>
168 lines
4.8 KiB
Python
168 lines
4.8 KiB
Python
# pylint: disable=line-too-long
|
|
# pylint: disable=unused-argument
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
import time
|
|
import pytest
|
|
from helpers.cluster import ClickHouseCluster
|
|
from helpers.test_tools import assert_eq_with_retry
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
node = cluster.add_instance(
|
|
"node_default",
|
|
stay_alive=True,
|
|
)
|
|
|
|
system_logs = [
|
|
# disabled by default
|
|
("system.text_log", 0),
|
|
# enabled by default
|
|
("system.query_log", 1),
|
|
("system.query_thread_log", 1),
|
|
("system.part_log", 1),
|
|
("system.trace_log", 1),
|
|
("system.metric_log", 1),
|
|
]
|
|
|
|
|
|
@pytest.fixture(scope="module", autouse=True)
|
|
def start_cluster():
|
|
try:
|
|
cluster.start()
|
|
yield cluster
|
|
finally:
|
|
cluster.shutdown()
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def flush_logs():
|
|
node.query("SYSTEM FLUSH LOGS")
|
|
|
|
|
|
@pytest.mark.parametrize("table,exists", system_logs)
|
|
def test_system_logs(flush_logs, table, exists):
|
|
q = "SELECT * FROM {}".format(table)
|
|
if exists:
|
|
node.query(q)
|
|
else:
|
|
response = node.query_and_get_error(q)
|
|
assert (
|
|
"Table {} does not exist".format(table) in response
|
|
or "Unknown table expression identifier '{}'".format(table) in response
|
|
)
|
|
|
|
|
|
# Logic is tricky, let's check that there is no hang in case of message queue
|
|
# is not empty (this is another code path in the code).
|
|
def test_system_logs_non_empty_queue():
|
|
node.query(
|
|
"SELECT 1",
|
|
settings={
|
|
# right now defaults are the same,
|
|
# this set explicitly to avoid depends from defaults.
|
|
"log_queries": 1,
|
|
"log_queries_min_type": "QUERY_START",
|
|
},
|
|
)
|
|
node.query("SYSTEM FLUSH LOGS")
|
|
|
|
|
|
def test_system_suspend():
|
|
node.query("CREATE TABLE t (x DateTime) ENGINE=Memory;")
|
|
node.query("INSERT INTO t VALUES (now());")
|
|
node.query("SYSTEM SUSPEND FOR 1 SECOND;")
|
|
node.query("INSERT INTO t VALUES (now());")
|
|
assert "1\n" == node.query("SELECT max(x) - min(x) >= 1 FROM t;")
|
|
|
|
|
|
def test_log_max_size(start_cluster):
|
|
node.exec_in_container(
|
|
[
|
|
"bash",
|
|
"-c",
|
|
f"""echo "
|
|
<clickhouse>
|
|
<query_log>
|
|
<flush_interval_milliseconds replace=\\"replace\\">1000000</flush_interval_milliseconds>
|
|
<max_size_rows replace=\\"replace\\">10</max_size_rows>
|
|
<reserved_size_rows replace=\\"replace\\">10</reserved_size_rows>
|
|
</query_log>
|
|
</clickhouse>
|
|
" > /etc/clickhouse-server/config.d/yyy-override-query_log.xml
|
|
""",
|
|
]
|
|
)
|
|
node.restart_clickhouse()
|
|
for i in range(10):
|
|
node.query(f"select {i}")
|
|
|
|
assert node.query("select count() >= 10 from system.query_log") == "1\n"
|
|
node.exec_in_container(
|
|
["rm", f"/etc/clickhouse-server/config.d/yyy-override-query_log.xml"]
|
|
)
|
|
|
|
|
|
def test_log_buffer_size_rows_flush_threshold(start_cluster):
|
|
node.exec_in_container(
|
|
[
|
|
"bash",
|
|
"-c",
|
|
f"""echo "
|
|
<clickhouse>
|
|
<query_log>
|
|
<flush_interval_milliseconds replace=\\"replace\\">1000000</flush_interval_milliseconds>
|
|
<buffer_size_rows_flush_threshold replace=\\"replace\\">10</buffer_size_rows_flush_threshold>
|
|
<max_size_rows replace=\\"replace\\">10000</max_size_rows>
|
|
</query_log>
|
|
</clickhouse>
|
|
" > /etc/clickhouse-server/config.d/yyy-override-query_log.xml
|
|
""",
|
|
]
|
|
)
|
|
node.restart_clickhouse()
|
|
node.query(f"TRUNCATE TABLE IF EXISTS system.query_log")
|
|
for i in range(10):
|
|
node.query(f"select {i}")
|
|
|
|
assert_eq_with_retry(
|
|
node,
|
|
f"select count() >= 11 from system.query_log",
|
|
"1",
|
|
sleep_time=0.2,
|
|
retry_count=100,
|
|
)
|
|
|
|
node.query(f"TRUNCATE TABLE IF EXISTS system.query_log")
|
|
node.exec_in_container(
|
|
[
|
|
"bash",
|
|
"-c",
|
|
f"""echo "
|
|
<clickhouse>
|
|
<query_log>
|
|
<flush_interval_milliseconds replace=\\"replace\\">1000000</flush_interval_milliseconds>
|
|
<buffer_size_rows_flush_threshold replace=\\"replace\\">10000</buffer_size_rows_flush_threshold>
|
|
<max_size_rows replace=\\"replace\\">10000</max_size_rows>
|
|
</query_log>
|
|
</clickhouse>
|
|
" > /etc/clickhouse-server/config.d/yyy-override-query_log.xml
|
|
""",
|
|
]
|
|
)
|
|
node.restart_clickhouse()
|
|
for i in range(10):
|
|
node.query(f"select {i}")
|
|
|
|
# Logs aren't flushed
|
|
assert_eq_with_retry(
|
|
node,
|
|
f"select count() < 10 from system.query_log",
|
|
"1",
|
|
sleep_time=0.2,
|
|
retry_count=100,
|
|
)
|
|
|
|
node.exec_in_container(
|
|
["rm", f"/etc/clickhouse-server/config.d/yyy-override-query_log.xml"]
|
|
)
|