mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 03:22:14 +00:00
b75963d370
This PR formats all the `*.py` files found under the `tests/integration` folder. It also reorders the imports and cleans up a bunch of unused imports. The formatting also takes care of other things like wrapping lines and fixing spaces and indents such that the tests look more readable.
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
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", "")
|
|
|
|
node1.query("ATTACH TABLE test")
|
|
|
|
assert node1.query("SELECT date FROM test") == "2019-12-01\n"
|