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
@ -25,7 +25,10 @@
|
||||
# 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
|
||||
@ -146,35 +149,21 @@ db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# irebird\\QA
|
||||
# bt-repo mp\\C2208W2.FDB -ch utf8
|
||||
# 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
|
||||
@ -236,37 +225,101 @@ db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
|
||||
# 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)
|
||||
|
@ -22,12 +22,16 @@
|
||||
# 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);
|
||||
@ -101,16 +105,8 @@ db_1 = db_factory(sql_dialect=3, init=init_script_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')
|
||||
@ -163,14 +159,21 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
#
|
||||
#
|
||||
#---
|
||||
#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
|
||||
@ -180,8 +183,33 @@ expected_stdout_1 = """
|
||||
"""
|
||||
|
||||
@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
|
||||
|
@ -9,7 +9,8 @@
|
||||
# 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
|
||||
@ -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)
|
||||
|
@ -14,47 +14,47 @@
|
||||
# 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
|
||||
#---
|
||||
@ -113,7 +113,11 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
# 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
|
||||
|
@ -43,7 +43,10 @@
|
||||
# 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
|
||||
@ -151,7 +154,8 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
||||
#
|
||||
#
|
||||
#---
|
||||
#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
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
# 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
|
||||
@ -25,7 +25,8 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_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
|
||||
|
||||
|
||||
|
@ -29,7 +29,8 @@
|
||||
# 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
|
||||
@ -165,15 +166,78 @@ db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
|
||||
#
|
||||
#
|
||||
#---
|
||||
#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