mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
apply trash-formatter
This commit is contained in:
parent
dbf2763788
commit
09f09bd96d
@ -3403,7 +3403,11 @@ class ClickHouseInstance:
|
||||
self.wait_start(time_left)
|
||||
|
||||
def restart_with_latest_version(
|
||||
self, stop_start_wait_sec=300, callback_onstop=None, signal=15, fix_metadata=False
|
||||
self,
|
||||
stop_start_wait_sec=300,
|
||||
callback_onstop=None,
|
||||
signal=15,
|
||||
fix_metadata=False,
|
||||
):
|
||||
begin_time = time.time()
|
||||
if not self.stay_alive:
|
||||
@ -3454,10 +3458,18 @@ class ClickHouseInstance:
|
||||
# Versions older than 20.7 might not create .sql file for system and default database
|
||||
# Create it manually if upgrading from older version
|
||||
self.exec_in_container(
|
||||
["bash", "-c", "echo 'ATTACH DATABASE system ENGINE=Ordinary' > /var/lib/clickhouse/metadata/system.sql"],
|
||||
[
|
||||
"bash",
|
||||
"-c",
|
||||
"echo 'ATTACH DATABASE system ENGINE=Ordinary' > /var/lib/clickhouse/metadata/system.sql",
|
||||
],
|
||||
)
|
||||
self.exec_in_container(
|
||||
["bash", "-c", "echo 'ATTACH DATABASE system ENGINE=Ordinary' > /var/lib/clickhouse/metadata/default.sql"],
|
||||
[
|
||||
"bash",
|
||||
"-c",
|
||||
"echo 'ATTACH DATABASE system ENGINE=Ordinary' > /var/lib/clickhouse/metadata/default.sql",
|
||||
],
|
||||
)
|
||||
self.exec_in_container(
|
||||
["bash", "-c", "{} --daemon".format(self.clickhouse_start_command)],
|
||||
|
@ -20,7 +20,8 @@ def start_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
node1.query(
|
||||
"CREATE DATABASE zktest ENGINE=Ordinary;", settings={"allow_deprecated_database_ordinary": 1}
|
||||
"CREATE DATABASE zktest ENGINE=Ordinary;",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
) # Different behaviour with Atomic
|
||||
node1.query(
|
||||
"""
|
||||
|
@ -34,7 +34,10 @@ def create_force_drop_flag(node):
|
||||
@pytest.mark.parametrize("engine", ["Ordinary", "Atomic"])
|
||||
def test_attach_partition_with_large_destination(started_cluster, engine):
|
||||
# Initialize
|
||||
node.query("CREATE DATABASE db ENGINE={}".format(engine), settings={"allow_deprecated_database_ordinary": 1})
|
||||
node.query(
|
||||
"CREATE DATABASE db ENGINE={}".format(engine),
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
node.query(
|
||||
"CREATE TABLE db.destination (n UInt64) ENGINE=ReplicatedMergeTree('/test/destination', 'r1') ORDER BY n PARTITION BY n % 2"
|
||||
)
|
||||
|
@ -15,7 +15,8 @@ def started_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
instance.query(
|
||||
"CREATE DATABASE test ENGINE = Ordinary", settings={"allow_deprecated_database_ordinary": 1}
|
||||
"CREATE DATABASE test ENGINE = Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
) # Different path in shadow/ with Atomic
|
||||
instance.query("DROP TABLE IF EXISTS test.tbl")
|
||||
instance.query(
|
||||
|
@ -202,7 +202,8 @@ def test_backup_from_old_version_config(started_cluster):
|
||||
|
||||
def test_backup_and_alter(started_cluster):
|
||||
node4.query(
|
||||
"CREATE DATABASE test ENGINE=Ordinary", settings={"allow_deprecated_database_ordinary": 1}
|
||||
"CREATE DATABASE test ENGINE=Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
) # Different path in shadow/ with Atomic
|
||||
|
||||
node4.query(
|
||||
|
@ -10,6 +10,7 @@ node = cluster.add_instance(
|
||||
with_installed_binary=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def start_cluster():
|
||||
try:
|
||||
@ -19,17 +20,23 @@ def start_cluster():
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
def q(query):
|
||||
return node.query(query, settings={"log_queries": 1})
|
||||
|
||||
|
||||
def test_convert_system_db_to_atomic(start_cluster):
|
||||
q("CREATE TABLE t(date Date, id UInt32) ENGINE = MergeTree PARTITION BY toYYYYMM(date) ORDER BY id")
|
||||
q(
|
||||
"CREATE TABLE t(date Date, id UInt32) ENGINE = MergeTree PARTITION BY toYYYYMM(date) ORDER BY id"
|
||||
)
|
||||
q("INSERT INTO t VALUES (today(), 1)")
|
||||
q("INSERT INTO t SELECT number % 1000, number FROM system.numbers LIMIT 1000000")
|
||||
|
||||
assert "1000001\n" == q("SELECT count() FROM t")
|
||||
assert "499999500001\n" == q("SELECT sum(id) FROM t")
|
||||
assert "1970-01-01\t1000\t499500000\n1970-01-02\t1000\t499501000\n" == q("SELECT date, count(), sum(id) FROM t GROUP BY date ORDER BY date LIMIT 2")
|
||||
assert "1970-01-01\t1000\t499500000\n1970-01-02\t1000\t499501000\n" == q(
|
||||
"SELECT date, count(), sum(id) FROM t GROUP BY date ORDER BY date LIMIT 2"
|
||||
)
|
||||
q("SYSTEM FLUSH LOGS")
|
||||
|
||||
assert "query_log" in q("SHOW TABLES FROM system")
|
||||
@ -50,10 +57,13 @@ def test_convert_system_db_to_atomic(start_cluster):
|
||||
assert "part_log_0" in node.query("SHOW TABLES FROM system")
|
||||
assert "1\n" == node.query("SELECT count() != 0 FROM system.query_log_0")
|
||||
assert "1\n" == node.query("SELECT count() != 0 FROM system.part_log_0")
|
||||
assert "1970-01-01\t1000\t499500000\n1970-01-02\t1000\t499501000\n" == node.query("SELECT date, count(), sum(id) FROM t GROUP BY date ORDER BY date LIMIT 2")
|
||||
assert "INFORMATION_SCHEMA\ndefault\ninformation_schema\nsystem\n" == node.query("SELECT name FROM system.databases ORDER BY name")
|
||||
assert "1970-01-01\t1000\t499500000\n1970-01-02\t1000\t499501000\n" == node.query(
|
||||
"SELECT date, count(), sum(id) FROM t GROUP BY date ORDER BY date LIMIT 2"
|
||||
)
|
||||
assert "INFORMATION_SCHEMA\ndefault\ninformation_schema\nsystem\n" == node.query(
|
||||
"SELECT name FROM system.databases ORDER BY name"
|
||||
)
|
||||
|
||||
assert "0\n" == node.count_in_log("<Error>")
|
||||
assert "0\n" == node.count_in_log("<Warning> Database")
|
||||
assert "0\n" == node.count_in_log("always include the lines below")
|
||||
|
||||
|
@ -16,7 +16,10 @@ def start_cluster():
|
||||
for node in nodes:
|
||||
node.query("CREATE DATABASE IF NOT EXISTS test")
|
||||
# Different internal dictionary name with Atomic
|
||||
node.query("CREATE DATABASE IF NOT EXISTS test_ordinary ENGINE=Ordinary", settings={"allow_deprecated_database_ordinary": 1})
|
||||
node.query(
|
||||
"CREATE DATABASE IF NOT EXISTS test_ordinary ENGINE=Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
node.query("CREATE DATABASE IF NOT EXISTS atest")
|
||||
node.query("CREATE DATABASE IF NOT EXISTS ztest")
|
||||
node.query("CREATE TABLE test.source(x UInt64, y UInt64) ENGINE=Log")
|
||||
|
@ -552,7 +552,9 @@ def test_replicated_without_arguments(test_cluster):
|
||||
)
|
||||
|
||||
test_cluster.ddl_check_query(
|
||||
instance, "CREATE DATABASE test_ordinary ON CLUSTER cluster ENGINE=Ordinary", settings={"allow_deprecated_database_ordinary": 1}
|
||||
instance,
|
||||
"CREATE DATABASE test_ordinary ON CLUSTER cluster ENGINE=Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
assert (
|
||||
"are supported only for ON CLUSTER queries with Atomic database engine"
|
||||
|
@ -20,7 +20,8 @@ def start_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
node.query(
|
||||
"CREATE DATABASE IF NOT EXISTS test ENGINE=Ordinary", settings={"allow_deprecated_database_ordinary": 1}
|
||||
"CREATE DATABASE IF NOT EXISTS test ENGINE=Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
) # Different paths with Atomic
|
||||
yield cluster
|
||||
finally:
|
||||
|
@ -16,7 +16,10 @@ def started_cluster():
|
||||
|
||||
|
||||
def test_file_path_escaping(started_cluster):
|
||||
node.query("CREATE DATABASE IF NOT EXISTS test ENGINE = Ordinary", settings={"allow_deprecated_database_ordinary": 1})
|
||||
node.query(
|
||||
"CREATE DATABASE IF NOT EXISTS test ENGINE = Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
node.query(
|
||||
"""
|
||||
CREATE TABLE test.`T.a_b,l-e!` (`~Id` UInt32)
|
||||
|
@ -33,7 +33,10 @@ def create_force_drop_flag(node):
|
||||
|
||||
@pytest.mark.parametrize("engine", ["Ordinary", "Atomic"])
|
||||
def test_drop_materialized_view(started_cluster, engine):
|
||||
node.query("CREATE DATABASE d ENGINE={}".format(engine), settings={"allow_deprecated_database_ordinary": 1})
|
||||
node.query(
|
||||
"CREATE DATABASE d ENGINE={}".format(engine),
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
node.query(
|
||||
"CREATE TABLE d.rmt (n UInt64) ENGINE=ReplicatedMergeTree('/test/rmt', 'r1') ORDER BY n PARTITION BY n % 2"
|
||||
)
|
||||
|
@ -95,7 +95,10 @@ def test_blocade_leader(started_cluster):
|
||||
wait_nodes()
|
||||
try:
|
||||
for i, node in enumerate([node1, node2, node3]):
|
||||
node.query("CREATE DATABASE IF NOT EXISTS ordinary ENGINE=Ordinary", settings={"allow_deprecated_database_ordinary": 1})
|
||||
node.query(
|
||||
"CREATE DATABASE IF NOT EXISTS ordinary ENGINE=Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
node.query(
|
||||
"CREATE TABLE IF NOT EXISTS ordinary.t1 (value UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/t1', '{}') ORDER BY tuple()".format(
|
||||
i + 1
|
||||
@ -296,7 +299,10 @@ def test_blocade_leader_twice(started_cluster):
|
||||
wait_nodes()
|
||||
try:
|
||||
for i, node in enumerate([node1, node2, node3]):
|
||||
node.query("CREATE DATABASE IF NOT EXISTS ordinary ENGINE=Ordinary", settings={"allow_deprecated_database_ordinary": 1})
|
||||
node.query(
|
||||
"CREATE DATABASE IF NOT EXISTS ordinary ENGINE=Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
node.query(
|
||||
"CREATE TABLE IF NOT EXISTS ordinary.t2 (value UInt64) ENGINE = ReplicatedMergeTree('/clickhouse/t2', '{}') ORDER BY tuple()".format(
|
||||
i + 1
|
||||
|
@ -93,7 +93,8 @@ def create_table(
|
||||
node.query(
|
||||
"CREATE DATABASE IF NOT EXISTS s3 ENGINE = {engine}".format(
|
||||
engine="Atomic" if db_atomic else "Ordinary"
|
||||
), settings={"allow_deprecated_database_ordinary": 1}
|
||||
),
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
|
||||
create_table_statement = """
|
||||
|
@ -14,7 +14,8 @@ def started_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
q(
|
||||
"CREATE DATABASE test ENGINE = Ordinary", settings={"allow_deprecated_database_ordinary": 1}
|
||||
"CREATE DATABASE test ENGINE = Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
) # Different path in shadow/ with Atomic
|
||||
|
||||
yield cluster
|
||||
|
@ -720,7 +720,8 @@ def test_in_memory_alters(start_cluster):
|
||||
|
||||
def test_polymorphic_parts_index(start_cluster):
|
||||
node1.query(
|
||||
"CREATE DATABASE test_index ENGINE=Ordinary", settings={"allow_deprecated_database_ordinary": 1}
|
||||
"CREATE DATABASE test_index ENGINE=Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
) # Different paths with Atomic
|
||||
node1.query(
|
||||
"""
|
||||
|
@ -52,7 +52,10 @@ def test_replicated_merge_tree_defaults_compatibility(started_cluster):
|
||||
"""
|
||||
|
||||
for node in (node1, node2):
|
||||
node.query("CREATE DATABASE test ENGINE = Ordinary", settings={"allow_deprecated_database_ordinary": 1})
|
||||
node.query(
|
||||
"CREATE DATABASE test ENGINE = Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
node.query(create_query.format(replica=node.name))
|
||||
|
||||
node1.query("DETACH TABLE test.table")
|
||||
|
@ -76,7 +76,8 @@ def create_table(node, table_name, schema, attach=False, db_atomic=False, uuid="
|
||||
"CREATE DATABASE IF NOT EXISTS s3 {on_cluster} ENGINE = {engine}".format(
|
||||
engine="Atomic" if db_atomic else "Ordinary",
|
||||
on_cluster="ON CLUSTER '{cluster}'",
|
||||
), settings={"allow_deprecated_database_ordinary": 1}
|
||||
),
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
|
||||
create_table_statement = """
|
||||
|
@ -26,9 +26,13 @@ def started_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
node1.query(
|
||||
"CREATE DATABASE test ENGINE=Ordinary", settings={"allow_deprecated_database_ordinary": 1}
|
||||
"CREATE DATABASE test ENGINE=Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
) # Different paths with Atomic
|
||||
node2.query("CREATE DATABASE test ENGINE=Ordinary", settings={"allow_deprecated_database_ordinary": 1})
|
||||
node2.query(
|
||||
"CREATE DATABASE test ENGINE=Ordinary",
|
||||
settings={"allow_deprecated_database_ordinary": 1},
|
||||
)
|
||||
yield cluster
|
||||
|
||||
finally:
|
||||
|
Loading…
Reference in New Issue
Block a user