fix tests

This commit is contained in:
Alexander Tokmakov 2022-08-26 15:33:04 +02:00
parent b8e3a582f7
commit 7fa0cc02f2
3 changed files with 3 additions and 59 deletions

View File

@ -1,56 +0,0 @@
import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node1 = cluster.add_instance("node1", with_zookeeper=True)
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_table_start_without_metadata(start_cluster):
node1.query(
"""
CREATE TABLE test (date Date)
ENGINE = ReplicatedMergeTree('/clickhouse/table/test_table', '1')
ORDER BY tuple()
"""
)
node1.query("INSERT INTO test VALUES(toDate('2019-12-01'))")
assert node1.query("SELECT date FROM test") == "2019-12-01\n"
# some fake alter
node1.query("ALTER TABLE test MODIFY COLUMN date Date DEFAULT toDate('2019-10-01')")
assert node1.query("SELECT date FROM test") == "2019-12-01\n"
node1.query("DETACH TABLE test")
zk_cli = cluster.get_kazoo_client("zoo1")
# simulate update from old version
zk_cli.delete("/clickhouse/table/test_table/replicas/1/metadata")
zk_cli.delete("/clickhouse/table/test_table/replicas/1/metadata_version")
node1.query("ATTACH TABLE test")
assert node1.query("SELECT date FROM test") == "2019-12-01\n"
node1.query("ALTER TABLE test MODIFY COLUMN date Date DEFAULT toDate('2019-09-01')")
node1.query("DETACH TABLE test")
zk_cli.set("/clickhouse/table/test_table/replicas/1/metadata", b"")
node1.query("ATTACH TABLE test")
assert node1.query("SELECT date FROM test") == "2019-12-01\n"

View File

@ -10,7 +10,7 @@ node1 = cluster.add_instance(
"node1",
with_zookeeper=True,
image="yandex/clickhouse-server",
tag="20.1.10.70",
tag="20.4.9.110",
with_installed_binary=True,
stay_alive=True,
)
@ -18,7 +18,7 @@ node2 = cluster.add_instance(
"node2",
with_zookeeper=True,
image="yandex/clickhouse-server",
tag="20.1.10.70",
tag="20.4.9.110",
with_installed_binary=True,
stay_alive=True,
)
@ -26,7 +26,7 @@ node3 = cluster.add_instance(
"node3",
with_zookeeper=True,
image="yandex/clickhouse-server",
tag="20.1.10.70",
tag="20.4.9.110",
with_installed_binary=True,
stay_alive=True,
)