From 85faa9ac41ce0ea94a0afa6d0d86efef36bf7111 Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Thu, 2 Mar 2023 11:45:52 +0300 Subject: [PATCH] Added/Updated tests\bugs\gh_7168_test.py: Checked on: 4.0.3.2904, 5.0.0.475 -- all OK. --- tests/bugs/gh_7168_test.py | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tests/bugs/gh_7168_test.py diff --git a/tests/bugs/gh_7168_test.py b/tests/bugs/gh_7168_test.py new file mode 100644 index 00000000..db40d74b --- /dev/null +++ b/tests/bugs/gh_7168_test.py @@ -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