mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 20:02:05 +00:00
101 lines
2.6 KiB
Python
101 lines
2.6 KiB
Python
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,
|
|
)
|
|
|
|
|
|
@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())
|
|
current.query(
|
|
"SELECT * FROM clusterAllReplicas('test_cluster_mixed', system.tables);",
|
|
query_id=query_id,
|
|
)
|
|
|
|
current.query("SYSTEM FLUSH LOGS")
|
|
backward.query("SYSTEM FLUSH LOGS")
|
|
|
|
assert (
|
|
current.query(
|
|
"""
|
|
SELECT hostname() AS h, getSetting('allow_experimental_analyzer')
|
|
FROM clusterAllReplicas('test_cluster_mixed', system.one)
|
|
ORDER BY h;"""
|
|
)
|
|
== TSV([["backward", "true"], ["current", "true"]])
|
|
)
|
|
|
|
# Should be enabled everywhere
|
|
analyzer_enabled = current.query(
|
|
f"""
|
|
SELECT
|
|
DISTINCT Settings['allow_experimental_analyzer']
|
|
FROM clusterAllReplicas('test_cluster_mixed', system.query_log)
|
|
WHERE initial_query_id = '{query_id}';"""
|
|
)
|
|
|
|
assert TSV(analyzer_enabled) == TSV("1")
|
|
|
|
query_id = str(uuid.uuid4())
|
|
backward.query(
|
|
"SELECT * FROM clusterAllReplicas('test_cluster_mixed', system.tables)",
|
|
query_id=query_id,
|
|
)
|
|
|
|
current.query("SYSTEM FLUSH LOGS")
|
|
backward.query("SYSTEM FLUSH LOGS")
|
|
|
|
assert (
|
|
backward.query(
|
|
"""
|
|
SELECT hostname() AS h, getSetting('allow_experimental_analyzer')
|
|
FROM clusterAllReplicas('test_cluster_mixed', system.one)
|
|
ORDER BY h;"""
|
|
)
|
|
== TSV([["backward", "false"], ["current", "false"]])
|
|
)
|
|
|
|
# Should be disabled everywhere
|
|
analyzer_enabled = backward.query(
|
|
f"""
|
|
SELECT
|
|
DISTINCT Settings['allow_experimental_analyzer']
|
|
FROM clusterAllReplicas('test_cluster_mixed', system.query_log)
|
|
WHERE initial_query_id = '{query_id}';"""
|
|
)
|
|
|
|
assert TSV(analyzer_enabled) == TSV("0")
|