mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated bugs\core_6264_test.py. Checked on 5.0.0.691, 4.0.1.2692, 3.0.8.33535 - both Windows and Linux.
This commit is contained in:
parent
da2bce9ee9
commit
a42cfd319a
@ -5,124 +5,45 @@ ID: issue-6506
|
||||
ISSUE: 6506
|
||||
TITLE: gbak with PIPE to stdout: invalid content if user '-se <host>:service_mgr' command switch
|
||||
DESCRIPTION:
|
||||
NB: bug can be reproduced only if we create batch file and run it from Python using shell invocation,
|
||||
i.e. via subprocess.call(). Python builtin PIPE mechanism does not show any errors.
|
||||
For this reason, we create temp batch scenario, add necessary commands there and run it.
|
||||
Currently this scenario exists only for Windows. It will be implemented for POSIX later.
|
||||
|
||||
Confirmed bug on 3.0.6.33276, 4.0.0.1850.
|
||||
Works fine on 3.0.6.33277, 4.0.0.1854
|
||||
Confirmed bug on 3.0.6.33276, 4.0.0.1850.
|
||||
Works fine on 3.0.6.33277, 4.0.0.1854
|
||||
JIRA: CORE-6264
|
||||
FBTEST: bugs.core_6264
|
||||
NOTES:
|
||||
[29.08.2022] pzotov
|
||||
1. Re-checked on 3.0.6.33276, 4.0.0.1850 - problem confirmed.
|
||||
2. Checked on 5.0.0.691, 4.0.1.2692, 3.0.8.33535 - both Windows and Linux.
|
||||
3. In case when '-user ... -pas ...' is missed in p_sender command, error message looks weird
|
||||
(and the same as it was originally detected and shown in this ticket):
|
||||
gbak: ERROR:expected backup description record
|
||||
gbak:Exiting before completion due to errors
|
||||
"""
|
||||
import subprocess
|
||||
from subprocess import PIPE
|
||||
from pathlib import Path
|
||||
import time
|
||||
|
||||
import pytest
|
||||
from firebird.qa import *
|
||||
|
||||
db = db_factory()
|
||||
|
||||
act = python_act('db')
|
||||
|
||||
@pytest.mark.skip('FIXME: Not IMPLEMENTED')
|
||||
@pytest.mark.version('>=3.0.6')
|
||||
#@pytest.mark.platform('Windows')
|
||||
def test_1(act: Action):
|
||||
pytest.fail("Not IMPLEMENTED")
|
||||
tmp_rest_fdb = db_factory(filename = 'core_4462_res.fdb', do_not_create = True, do_not_drop = True)
|
||||
act_rest_fdb = python_act('tmp_rest_fdb')
|
||||
|
||||
# test_script_1
|
||||
#---
|
||||
# import os
|
||||
# import sys
|
||||
# import time
|
||||
# import subprocess
|
||||
# from subprocess import PIPE
|
||||
# from fdb import services
|
||||
#
|
||||
# #--------------------------------------------
|
||||
#
|
||||
# def cleanup( f_names_list ):
|
||||
# global os
|
||||
# for i in range(len( f_names_list )):
|
||||
# if os.path.isfile( f_names_list[i]):
|
||||
# os.remove( f_names_list[i] )
|
||||
#
|
||||
# #--------------------------------------------
|
||||
#
|
||||
# os.environ["ISC_USER"] = user_name
|
||||
# os.environ["ISC_PASSWORD"] = user_password
|
||||
#
|
||||
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
|
||||
# this_db = db_conn.database_name
|
||||
# db_conn.close()
|
||||
#
|
||||
# tmp4restore=os.path.join(context['temp_directory'],'tmp_6264_check_restore.tmp')
|
||||
#
|
||||
# cleanup( (tmp4restore,) )
|
||||
#
|
||||
#
|
||||
# # BACKUP-RESTORE:
|
||||
# # C:\\FB SS\\gbak.exe -b -se localhost:service_mgr employee stdout | C:\\FB SS\\gbak -c stdin C: emp\\employee.check-restore.tmp
|
||||
#
|
||||
# fb_gbak = fb_home+'gbak'
|
||||
# fb_gfix = fb_home+'gfix'
|
||||
# txt = '''
|
||||
# @echo off
|
||||
# setlocal enabledelayedexpansion enableextensions
|
||||
# set ISC_USER=%(user_name)s
|
||||
# set ISC_PASSWORD=%(user_password)s
|
||||
# if exist %(tmp4restore)s del %(tmp4restore)s
|
||||
# if exist %(tmp4restore)s (
|
||||
# echo ### ERROR ###
|
||||
# echo Can not drop file %(tmp4restore)s
|
||||
# ) else (
|
||||
# %(fb_gbak)s -b -se localhost:service_mgr %(this_db)s stdout | %(fb_gbak)s -c stdin %(tmp4restore)s
|
||||
# if exist %(tmp4restore)s (
|
||||
# %(fb_gfix)s -v -full localhost:%(tmp4restore)s
|
||||
# %(fb_gfix)s -shut full -force 0 localhost:%(tmp4restore)s
|
||||
# del %(tmp4restore)s
|
||||
# )
|
||||
#
|
||||
# )
|
||||
# ''' % dict(globals(), **locals())
|
||||
#
|
||||
# f_tmp_bat=open( os.path.join(context['temp_directory'],'tmp_run_6264.bat'), 'w', buffering = 0)
|
||||
# f_tmp_bat.write(txt)
|
||||
# f_tmp_bat.close()
|
||||
#
|
||||
# #####################
|
||||
# # DOES NOT WORK HERE:
|
||||
# #####################
|
||||
# # https://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline
|
||||
# #p_sender = subprocess.Popen( [ fb_home+'gbak', '-b', '-se', 'localhost:service_mgr', this_db, 'stdout' ], stdout=PIPE)
|
||||
# #p_getter = subprocess.Popen( [ fb_home+'gbak', '-c', 'stdin', tmp4restore ], stdin = p_sender.stdout, stdout = PIPE )
|
||||
# #p_sender.stdout.close()
|
||||
# #p_getter_stdout, p_getter_stderr = p_getter.communicate()
|
||||
# #print('p_getter_stdout:', p_getter_stdout) -- returns EMPTY string
|
||||
# #print('p_getter_stderr:', p_getter_stderr) -- returns None.
|
||||
# ######################
|
||||
#
|
||||
# f_bat_log=open( os.path.join(context['temp_directory'],'tmp_c6264.log'), "w", buffering = 0)
|
||||
# f_bat_err=open( os.path.join(context['temp_directory'],'tmp_c6264.err'), "w", buffering = 0)
|
||||
#
|
||||
# subprocess.call( [ f_tmp_bat.name ], stdout=f_bat_log, stderr=f_bat_err)
|
||||
#
|
||||
# f_bat_log.close()
|
||||
# f_bat_err.close()
|
||||
#
|
||||
# # Both STDOUT and STDERR results must be empty, which means no errors:
|
||||
# ########################
|
||||
# with open(f_bat_log.name, 'r') as f:
|
||||
# for line in f:
|
||||
# if line.split():
|
||||
# print( ''.join( ( 'UNEXPECTED STDOUT: ', line.strip() ) ) )
|
||||
#
|
||||
# with open(f_bat_err.name, 'r') as f:
|
||||
# for line in f:
|
||||
# if line.split():
|
||||
# print( ''.join( ( 'UNEXPECTED STDERR: ', line.strip() ) ) )
|
||||
#
|
||||
# cleanup( [ i.name for i in ( f_tmp_bat,f_bat_log,f_bat_err ) ] + [tmp4restore,] )
|
||||
#
|
||||
#
|
||||
#
|
||||
#---
|
||||
@pytest.mark.version('>=3.0.6')
|
||||
def test_1(act: Action, act_rest_fdb: Action, capsys):
|
||||
|
||||
p_sender = subprocess.Popen( [ act.vars['gbak'], '-user', 'SYSDBA', '-pas', 'masterkey', '-b', '-se', 'localhost:service_mgr', act.db.db_path, 'stdout' ], stdout=PIPE)
|
||||
p_getter = subprocess.Popen( [ act.vars['gbak'], '-rep', 'stdin', act_rest_fdb.db.db_path ], stdin = p_sender.stdout, stdout = PIPE, stderr = subprocess.STDOUT)
|
||||
p_sender.stdout.close()
|
||||
# https://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline
|
||||
p_getter_stdout, p_getter_stderr = p_getter.communicate()
|
||||
act_rest_fdb.db.db_path.unlink(missing_ok = True)
|
||||
|
||||
print(p_getter_stdout.decode("utf-8"))
|
||||
|
||||
act.expected_stdout = ''
|
||||
act.stdout = capsys.readouterr().out
|
||||
assert act.clean_stdout == act.clean_expected_stdout
|
||||
|
Loading…
Reference in New Issue
Block a user