Add integration tests and delete stateless tests

This commit is contained in:
JackyWoo 2024-08-20 19:02:37 +08:00
parent 38c196a834
commit 08cb7ff8d8
6 changed files with 78 additions and 16 deletions

View File

@ -0,0 +1,12 @@
<clickhouse>
<remote_servers>
<test_cluster>
<shard>
<replica>
<host>node1</host>
<port>9000</port>
</replica>
</shard>
</test_cluster>
</remote_servers>
</clickhouse>

View File

@ -0,0 +1,9 @@
<clickhouse>
<logger>
<level>information</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>
</clickhouse>

View File

@ -0,0 +1,57 @@
import logging
import pytest
from helpers.cluster import ClickHouseCluster
@pytest.fixture(scope="module")
def cluster():
try:
cluster = ClickHouseCluster(__file__)
cluster.add_instance(
"node",
main_configs=[
"configs/config.d/cluster.xml",
]
)
logging.info("Starting cluster...")
cluster.start()
logging.info("Cluster started")
yield cluster
finally:
cluster.shutdown()
def test_incorrect_datetime_format(cluster):
"""
Test for an MSan issue which is caused by parsing incorrect datetime string
"""
node = cluster.instances["node"]
table_name = "test_delete_race_leftovers"
additional_settings = {
# use another disk not to interfere with other tests
"storage_policy": "one_disk",
# always remove parts in parallel
"concurrent_part_removal_threshold": 1,
}
node.query("""
CREATE TABLE tab
(
a DateTime,
pk String
) Engine = MergeTree() ORDER BY pk;
"""
)
res = node.query("SELECT count(*) FROM tab WHERE a = '2024-08-06 09:58:09'").strip()
assert res == "0"
error = node.query_and_get_error("SELECT count(*) FROM tab WHERE a = '2024-08-06 09:58:0'").strip()
print(error)
assert "Cannot parse time component of DateTime 09:58:0" in error
error = node.query_and_get_error("SELECT count(*) FROM tab WHERE a = '2024-08-0 09:58:09'").strip()
print(error)
assert "Cannot convert string '2024-08-0 09:58:09' to type DateTime" in error

View File

@ -1,15 +0,0 @@
DROP TABLE IF EXISTS tab SYNC;
CREATE TABLE tab
(
a DateTime,
pk String
) Engine = MergeTree() ORDER BY pk;
INSERT INTO tab select cast(number, 'DateTime'), generateUUIDv4() FROM system.numbers LIMIT 1;
SELECT count(*) FROM tab WHERE a = '2024-08-06 09:58:09';
SELECT count(*) FROM tab WHERE a = '2024-08-06 09:58:0'; -- { serverError CANNOT_PARSE_DATETIME }
SELECT count(*) FROM tab WHERE a = '2024-08-0 09:58:09'; -- { serverError TYPE_MISMATCH }
DROP TABLE IF EXISTS tab SYNC;