mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
More python tests
This commit is contained in:
parent
607cea07be
commit
236a067186
@ -2,30 +2,33 @@
|
||||
#
|
||||
# id: bugs.core_2208
|
||||
# title: New gbak option to ignore specific tables data during the backup
|
||||
# decription:
|
||||
# decription:
|
||||
# We create four tables with ascii and one with non-ascii (cyrillic) names.
|
||||
# Each table has one row.
|
||||
# Then we check that one may to:
|
||||
# 1) skip BACKUP data of some tables
|
||||
# 2) skip RESTORE data for same tables.
|
||||
# All cases are checked by call 'fbsvcmgr ... bkp_skip_data <pattern>',
|
||||
# All cases are checked by call 'fbsvcmgr ... bkp_skip_data <pattern>',
|
||||
# where <pattern> string matches several tables (i.e. we use SIMILAR_TO ability).
|
||||
#
|
||||
#
|
||||
# WARNING!
|
||||
# It was found that there is NO ability (in fbtest only! not in command interpreter)
|
||||
# to skip data from backup for table with non-ascii name, neither if we specify its name
|
||||
# as literal nor via pattern. For that reason one of checks currently is commented
|
||||
# It was found that there is NO ability (in fbtest only! not in command interpreter)
|
||||
# to skip data from backup for table with non-ascii name, neither if we specify its name
|
||||
# as literal nor via pattern. For that reason one of checks currently is commented
|
||||
# (see below block titled as: `Run-3: try to skip BACKUP of data for table "опечатка"`).
|
||||
#
|
||||
#
|
||||
# Checked on WI-V3.0.2.32644, WI-T4.0.0.469.
|
||||
#
|
||||
#
|
||||
# tracker_id: CORE-2208
|
||||
# min_versions: ['3.0']
|
||||
# versions: 3.0
|
||||
# qmid: None
|
||||
|
||||
import pytest
|
||||
from firebird.qa import db_factory, isql_act, Action
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from firebird.qa import db_factory, python_act, Action, temp_file
|
||||
from firebird.driver import SrvRestoreFlag
|
||||
|
||||
# version: 3.0
|
||||
# resources: None
|
||||
@ -37,7 +40,7 @@ init_script_1 = """
|
||||
recreate table test_02(id char(1));
|
||||
recreate table test_0a(id char(1));
|
||||
recreate table test_0b(id char(1));
|
||||
|
||||
|
||||
recreate table "опечатка"(id char(1));
|
||||
commit;
|
||||
|
||||
@ -49,224 +52,274 @@ init_script_1 = """
|
||||
commit;
|
||||
-- similar to '(о|а)(п|ч)(е|и)(п|ч)(а|я)(т|д)(к|г)(а|о)';
|
||||
recreate view v_check as
|
||||
select 'test_01' as msg, t.id
|
||||
select 'test_01' as msg, t.id
|
||||
from rdb$database left join test_01 t on 1=1
|
||||
union all
|
||||
select 'test_02' as msg, t.id
|
||||
union all
|
||||
select 'test_02' as msg, t.id
|
||||
from rdb$database left join test_02 t on 1=1
|
||||
union all
|
||||
select 'test_0a' as msg, t.id
|
||||
select 'test_0a' as msg, t.id
|
||||
from rdb$database left join test_0a t on 1=1
|
||||
union all
|
||||
select 'test_0b' as msg, t.id
|
||||
union all
|
||||
select 'test_0b' as msg, t.id
|
||||
from rdb$database left join test_0b t on 1=1
|
||||
union all
|
||||
select 'опечатка' as msg, t.id
|
||||
from rdb$database left join "опечатка" t on 1=1
|
||||
;
|
||||
;
|
||||
"""
|
||||
|
||||
db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
|
||||
|
||||
# test_script_1
|
||||
#---
|
||||
#
|
||||
#
|
||||
# import os
|
||||
# import subprocess
|
||||
# import time
|
||||
# from subprocess import Popen
|
||||
#
|
||||
#
|
||||
# os.environ["ISC_USER"] = user_name
|
||||
# os.environ["ISC_PASSWORD"] = user_password
|
||||
#
|
||||
#
|
||||
# # Obtain engine version:
|
||||
# engine = str(db_conn.engine_version) # convert to text because 'float' object has no attribute 'startswith'
|
||||
#
|
||||
#
|
||||
# db_conn.close()
|
||||
#
|
||||
#
|
||||
# thisdb='$(DATABASE_LOCATION)bugs.core_2208.fdb'
|
||||
# tmpbkp='$(DATABASE_LOCATION)bugs.core_2208_fbk.tmp'
|
||||
# tmpres='$(DATABASE_LOCATION)bugs.core_2208_new.tmp'
|
||||
#
|
||||
#
|
||||
# f_run_sql=open( os.path.join(context['temp_directory'],'tmp_check_2208.sql'), 'w')
|
||||
# f_run_sql.write('set list on; set count on; select * from v_check;')
|
||||
# f_run_sql.close()
|
||||
#
|
||||
#
|
||||
# f_svc_log=open( os.path.join(context['temp_directory'],'tmp_svc_2208.log'), 'w')
|
||||
# f_svc_err=open( os.path.join(context['temp_directory'],'tmp_svc_2208.err'), 'w')
|
||||
#
|
||||
#
|
||||
# # Run-1: try to skip BACKUP of data for tables 'test_0a' and 'test_0b'.
|
||||
# ###########################
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_backup',
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_backup',
|
||||
# 'dbname', thisdb, 'bkp_file', tmpbkp,
|
||||
# 'bkp_skip_data', 'test_0[[:alpha:]]'
|
||||
# ],
|
||||
# ],
|
||||
# stdout=f_svc_log,stderr=f_svc_err
|
||||
# )
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_restore',
|
||||
# 'bkp_file', tmpbkp, 'dbname', tmpres,
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_restore',
|
||||
# 'bkp_file', tmpbkp, 'dbname', tmpres,
|
||||
# 'res_replace'
|
||||
# ],
|
||||
# ],
|
||||
# stdout=f_svc_log,stderr=f_svc_err
|
||||
# )
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# f_run1_log=open( os.path.join(context['temp_directory'],'tmp_run1_2208.log'), 'w')
|
||||
# subprocess.call( [ context['isql_path'], 'localhost:'+tmpres,'-q','-ch','utf8', '-i', f_run_sql.name],stdout=f_run1_log,stderr=subprocess.STDOUT )
|
||||
# f_run1_log.close()
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# # Run-2: try to skip RESTORE of data for tables 'test_01' and 'test_02'.
|
||||
# ###########################
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_backup',
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_backup',
|
||||
# 'dbname', thisdb, 'bkp_file', tmpbkp,
|
||||
# 'bkp_skip_data', 'test_0[[:digit:]]'
|
||||
# ],
|
||||
# ],
|
||||
# stdout=f_svc_log,stderr=f_svc_err
|
||||
# )
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_restore',
|
||||
# 'bkp_file', tmpbkp, 'dbname', tmpres,
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_restore',
|
||||
# 'bkp_file', tmpbkp, 'dbname', tmpres,
|
||||
# 'res_replace'
|
||||
# ],
|
||||
# ],
|
||||
# stdout=f_svc_log,stderr=f_svc_err
|
||||
# )
|
||||
#
|
||||
#
|
||||
# f_run2_log=open( os.path.join(context['temp_directory'],'tmp_run2_2208.log'), 'w')
|
||||
# subprocess.call( [ context['isql_path'], 'localhost:'+tmpres,'-q','-ch','utf8', '-i', f_run_sql.name],stdout=f_run2_log,stderr=subprocess.STDOUT )
|
||||
# f_run2_log.close()
|
||||
#
|
||||
#
|
||||
# ########################################
|
||||
#
|
||||
#
|
||||
# '''
|
||||
# DEFERRED! IT SEEMS THAT WRONG PATTERN IS PASSED FROM FBTEST TO FBSVCMGR WHEN USE NON-ASCII TABLE NAME!
|
||||
#
|
||||
#
|
||||
# CAN NOT BE REPRODUCED IN CMD.EXE (chcp 65001):
|
||||
# ==============================================
|
||||
#
|
||||
#
|
||||
# Script for isql (do not forget to make chcp 65001 before run it):
|
||||
# ===
|
||||
# set names utf8;
|
||||
# shell del C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\c2208w.fdb 2>nul;
|
||||
# create database 'localhost:C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\c2208w.fdb' default character set utf8;
|
||||
# shell del C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\c2208w.fdb 2>nul;
|
||||
# create database 'localhost:C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\c2208w.fdb' default character set utf8;
|
||||
# recreate table "опечатка"(id char(1));
|
||||
# insert into "опечатка"(id) values('ы');
|
||||
# commit;
|
||||
# ===
|
||||
#
|
||||
# fbsvcmgr localhost:service_mgr action_backup
|
||||
# dbname C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\C2208W.FDB
|
||||
# bkp_file C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\C2208W.fbk
|
||||
#
|
||||
# fbsvcmgr localhost:service_mgr action_backup
|
||||
# dbname C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\C2208W.FDB
|
||||
# bkp_file C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\C2208W.fbk
|
||||
# -bkp_skip_data "(о|а)(п|ч)(е|и)(п|ч)(а|я)(т|д)(к|г)(о|а)"
|
||||
#
|
||||
# gbak -rep C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\C2208W.fbk localhost:C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\C2208W2.FDB
|
||||
#
|
||||
# echo show table; set list on; set count on; select * from "опечатка";|isql /:C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\C2208W2.FDB -ch utf8
|
||||
#
|
||||
#
|
||||
# gbak -rep C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\C2208W.fbk localhost:C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\C2208W2.FDB
|
||||
#
|
||||
# echo show table; set list on; set count on; select * from "опечатка";|isql /:C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\C2208W2.FDB -ch utf8
|
||||
#
|
||||
# опечатка
|
||||
# Records affected: 0
|
||||
#
|
||||
#
|
||||
# # Run-3: try to skip BACKUP of data for table "опечатка".
|
||||
# ###########################
|
||||
# # 'bkp_skip_data', '"(о|а)(п|ч)(е|и)(п|ч)(а|я)(т|д)(к|г)(а|о)"'
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_backup',
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_backup',
|
||||
# 'dbname', thisdb, 'bkp_file', tmpbkp,
|
||||
# 'bkp_skip_data', '%о%'
|
||||
# ],
|
||||
# ],
|
||||
# stdout=f_svc_log,stderr=f_svc_err
|
||||
# )
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_restore',
|
||||
# 'bkp_file', tmpbkp, 'dbname', tmpres,
|
||||
# subprocess.call( [ context['fbsvcmgr_path'], 'localhost:service_mgr','action_restore',
|
||||
# 'bkp_file', tmpbkp, 'dbname', tmpres,
|
||||
# 'res_replace'
|
||||
# ],
|
||||
# ],
|
||||
# stdout=f_svc_log,stderr=f_svc_err
|
||||
# )
|
||||
#
|
||||
#
|
||||
# f_run3_log=open( os.path.join(context['temp_directory'],'tmp_run3_2208.log'), 'w')
|
||||
# subprocess.call( [ context['isql_path'], 'localhost:'+tmpres,'-q','-ch','utf8', '-i', f_run_sql.name],stdout=f_run3_log,stderr=subprocess.STDOUT )
|
||||
# f_run3_log.close()
|
||||
# '''
|
||||
#
|
||||
#
|
||||
# f_svc_log.close()
|
||||
# f_svc_err.close()
|
||||
#
|
||||
#
|
||||
# # Should be EMPTY:
|
||||
# with open( f_svc_err.name,'r') as f:
|
||||
# for line in f:
|
||||
# if line.split():
|
||||
# print('fbsvcmgr(2) unexpected STDERR: '+line.upper() )
|
||||
# f.close()
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# with open( f_run1_log.name,'r') as f:
|
||||
# for line in f:
|
||||
# if line.split():
|
||||
# print('run-1: ' + line)
|
||||
# f.close()
|
||||
#
|
||||
#
|
||||
# with open( f_run2_log.name,'r') as f:
|
||||
# for line in f:
|
||||
# if line.split():
|
||||
# print('run-2: ' + line)
|
||||
# f.close()
|
||||
#
|
||||
#
|
||||
# # CLEANUP
|
||||
# #########
|
||||
# f_list=(f_svc_log, f_svc_err,f_run_sql,f_run1_log,f_run2_log)
|
||||
# for i in range(len(f_list)):
|
||||
# if os.path.isfile(f_list[i].name):
|
||||
# os.remove(f_list[i].name)
|
||||
#
|
||||
#
|
||||
# if os.path.isfile(tmpbkp):
|
||||
# os.remove(tmpbkp)
|
||||
# if os.path.isfile(tmpres):
|
||||
# os.remove(tmpres)
|
||||
#
|
||||
#
|
||||
#---
|
||||
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
|
||||
|
||||
expected_stdout_1 = """
|
||||
run-1: MSG test_01
|
||||
run-1: ID 1
|
||||
run-1: MSG test_02
|
||||
run-1: ID 2
|
||||
run-1: MSG test_0a
|
||||
run-1: ID <null>
|
||||
run-1: MSG test_0b
|
||||
run-1: ID <null>
|
||||
run-1: MSG опечатка
|
||||
run-1: ID ы
|
||||
run-1: Records affected: 5
|
||||
act_1 = python_act('db_1', substitutions=substitutions_1)
|
||||
|
||||
run-2: MSG test_01
|
||||
run-2: ID <null>
|
||||
run-2: MSG test_02
|
||||
run-2: ID <null>
|
||||
run-2: MSG test_0a
|
||||
run-2: ID 3
|
||||
run-2: MSG test_0b
|
||||
run-2: ID 4
|
||||
run-2: MSG опечатка
|
||||
run-2: ID ы
|
||||
run-2: Records affected: 5
|
||||
"""
|
||||
expected_stdout_1_a = """
|
||||
MSG test_01
|
||||
ID 1
|
||||
MSG test_02
|
||||
ID 2
|
||||
MSG test_0a
|
||||
ID <null>
|
||||
MSG test_0b
|
||||
ID <null>
|
||||
MSG опечатка
|
||||
ID ы
|
||||
Records affected: 5
|
||||
"""
|
||||
|
||||
expected_stdout_1_b = """
|
||||
MSG test_01
|
||||
ID <null>
|
||||
MSG test_02
|
||||
ID <null>
|
||||
MSG test_0a
|
||||
ID 3
|
||||
MSG test_0b
|
||||
ID 4
|
||||
MSG опечатка
|
||||
ID ы
|
||||
Records affected: 5
|
||||
"""
|
||||
|
||||
expected_stdout_1_c = """
|
||||
MSG test_01
|
||||
ID 1
|
||||
MSG test_02
|
||||
ID 2
|
||||
MSG test_0a
|
||||
ID 3
|
||||
MSG test_0b
|
||||
ID 4
|
||||
MSG опечатка
|
||||
ID <null>
|
||||
Records affected: 5
|
||||
"""
|
||||
|
||||
# We need additional test database for restore
|
||||
file_1 = temp_file('extra-test.fdb')
|
||||
|
||||
@pytest.mark.version('>=3.0')
|
||||
@pytest.mark.xfail
|
||||
def test_1(db_1):
|
||||
pytest.fail("Test not IMPLEMENTED")
|
||||
|
||||
|
||||
def test_1(act_1: Action, file_1: Path):
|
||||
check_script = 'set list on; set count on; select * from v_check;'
|
||||
if file_1.is_file():
|
||||
file_1.unlink()
|
||||
with act_1.connect_server() as srv:
|
||||
backup = BytesIO()
|
||||
# Run-1: try to skip BACKUP of data for tables 'test_0a' and 'test_0b'.
|
||||
srv.database.local_backup(database=str(act_1.db.db_path), backup_stream=backup,
|
||||
skip_data='test_0[[:alpha:]]')
|
||||
backup.seek(0)
|
||||
srv.database.local_restore(backup_stream=backup, database=str(file_1))
|
||||
# check
|
||||
act_1.expected_stdout = expected_stdout_1_a
|
||||
act_1.isql(switches=['-user', act_1.db.user,
|
||||
'-password', act_1.db.password,
|
||||
str(file_1)], input=check_script, connect_db=False)
|
||||
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
||||
# Run-2: try to skip RESTORE of data for tables 'test_01' and 'test_02'.
|
||||
if file_1.is_file():
|
||||
file_1.unlink()
|
||||
backup.close()
|
||||
backup = BytesIO()
|
||||
srv.database.local_backup(database=str(act_1.db.db_path), backup_stream=backup)
|
||||
backup.seek(0)
|
||||
srv.database.local_restore(backup_stream=backup, database=str(file_1),
|
||||
skip_data='test_0[[:digit:]]')
|
||||
# check
|
||||
act_1.reset()
|
||||
act_1.expected_stdout = expected_stdout_1_b
|
||||
act_1.isql(switches=['-user', act_1.db.user,
|
||||
'-password', act_1.db.password,
|
||||
str(file_1)], input=check_script, connect_db=False)
|
||||
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
||||
# Run-3: try to skip BACKUP of data for table "опечатка".
|
||||
srv.encoding = 'utf8'
|
||||
if file_1.is_file():
|
||||
file_1.unlink()
|
||||
backup.close()
|
||||
backup = BytesIO()
|
||||
srv.database.local_backup(database=str(act_1.db.db_path), backup_stream=backup,
|
||||
skip_data='(о|а)(п|ч)(е|и)(п|ч)(а|я)(т|д)(к|г)(о|а)')
|
||||
backup.seek(0)
|
||||
srv.database.local_restore(backup_stream=backup, database=str(file_1))
|
||||
# check
|
||||
act_1.reset()
|
||||
act_1.expected_stdout = expected_stdout_1_c
|
||||
act_1.isql(switches=['-user', act_1.db.user,
|
||||
'-password', act_1.db.password,
|
||||
str(file_1)], input=check_script, connect_db=False)
|
||||
|
@ -2,64 +2,68 @@
|
||||
#
|
||||
# id: bugs.core_2216
|
||||
# title: Nbackup as online dump
|
||||
# decription:
|
||||
# decription:
|
||||
# We create table and leave it empty, than we run "nbackup -b 0 <source_db> <nbk_level_0>".
|
||||
# After this add one row in the table in source DB.
|
||||
# Then we obtain database GUID of sourec DB and use it in following commands:
|
||||
# 1. nbackup -b <GUID> <source_db> <addi_file>
|
||||
# 2. nbackup -i -r <nbk_level_0> <addi_file>
|
||||
# Finally, we:
|
||||
# 1. Check that inserted record actually does exist in <nbk_level_0>;
|
||||
# 1. Check that inserted record actually does exist in <nbk_level_0>;
|
||||
# 2. Run online validation of <nbk_level_0> - it sould NOT produce any errors.
|
||||
#
|
||||
#
|
||||
# 40CS, build 4.0.0.651: OK, 5.031s.
|
||||
# 40SC, build 4.0.0.651: OK, 4.765s.
|
||||
# 40SS, build 4.0.0.680: OK, 4.031s.
|
||||
#
|
||||
#
|
||||
# tracker_id: CORE-2216
|
||||
# min_versions: ['4.0']
|
||||
# versions: 4.0
|
||||
# qmid:
|
||||
# qmid:
|
||||
|
||||
import pytest
|
||||
from firebird.qa import db_factory, isql_act, Action
|
||||
from pathlib import Path
|
||||
from firebird.qa import db_factory, python_act, Action, temp_file
|
||||
from firebird.driver import SrvNBackupFlag
|
||||
|
||||
# version: 4.0
|
||||
# resources: None
|
||||
|
||||
substitutions_1 = [('BLOB_ID.*', ''), ('[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]', ''), ('Relation [0-9]{3,4}', 'Relation')]
|
||||
substitutions_1 = [('BLOB_ID.*', ''),
|
||||
('[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]', ''),
|
||||
('Relation [0-9]{3,4}', 'Relation')]
|
||||
|
||||
init_script_1 = """
|
||||
create table test(id int, s varchar(10) unique using index test_s, t timestamp, b blob);
|
||||
"""
|
||||
create table test(id int, s varchar(10) unique using index test_s, t timestamp, b blob);
|
||||
"""
|
||||
|
||||
db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
|
||||
# test_script_1
|
||||
#---
|
||||
#
|
||||
#
|
||||
# import os
|
||||
# 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
|
||||
# # 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()
|
||||
# os.fsync(file_handle.fileno())
|
||||
#
|
||||
#
|
||||
# file_handle.close()
|
||||
#
|
||||
#
|
||||
# #--------------------------------------------
|
||||
#
|
||||
#
|
||||
# def cleanup( f_names_list ):
|
||||
# global os
|
||||
# for i in range(len( f_names_list )):
|
||||
@ -67,72 +71,64 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
# os.remove( f_names_list[i] )
|
||||
# if os.path.isfile( f_names_list[i]):
|
||||
# print('ERROR: can not remove file ' + f_names_list[i])
|
||||
#
|
||||
#
|
||||
# #-------------------------------------------
|
||||
#
|
||||
#
|
||||
# dbfile='$(DATABASE_LOCATION)bugs.core_2216.fdb'
|
||||
# tmpnbk='$(DATABASE_LOCATION)bugs.core_2216_nb0.fdb'
|
||||
# tmpadd='$(DATABASE_LOCATION)bugs.core_2216_add.tmp'
|
||||
#
|
||||
#
|
||||
# if os.path.isfile(tmpnbk):
|
||||
# os.remove(tmpnbk)
|
||||
# if os.path.isfile(tmpadd):
|
||||
# os.remove(tmpadd)
|
||||
#
|
||||
#
|
||||
# f_nbk1_log=open( os.path.join(context['temp_directory'],'tmp_nbk1_2216.log'), 'w')
|
||||
# f_nbk1_err=open( os.path.join(context['temp_directory'],'tmp_nbk1_2216.err'), 'w')
|
||||
# subprocess.call( [ context['nbackup_path'], '-b', '0', dbfile, tmpnbk], stdout=f_nbk1_log,stderr=f_nbk1_err )
|
||||
# flush_and_close( f_nbk1_log )
|
||||
# flush_and_close( f_nbk1_err )
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# f_run_sql=open( os.path.join(context['temp_directory'],'tmp_run_2216.sql'), 'w')
|
||||
# f_run_sql.write('set list on; select rb.rdb$guid as db_guid from rdb$backup_history rb;')
|
||||
# f_run_sql.close()
|
||||
#
|
||||
#
|
||||
# f_run_log=open( os.path.join(context['temp_directory'],'tmp_run_2216.log'), 'w')
|
||||
# subprocess.call( [ context['isql_path'], dsn, '-i', f_run_sql.name], stdout=f_run_log,stderr=subprocess.STDOUT )
|
||||
# flush_and_close( f_run_log )
|
||||
#
|
||||
#
|
||||
# with open( f_run_log.name,'r') as f:
|
||||
# for line in f:
|
||||
# if line.split():
|
||||
# db_guid=line.split()[1]
|
||||
#
|
||||
#
|
||||
# runProgram('isql',[dsn], "insert into test(id,s,t,b) values(1, 'qwerty','11.12.2013 14:15:16.178', 'foo-rio-bar');")
|
||||
#
|
||||
# # nbackup -b {28287188-0E3A-4662-29AB-61F7E117E1C0} C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\E40.FDB C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\e40.bku
|
||||
# # nbackup -i -r C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\e40.nb0 C:\\MIX
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\e40.bku
|
||||
#
|
||||
#
|
||||
# # nbackup -b {28287188-0E3A-4662-29AB-61F7E117E1C0} C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\E40.FDB C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\e40.bku
|
||||
# # nbackup -i -r C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\e40.nb0 C:\\MIX\\firebird\\QA\\fbt-repo\\tmp\\e40.bku
|
||||
#
|
||||
# f_nbk2_log=open( os.path.join(context['temp_directory'],'tmp_nbk2_2216.log'), 'w')
|
||||
# f_nbk2_err=open( os.path.join(context['temp_directory'],'tmp_nbk2_2216.err'), 'w')
|
||||
# subprocess.call( [ context['nbackup_path'], '-b', db_guid, dbfile, tmpadd], stdout=f_nbk2_log, stderr=f_nbk2_err )
|
||||
# flush_and_close( f_nbk2_log )
|
||||
# flush_and_close( f_nbk2_err )
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# f_nbk3_log=open( os.path.join(context['temp_directory'],'tmp_nbk3_2216.log'), 'w')
|
||||
# f_nbk3_err=open( os.path.join(context['temp_directory'],'tmp_nbk3_2216.err'), 'w')
|
||||
# subprocess.call( [ context['nbackup_path'], '-i', '-r', tmpnbk, tmpadd], stdout=f_nbk3_log, stderr=f_nbk3_err )
|
||||
# flush_and_close( f_nbk3_log )
|
||||
# flush_and_close( f_nbk3_err )
|
||||
#
|
||||
#
|
||||
# # Checking query:
|
||||
# #################
|
||||
# runProgram('isql',['localhost:'+tmpnbk],"set list on;set count on;set blob all;select id,s,t,b as blob_id from test;" )
|
||||
#
|
||||
#
|
||||
# f_val_log=open( os.path.join(context['temp_directory'],'tmp_val_2216.log'), "w")
|
||||
# f_val_err=open( os.path.join(context['temp_directory'],'tmp_val_2216.err'), "w")
|
||||
#
|
||||
#
|
||||
# subprocess.call([ context['fbsvcmgr_path'],"localhost:service_mgr",
|
||||
# "action_validate",
|
||||
# "dbname", tmpnbk
|
||||
@ -141,10 +137,10 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
# stderr=f_val_err)
|
||||
# flush_and_close( f_val_log )
|
||||
# flush_and_close( f_val_err )
|
||||
#
|
||||
#
|
||||
# with open( f_val_log.name,'r') as f:
|
||||
# print(f.read())
|
||||
#
|
||||
#
|
||||
# # All of these files must be empty:
|
||||
# ###################################
|
||||
# f_list=(f_nbk1_err, f_nbk2_err, f_nbk3_err, f_val_err)
|
||||
@ -153,35 +149,67 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
# for line in f:
|
||||
# if line.split():
|
||||
# print( 'UNEXPECTED STDERR in file '+f_list[i].name+': '+line.upper() )
|
||||
#
|
||||
#
|
||||
# # Cleanup.
|
||||
# ###############################
|
||||
# cleanup( [i.name for i in ( f_run_sql,f_run_log, f_nbk1_log,f_nbk1_err, f_nbk2_log,f_nbk2_err, f_nbk3_log,f_nbk3_err, f_val_log,f_val_err) ] )
|
||||
#
|
||||
#
|
||||
# os.remove(tmpnbk)
|
||||
# os.remove(tmpadd)
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#---
|
||||
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
|
||||
|
||||
expected_stdout_1 = """
|
||||
act_1 = python_act('db_1', substitutions=substitutions_1)
|
||||
|
||||
nbak_file_base = temp_file('nbak-file.fdb')
|
||||
nbak_file_add = temp_file('nbak-file.add')
|
||||
|
||||
expected_stdout_1_a = """
|
||||
ID 1
|
||||
S qwerty
|
||||
T 2013-12-11 14:15:16.1780
|
||||
foo-rio-bar
|
||||
Records affected: 1
|
||||
"""
|
||||
|
||||
expected_stdout_1_b = """
|
||||
Validation started
|
||||
Relation (TEST)
|
||||
process pointer page 0 of 1
|
||||
Index 1 (TEST_S)
|
||||
Relation (TEST) is ok
|
||||
Validation finished
|
||||
"""
|
||||
"""
|
||||
|
||||
@pytest.mark.version('>=4.0')
|
||||
@pytest.mark.xfail
|
||||
def test_1(db_1):
|
||||
pytest.fail("Test not IMPLEMENTED")
|
||||
|
||||
|
||||
def test_1(act_1: Action, nbak_file_base: Path, nbak_file_add: Path):
|
||||
with act_1.connect_server() as srv, act_1.db.connect() as con:
|
||||
# Backup base database
|
||||
srv.database.nbackup(database=str(act_1.db.db_path), backup=str(nbak_file_base),
|
||||
level=0)
|
||||
c = con.cursor()
|
||||
# get db GUID
|
||||
c.execute('select rb.rdb$guid as db_guid from rdb$backup_history rb')
|
||||
db_guid = c.fetchone()[0]
|
||||
# Insert data
|
||||
c.execute("insert into test(id,s,t,b) values(1, 'qwerty', '11.12.2013 14:15:16.178', 'foo-rio-bar')")
|
||||
con.commit()
|
||||
# Backup changes
|
||||
srv.database.nbackup(database=str(act_1.db.db_path), backup=str(nbak_file_add),
|
||||
guid=db_guid)
|
||||
# Restore inplace
|
||||
srv.database.nrestore(flags=SrvNBackupFlag.IN_PLACE, database=str(nbak_file_base),
|
||||
backups=[str(nbak_file_add)])
|
||||
# Check restored database
|
||||
act_1.expected_stdout = expected_stdout_1_a
|
||||
act_1.isql(switches=['-user', act_1.db.user, '-password', act_1.db.password, str(nbak_file_base)],
|
||||
connect_db=False,
|
||||
input="set list on;set count on;set blob all;select id,s,t,b as blob_id from test;")
|
||||
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
||||
# Validate restored database
|
||||
srv.database.validate(database=str(nbak_file_base))
|
||||
act_1.reset()
|
||||
act_1.expected_stdout = expected_stdout_1_b
|
||||
act_1.stdout = '\n'.join(srv.readlines())
|
||||
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
||||
|
@ -2,14 +2,15 @@
|
||||
#
|
||||
# id: bugs.core_2230
|
||||
# title: Implement domain check of input parameters of execute block
|
||||
# decription:
|
||||
# decription:
|
||||
# tracker_id: CORE-2230
|
||||
# min_versions: []
|
||||
# versions: 3.0
|
||||
# qmid: None
|
||||
|
||||
import pytest
|
||||
from firebird.qa import db_factory, isql_act, Action
|
||||
from firebird.qa import db_factory, python_act, Action
|
||||
from firebird.driver import DatabaseError
|
||||
|
||||
# version: 3.0
|
||||
# resources: None
|
||||
@ -25,10 +26,10 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
#---
|
||||
# c = db_conn.cursor()
|
||||
# cmd = c.prep('execute block (x DOM1 = ?) returns (y integer) as begin y = x; suspend; end')
|
||||
#
|
||||
#
|
||||
# c.execute(cmd,[1])
|
||||
# printData(c)
|
||||
#
|
||||
#
|
||||
# try:
|
||||
# c.execute(cmd,[10])
|
||||
# printData(c)
|
||||
@ -37,21 +38,24 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
# else:
|
||||
# print ('Test Failed')
|
||||
#---
|
||||
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
|
||||
|
||||
act_1 = python_act('db_1', substitutions=substitutions_1)
|
||||
|
||||
expected_stdout_1 = """Y
|
||||
-----------
|
||||
1
|
||||
Y
|
||||
-----------
|
||||
Cursor.fetchone:
|
||||
- SQLCODE: -625
|
||||
- validation error for variable X, value "10"
|
||||
"""
|
||||
|
||||
@pytest.mark.version('>=3.0')
|
||||
@pytest.mark.xfail
|
||||
def test_1(db_1):
|
||||
pytest.fail("Test not IMPLEMENTED")
|
||||
|
||||
|
||||
def test_1(act_1: Action, capsys):
|
||||
with act_1.db.connect() as con:
|
||||
c = con.cursor()
|
||||
cmd = c.prepare('execute block (x DOM1 = ?) returns (y integer) as begin y = x; suspend; end')
|
||||
c.execute(cmd, [1])
|
||||
act_1.print_data(c)
|
||||
act_1.expected_stdout = expected_stdout_1
|
||||
act_1.stdout = capsys.readouterr().out
|
||||
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
||||
with pytest.raises(Exception, match='.*validation error for variable X, value "10"'):
|
||||
c.execute(cmd, [10])
|
||||
act_1.print_data(c)
|
||||
|
@ -2,76 +2,76 @@
|
||||
#
|
||||
# id: bugs.core_2233
|
||||
# title: Allow non-SYSDBA users to monitor not only their current attachment but other their attachments as well
|
||||
# decription:
|
||||
# decription:
|
||||
# Checked on:
|
||||
# 4.0.0.1635 SS: OK, 1.605s. 4.0.0.1633 CS: OK, 2.133s.
|
||||
# 3.0.5.33180 SS: OK, 1.925s. 3.0.5.33178 CS: OK, 1.581s.
|
||||
# 2.5.9.27119 SC: OK, 0.338s. 2.5.9.27146 SS: OK, 0.317s.
|
||||
#
|
||||
#
|
||||
# tracker_id: CORE-2233
|
||||
# min_versions: ['2.5.0']
|
||||
# versions: 2.5
|
||||
# qmid: None
|
||||
|
||||
import pytest
|
||||
from firebird.qa import db_factory, isql_act, Action
|
||||
from firebird.qa import db_factory, python_act, Action, user_factory, User
|
||||
|
||||
# version: 2.5
|
||||
# resources: None
|
||||
|
||||
substitutions_1 = [('[ \t]+', ' '), ('=', '')]
|
||||
|
||||
init_script_1 = """
|
||||
set wng off;
|
||||
-- Drop old account if it remains from prevoius run:
|
||||
set term ^;
|
||||
execute block as
|
||||
begin
|
||||
begin
|
||||
execute statement 'drop user tmp$c2233_adam' with autonomous transaction;
|
||||
when any do begin end
|
||||
end
|
||||
begin
|
||||
execute statement 'drop user tmp$c2233_mike' with autonomous transaction;
|
||||
when any do begin end
|
||||
end
|
||||
begin
|
||||
execute statement 'drop role tmp$r2233_boss';
|
||||
when any do begin end
|
||||
end
|
||||
end
|
||||
^
|
||||
set term ;^
|
||||
commit;
|
||||
#init_script_1 = """
|
||||
#set wng off;
|
||||
#-- Drop old account if it remains from prevoius run:
|
||||
#set term ^;
|
||||
#execute block as
|
||||
#begin
|
||||
#begin
|
||||
#execute statement 'drop user tmp$c2233_adam' with autonomous transaction;
|
||||
#when any do begin end
|
||||
#end
|
||||
#begin
|
||||
#execute statement 'drop user tmp$c2233_mike' with autonomous transaction;
|
||||
#when any do begin end
|
||||
#end
|
||||
#begin
|
||||
#execute statement 'drop role tmp$r2233_boss';
|
||||
#when any do begin end
|
||||
#end
|
||||
#end
|
||||
#^
|
||||
#set term ;^
|
||||
#commit;
|
||||
|
||||
create user tmp$c2233_adam password '123';
|
||||
create user tmp$c2233_mike password '456';
|
||||
commit;
|
||||
create role tmp$r2233_boss;
|
||||
create role tmp$r2233_acnt;
|
||||
grant tmp$r2233_boss to tmp$c2233_adam;
|
||||
grant tmp$r2233_acnt to tmp$c2233_adam;
|
||||
commit;
|
||||
"""
|
||||
#create user tmp$c2233_adam password '123';
|
||||
#create user tmp$c2233_mike password '456';
|
||||
#commit;
|
||||
#create role tmp$r2233_boss;
|
||||
#create role tmp$r2233_acnt;
|
||||
#grant tmp$r2233_boss to tmp$c2233_adam;
|
||||
#grant tmp$r2233_acnt to tmp$c2233_adam;
|
||||
#commit;
|
||||
#"""
|
||||
|
||||
db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
db_1 = db_factory(sql_dialect=3, init='')
|
||||
|
||||
# test_script_1
|
||||
#---
|
||||
#
|
||||
#
|
||||
# con0=fdb.connect( dsn = dsn, user='tmp$c2233_mike', password='456' )
|
||||
# con1=fdb.connect( dsn = dsn, user='tmp$c2233_adam', password='123' )
|
||||
# con2=fdb.connect( dsn = dsn, user='tmp$c2233_adam', password='123' )
|
||||
# con3=fdb.connect( dsn = dsn, user='tmp$c2233_adam', password='123', role='tmp$r2233_boss' )
|
||||
# con4=fdb.connect( dsn = dsn, user='tmp$c2233_adam', password='123', role='tmp$r2233_acnt' )
|
||||
#
|
||||
#
|
||||
# chk_sql='''
|
||||
# select current_user as who_am_i, mon$user mon_att_user, mon$role as mon_att_role, count( mon$user ) as mon_att_cnt
|
||||
# from rdb$database r
|
||||
# left join mon$attachments a on a.mon$attachment_id != current_connection
|
||||
# from rdb$database r
|
||||
# left join mon$attachments a on a.mon$attachment_id != current_connection
|
||||
# group by 1,2,3
|
||||
# '''
|
||||
#
|
||||
#
|
||||
# cur_mngr=con0.cursor()
|
||||
# cur_mngr.execute(chk_sql)
|
||||
# cur_cols=cur_mngr.description
|
||||
@ -80,7 +80,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
# print( cur_cols[i][0],':', r[i] )
|
||||
# cur_mngr.close()
|
||||
# #-------------------------------------------
|
||||
#
|
||||
#
|
||||
# cur_boss=con1.cursor()
|
||||
# cur_boss.execute(chk_sql)
|
||||
# cur_cols=cur_boss.description
|
||||
@ -89,14 +89,14 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
# print( cur_cols[i][0],':', r[i] )
|
||||
# cur_boss.close()
|
||||
# #-------------------------------------------
|
||||
#
|
||||
#
|
||||
# for c in (con0,con1,con2,con3,con4):
|
||||
# c.close()
|
||||
#
|
||||
#
|
||||
# db_conn.execute_immediate('drop user tmp$c2233_adam')
|
||||
# db_conn.execute_immediate('drop user tmp$c2233_mike')
|
||||
# db_conn.commit()
|
||||
#
|
||||
#
|
||||
# ## ||||||||||||||||||||||||||||
|
||||
# ## ###################################||| FB 4.0+, SS and SC |||##############################
|
||||
# ## ||||||||||||||||||||||||||||
|
||||
@ -111,9 +111,13 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
# ## #############################################################################################
|
||||
# db_conn.execute_immediate('delete from mon$attachments where mon$attachment_id != current_connection')
|
||||
# db_conn.commit()
|
||||
#
|
||||
#
|
||||
#---
|
||||
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
|
||||
|
||||
act_1 = python_act('db_1', substitutions=substitutions_1)
|
||||
|
||||
user_mike = user_factory(name='tmp$c2233_mike', password='456')
|
||||
user_adam = user_factory(name='tmp$c2233_adam', password='123')
|
||||
|
||||
expected_stdout_1 = """
|
||||
WHO_AM_I : TMP$C2233_MIKE
|
||||
@ -138,8 +142,43 @@ expected_stdout_1 = """
|
||||
"""
|
||||
|
||||
@pytest.mark.version('>=2.5')
|
||||
@pytest.mark.xfail
|
||||
def test_1(db_1):
|
||||
pytest.fail("Test not IMPLEMENTED")
|
||||
|
||||
|
||||
def test_1(act_1: Action, user_mike: User, user_adam: User, capsys):
|
||||
act_1.expected_stdout = expected_stdout_1
|
||||
with act_1.db.connect() as con, act_1.test_role('tmp$r2233_boss') as boss,\
|
||||
act_1.test_role('tmp$r2233_acnt') as acnt:
|
||||
c = con.cursor()
|
||||
c.execute('grant tmp$r2233_boss to tmp$c2233_adam')
|
||||
c.execute('grant tmp$r2233_acnt to tmp$c2233_adam')
|
||||
con.commit()
|
||||
#
|
||||
with act_1.db.connect(user=user_mike.name, password=user_mike.password) as con0, \
|
||||
act_1.db.connect(user=user_adam.name, password=user_adam.password) as con1, \
|
||||
act_1.db.connect(user=user_adam.name, password=user_adam.password) as con2, \
|
||||
act_1.db.connect(user=user_adam.name, password=user_adam.password, role=boss.name) as con3, \
|
||||
act_1.db.connect(user=user_adam.name, password=user_adam.password, role=acnt.name) as con4:
|
||||
#
|
||||
chk_sql = '''
|
||||
select current_user as who_am_i, mon$user mon_att_user, mon$role as mon_att_role, count( mon$user ) as mon_att_cnt
|
||||
from rdb$database r
|
||||
left join mon$attachments a on a.mon$attachment_id != current_connection
|
||||
group by 1,2,3
|
||||
'''
|
||||
#
|
||||
cur_mngr = con0.cursor()
|
||||
cur_mngr.execute(chk_sql)
|
||||
cur_cols = cur_mngr.description
|
||||
for r in cur_mngr:
|
||||
for i in range(0,len(cur_cols)):
|
||||
print( cur_cols[i][0], ':', r[i] )
|
||||
cur_mngr.close()
|
||||
#
|
||||
cur_boss = con1.cursor()
|
||||
cur_boss.execute(chk_sql)
|
||||
cur_cols = cur_boss.description
|
||||
for r in cur_boss:
|
||||
for i in range(0,len(cur_cols)):
|
||||
print( cur_cols[i][0], ':', r[i] )
|
||||
cur_boss.close()
|
||||
#
|
||||
act_1.stdout = capsys.readouterr().out
|
||||
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
||||
|
@ -2,14 +2,14 @@
|
||||
#
|
||||
# id: bugs.core_2251
|
||||
# title: gbak doesn't return error code
|
||||
# decription:
|
||||
# decription:
|
||||
# Inaccessible folder is defined here as $tmp + GUID (i.e. it 100% not yet exists).
|
||||
# We have to check allof kind for inaccessible file:
|
||||
# * .fbk when trying to make backup of existing database;
|
||||
# * .fdb when trying to restore from existing .fbk;
|
||||
# * .log - for any of these operation
|
||||
# We are NOT interested when all of these files are in accessible folder(s).
|
||||
#
|
||||
#
|
||||
# Query to obtain set of interested combinations (all of them should have retcode = 1):
|
||||
# with
|
||||
# a as (
|
||||
@ -31,19 +31,22 @@
|
||||
# select * from a,s,t,g
|
||||
# where NOT (s.path_to_source_file = 'accessible' and t.path_to_target_file = 'accessible' and g.path_to_action_log = 'accessible')
|
||||
# order by 1,2,3,4;
|
||||
#
|
||||
#
|
||||
# Confirmed wrong results on: 4.0.0.1714 SC; 4.0.0.1715 CS; 3.0.5.33221 SC; 3.0.5.33225 CS
|
||||
# Checked on:
|
||||
# 4.0.0.1726 SS: 3.759s.
|
||||
# 3.0.5.33232 SS: 1.671s.
|
||||
#
|
||||
#
|
||||
# tracker_id: CORE-2251
|
||||
# min_versions: ['3.0.5']
|
||||
# versions: 3.0.5
|
||||
# qmid: None
|
||||
|
||||
import pytest
|
||||
from firebird.qa import db_factory, isql_act, Action
|
||||
import subprocess
|
||||
from uuid import uuid4
|
||||
from pathlib import Path
|
||||
from firebird.qa import db_factory, python_act, Action, temp_file
|
||||
|
||||
# version: 3.0.5
|
||||
# resources: None
|
||||
@ -56,102 +59,103 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
|
||||
# test_script_1
|
||||
#---
|
||||
#
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# import uuid
|
||||
# import subprocess
|
||||
#
|
||||
#
|
||||
# os.environ["ISC_USER"] = user_name
|
||||
# os.environ["ISC_PASSWORD"] = user_password
|
||||
# correct_fdb=db_conn.database_name
|
||||
# db_conn.close()
|
||||
#
|
||||
#
|
||||
# #--------------------------------------------
|
||||
#
|
||||
#
|
||||
# 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] )
|
||||
#
|
||||
#
|
||||
# #--------------------------------------------
|
||||
#
|
||||
#
|
||||
# inaccessible_dir = os.path.join(context['temp_directory'], str(uuid.uuid4()) )
|
||||
#
|
||||
#
|
||||
# invalid_fdb=os.path.join(inaccessible_dir,'tmp_2251.fdb')
|
||||
#
|
||||
#
|
||||
# invalid_fbk=os.path.join(inaccessible_dir,'tmp_2251.fbk')
|
||||
# correct_fbk=os.path.join(context['temp_directory'],'tmp_2251.fbk')
|
||||
#
|
||||
#
|
||||
# invalid_res=os.path.join(inaccessible_dir,'tmp_2251.tmp')
|
||||
# correct_res=os.path.join(context['temp_directory'],'tmp_2251.tmp')
|
||||
#
|
||||
#
|
||||
# invalid_log=os.path.join(inaccessible_dir,'tmp_2251.log')
|
||||
# correct_log=os.path.join(context['temp_directory'],'tmp_2251.log')
|
||||
#
|
||||
#
|
||||
# ##########################################################################################
|
||||
#
|
||||
#
|
||||
# f_null_log = open(os.devnull,"w")
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-b', '-se', 'localhost:service_mgr', correct_fdb, correct_fbk, '-y', invalid_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print( 'backup source_fdb=accessible target_fbk=accessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
#
|
||||
#
|
||||
# cleanup( (correct_log,) )
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-b', '-se', 'localhost:service_mgr', correct_fdb, invalid_fbk, '-y', correct_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print('backup source_fdb=accessible target_fbk=inaccessible log_file=accessible:'.ljust(100), gbak_retcode)
|
||||
#
|
||||
#
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-b', '-se', 'localhost:service_mgr', correct_fdb, invalid_fbk, '-y', invalid_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print('backup source_fdb=accessible target_fbk=inaccessible log_file=inaccessible:'.ljust(100), gbak_retcode)
|
||||
#
|
||||
#
|
||||
# cleanup( (correct_log,) )
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-b', '-se', 'localhost:service_mgr', invalid_fdb, correct_fbk, '-y', correct_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print('backup source_fdb=inaccessible target_fbk=accessible log_file=accessible:'.ljust(100), gbak_retcode)
|
||||
#
|
||||
#
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-b', '-se', 'localhost:service_mgr', invalid_fdb, correct_fbk, '-y', invalid_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print('backup source_fdb=inaccessible target_fbk=accessible log_file=inaccessible:'.ljust(100), gbak_retcode)
|
||||
#
|
||||
#
|
||||
# cleanup( (correct_log,) )
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-b', '-se', 'localhost:service_mgr', invalid_fdb, invalid_fbk, '-y', correct_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print('backup source_fdb=inaccessible target_fbk=inaccessible log_file=accessible:'.ljust(100), gbak_retcode)
|
||||
#
|
||||
#
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-b', '-se', 'localhost:service_mgr', invalid_fdb, invalid_fbk, '-y', invalid_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print('backup source_fdb=inaccessible target_fbk=inaccessible log_file=inaccessible:'.ljust(100), gbak_retcode)
|
||||
#
|
||||
#
|
||||
# ######################################################################################
|
||||
# runProgram('gbak', [ '-b', '-se', 'localhost:service_mgr', correct_fdb, correct_fbk] )
|
||||
# ######################################################################################
|
||||
#
|
||||
#
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-rep', '-se', 'localhost:service_mgr', correct_fbk, correct_fdb, '-y', invalid_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print( 'restore source_fbk=accessible target_fdb=accessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
#
|
||||
#
|
||||
# cleanup( (correct_log,) )
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-rep', '-se', 'localhost:service_mgr', correct_fbk, invalid_fdb, '-y', correct_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print( 'restore source_fbk=accessible target_fdb=inaccessible log_file=accessible:'.ljust(100), gbak_retcode )
|
||||
#
|
||||
#
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-rep', '-se', 'localhost:service_mgr', correct_fbk, invalid_fdb, '-y', invalid_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print( 'restore source_fbk=accessible target_fdb=inaccessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
#
|
||||
#
|
||||
# cleanup( (correct_log,) )
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-rep', '-se', 'localhost:service_mgr', invalid_fbk, correct_fdb, '-y', correct_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print( 'restore source_fbk=inaccessible target_fdb=accessible log_file=accessible:'.ljust(100), gbak_retcode )
|
||||
#
|
||||
#
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-rep', '-se', 'localhost:service_mgr', invalid_fbk, correct_fdb, '-y', invalid_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print( 'restore source_fbk=inaccessible target_fdb=accessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
#
|
||||
#
|
||||
# cleanup( (correct_log,) )
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-rep', '-se', 'localhost:service_mgr', invalid_fbk, invalid_fdb, '-y', correct_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print( 'restore source_fbk=inaccessible target_fdb=inaccessible log_file=accessible:'.ljust(100), gbak_retcode )
|
||||
#
|
||||
#
|
||||
# gbak_retcode = subprocess.call( [context['gbak_path'], '-rep', '-se', 'localhost:service_mgr', invalid_fbk, invalid_fdb, '-y', invalid_log ], stdout=f_null_log, stderr=subprocess.STDOUT)
|
||||
# print( 'restore source_fbk=inaccessible target_fdb=inaccessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
#
|
||||
#
|
||||
# f_null_log.close()
|
||||
#
|
||||
#
|
||||
# cleanup( (correct_log,correct_fbk,) )
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#---
|
||||
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
|
||||
|
||||
act_1 = python_act('db_1', substitutions=substitutions_1)
|
||||
|
||||
expected_stdout_1 = """
|
||||
backup source_fdb=accessible target_fbk=accessible log_file=inaccessible: 1
|
||||
@ -170,9 +174,95 @@ expected_stdout_1 = """
|
||||
restore source_fbk=inaccessible target_fdb=inaccessible log_file=inaccessible: 1
|
||||
"""
|
||||
|
||||
inaccessible_dir = temp_file(uuid4().hex)
|
||||
correct_fbk = temp_file('tmp_2251.fbk')
|
||||
correct_res = temp_file('tmp_2251.tmp')
|
||||
correct_log = temp_file('tmp_2251.log')
|
||||
|
||||
@pytest.mark.version('>=3.0.5')
|
||||
@pytest.mark.xfail
|
||||
def test_1(db_1):
|
||||
pytest.fail("Test not IMPLEMENTED")
|
||||
def test_1(act_1: Action, capsys, inaccessible_dir: Path, correct_fbk: Path,
|
||||
correct_res: Path, correct_log: Path):
|
||||
correct_fdb = act_1.db.db_path
|
||||
invalid_fdb = inaccessible_dir / 'tmp_2251.fdb'
|
||||
invalid_fbk = inaccessible_dir / 'tmp_2251.fbk'
|
||||
#invalid_res = inaccessible_dir / 'tmp_2251.tmp'
|
||||
invalid_log = inaccessible_dir / 'tmp_2251.log'
|
||||
#
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-b', '-se', 'localhost:service_mgr',
|
||||
correct_fdb, correct_fbk, '-y', invalid_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print( 'backup source_fdb=accessible target_fbk=accessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-b', '-se', 'localhost:service_mgr',
|
||||
correct_fdb, invalid_fbk, '-y', correct_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print('backup source_fdb=accessible target_fbk=inaccessible log_file=accessible:'.ljust(100), gbak_retcode)
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-b', '-se', 'localhost:service_mgr',
|
||||
correct_fdb, invalid_fbk, '-y', invalid_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print('backup source_fdb=accessible target_fbk=inaccessible log_file=inaccessible:'.ljust(100), gbak_retcode)
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-b', '-se', 'localhost:service_mgr',
|
||||
invalid_fdb, correct_fbk, '-y', correct_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print('backup source_fdb=inaccessible target_fbk=accessible log_file=accessible:'.ljust(100), gbak_retcode)
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-b', '-se', 'localhost:service_mgr',
|
||||
invalid_fdb, correct_fbk, '-y', invalid_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print('backup source_fdb=inaccessible target_fbk=accessible log_file=inaccessible:'.ljust(100), gbak_retcode)
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-b', '-se', 'localhost:service_mgr',
|
||||
invalid_fdb, invalid_fbk, '-y', correct_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print('backup source_fdb=inaccessible target_fbk=inaccessible log_file=accessible:'.ljust(100), gbak_retcode)
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-b', '-se', 'localhost:service_mgr',
|
||||
invalid_fdb, invalid_fbk, '-y', invalid_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print('backup source_fdb=inaccessible target_fbk=inaccessible log_file=inaccessible:'.ljust(100), gbak_retcode)
|
||||
|
||||
######################################################################################
|
||||
act_1.gbak(switches=['-b', '-se', 'localhost:service_mgr', correct_fdb, correct_fbk] )
|
||||
######################################################################################
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-rep', '-se', 'localhost:service_mgr',
|
||||
correct_fbk, correct_fdb, '-y', invalid_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print( 'restore source_fbk=accessible target_fdb=accessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-rep', '-se', 'localhost:service_mgr',
|
||||
correct_fbk, invalid_fdb, '-y', correct_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print( 'restore source_fbk=accessible target_fdb=inaccessible log_file=accessible:'.ljust(100), gbak_retcode )
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-rep', '-se', 'localhost:service_mgr',
|
||||
correct_fbk, invalid_fdb, '-y', invalid_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print( 'restore source_fbk=accessible target_fdb=inaccessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-rep', '-se', 'localhost:service_mgr',
|
||||
invalid_fbk, correct_fdb, '-y', correct_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print( 'restore source_fbk=inaccessible target_fdb=accessible log_file=accessible:'.ljust(100), gbak_retcode )
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-rep', '-se', 'localhost:service_mgr',
|
||||
invalid_fbk, correct_fdb, '-y', invalid_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print( 'restore source_fbk=inaccessible target_fdb=accessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-rep', '-se', 'localhost:service_mgr',
|
||||
invalid_fbk, invalid_fdb, '-y', correct_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print( 'restore source_fbk=inaccessible target_fdb=inaccessible log_file=accessible:'.ljust(100), gbak_retcode )
|
||||
|
||||
gbak_retcode = subprocess.call( [act_1.vars['gbak'], '-rep', '-se', 'localhost:service_mgr',
|
||||
invalid_fbk, invalid_fdb, '-y', invalid_log ],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
print( 'restore source_fbk=inaccessible target_fdb=inaccessible log_file=inaccessible:'.ljust(100), gbak_retcode )
|
||||
#
|
||||
act_1.expected_stdout = expected_stdout_1
|
||||
act_1.stdout = capsys.readouterr().out
|
||||
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
||||
|
||||
|
@ -2,14 +2,14 @@
|
||||
#
|
||||
# id: bugs.core_2268
|
||||
# title: GFIX causes BUGCHECK errors with non valid transaction numbers
|
||||
# decription:
|
||||
# decription:
|
||||
# tracker_id: CORE-2268
|
||||
# min_versions: []
|
||||
# versions: 2.5
|
||||
# qmid: None
|
||||
|
||||
import pytest
|
||||
from firebird.qa import db_factory, isql_act, Action
|
||||
from firebird.qa import db_factory, python_act, Action
|
||||
|
||||
# version: 2.5
|
||||
# resources: None
|
||||
@ -23,9 +23,10 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
# test_script_1
|
||||
#---
|
||||
# runProgram('gfix',['-user',user_name,'-pas',user_password,'-commit','1000000',dsn])
|
||||
#
|
||||
#
|
||||
#---
|
||||
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
|
||||
|
||||
act_1 = python_act('db_1', substitutions=substitutions_1)
|
||||
|
||||
expected_stderr_1 = """transaction is not in limbo
|
||||
-transaction 1000000 is in an ill-defined state
|
||||
@ -33,8 +34,9 @@ expected_stderr_1 = """transaction is not in limbo
|
||||
"""
|
||||
|
||||
@pytest.mark.version('>=2.5')
|
||||
@pytest.mark.xfail
|
||||
def test_1(db_1):
|
||||
pytest.fail("Test not IMPLEMENTED")
|
||||
def test_1(act_1: Action):
|
||||
act_1.expected_stderr = expected_stderr_1
|
||||
act_1.gfix(switches=['-commit', '1000000', act_1.db.dsn])
|
||||
assert act_1.clean_stderr == act_1.clean_expected_stderr
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# id: bugs.core_2307
|
||||
# title: Incomplete API information values
|
||||
# decription:
|
||||
# decription:
|
||||
# Test creates lot of tables with names starting with 'TEST'.
|
||||
# Then we retrieve from rdb$relations min and max values of this tables ID ('r_min', 'r_max').
|
||||
# After each table is scanned via execute statement, statistics that we retrieve by call db_into()
|
||||
@ -10,26 +10,27 @@
|
||||
# We have to ckeck that number of entries in this set with r_min <= relation_id <= rmax NOT LESS than
|
||||
# number of created tables.
|
||||
# Also, scan for every table should take at least 1 sequential read - and this is checked too.
|
||||
#
|
||||
#
|
||||
# NOTE: we can SKIP checking concrete values of 'number_of_seq_reads', it does not matter in this test!
|
||||
#
|
||||
#
|
||||
# See also:
|
||||
# http://pythonhosted.org/fdb/reference.html#fdb.Connection.database_info
|
||||
#
|
||||
#
|
||||
# Info about 'isc_info_read_seq_count':
|
||||
# Number of sequential database reads, that is, the number of sequential table scans (row reads)
|
||||
# Reported per table.
|
||||
# Calculated since the current database attachment started.
|
||||
#
|
||||
#
|
||||
# Confirmed bug on WI-V2.1.2.18118: db_into() received imcompleted data (i.e. not for all tables).
|
||||
#
|
||||
#
|
||||
# tracker_id: CORE-2307
|
||||
# min_versions: ['2.5.0']
|
||||
# versions: 2.5
|
||||
# qmid: None
|
||||
|
||||
import pytest
|
||||
from firebird.qa import db_factory, isql_act, Action
|
||||
from firebird.qa import db_factory, python_act, Action
|
||||
from firebird.driver import DbWriteMode, DbInfoCode
|
||||
|
||||
# version: 2.5
|
||||
# resources: None
|
||||
@ -45,17 +46,17 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
# import os
|
||||
# import subprocess
|
||||
# import fdb
|
||||
#
|
||||
#
|
||||
# db_file=db_conn.database_name
|
||||
# db_conn.close()
|
||||
#
|
||||
#
|
||||
# os.environ["ISC_USER"] = user_name
|
||||
# os.environ["ISC_PASSWORD"] = user_password
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# # Change FW to OFF in order to speed up initial data filling:
|
||||
# ##################
|
||||
#
|
||||
#
|
||||
# fn_nul = open(os.devnull, 'w')
|
||||
# subprocess.call([ context['fbsvcmgr_path'], "localhost:service_mgr",
|
||||
# "action_properties", "prp_write_mode", "prp_wm_async",
|
||||
@ -64,13 +65,13 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
# stderr = subprocess.STDOUT
|
||||
# )
|
||||
# fn_nul.close()
|
||||
#
|
||||
#
|
||||
# # prepare DB for testing: create lot of tables:
|
||||
# ###############################################
|
||||
# f_work_sql=open( os.path.join(context['temp_directory'],'tmp_work_2307.sql'), 'w')
|
||||
#
|
||||
#
|
||||
# num_of_tables = 1000
|
||||
#
|
||||
#
|
||||
# sql_ddl='''
|
||||
# set term ^;
|
||||
# Execute block as
|
||||
@ -84,7 +85,7 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
# end
|
||||
# end ^
|
||||
# commit ^
|
||||
#
|
||||
#
|
||||
# execute block as
|
||||
# declare variable i integer = 0;
|
||||
# begin
|
||||
@ -94,38 +95,38 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
# execute statement 'insert into test' || cast(:i as varchar(5)) || ' (c) values (1)';
|
||||
# i = i + 1 ;
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# ^
|
||||
# set term ;^
|
||||
# commit;
|
||||
# ''' % locals()
|
||||
#
|
||||
#
|
||||
# f_work_sql.write(sql_ddl)
|
||||
# f_work_sql.close()
|
||||
#
|
||||
#
|
||||
# f_work_log=open( os.path.join(context['temp_directory'],'tmp_work_2307.log'), 'w')
|
||||
# f_work_err=open( os.path.join(context['temp_directory'],'tmp_work_2307.err'), 'w')
|
||||
# subprocess.call( [ context['isql_path'], dsn, "-i", f_work_sql.name],
|
||||
# stdout = f_work_log,
|
||||
# stderr = f_work_err
|
||||
# )
|
||||
#
|
||||
#
|
||||
# f_work_log.close()
|
||||
# f_work_err.close()
|
||||
#
|
||||
#
|
||||
# sql_dml = '''
|
||||
# execute block returns(r_min int, r_max int) as
|
||||
# declare n varchar(31);
|
||||
# declare i integer;
|
||||
# begin
|
||||
# for
|
||||
# select min(rdb$relation_id),max(rdb$relation_id)
|
||||
# from rdb$relations
|
||||
# select min(rdb$relation_id),max(rdb$relation_id)
|
||||
# from rdb$relations
|
||||
# where rdb$relation_name starting with upper('test')
|
||||
# into r_min, r_max
|
||||
# do
|
||||
# suspend;
|
||||
#
|
||||
#
|
||||
# for
|
||||
# select rdb$relation_name
|
||||
# from rdb$relations
|
||||
@ -135,8 +136,8 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
# execute statement 'select 1 as k from ' || :n || ' rows 1' into :i;
|
||||
# end
|
||||
# '''
|
||||
#
|
||||
# con = fdb.connect(dsn=dsn)
|
||||
#
|
||||
# con = fdb.connect(dsn=dsn)
|
||||
# cur = con.cursor()
|
||||
# cur.execute(sql_dml)
|
||||
# r_min=99999999
|
||||
@ -144,36 +145,99 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
# for r in cur:
|
||||
# r_min=r[0] # minimal ID in rdb$relations for user tables ('TEST1')
|
||||
# r_max=r[1] # maximal ID in rdb$relations for user tables ('TESTnnnnn')
|
||||
#
|
||||
#
|
||||
# info = con.db_info(fdb.isc_info_read_seq_count)
|
||||
# cnt=0
|
||||
# for k,v in info.items():
|
||||
# cnt = cnt+1 if k >= r_min and k <= r_max and v >= 1 else cnt
|
||||
#
|
||||
#
|
||||
# print( 'OK' if cnt >= num_of_tables else 'FAILED: db_info(fdb.isc_info_read_seq_count) contains only '+str(cnt)+' entries for scanned '+str(num_of_tables)+ ' user tables.' )
|
||||
#
|
||||
#
|
||||
# #for k, v in sorted(info.items()):
|
||||
# # print('page: '+str(k).zfill(8) + ', num of seq_reads: '+str(v).zfill(8) )
|
||||
#
|
||||
#
|
||||
# # Cleanup.
|
||||
# ###############################
|
||||
#
|
||||
#
|
||||
# f_list=[f_work_sql,f_work_log,f_work_err]
|
||||
# for i in range(len(f_list)):
|
||||
# if os.path.isfile(f_list[i].name):
|
||||
# os.remove(f_list[i].name)
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#---
|
||||
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
|
||||
|
||||
expected_stdout_1 = """
|
||||
OK
|
||||
"""
|
||||
act_1 = python_act('db_1', substitutions=substitutions_1)
|
||||
|
||||
@pytest.mark.version('>=2.5')
|
||||
@pytest.mark.xfail
|
||||
def test_1(db_1):
|
||||
pytest.fail("Test not IMPLEMENTED")
|
||||
def test_1(act_1: Action):
|
||||
# Change FW to OFF in order to speed up initial data filling:
|
||||
with act_1.connect_server() as srv:
|
||||
srv.database.set_write_mode(database=str(act_1.db.db_path), mode=DbWriteMode.ASYNC)
|
||||
# prepare DB for testing: create lot of tables:
|
||||
num_of_tables = 1000
|
||||
sql_ddl = f'''
|
||||
set term ^;
|
||||
Execute block as
|
||||
declare variable i integer = 0;
|
||||
begin
|
||||
while ( i < {num_of_tables} )
|
||||
do
|
||||
begin
|
||||
execute statement 'create table test' || cast(:i as varchar(5)) || ' (c integer)';
|
||||
i = i + 1 ;
|
||||
end
|
||||
end ^
|
||||
commit ^
|
||||
|
||||
execute block as
|
||||
declare variable i integer = 0;
|
||||
begin
|
||||
while (i < {num_of_tables} )
|
||||
do
|
||||
begin
|
||||
execute statement 'insert into test' || cast(:i as varchar(5)) || ' (c) values (1)';
|
||||
i = i + 1 ;
|
||||
end
|
||||
end
|
||||
^
|
||||
set term ;^
|
||||
commit;
|
||||
'''
|
||||
act_1.isql(switches=[], input=sql_ddl)
|
||||
sql_dml = '''
|
||||
execute block returns(r_min int, r_max int) as
|
||||
declare n varchar(31);
|
||||
declare i integer;
|
||||
begin
|
||||
for
|
||||
select min(rdb$relation_id),max(rdb$relation_id)
|
||||
from rdb$relations
|
||||
where rdb$relation_name starting with upper('test')
|
||||
into r_min, r_max
|
||||
do
|
||||
suspend;
|
||||
|
||||
for
|
||||
select rdb$relation_name
|
||||
from rdb$relations
|
||||
-- 4 debug only! >> rows 100
|
||||
into :n
|
||||
do
|
||||
execute statement 'select 1 as k from ' || :n || ' rows 1' into :i;
|
||||
end
|
||||
'''
|
||||
with act_1.db.connect() as con:
|
||||
c = con.cursor()
|
||||
c.execute(sql_dml)
|
||||
r_min = 99999999
|
||||
r_max = -9999999
|
||||
for r in c:
|
||||
r_min = r[0] # minimal ID in rdb$relations for user tables ('TEST1')
|
||||
r_max = r[1] # maximal ID in rdb$relations for user tables ('TESTnnnnn')
|
||||
#
|
||||
info = con.info.get_info(DbInfoCode.READ_SEQ_COUNT)
|
||||
cnt = 0
|
||||
for k, v in info.items():
|
||||
cnt = cnt + 1 if k >= r_min and k <= r_max and v >= 1 else cnt
|
||||
assert cnt >= num_of_tables
|
||||
|
Loading…
Reference in New Issue
Block a user