6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-02-02 10:50:42 +01:00
firebird-qa/tests/bugs/core_5704_test.py

234 lines
8.0 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_5704
# title: Avoid UPDATE of RDB$DATABASE by ALTER DATABASE statement when possible
# decription:
# Instead of doing 'nbackup -L' plus fill database with lot of new data and then 'nbackup -N' with waiting for
# delta will be integrated into main file, we can get the same result by invoking 'alter database add difference file'
# statement in the 1st attachment in RC NO_REC_VERS and WITHOUT COMMITTING it, and then attempt to establish new connect
# using ES/EDS. Second attachment should be made without any problem, despite that transaction in 1st connect not yet
# committed or rolled back.
#
# Confirmed lock of rdb$database record (which leads to inability to establish new connect) on WI-V3.0.3.32837.
# Works fine on (SS, CS):
# 3.0.3.32876: OK, 5.266s.
# 4.0.0.852: OK, 5.594s.
#
# tracker_id: CORE-5704
# min_versions: ['3.0.3']
# versions: 3.0.3
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 3.0.3
# resources: None
substitutions_1 = []
init_script_1 = """"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
# import os
# import subprocess
# from subprocess import Popen
# import time
# from fdb import services
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
# db_file = db_conn.database_name
#
# 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 )
#
# #--------------------------------------------
#
# usr=user_name
# pwd=user_password
# new_diff_file=os.path.join(context['temp_directory'],'tmp_new_diff_5704.tmp')
# new_main_file=os.path.join(context['temp_directory'],'tmp_new_main_5704.tmp')
#
# eds_query='''
# set count on;
# set list on;
# set autoddl off;
#
# set term ^;
# create or alter procedure sp_connect returns(check_eds_result int) as
# declare usr varchar(31);
# declare pwd varchar(31);
# declare v_sttm varchar(255) = 'select 1 from rdb$database';
# begin
# usr ='%(usr)s';
# pwd = '%(pwd)s';
# execute statement v_sttm
# on external 'localhost:' || rdb$get_context('SYSTEM','DB_NAME')
# as user usr password pwd
# into check_eds_result;
# suspend;
# end
# ^
# set term ^;
#
# commit;
# set transaction read committed no record_version lock timeout 1;
#
# alter database add difference file '%(new_diff_file)s';
# select * from sp_connect;
#
# rollback;
# select * from rdb$files;
# rollback;
#
# set transaction read committed no record_version lock timeout 1;
#
# alter database add file '%(new_main_file)s';
# select * from sp_connect;
# --select * from rdb$files;
# rollback;
# select * from rdb$files;
# '''
#
# f_eds_to_local_host_sql = open( os.path.join(context['temp_directory'],'tmp_local_host_5704.sql'), 'w')
# f_eds_to_local_host_sql.write( eds_query % locals() )
# flush_and_close( f_eds_to_local_host_sql )
#
# f_eds_to_local_host_log = open( os.path.join(context['temp_directory'],'tmp_local_host_5704.log'), 'w')
# f_eds_to_local_host_err = open( os.path.join(context['temp_directory'],'tmp_local_host_5704.err'), 'w')
#
# # WARNING: we launch ISQL here in async mode in order to have ability to kill its process if it will hang!
# ############################################
# p_isql_to_local_host=subprocess.Popen( [context['isql_path'], dsn, "-i", f_eds_to_local_host_sql.name ],
# stdout = f_eds_to_local_host_log,
# stderr = f_eds_to_local_host_err
# )
#
# time.sleep(3)
#
# p_isql_to_local_host.terminate()
# flush_and_close( f_eds_to_local_host_log )
# flush_and_close( f_eds_to_local_host_err )
#
#
# # Make DB shutdown and bring online because some internal server process still can be active!
# # If we skip this step than runtime error related to dropping test DB can occur!
# #########################################
#
# f_db_reset_log=open( os.path.join(context['temp_directory'],'tmp_reset_5704.log'), 'w')
# f_db_reset_err=open( os.path.join(context['temp_directory'],'tmp_reset_5704.err'), 'w')
#
# f_db_reset_log.write('Point before DB shutdown.'+os.linesep)
# f_db_reset_log.seek(0,2)
# subprocess.call( [context['fbsvcmgr_path'], "localhost:service_mgr",
# "action_properties", "prp_shutdown_mode", "prp_sm_full", "prp_shutdown_db", "0",
# "dbname", db_file,
# ],
# stdout = f_db_reset_log,
# stderr = f_db_reset_err
# )
# f_db_reset_log.write(os.linesep+'Point after DB shutdown.'+os.linesep)
#
# subprocess.call( [context['fbsvcmgr_path'], "localhost:service_mgr",
# "action_properties", "prp_db_online",
# "dbname", db_file,
# ],
# stdout = f_db_reset_log,
# stderr = f_db_reset_err
# )
#
# f_db_reset_log.write(os.linesep+'Point after DB online.'+os.linesep)
# flush_and_close( f_db_reset_log )
# flush_and_close( f_db_reset_err )
#
# with open( f_eds_to_local_host_log.name,'r') as f:
# for line in f:
# if line.split():
# print('STDOUT in ISQL: ', ' '.join(line.split()) )
#
# with open( f_eds_to_local_host_err.name,'r') as f:
# for line in f:
# if line.split():
# print('UNEXPECTED STDERR in '+f_eds_to_local_host_err.name+': '+line)
#
# with open( f_db_reset_log.name,'r') as f:
# for line in f:
# if line.split():
# print('STDOUT in DB reset: ', ' '.join(line.split()) )
#
# with open( f_db_reset_err.name,'r') as f:
# for line in f:
# if line.split():
# print('UNEXPECTED STDERR in '+f_db_reset_log.name+': '+line)
#
# ###############################
# # Cleanup.
# time.sleep(1)
#
# f_list=(
# f_eds_to_local_host_sql
# ,f_eds_to_local_host_log
# ,f_eds_to_local_host_err
# ,f_db_reset_log
# ,f_db_reset_err
# )
# cleanup( f_list )
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
STDOUT in ISQL: CHECK_EDS_RESULT 1
STDOUT in ISQL: Records affected: 1
STDOUT in ISQL: Records affected: 0
STDOUT in ISQL: CHECK_EDS_RESULT 1
STDOUT in ISQL: Records affected: 1
STDOUT in ISQL: Records affected: 0
STDOUT in DB reset: Point before DB shutdown.
STDOUT in DB reset: Point after DB shutdown.
STDOUT in DB reset: Point after DB online.
"""
@pytest.mark.version('>=3.0.3')
@pytest.mark.xfail
2021-04-28 12:42:11 +02:00
def test_1(db_1):
2021-04-26 20:07:00 +02:00
pytest.fail("Test not IMPLEMENTED")