6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00

Added/Updated tests\bugs\gh_7168_test.py: Checked on: 4.0.3.2904, 5.0.0.475 -- all OK.

This commit is contained in:
pavel-zotov 2023-03-02 11:45:52 +03:00
parent ee06a7db85
commit 85faa9ac41

View File

@ -0,0 +1,62 @@
#coding:utf-8
"""
ID: issue-7168
ISSUE: https://github.com/FirebirdSQL/firebird/issues/7168
TITLE: Ignore missing UDR libraries during restore
DESCRIPTION:
Database with 3d-party UDR was created beforehand in FB 4.0.1, backed up and .fbk was compressed.
After decompressing .fbk we try to restore this database using FB snapshot which for sure has no
such UDR, with verbose = True.
Test verifies that restore log contains messages about UDR and correct finish of restoring process.
NOTES:
[02.03.2023] pzotov
Confirmed problem on 4.0.1.2707 (21-jan-2022), 5.0.0.471 (09-apr-2022): restore fails with error
"firebird.driver.types.DatabaseError: UDR module not loaded" and message after it that can be in localized.
Checked on: 4.0.3.2904, 5.0.0.475 -- all OK.
"""
import pytest
from firebird.qa import *
import zipfile
from pathlib import Path
from firebird.driver import SrvRestoreFlag
import locale
import re
db = db_factory()
act = python_act('db')
expected_stdout = """
gbak:restoring function CRYPTO_RSA_PRIVATE_KEY
gbak:finishing, closing, and going home
gbak:adjusting the ONLINE and FORCED WRITES flags
"""
fbk_file = temp_file('gh_7168.tmp.fbk')
@pytest.mark.version('>=4.0.1')
def test_1(act: Action, fbk_file: Path, capsys):
zipped_fbk_file = zipfile.Path(act.files_dir / 'gh_7168.zip', at = 'gh_7168.fbk')
fbk_file.write_bytes(zipped_fbk_file.read_bytes())
allowed_patterns = \
(
'gbak:restoring function CRYPTO_RSA_PRIVATE_KEY'
,'gbak:finishing, closing, and going home'
,'gbak:adjusting the ONLINE and FORCED WRITES flags'
)
allowed_patterns = [ re.compile(p, re.IGNORECASE) for p in allowed_patterns ]
with act.connect_server(encoding=locale.getpreferredencoding()) as srv:
srv.database.restore(database=act.db.db_path, backup=fbk_file, flags=SrvRestoreFlag.REPLACE, verbose=True)
restore_log = srv.readlines()
for line in restore_log:
if act.match_any(line.strip(), allowed_patterns):
print(line)
#assert restore_log == []
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout