ClickHouse/tests/integration/test_disable_insertion_and_mutation/test.py

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

76 lines
2.4 KiB
Python
Raw Normal View History

2024-07-15 07:10:39 +00:00
import pytest
from helpers.client import QueryRuntimeException
from helpers.cluster import ClickHouseCluster
import time
cluster = ClickHouseCluster(__file__)
writing_node = cluster.add_instance(
"writing_node",
2024-07-15 09:46:31 +00:00
main_configs=["config/writing_node.xml", "config/cluster.xml"],
2024-07-15 07:10:39 +00:00
with_zookeeper=True,
with_minio=True,
stay_alive=True,
macros={"shard": 1, "replica": 1},
)
reading_node = cluster.add_instance(
"reading_node",
2024-07-15 09:46:31 +00:00
main_configs=["config/reading_node.xml", "config/cluster.xml"],
2024-07-15 07:10:39 +00:00
with_zookeeper=True,
with_minio=True,
stay_alive=True,
macros={"shard": 1, "replica": 2},
)
@pytest.fixture(scope="module")
def started_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_disable_insertion_and_mutation(started_cluster):
2024-07-18 12:58:37 +00:00
writing_node.query(
"""CREATE TABLE my_table on cluster default (key UInt64, value String) ENGINE=ReplicatedMergeTree('/clickhouse/tables/{shard}/default.my_table', '{replica}') ORDER BY key partition by (key % 5) """
)
2024-07-15 07:10:39 +00:00
2024-07-18 07:41:08 +00:00
assert "QUERY_IS_PROHIBITED" in reading_node.query_and_get_error(
"INSERT INTO my_table VALUES (1, 'hello')"
2024-07-15 07:10:39 +00:00
)
2024-07-18 07:41:08 +00:00
assert "QUERY_IS_PROHIBITED" in reading_node.query_and_get_error(
"INSERT INTO my_table SETTINGS async_insert = 1 VALUES (1, 'hello')"
2024-07-15 07:10:39 +00:00
)
2024-07-18 07:41:08 +00:00
assert "QUERY_IS_PROHIBITED" in reading_node.query_and_get_error(
"ALTER TABLE my_table delete where 1"
2024-07-15 07:10:39 +00:00
)
2024-07-18 07:41:08 +00:00
assert "QUERY_IS_PROHIBITED" in reading_node.query_and_get_error(
"ALTER table my_table update key = 1 where 1"
2024-07-15 07:10:39 +00:00
)
2024-07-18 07:41:08 +00:00
assert "QUERY_IS_PROHIBITED" in reading_node.query_and_get_error(
"ALTER TABLE my_table drop partition 0"
2024-07-15 07:10:39 +00:00
)
2024-07-18 12:58:37 +00:00
reading_node.query("SELECT * from my_table")
2024-07-15 07:10:39 +00:00
writing_node.query("INSERT INTO my_table VALUES (1, 'hello')")
writing_node.query("ALTER TABLE my_table delete where 1")
writing_node.query("ALTER table my_table update value = 'no hello' where 1")
reading_node.query("ALTER TABLE my_table ADD COLUMN new_column UInt64")
writing_node.query("SELECT new_column from my_table")
reading_node.query("SELECT new_column from my_table")
reading_node.query("ALter Table my_table MODIFY COLUMN new_column String")
2024-07-18 12:58:37 +00:00
assert "new_column\tString" in reading_node.query("DESC my_table")
2024-07-15 07:10:39 +00:00
2024-07-18 12:58:37 +00:00
assert "new_column\tString" in writing_node.query("DESC my_table")