2022-06-29 15:53:08 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import logging
|
|
|
|
import pytest
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
node = cluster.add_instance("node", stay_alive=True)
|
|
|
|
|
2022-06-29 18:29:50 +00:00
|
|
|
|
2022-06-29 15:53:08 +00:00
|
|
|
@pytest.fixture(scope="module", autouse=True)
|
|
|
|
def start_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
2022-06-29 15:56:59 +00:00
|
|
|
def test_restart_success_ipv4():
|
2022-06-29 18:29:50 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2022-06-29 15:53:08 +00:00
|
|
|
CREATE TABLE ipv4_test
|
|
|
|
(
|
|
|
|
id UInt64,
|
|
|
|
value String
|
|
|
|
) ENGINE=MergeTree ORDER BY id""",
|
2022-06-29 18:29:50 +00:00
|
|
|
settings={"cast_ipv4_ipv6_default_on_conversion_error": 1},
|
|
|
|
)
|
2022-06-29 15:53:08 +00:00
|
|
|
|
2022-06-29 18:29:50 +00:00
|
|
|
node.query(
|
|
|
|
"ALTER TABLE ipv4_test MODIFY COLUMN value IPv4 DEFAULT ''",
|
|
|
|
settings={"cast_ipv4_ipv6_default_on_conversion_error": 1},
|
|
|
|
)
|
2022-06-29 15:53:08 +00:00
|
|
|
|
|
|
|
node.restart_clickhouse()
|
|
|
|
|
|
|
|
assert node.query("SELECT 1") == "1\n"
|
2022-06-29 15:56:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_restart_success_ipv6():
|
2022-06-29 18:29:50 +00:00
|
|
|
node.query(
|
|
|
|
"""
|
2022-06-29 15:56:59 +00:00
|
|
|
CREATE TABLE ipv6_test
|
|
|
|
(
|
|
|
|
id UInt64,
|
|
|
|
value String
|
|
|
|
) ENGINE=MergeTree ORDER BY id""",
|
2022-06-29 18:29:50 +00:00
|
|
|
settings={"cast_ipv4_ipv6_default_on_conversion_error": 1},
|
|
|
|
)
|
2022-06-29 15:56:59 +00:00
|
|
|
|
2022-06-29 18:29:50 +00:00
|
|
|
node.query(
|
|
|
|
"ALTER TABLE ipv6_test MODIFY COLUMN value IPv6 DEFAULT ''",
|
|
|
|
settings={"cast_ipv4_ipv6_default_on_conversion_error": 1},
|
|
|
|
)
|
2022-06-29 15:56:59 +00:00
|
|
|
|
|
|
|
node.restart_clickhouse()
|
|
|
|
|
|
|
|
assert node.query("SELECT 1") == "1\n"
|