mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Add integration test
This commit is contained in:
parent
7f4a01b903
commit
5e9340f682
@ -85,8 +85,6 @@ namespace
|
||||
last_exception = std::current_exception();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
NamesAndTypesList StorageSystemDictionaries::getNamesAndTypes()
|
||||
|
@ -0,0 +1,28 @@
|
||||
<clickhouse>
|
||||
<logger>
|
||||
<level>trace</level>
|
||||
<log>/var/log/clickhouse-server/clickhouse-server.log</log>
|
||||
<errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>
|
||||
<size>1000M</size>
|
||||
<count>10</count>
|
||||
</logger>
|
||||
|
||||
<tcp_port>9000</tcp_port>
|
||||
<listen_host>127.0.0.1</listen_host>
|
||||
|
||||
<openSSL>
|
||||
<client>
|
||||
<cacheSessions>true</cacheSessions>
|
||||
<verificationMode>none</verificationMode>
|
||||
<invalidCertificateHandler>
|
||||
<name>AcceptCertificateHandler</name>
|
||||
</invalidCertificateHandler>
|
||||
</client>
|
||||
</openSSL>
|
||||
|
||||
<max_concurrent_queries>500</max_concurrent_queries>
|
||||
<path>./clickhouse/</path>
|
||||
<users_config>users.xml</users_config>
|
||||
|
||||
<dictionaries_config>/etc/clickhouse-server/config.d/*.xml</dictionaries_config>
|
||||
</clickhouse>
|
@ -0,0 +1,37 @@
|
||||
<clickhouse>
|
||||
<dictionary>
|
||||
<name>bad_dict</name>
|
||||
|
||||
<source>
|
||||
<clickhouse>
|
||||
<host>localhost</host>
|
||||
<port>9000</port>
|
||||
<user>default</user>
|
||||
<password></password>
|
||||
<db>test</db>
|
||||
<table>source</table>
|
||||
</clickhouse>
|
||||
</source>
|
||||
|
||||
<lifetime>0</lifetime>
|
||||
|
||||
<layout>
|
||||
<cache><size_in_cells>128</size_in_cells></cache>
|
||||
</layout>
|
||||
|
||||
<structure>
|
||||
<id>
|
||||
<name>id</name>
|
||||
</id>
|
||||
|
||||
<attribute>
|
||||
<name>bad_attr</name>
|
||||
<type>bad_type</type>
|
||||
<null_value></null_value>
|
||||
<hierarchical>false</hierarchical>
|
||||
<injective>false</injective>
|
||||
</attribute>
|
||||
|
||||
</structure>
|
||||
</dictionary>
|
||||
</clickhouse>
|
@ -0,0 +1,37 @@
|
||||
<clickhouse>
|
||||
<dictionary>
|
||||
<name>valid_dict</name>
|
||||
|
||||
<source>
|
||||
<clickhouse>
|
||||
<host>localhost</host>
|
||||
<port>9000</port>
|
||||
<user>default</user>
|
||||
<password></password>
|
||||
<db>test</db>
|
||||
<table>source</table>
|
||||
</clickhouse>
|
||||
</source>
|
||||
|
||||
<lifetime>0</lifetime>
|
||||
|
||||
<layout>
|
||||
<cache><size_in_cells>128</size_in_cells></cache>
|
||||
</layout>
|
||||
|
||||
<structure>
|
||||
<id>
|
||||
<name>id</name>
|
||||
</id>
|
||||
|
||||
<attribute>
|
||||
<name>UInt64_attr</name>
|
||||
<type>UInt64</type>
|
||||
<null_value></null_value>
|
||||
<hierarchical>false</hierarchical>
|
||||
<injective>false</injective>
|
||||
</attribute>
|
||||
|
||||
</structure>
|
||||
</dictionary>
|
||||
</clickhouse>
|
@ -0,0 +1,22 @@
|
||||
<clickhouse>
|
||||
<profiles>
|
||||
<default>
|
||||
</default>
|
||||
</profiles>
|
||||
|
||||
<users>
|
||||
<default>
|
||||
<password></password>
|
||||
<networks incl="networks" replace="replace">
|
||||
<ip>::/0</ip>
|
||||
</networks>
|
||||
<profile>default</profile>
|
||||
<quota>default</quota>
|
||||
</default>
|
||||
</users>
|
||||
|
||||
<quotas>
|
||||
<default>
|
||||
</default>
|
||||
</quotas>
|
||||
</clickhouse>
|
@ -0,0 +1,56 @@
|
||||
import pytest
|
||||
|
||||
from helpers.client import QueryRuntimeException
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
|
||||
DICTIONARY_FILES = [
|
||||
"configs/dictionaries/bad_dict.xml",
|
||||
"configs/dictionaries/valid_dict.xml",
|
||||
]
|
||||
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
instance = cluster.add_instance("instance", dictionaries=DICTIONARY_FILES)
|
||||
|
||||
VALID_DICT_NAME = "valid_dict"
|
||||
BAD_DICT_NAME = "bad_dict"
|
||||
UNKNOWN_DATA_TYPE_EXCEPTION_STR = "DB::Exception: Unknown data type"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def started_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
yield cluster
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
def test_select_from_system_dictionaries_with_bad_dictionary(started_cluster):
|
||||
query = instance.query
|
||||
|
||||
assert query("SELECT name FROM system.dictionaries;").splitlines() == [
|
||||
VALID_DICT_NAME,
|
||||
BAD_DICT_NAME,
|
||||
]
|
||||
|
||||
assert (
|
||||
query(
|
||||
f"select last_exception from system.dictionaries WHERE name='{VALID_DICT_NAME}';"
|
||||
).strip()
|
||||
== ""
|
||||
)
|
||||
|
||||
assert (
|
||||
UNKNOWN_DATA_TYPE_EXCEPTION_STR
|
||||
in query(
|
||||
f"select last_exception from system.dictionaries WHERE name='{BAD_DICT_NAME}';"
|
||||
).strip()
|
||||
)
|
||||
|
||||
|
||||
def test_dictGet_func_for_bad_dictionary(started_cluster):
|
||||
query = instance.query
|
||||
|
||||
with pytest.raises(QueryRuntimeException) as exc:
|
||||
query(f"SELECT dictGetString('{BAD_DICT_NAME}', 'bad_attr', toInt64(1));")
|
||||
assert UNKNOWN_DATA_TYPE_EXCEPTION_STR in str(exc.value)
|
Loading…
Reference in New Issue
Block a user