mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Fix test "test_backup_all" and add more test cases.
This commit is contained in:
parent
42c2ccb7cc
commit
225fee16dc
@ -1184,7 +1184,8 @@ def test_restore_partition():
|
||||
)
|
||||
|
||||
|
||||
def test_backup_all():
|
||||
@pytest.mark.parametrize("exclude_system_log_tables", [False, True])
|
||||
def test_backup_all(exclude_system_log_tables):
|
||||
create_and_fill_table()
|
||||
|
||||
session_id = new_session_id()
|
||||
@ -1201,20 +1202,34 @@ def test_backup_all():
|
||||
instance.query("CREATE USER u1 IDENTIFIED BY 'qwe123' SETTINGS custom_a = 1")
|
||||
|
||||
backup_name = new_backup_name()
|
||||
instance.http_query(
|
||||
f"BACKUP ALL TO {backup_name}",
|
||||
params={"session_id": session_id},
|
||||
)
|
||||
|
||||
exclude_from_backup = []
|
||||
if exclude_system_log_tables:
|
||||
system_log_tables = (
|
||||
instance.query(
|
||||
"SELECT concat('system.', table) FROM system.tables WHERE (database = 'system') AND (table LIKE '%_log')"
|
||||
)
|
||||
.rstrip("\n")
|
||||
.split("\n")
|
||||
)
|
||||
exclude_from_backup += system_log_tables
|
||||
|
||||
backup_command = f"BACKUP ALL {'EXCEPT TABLES ' + ','.join(exclude_from_backup) if exclude_from_backup else ''} TO {backup_name}"
|
||||
|
||||
instance.http_query(backup_command, params={"session_id": session_id})
|
||||
|
||||
instance.query("DROP TABLE test.table")
|
||||
instance.query("DROP FUNCTION two_and_half")
|
||||
instance.query("DROP USER u1")
|
||||
|
||||
restore_settings = []
|
||||
if not exclude_system_log_tables:
|
||||
restore_settings.append("allow_non_empty_tables=true")
|
||||
restore_command = f"RESTORE ALL FROM {backup_name} {'SETTINGS '+ ', '.join(restore_settings) if restore_settings else ''}"
|
||||
|
||||
session_id = new_session_id()
|
||||
instance.http_query(
|
||||
f"RESTORE ALL FROM {backup_name}",
|
||||
params={"session_id": session_id},
|
||||
method="POST",
|
||||
restore_command, params={"session_id": session_id}, method="POST"
|
||||
)
|
||||
|
||||
assert instance.query("SELECT count(), sum(x) FROM test.table") == "100\t4950\n"
|
||||
@ -1230,6 +1245,10 @@ def test_backup_all():
|
||||
== "CREATE USER u1 IDENTIFIED WITH sha256_password SETTINGS custom_a = 1\n"
|
||||
)
|
||||
|
||||
instance.query("DROP TABLE test.table")
|
||||
instance.query("DROP FUNCTION two_and_half")
|
||||
instance.query("DROP USER u1")
|
||||
|
||||
|
||||
def test_operation_id():
|
||||
create_and_fill_table(n=30)
|
||||
|
Loading…
Reference in New Issue
Block a user