mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
fix tests
This commit is contained in:
parent
31dcc7634e
commit
94dd80e900
@ -94,6 +94,15 @@ static void loadDatabase(
|
||||
}
|
||||
}
|
||||
|
||||
static void checkUnsupportedVersion(ContextMutablePtr context, const String & database_name)
|
||||
{
|
||||
/// Produce better exception message
|
||||
String metadata_path = context->getPath() + "metadata/" + database_name;
|
||||
if (fs::exists(fs::path(metadata_path)))
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Data directory for {} database exists, but metadata file does not. "
|
||||
"Probably you are trying to upgrade from version older than 20.7. "
|
||||
"If so, you should upgrade through intermediate version.", database_name);
|
||||
}
|
||||
|
||||
void loadMetadata(ContextMutablePtr context, const String & default_database_name)
|
||||
{
|
||||
@ -151,7 +160,10 @@ void loadMetadata(ContextMutablePtr context, const String & default_database_nam
|
||||
bool create_default_db_if_not_exists = !default_database_name.empty();
|
||||
bool metadata_dir_for_default_db_already_exists = databases.contains(default_database_name);
|
||||
if (create_default_db_if_not_exists && !metadata_dir_for_default_db_already_exists)
|
||||
{
|
||||
checkUnsupportedVersion(context, default_database_name);
|
||||
databases.emplace(default_database_name, std::filesystem::path(path) / escapeForFileName(default_database_name));
|
||||
}
|
||||
|
||||
TablesLoader::Databases loaded_databases;
|
||||
for (const auto & [name, db_path] : databases)
|
||||
@ -186,15 +198,9 @@ static void loadSystemDatabaseImpl(ContextMutablePtr context, const String & dat
|
||||
/// 'has_force_restore_data_flag' is true, to not fail on loading query_log table, if it is corrupted.
|
||||
loadDatabase(context, database_name, path, true);
|
||||
}
|
||||
else if (fs::exists(fs::path(path)))
|
||||
{
|
||||
chassert(database_name == "system");
|
||||
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Data directory for {} database exists, but metadata file does not. "
|
||||
"Probably you are trying to upgrade from version older than 20.7. "
|
||||
"If so, you should upgrade through intermediate version.", database_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkUnsupportedVersion(context, database_name);
|
||||
/// Initialize system database manually
|
||||
String database_create_query = "CREATE DATABASE ";
|
||||
database_create_query += database_name;
|
||||
|
@ -64,6 +64,10 @@ def test_convert_system_db_to_atomic(start_cluster):
|
||||
"SELECT name FROM system.databases ORDER BY name"
|
||||
)
|
||||
|
||||
assert "0\n" == node.count_in_log("<Error>")
|
||||
errors_count = node.count_in_log("<Error>")
|
||||
assert "0\n" == errors_count or (
|
||||
"1\n" == errors_count
|
||||
and "1\n" == node.count_in_log("Can't receive Netlink response")
|
||||
)
|
||||
assert "0\n" == node.count_in_log("<Warning> Database")
|
||||
assert "0\n" == node.count_in_log("always include the lines below")
|
||||
|
@ -228,11 +228,11 @@ def test_inserts_batching(started_cluster):
|
||||
# 4. Full batch of inserts after ALTER (that have different block structure).
|
||||
# 5. What was left to insert with the column structure before ALTER.
|
||||
expected = """\
|
||||
20000101__1_1_0\t[1]
|
||||
20000101__2_2_0\t[2,3,4]
|
||||
20000101__3_3_0\t[5,6,7]
|
||||
20000101__4_4_0\t[10,11,12]
|
||||
20000101__5_5_0\t[8,9]
|
||||
200001_1_1_0\t[1]
|
||||
200001_2_2_0\t[2,3,4]
|
||||
200001_3_3_0\t[5,6,7]
|
||||
200001_4_4_0\t[10,11,12]
|
||||
200001_5_5_0\t[8,9]
|
||||
"""
|
||||
assert TSV(result) == TSV(expected)
|
||||
|
||||
|
@ -44,7 +44,8 @@ CREATE TABLE distributed (x UInt32) ENGINE = Distributed('test_cluster', 'defaul
|
||||
)
|
||||
|
||||
remote.query(
|
||||
"CREATE TABLE local2 (d Date, x UInt32, s String) ENGINE = MergeTree(d, x, 8192)"
|
||||
"CREATE TABLE local2 (d Date, x UInt32, s String) ENGINE = MergeTree(d, x, 8192)",
|
||||
settings={"allow_deprecated_syntax_for_merge_tree": 1},
|
||||
)
|
||||
instance_test_inserts_batching.query(
|
||||
"""
|
||||
@ -65,7 +66,8 @@ CREATE TABLE distributed (d Date, x UInt32) ENGINE = Distributed('test_cluster',
|
||||
"CREATE MATERIALIZED VIEW local_view to distributed_on_local AS SELECT d,x FROM local_source"
|
||||
)
|
||||
instance_test_inserts_local_cluster.query(
|
||||
"CREATE TABLE local (d Date, x UInt32) ENGINE = MergeTree(d, x, 8192)"
|
||||
"CREATE TABLE local (d Date, x UInt32) ENGINE = MergeTree(d, x, 8192)",
|
||||
settings={"allow_deprecated_syntax_for_merge_tree": 1},
|
||||
)
|
||||
instance_test_inserts_local_cluster.query(
|
||||
"""
|
||||
|
@ -2,6 +2,7 @@
|
||||
<profiles>
|
||||
<default>
|
||||
<optimize_trivial_count_query>0</optimize_trivial_count_query>
|
||||
<allow_deprecated_syntax_for_merge_tree>1</allow_deprecated_syntax_for_merge_tree>
|
||||
</default>
|
||||
</profiles>
|
||||
</clickhouse>
|
||||
|
@ -66,7 +66,8 @@ def create_tables_old_format(name, nodes, shard):
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/{shard}/{name}', '{repl}', date, id, 64)
|
||||
""".format(
|
||||
name=name, shard=shard, repl=i
|
||||
)
|
||||
),
|
||||
settings={"allow_deprecated_syntax_for_merge_tree": 1},
|
||||
)
|
||||
|
||||
|
||||
|
@ -96,14 +96,17 @@ def test_create_replicated_table(started_cluster):
|
||||
"Explicit zookeeper_path and replica_name are specified"
|
||||
in main_node.query_and_get_error(
|
||||
"CREATE TABLE testdb.replicated_table (d Date, k UInt64, i32 Int32) "
|
||||
"ENGINE=ReplicatedMergeTree('/test/tmp', 'r', d, k, 8192);"
|
||||
"ENGINE=ReplicatedMergeTree('/test/tmp', 'r') ORDER BY k PARTITION BY toYYYYMM(d);"
|
||||
)
|
||||
)
|
||||
|
||||
assert "Old syntax is not allowed" in main_node.query_and_get_error(
|
||||
assert (
|
||||
"This syntax for *MergeTree engine is deprecated"
|
||||
in main_node.query_and_get_error(
|
||||
"CREATE TABLE testdb.replicated_table (d Date, k UInt64, i32 Int32) "
|
||||
"ENGINE=ReplicatedMergeTree('/test/tmp/{shard}', '{replica}', d, k, 8192);"
|
||||
)
|
||||
)
|
||||
|
||||
main_node.query(
|
||||
"CREATE TABLE testdb.replicated_table (d Date, k UInt64, i32 Int32) ENGINE=ReplicatedMergeTree ORDER BY k PARTITION BY toYYYYMM(d);"
|
||||
|
@ -0,0 +1 @@
|
||||
ATTACH DATABASE default ENGINE=Ordinary
|
Loading…
Reference in New Issue
Block a user