2024-06-10 20:46:13 +00:00
|
|
|
import pytest
|
|
|
|
from helpers.client import QueryRuntimeException
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
|
2024-07-21 09:15:13 +00:00
|
|
|
node = cluster.add_instance("node", main_configs=["config/config.xml"])
|
2024-06-10 20:46:13 +00:00
|
|
|
|
2024-06-10 21:02:34 +00:00
|
|
|
|
2024-06-10 20:46:13 +00:00
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def started_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
|
|
|
|
yield cluster
|
|
|
|
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
2024-06-10 21:02:34 +00:00
|
|
|
|
2024-06-10 20:46:13 +00:00
|
|
|
def test_table_db_limit(started_cluster):
|
2024-07-21 09:29:12 +00:00
|
|
|
# By the way, default database already exists.
|
|
|
|
for i in range(9):
|
2024-07-21 09:08:38 +00:00
|
|
|
node.query("create database db{}".format(i))
|
2024-06-10 20:46:13 +00:00
|
|
|
|
|
|
|
with pytest.raises(QueryRuntimeException) as exp_info:
|
2024-07-21 09:08:38 +00:00
|
|
|
node.query("create database db_exp".format(i))
|
2024-06-10 20:46:13 +00:00
|
|
|
|
|
|
|
assert "TOO_MANY_DATABASES" in str(exp_info)
|
2024-06-14 13:28:21 +00:00
|
|
|
|
|
|
|
for i in range(10):
|
2024-07-21 09:08:38 +00:00
|
|
|
node.query("create table t{} (a Int32) Engine = Log".format(i))
|
|
|
|
|
|
|
|
# This checks that system tables are not accounted in the number of tables.
|
|
|
|
node.query("system flush logs")
|
2024-06-14 13:28:21 +00:00
|
|
|
|
|
|
|
for i in range(10):
|
2024-07-21 09:08:38 +00:00
|
|
|
node.query("drop table t{}".format(i))
|
|
|
|
|
2024-06-10 20:46:13 +00:00
|
|
|
for i in range(10):
|
2024-07-21 09:08:38 +00:00
|
|
|
node.query("create table t{} (a Int32) Engine = Log".format(i))
|
2024-06-10 20:46:13 +00:00
|
|
|
|
|
|
|
with pytest.raises(QueryRuntimeException) as exp_info:
|
2024-07-21 09:08:38 +00:00
|
|
|
node.query("create table default.tx (a Int32) Engine = Log")
|
|
|
|
|
2024-06-10 20:46:13 +00:00
|
|
|
assert "TOO_MANY_TABLES" in str(exp_info)
|