6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_5329_test.py

52 lines
1.8 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5605
ISSUE: 5605
TITLE: Database gets partially corrupted in the "no-reserve" mode
DESCRIPTION:
Test uses .fbk which was created on 2.5.7.
We restore this database and run validation using gfix (NOT fbsvcmgr!).
Validation should not produce any output and new lines in firebird.log should contain
only messages about start and finish of validation with zero errors and warnings.
JIRA: CORE-5329
FBTEST: bugs.core_5329
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-12-06 19:23:35 +01:00
import re
from difflib import unified_diff
2022-01-25 22:55:48 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory(from_backup='core5329.fbk')
2021-12-06 19:23:35 +01:00
2022-01-25 22:55:48 +01:00
act = python_act('db', substitutions=[('\t+', ' ')])
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
+ VALIDATION STARTED
+ VALIDATION FINISHED: 0 ERRORS, 0 WARNINGS, 0 FIXED
2021-12-06 19:23:35 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.1')
2022-01-25 22:55:48 +01:00
def test_1(act: Action, capsys):
2021-12-06 19:23:35 +01:00
pattern = re.compile('.*VALIDATION.*|.*ERROR:.*')
# Get firebird.log content BEFORE running validation
2022-01-25 22:55:48 +01:00
log_before = act.get_firebird_log()
2021-12-06 19:23:35 +01:00
# Only 'gfix -v' did show errors.
# Online validation ('fbsvcmgr action_validate ...') worked WITHOUT any error/warningin its output.
2022-01-25 22:55:48 +01:00
act.gfix(switches=['-v', '-full', act.db.dsn])
2021-12-06 19:23:35 +01:00
# Get firebird.log content AFTER running validation
2022-01-25 22:55:48 +01:00
log_after = act.get_firebird_log()
2021-12-06 19:23:35 +01:00
# Check-1. Log of 'gfix -v -full'should be EMPTY
2022-01-25 22:55:48 +01:00
assert act.clean_stdout == act.clean_expected_stdout
2021-12-06 19:23:35 +01:00
# Check-2. Difference betweenold and new firebird.log should contain
# only lines about validation start and finish, without errors:
for line in unified_diff(log_before, log_after):
if line.startswith('+'):
if pattern.match(line.upper()):
print(line.upper())
2022-01-25 22:55:48 +01:00
act.reset()
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout