ClickHouse/tests/integration/test_analyzer_compatibility/test.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

101 lines
2.6 KiB
Python
Raw Normal View History

2024-07-02 22:51:21 +00:00
import uuid
import pytest
from helpers.cluster import ClickHouseCluster
from helpers.test_tools import TSV
CLICKHOUSE_MAX_VERSION_WITH_ANALYZER_DISABLED_BY_DEFAULT = "24.2"
cluster = ClickHouseCluster(__file__)
# Here analyzer is enabled by default
current = cluster.add_instance(
"current",
main_configs=["configs/remote_servers.xml"],
)
# Here analyzer is disabled by default
backward = cluster.add_instance(
"backward",
use_old_analyzer=True,
main_configs=["configs/remote_servers.xml"],
image="clickhouse/clickhouse-server",
tag=CLICKHOUSE_MAX_VERSION_WITH_ANALYZER_DISABLED_BY_DEFAULT,
with_installed_binary=True,
)
2024-07-02 22:59:22 +00:00
2024-07-02 22:51:21 +00:00
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_two_new_versions(start_cluster):
# Two new versions (both know about the analyzer)
# One have it enabled by default, another one - disabled.
current.query("SYSTEM FLUSH LOGS")
backward.query("SYSTEM FLUSH LOGS")
query_id = str(uuid.uuid4())
2024-07-02 22:59:22 +00:00
current.query(
"SELECT * FROM clusterAllReplicas('test_cluster_mixed', system.tables);",
query_id=query_id,
)
2024-07-02 22:51:21 +00:00
current.query("SYSTEM FLUSH LOGS")
backward.query("SYSTEM FLUSH LOGS")
2024-07-02 22:59:22 +00:00
assert (
current.query(
"""
2024-07-02 22:51:21 +00:00
SELECT hostname() AS h, getSetting('allow_experimental_analyzer')
FROM clusterAllReplicas('test_cluster_mixed', system.one)
2024-07-02 22:59:22 +00:00
ORDER BY h;"""
)
== TSV([["backward", "true"], ["current", "true"]])
)
2024-07-02 22:51:21 +00:00
# Should be enabled everywhere
2024-07-02 22:59:22 +00:00
analyzer_enabled = current.query(
f"""
2024-07-02 22:51:21 +00:00
SELECT
DISTINCT Settings['allow_experimental_analyzer']
FROM clusterAllReplicas('test_cluster_mixed', system.query_log)
2024-07-02 22:59:22 +00:00
WHERE initial_query_id = '{query_id}';"""
)
2024-07-02 22:51:21 +00:00
assert TSV(analyzer_enabled) == TSV("1")
query_id = str(uuid.uuid4())
2024-07-02 22:59:22 +00:00
backward.query(
"SELECT * FROM clusterAllReplicas('test_cluster_mixed', system.tables)",
query_id=query_id,
)
2024-07-02 22:51:21 +00:00
current.query("SYSTEM FLUSH LOGS")
backward.query("SYSTEM FLUSH LOGS")
2024-07-02 22:59:22 +00:00
assert (
backward.query(
"""
2024-07-02 22:51:21 +00:00
SELECT hostname() AS h, getSetting('allow_experimental_analyzer')
FROM clusterAllReplicas('test_cluster_mixed', system.one)
2024-07-02 22:59:22 +00:00
ORDER BY h;"""
)
== TSV([["backward", "false"], ["current", "false"]])
)
2024-07-02 22:51:21 +00:00
# Should be disabled everywhere
2024-07-02 22:59:22 +00:00
analyzer_enabled = backward.query(
f"""
2024-07-02 22:51:21 +00:00
SELECT
DISTINCT Settings['allow_experimental_analyzer']
FROM clusterAllReplicas('test_cluster_mixed', system.query_log)
2024-07-02 22:59:22 +00:00
WHERE initial_query_id = '{query_id}';"""
)
2024-07-02 22:51:21 +00:00
assert TSV(analyzer_enabled) == TSV("0")