6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_5637_test.py

219 lines
7.8 KiB
Python

#coding:utf-8
#
# id: bugs.core_5637
# title: string right truncation on restore of security db
# decription:
# Confirmed bug on 4.0.0.838, got:
# gbak: ERROR:arithmetic exception, numeric overflow, or string truncation
# gbak: ERROR: string right truncation
# gbak: ERROR: expected length 10, actual 13
# gbak: ERROR:gds_$send failed
# ...
# Checked on:
# 4.0.0.918: OK, 6.516s.
#
# Refactored 25.10.2019: restored DB state must be changed to full shutdown in order to make sure tha all attachments are gone.
# Otherwise got on CS: "WindowsError: 32 The process cannot access the file because it is being used by another process".
# Checked on 4.0.0.1633 SS, CS.
#
# tracker_id: CORE-5637
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 4.0
# resources: None
substitutions_1 = []
init_script_1 = """"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
# import os
# import time
# import zipfile
# import difflib
# import subprocess
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
# db_conn.close()
#
# #--------------------------------------------
#
# def flush_and_close( file_handle ):
# # https://docs.python.org/2/library/os.html#os.fsync
# # If you're starting with a Python file object f,
# # first do f.flush(), and
# # then do os.fsync(f.fileno()), to ensure that all internal buffers associated with f are written to disk.
# global os
#
# file_handle.flush()
# if file_handle.mode not in ('r', 'rb') and file_handle.name != os.devnull:
# # otherwise: "OSError: [Errno 9] Bad file descriptor"!
# os.fsync(file_handle.fileno())
# file_handle.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.')
# del_name = None
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
# #--------------------------------------------
#
# def svc_get_fb_log( f_fb_log ):
#
# global subprocess
#
# subprocess.call( [ context['fbsvcmgr_path'],
# "localhost:service_mgr",
# "action_get_fb_log"
# ],
# stdout=f_fb_log, stderr=subprocess.STDOUT
# )
# return
#
#
#
# zf = zipfile.ZipFile( os.path.join(context['files_location'],'core5637.zip') )
# tmpfbk = 'core5637-security3.fbk'
# zf.extract( tmpfbk, '$(DATABASE_LOCATION)')
# zf.close()
#
# tmpfbk='$(DATABASE_LOCATION)'+tmpfbk
# tmpfdb='$(DATABASE_LOCATION)'+'tmp_5637_check_restored.fdb'
#
# f_fblog_before=open( os.path.join(context['temp_directory'],'tmp_5637_fblog_before.txt'), 'w')
# svc_get_fb_log( f_fblog_before )
# flush_and_close( f_fblog_before )
#
#
# f_restore_log=open( os.path.join(context['temp_directory'],'tmp_5637_check_restored.log'), 'w')
# subprocess.check_call([context['fbsvcmgr_path'],"localhost:service_mgr",
# "action_restore",
# "bkp_file", tmpfbk,
# "dbname", tmpfdb,
# "res_replace",
# "verbose"
# ],
# stdout=f_restore_log,
# stderr=subprocess.STDOUT)
# flush_and_close( f_restore_log )
#
# f_fblog_after=open( os.path.join(context['temp_directory'],'tmp_5637_fblog_after.txt'), 'w')
# svc_get_fb_log( f_fblog_after )
# flush_and_close( f_fblog_after )
#
#
# f_validation_log=open( os.path.join(context['temp_directory'],'tmp_5637_validation.log'), 'w')
# subprocess.check_call([context['fbsvcmgr_path'],"localhost:service_mgr",
# "action_validate",
# "dbname", tmpfdb,
# ],
# stdout=f_validation_log,
# stderr=subprocess.STDOUT)
# flush_and_close( f_validation_log )
#
# #time.sleep(1)
#
# # 25.10.2019: add full shutdown to forcedly drop all attachments.
# ## ||||||||||||||||||||||||||||
# ## ###################################||| FB 4.0+, SS and SC |||##############################
# ## ||||||||||||||||||||||||||||
# ## If we check SS or SC and ExtConnPoolLifeTime > 0 (config parameter FB 4.0+) then current
# ## DB (bugs.core_NNNN.fdb) will be 'captured' by firebird.exe process and fbt_run utility
# ## will not able to drop this database at the final point of test.
# ## Moreover, DB file will be hold until all activity in firebird.exe completed and AFTER this
# ## we have to wait for <ExtConnPoolLifeTime> seconds after it (discussion and small test see
# ## in the letter to hvlad and dimitr 13.10.2019 11:10).
# ## This means that one need to kill all connections to prevent from exception on cleanup phase:
# ## SQLCODE: -901 / lock time-out on wait transaction / object <this_test_DB> is in use
# ## #############################################################################################
#
# f_shutdown_log=open( os.path.join(context['temp_directory'],'tmp_5637_shutdown.log'), 'w')
#
# subprocess.call( [context['fbsvcmgr_path'], "localhost:service_mgr",
# "action_properties", "prp_shutdown_mode", "prp_sm_full", "prp_shutdown_db", "0", "dbname", tmpfdb,
# ],
# stdout = f_shutdown_log,
# stderr = subprocess.STDOUT
# )
#
# flush_and_close( f_shutdown_log )
#
#
# # Compare firebird.log versions BEFORE and AFTER this test:
# ######################
#
# oldfb=open(f_fblog_before.name, 'r')
# newfb=open(f_fblog_after.name, 'r')
#
# difftext = ''.join(difflib.unified_diff(
# oldfb.readlines(),
# newfb.readlines()
# ))
# oldfb.close()
# newfb.close()
#
# f_diff_txt=open( os.path.join(context['temp_directory'],'tmp_5637_diff.txt'), 'w')
# f_diff_txt.write(difftext)
# flush_and_close( f_diff_txt )
#
# # Check logs:
# #############
# with open( f_restore_log.name,'r') as f:
# for line in f:
# if 'Error'.upper() in line.upper():
# print( 'UNEXPECTED ERROR IN RESTORE LOG: ' + (' '.join(line.split()).upper()) )
#
# with open( f_validation_log.name,'r') as f:
# for line in f:
# if 'Error'.upper() in line.upper():
# print( 'UNEXPECTED ERROR IN VALIDATION LOG: ' + (' '.join(line.split()).upper()) )
#
# with open( f_shutdown_log.name,'r') as f:
# for line in f:
# if line.split():
# print( 'UNEXPECTED OUTPUT IN DB SHUTDOWN LOG: ' + (' '.join(line.split()).upper()) )
#
# with open( f_diff_txt.name,'r') as f:
# for line in f:
# if line.startswith('+'):
# print( 'UNEXPECTED DIFF IN FIREBIRD.LOG: ' + (' '.join(line.split()).upper()) )
#
#
# # Cleanup:
# ##########
# time.sleep(1)
# cleanup( (f_restore_log,f_validation_log,f_shutdown_log,f_fblog_before,f_fblog_after,f_diff_txt, tmpfbk,tmpfdb) )
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")