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

Added/Updated bugs\gh_6709_test.py. Checked on 4.0.1.2692, 5.0.0.509. Re-check reproducing of problem on 4.0.0.2353.

This commit is contained in:
zotov 2022-06-29 21:36:54 +03:00
parent c25cbc3cef
commit fccda06597

View File

@ -5,74 +5,54 @@ ID: issue-6709
ISSUE: 6709
TITLE: gbak discards replica mode
DESCRIPTION:
https://github.com/FirebirdSQL/firebird/issues/6709
Confirmed bug on 4.0.0.2353: 'replica' flag was not preserved after restoring DB.
Checked on: 4.0.1.2624, 5.0.0.244 -- all OK.
JIRA: CORE-6478
FBTEST: bugs.gh_6709
NOTES:
[29.06.2022] pzotov
Checked on 4.0.1.2692, 5.0.0.509. Re-check reproducing of problem on 4.0.0.2353.
"""
import locale
import pytest
from firebird.qa import *
from pathlib import Path
from firebird.driver import ReplicaMode
db = db_factory()
tmp_fbk = temp_file( filename = 'tmp_gh_6709.fbk')
tmp_res = db_factory(filename='tmp_gh_6709.tmp')
act = python_act('db', substitutions=[('[ \t]+', ' ')])
expected_stdout = """
Result of gfix -replica read_only: READ-ONLY
Result of backup/restore for read_only: READ-ONLY
Result of gfix -replica read_write: READ-WRITE
Result of backup/restore for read_write: READ-WRITE
chk_sql = """
set heading off;
select rdb$get_context('SYSTEM', 'REPLICA_MODE') as "gfix -repl %(r_mode)s"
from rdb$database r
;
"""
@pytest.mark.skip('FIXME: Not IMPLEMENTED')
@pytest.mark.version('>=4.0')
def test_1(act: Action):
pytest.fail("Not IMPLEMENTED")
# test_script_1
#---
#
# import os
# import shutil
# import subprocess
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
# this_fdb=db_conn.database_name
# db_conn.close()
#
# #--------------------------------------------
#
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
# if type(f_names_list[i]) == file:
# del_name = f_names_list[i].name
# elif type(f_names_list[i]) == str:
# del_name = f_names_list[i]
# else:
# print('Unrecognized type of element:', f_names_list[i], ' - can not be treated as file.')
# print('type(f_names_list[i])=',type(f_names_list[i]))
# del_name = None
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
# #--------------------------------------------
#
# test_fdb=os.path.join(context['temp_directory'],'tmp_gh_6709.source.fdb')
# test_fbk=os.path.join(context['temp_directory'],'tmp_gh_6709.fbk')
# test_res=os.path.join(context['temp_directory'],'tmp_gh_6709.restored')
#
# for r_mode in ('read_only', 'read_write'):
# cleanup( (test_fdb, test_res) )
# shutil.copy2( this_fdb, test_fdb )
# runProgram('gfix', [ 'localhost:' + test_fdb, '-replica', r_mode ] )
# runProgram('isql', [ 'localhost:' + test_fdb ], '''set list on; select rdb$get_context('SYSTEM', 'REPLICA_MODE') as "Result of gfix -replica %(r_mode)s:" from rdb$database;''' % locals() )
# runProgram('gbak', [ '-b', 'localhost:' + test_fdb, test_fbk ] )
# runProgram('gbak', [ '-c', '-m', test_fbk, 'localhost:' + test_res ] )
# runProgram('isql', [ 'localhost:' + test_res ], '''set list on; select rdb$get_context('SYSTEM', 'REPLICA_MODE') as "Result of backup/restore for %(r_mode)s:" from rdb$database;''' % locals() )
#
# cleanup( (test_fdb, test_fbk, test_res) )
#
#---
def test_1(act: Action, tmp_fbk: Path, tmp_res: Database, capsys):
for r_mode in ('read_only', 'read_write', 'none'):
# -----------------------------------------------------
act.gfix(switches=['-replica', r_mode, act.db.dsn], io_enc = locale.getpreferredencoding())
act.expected_stdout = r_mode.upper().replace('_','-') if r_mode != 'none' else '<null>'
act.isql(switches=['-q'], input = chk_sql % locals())
assert act.clean_stdout == act.clean_expected_stdout
act.reset()
# -----------------------------------------------------
act.gbak(switches=['-b', str(act.db.db_path), str(tmp_fbk)], io_enc = locale.getpreferredencoding())
act.gbak(switches=['-rep', str(tmp_fbk), tmp_res.db_path], io_enc = locale.getpreferredencoding())
#act.gbak(switches=['-b', '-se', 'localhost:service_mgr', str(act.db.db_path), str(tmp_fbk)])
#act.gbak(switches=['-rep', '-se', 'localhost:service_mgr', str(tmp_fbk), str(tmp_res)])
act.expected_stdout = r_mode.upper().replace('_','-') if r_mode != 'none' else '<null>'
act.isql(switches=['-q'], input = chk_sql % locals(), use_db = tmp_res, io_enc = locale.getpreferredencoding())
assert act.clean_stdout == act.clean_expected_stdout
act.reset()