From 772209e6c0bd0a124d6605a6fe6ef873df8ec161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=93=D0=B0=D1=80?= =?UTF-8?q?=D0=B1=D0=B0=D1=80?= Date: Tue, 29 Oct 2024 16:23:21 +0300 Subject: [PATCH] Test other replica and cleanup --- .../test_table_db_num_limit/config/config.xml | 5 ++- .../config/config1.xml | 4 ++ .../config/config2.xml | 4 ++ .../test_table_db_num_limit/test.py | 40 +++++++++++++++++-- 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 tests/integration/test_table_db_num_limit/config/config1.xml create mode 100644 tests/integration/test_table_db_num_limit/config/config2.xml diff --git a/tests/integration/test_table_db_num_limit/config/config.xml b/tests/integration/test_table_db_num_limit/config/config.xml index bfe50325d3f..88438d51b94 100644 --- a/tests/integration/test_table_db_num_limit/config/config.xml +++ b/tests/integration/test_table_db_num_limit/config/config.xml @@ -6,13 +6,16 @@ node1 9000 + + node2 + 9000 + 10 10 - 5 10 diff --git a/tests/integration/test_table_db_num_limit/config/config1.xml b/tests/integration/test_table_db_num_limit/config/config1.xml new file mode 100644 index 00000000000..73b695f3cd6 --- /dev/null +++ b/tests/integration/test_table_db_num_limit/config/config1.xml @@ -0,0 +1,4 @@ + + 5 + + diff --git a/tests/integration/test_table_db_num_limit/config/config2.xml b/tests/integration/test_table_db_num_limit/config/config2.xml new file mode 100644 index 00000000000..e46ca03d70f --- /dev/null +++ b/tests/integration/test_table_db_num_limit/config/config2.xml @@ -0,0 +1,4 @@ + + 3 + + diff --git a/tests/integration/test_table_db_num_limit/test.py b/tests/integration/test_table_db_num_limit/test.py index bcfa60e48cd..53a644a262c 100644 --- a/tests/integration/test_table_db_num_limit/test.py +++ b/tests/integration/test_table_db_num_limit/test.py @@ -7,7 +7,15 @@ cluster = ClickHouseCluster(__file__) node = cluster.add_instance( "node1", with_zookeeper=True, - main_configs=["config/config.xml"], + macros={"replica": "r1"}, + main_configs=["config/config.xml", "config/config1.xml"], +) + +node2 = cluster.add_instance( + "node2", + with_zookeeper=True, + macros={"replica": "r2"}, + main_configs=["config/config.xml", "config/config2.xml"], ) @@ -64,15 +72,27 @@ def test_table_db_limit(started_cluster): for i in range(10): node.query("drop table t{}".format(i)) - for i in range(5): + for i in range(3): node.query( - "create table t{} (a Int32) Engine = ReplicatedMergeTree('/clickhouse/tables/t{}', 'r1') order by a".format( + "create table t{} on cluster 'cluster' (a Int32) Engine = ReplicatedMergeTree('/clickhouse/tables/t{}', '{{replica}}') order by a".format( + i, i + ) + ) + + # Test limit on other replica + assert "Too many replicated tables" in node2.query_and_get_error( + "create table tx (a Int32) Engine = ReplicatedMergeTree('/clickhouse/tables/tx', '{replica}') order by a" + ) + + for i in range(3, 5): + node.query( + "create table t{} (a Int32) Engine = ReplicatedMergeTree('/clickhouse/tables/t{}', '{{replica}}') order by a".format( i, i ) ) assert "Too many replicated tables" in node.query_and_get_error( - "create table tx (a Int32) Engine = ReplicatedMergeTree('/clickhouse/tables/tx', 'r1') order by a" + "create table tx (a Int32) Engine = ReplicatedMergeTree('/clickhouse/tables/tx', '{replica}') order by a" ) # Checks that replicated tables are also counted as regular tables @@ -82,3 +102,15 @@ def test_table_db_limit(started_cluster): assert "TOO_MANY_TABLES" in node.query_and_get_error( "create table tx (a Int32) Engine = Log" ) + + # Cleanup + for i in range(10): + node.query("drop table t{} sync".format(i)) + for i in range(3): + node2.query("drop table t{} sync".format(i)) + node.query("system drop replica 'r1' from ZKPATH '/clickhouse/tables/tx'") + node.query("system drop replica 'r2' from ZKPATH '/clickhouse/tables/tx'") + for i in range(9): + node.query("drop database db{}".format(i)) + for i in range(10): + node.query("drop dictionary d{}".format(i))