2019-12-22 22:10:33 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from helpers.client import QueryRuntimeException
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
from helpers.test_tools import TSV
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
2022-03-22 16:39:58 +00:00
|
|
|
instance = cluster.add_instance(
|
|
|
|
"instance", user_configs=["configs/combined_profile.xml"]
|
|
|
|
)
|
2019-12-22 22:10:33 +00:00
|
|
|
q = instance.query
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def started_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
|
|
|
|
yield cluster
|
|
|
|
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
|
|
|
def test_combined_profile(started_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
settings = q(
|
|
|
|
"""
|
2019-12-22 22:10:33 +00:00
|
|
|
SELECT name, value FROM system.settings
|
|
|
|
WHERE name IN
|
2019-12-27 17:14:30 +00:00
|
|
|
('max_insert_block_size', 'max_network_bytes', 'max_query_size',
|
2019-12-22 22:10:33 +00:00
|
|
|
'max_parallel_replicas', 'readonly')
|
|
|
|
AND changed
|
|
|
|
ORDER BY name
|
2022-03-22 16:39:58 +00:00
|
|
|
""",
|
|
|
|
user="test_combined_profile",
|
|
|
|
)
|
2019-12-22 22:10:33 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
expected1 = """\
|
2019-12-22 22:10:33 +00:00
|
|
|
max_insert_block_size 654321
|
|
|
|
max_network_bytes 1234567890
|
|
|
|
max_parallel_replicas 2
|
2019-12-27 17:14:30 +00:00
|
|
|
max_query_size 400000000
|
2022-03-22 16:39:58 +00:00
|
|
|
readonly 2"""
|
2019-12-22 22:10:33 +00:00
|
|
|
|
|
|
|
assert TSV(settings) == TSV(expected1)
|
|
|
|
|
|
|
|
with pytest.raises(QueryRuntimeException) as exc:
|
2022-03-22 16:39:58 +00:00
|
|
|
q(
|
|
|
|
"""
|
2019-12-22 22:10:33 +00:00
|
|
|
SET max_insert_block_size = 1000;
|
2022-03-22 16:39:58 +00:00
|
|
|
""",
|
|
|
|
user="test_combined_profile",
|
|
|
|
)
|
2019-12-22 22:10:33 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
assert "max_insert_block_size shouldn't be less than 654320." in str(exc.value)
|
2019-12-22 22:10:33 +00:00
|
|
|
|
|
|
|
with pytest.raises(QueryRuntimeException) as exc:
|
2022-03-22 16:39:58 +00:00
|
|
|
q(
|
|
|
|
"""
|
2019-12-22 22:10:33 +00:00
|
|
|
SET max_network_bytes = 2000000000;
|
2022-03-22 16:39:58 +00:00
|
|
|
""",
|
|
|
|
user="test_combined_profile",
|
|
|
|
)
|
2019-12-22 22:10:33 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
assert "max_network_bytes shouldn't be greater than 1234567891." in str(exc.value)
|
2019-12-22 22:10:33 +00:00
|
|
|
|
|
|
|
with pytest.raises(QueryRuntimeException) as exc:
|
2022-03-22 16:39:58 +00:00
|
|
|
q(
|
|
|
|
"""
|
2019-12-22 22:10:33 +00:00
|
|
|
SET max_parallel_replicas = 1000;
|
2022-03-22 16:39:58 +00:00
|
|
|
""",
|
|
|
|
user="test_combined_profile",
|
|
|
|
)
|
2019-12-22 22:10:33 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
assert "max_parallel_replicas should not be changed." in str(exc.value)
|
2019-12-27 17:14:30 +00:00
|
|
|
|
|
|
|
with pytest.raises(QueryRuntimeException) as exc:
|
2022-03-22 16:39:58 +00:00
|
|
|
q(
|
|
|
|
"""
|
2019-12-27 17:14:30 +00:00
|
|
|
SET max_memory_usage = 1000;
|
2022-03-22 16:39:58 +00:00
|
|
|
""",
|
|
|
|
user="test_combined_profile",
|
|
|
|
)
|
2019-12-27 17:14:30 +00:00
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
assert "max_memory_usage shouldn't be less than 300000000." in str(exc.value)
|