2021-07-26 18:17:39 +00:00
|
|
|
# pylint: disable=unused-argument
|
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
# pylint: disable=line-too-long
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from helpers.client import QueryRuntimeException
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
node = cluster.add_instance(
|
|
|
|
"node", main_configs=["configs/rocksdb.xml"], stay_alive=True
|
|
|
|
)
|
2021-07-26 18:17:39 +00:00
|
|
|
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
@pytest.fixture(scope="module")
|
2021-07-26 18:17:39 +00:00
|
|
|
def start_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
|
2021-09-23 09:19:30 +00:00
|
|
|
def test_valid_options(start_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2021-07-26 18:17:39 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB PRIMARY KEY(key);
|
|
|
|
DROP TABLE test;
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
|
|
|
)
|
2022-08-10 13:20:25 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2022-08-17 15:27:18 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB(0) PRIMARY KEY(key);
|
2022-08-10 13:20:25 +00:00
|
|
|
DROP TABLE test;
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
node.query(
|
|
|
|
"""
|
2022-08-22 15:31:55 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB(10) PRIMARY KEY(key);
|
2022-08-10 13:20:25 +00:00
|
|
|
DROP TABLE test;
|
|
|
|
"""
|
|
|
|
)
|
2022-08-24 15:42:13 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB(0, '/var/lib/clickhouse/store/test_rocksdb_read_only') PRIMARY KEY(key);
|
|
|
|
DROP TABLE test;
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
node.query(
|
|
|
|
"""
|
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB(10, '/var/lib/clickhouse/store/test_rocksdb_read_only', 1) PRIMARY KEY(key);
|
|
|
|
DROP TABLE test;
|
|
|
|
"""
|
|
|
|
)
|
2022-08-26 12:00:17 +00:00
|
|
|
|
|
|
|
|
2021-09-23 09:19:30 +00:00
|
|
|
def test_invalid_options(start_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.exec_in_container(
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
"-c",
|
|
|
|
"sed -i 's/max_background_jobs/no_such_option/g' /etc/clickhouse-server/config.d/rocksdb.xml",
|
|
|
|
]
|
|
|
|
)
|
2021-07-26 18:17:39 +00:00
|
|
|
node.restart_clickhouse()
|
|
|
|
with pytest.raises(QueryRuntimeException):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2021-07-26 18:17:39 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB PRIMARY KEY(key);
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
node.exec_in_container(
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
"-c",
|
|
|
|
"sed -i 's/no_such_option/max_background_jobs/g' /etc/clickhouse-server/config.d/rocksdb.xml",
|
|
|
|
]
|
|
|
|
)
|
2021-07-26 18:17:39 +00:00
|
|
|
node.restart_clickhouse()
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
|
2021-09-23 09:19:30 +00:00
|
|
|
def test_table_valid_options(start_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2021-07-26 18:17:39 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB PRIMARY KEY(key);
|
|
|
|
DROP TABLE test;
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
2021-07-26 18:17:39 +00:00
|
|
|
|
2021-09-23 09:19:30 +00:00
|
|
|
def test_table_invalid_options(start_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.exec_in_container(
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
"-c",
|
|
|
|
"sed -i 's/max_open_files/no_such_table_option/g' /etc/clickhouse-server/config.d/rocksdb.xml",
|
|
|
|
]
|
|
|
|
)
|
2021-07-26 18:17:39 +00:00
|
|
|
node.restart_clickhouse()
|
|
|
|
with pytest.raises(QueryRuntimeException):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2021-07-26 18:17:39 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB PRIMARY KEY(key);
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
node.exec_in_container(
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
"-c",
|
|
|
|
"sed -i 's/no_such_table_option/max_open_files/g' /etc/clickhouse-server/config.d/rocksdb.xml",
|
|
|
|
]
|
|
|
|
)
|
2021-07-26 18:17:39 +00:00
|
|
|
node.restart_clickhouse()
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
|
2021-09-23 09:19:30 +00:00
|
|
|
def test_valid_column_family_options(start_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2021-07-26 18:17:39 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB PRIMARY KEY(key);
|
|
|
|
DROP TABLE test;
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
2021-07-26 18:17:39 +00:00
|
|
|
|
2021-09-26 05:21:59 +00:00
|
|
|
def test_invalid_column_family_options(start_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.exec_in_container(
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
"-c",
|
|
|
|
"sed -i 's/num_levels/no_such_column_family_option/g' /etc/clickhouse-server/config.d/rocksdb.xml",
|
|
|
|
]
|
|
|
|
)
|
2021-09-26 05:21:59 +00:00
|
|
|
node.restart_clickhouse()
|
|
|
|
with pytest.raises(QueryRuntimeException):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2021-09-26 05:21:59 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB PRIMARY KEY(key);
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
node.exec_in_container(
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
"-c",
|
|
|
|
"sed -i 's/no_such_column_family_option/num_levels/g' /etc/clickhouse-server/config.d/rocksdb.xml",
|
|
|
|
]
|
|
|
|
)
|
2021-09-26 05:21:59 +00:00
|
|
|
node.restart_clickhouse()
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
|
2021-09-24 23:04:53 +00:00
|
|
|
def test_table_valid_column_family_options(start_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2021-07-26 18:17:39 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB PRIMARY KEY(key);
|
|
|
|
DROP TABLE test;
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
2021-09-26 05:23:21 +00:00
|
|
|
|
|
|
|
def test_table_invalid_column_family_options(start_cluster):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.exec_in_container(
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
"-c",
|
|
|
|
"sed -i 's/max_bytes_for_level_base/no_such_table_column_family_option/g' /etc/clickhouse-server/config.d/rocksdb.xml",
|
|
|
|
]
|
|
|
|
)
|
2021-09-26 05:23:21 +00:00
|
|
|
node.restart_clickhouse()
|
|
|
|
with pytest.raises(QueryRuntimeException):
|
2022-03-22 16:39:58 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2021-09-26 05:23:21 +00:00
|
|
|
CREATE TABLE test (key UInt64, value String) Engine=EmbeddedRocksDB PRIMARY KEY(key);
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
|
|
|
)
|
|
|
|
node.exec_in_container(
|
|
|
|
[
|
|
|
|
"bash",
|
|
|
|
"-c",
|
|
|
|
"sed -i 's/no_such_table_column_family_option/max_bytes_for_level_base/g' /etc/clickhouse-server/config.d/rocksdb.xml",
|
|
|
|
]
|
|
|
|
)
|
2021-09-26 05:23:21 +00:00
|
|
|
node.restart_clickhouse()
|