6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-02-02 02:40:42 +01:00

More Python tests and adjustments/ehancements to old tests

This commit is contained in:
Pavel Císař 2021-12-15 22:02:07 +01:00
parent c62721bcd3
commit 264650d58e
87 changed files with 7439 additions and 4750 deletions

View File

@ -348,7 +348,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 = """
RESULT_OF_REQ_COMPARE_TO_ACTUAL EXPECTED: actual values were equal to required.
@ -356,5 +357,4 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(db_1):
pytest.skip("Test requires manipulation with firebird.conf")
#pytest.fail("Test not IMPLEMENTED")
pytest.skip("Requires changes to firebird.conf")

View File

@ -45,7 +45,7 @@ test_script_1 = """
select cast('' as varchar(32765)), cast('' as varchar(32748)) from rdb$database;
select cast('' as varchar(32765)), cast('' as varchar(32748)) from rdb$database;
"""
"""
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
@ -54,11 +54,10 @@ expected_stdout_1 = """
CAST
CAST
CAST
"""
"""
@pytest.mark.version('>=2.1')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -33,6 +33,8 @@ from firebird.qa import db_factory, isql_act, Action
substitutions_1 = []
init_script_1 = """
set echo on;
set bail on;
create collation test_coll_ci_ai for win1252 from WIN_PTBR
case insensitive
accent insensitive
@ -75,7 +77,6 @@ db_1 = db_factory(charset='WIN1252', sql_dialect=3, init=init_script_1)
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
CONNECTION_CSET WIN1252
@ -104,7 +105,6 @@ act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
@pytest.mark.version('>=2.5')
def test_1(act_1: Action):
act_1.charset = 'WIN1252'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -9,7 +9,8 @@
# qmid: bugs.core_859
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: 9.1
# resources: None
@ -30,36 +31,42 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# pass
# else:
# print ('Test Failed in case 1')
#
#
# try:
# c.prep('select * from t order by a')
# except:
# pass
# else:
# print ('Test Failed in case 2')
#
#
# try:
# c.prep('select b, count(*) from t group by b')
# except:
# pass
# else:
# print ('Test Failed in case 3')
#
#
# try:
# c.prep('select a, count(*) from t group by a')
# except:
# pass
# else:
# print ('Test Failed in case 4')
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
@pytest.mark.version('>=9.1')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
act_1 = python_act('db_1', substitutions=substitutions_1)
@pytest.mark.version('>=2.1')
def test_1(act_1: Action):
with act_1.db.connect() as con:
c = con.cursor()
c.prepare('select * from t order by b')
with pytest.raises(DatabaseError, match='.*Datatype ARRAY is not supported for sorting operation.*'):
c.prepare('select * from t order by a')
c.prepare('select b, count(*) from t group by b')
with pytest.raises(DatabaseError, match='.*Datatype ARRAY is not supported for sorting operation.*'):
c.prepare('select a, count(*) from t group by a')
# Passed.

View File

@ -373,7 +373,6 @@ 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)
@ -550,6 +549,7 @@ tmp_file_1 = temp_file('non_ascii_ddl.sql')
@pytest.mark.version('>=3.0')
def test_1(act_1: Action, tmp_file_1: Path):
act_1.db.set_async_write()
#
tmp_file_1.write_bytes(non_ascii_ddl.encode('cp1251'))
# run without specifying charset

View File

@ -484,11 +484,10 @@ expected_stdout_1 = """
PTN [^[:DIGIT:]]
str similar to ptn 1
subs(str similar to ptn) a
"""
"""
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -56,7 +56,7 @@ test_script_1 = """
select char_length(b) from test;
select substring(b from char_length(b)-1 for 1) from test;
rollback;
"""
"""
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
@ -64,11 +64,11 @@ expected_stdout_1 = """
CHAR_LENGTH 1048320
SUBSTRING 0:43
#
"""
"""
@pytest.mark.version('>=2.5')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -2,26 +2,26 @@
#
# id: bugs.core_2493
# title: Append the IP address of the remote host to error messages in firebird.log for TCP connections
# decription:
# decription:
# Following actions are performed by this test:
#
#
# 1. Obtain current firebird.log and saves it to the file with name = 'tmp_2493_fblog_before.txt';
#
#
# 2. Asynchronously launch ISQL in child process with request to return client IP address (via asking context variable)
# and after this - do some 'heavy query' that for sure will take a lot of time and resources.
# Output is redirected to file with name = 'tmp_2493_isql.log' and will be parsed further (we'll search for client IP there).
#
#
# 3. Kill launched ISQL process after several seconds. At this point new message must appear in firebird.log and it MUST
# be in format described in the ticket. Because this abend will be detected by SERVER, format of message will be like this:
# (for TCPv4): INET/inet_error: read errno = 10054, client host = prog1, address = 127.0.0.1/4076, user = john
# (for TCPv6): INET/inet_error: read errno = 10054, client host = prog2, address = fe80::c40e:21ec:b5c7:8963/56831, user = mick
#
#
# 4. Wait several seconds and after it - obtain again firebird.log (new content) and save it in 'tmp_2493_fblog_after.txt'.
#
#
# 5. Make file comparison by calling method from standard Python tool - difflib. Result of this comparison will be stored
# in file with name 'tmp_2493_diff.txt'. This file will have several lines from which we are interested only for one which
# STARTS with "+" (PLUS sign) and does contain phrase 'INET/INET_ERROR'. Diff-file must contain only ONE such line.
#
#
# 6. Next we parse this line: remove "/" and "="characters from it and split then text into array of words:
# + INET inet_error read errno 10054 client host prog1 address 127.0.0.1 4417 user john ------- for IPv4
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13
@ -32,7 +32,7 @@
# * token N-2 is just word "user" (as is);
# * token N-3 is port number, it has to be positive value;
# * token N-4 is IP. It must be equal to rdb$get_context('SYSTEM','CLIENT_ADDRESS').
#
#
# This is how differences look in firebird.log:
# # 2.5.9:
# # INET/inet_error: read errno = 10054, client address = 127.0.0.1 3268, user ZOTOV.-1.-1
@ -45,8 +45,8 @@
# # 3.0.8 and 4.0.0 RC1:
# # INET/inet_error: read errno = 10054, client host = csprog, address = fe80::fcf1:e33c:e924:969d%16/56887, user = zotov
# # INET/inet_error: read errno = 10054, client host = csprog, address = fe80::fcf1:e33c:e924:969d%16/56883, user = zotov
#
#
#
#
# Checked on WI-V3.0.0.32272 x86 and amd64, OS = Windows XP and 8.1, TCPv4 and TCPv6; fdb version = 1.5, Python 2.7 and 3.4.
# Checked 17.02.2018 after adding 2.5.9 to the list of avaliable versions:
# 2.5.9.27103: OK, 5.547s.
@ -61,17 +61,17 @@
# For that reason it was decided do NOT use calls of socket.inet_pton() and operate only with remote_address that can be easy
# received using built-in FB context variable. User-defined functions 'is_valid_ipv4' and 'is_valid_ipv6' are left here for
# possible further usage in some other tests.
#
#
# 20.02.2021: changed 'platform' attribute to Windows only. Content of firebird.log has no changes on Linux during this test run.
# Perhaps, this is temporary and another solution will be found/implemented. Sent letter to dimitr et al, 21.02.2021 08:20.
#
#
# tracker_id: CORE-2493
# min_versions: ['2.5.9']
# versions: 2.5.9
# qmid:
# qmid:
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 2.5.9
# resources: None
@ -82,7 +82,7 @@ init_script_1 = """
recreate table log(ip varchar(255));
create sequence g;
commit;
"""
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
@ -97,29 +97,29 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import re
# import socket
# import getpass
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# engine = str(db_conn.engine_version)
# 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 )):
@ -127,31 +127,31 @@ 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])
#
#
# #-------------------------------------------
#
#
#
#
# def svc_get_fb_log( engine, f_fb_log ):
#
#
# import subprocess
#
#
# if engine.startswith('2.5'):
# get_firebird_log_key='action_get_ib_log'
# else:
# get_firebird_log_key='action_get_fb_log'
#
#
# subprocess.call([ context['fbsvcmgr_path'],
# "localhost:service_mgr",
# get_firebird_log_key
# ],
# stdout=f_fb_log,
# stdout=f_fb_log,
# stderr=subprocess.STDOUT
# )
#
#
# return
#
#
# #--------------------------------------------
#
#
# # http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python
# def is_valid_ipv4(address):
# import socket
@ -165,11 +165,11 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# return address.count('.') == 3
# except socket.error: # not a valid address
# return False
#
#
# return True
#
#
# #--------------------------------------------
#
#
# def is_valid_ipv6(address):
# import socket
# try:
@ -177,62 +177,62 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# except socket.error: # not a valid address
# return False
# return True
#
#
# #--------------------------------------------
#
#
# f_fblog_before=open(os.path.join(context['temp_directory'],'tmp_2493_fblog_before.txt'), 'w')
#
#
# svc_get_fb_log( engine, f_fblog_before )
#
#
# f_fblog_before.close()
#
#
# isql_txt=''' insert into log(ip) values( rdb$get_context('SYSTEM','CLIENT_ADDRESS') );
# commit;
# select count(i) from (select gen_id(g,1) i from rdb$types a,rdb$types b,rdb$types c,rdb$types d);
# '''
#
#
# f_sql_txt=open( os.path.join(context['temp_directory'],'tmp_2493_isql.sql'), 'w')
# f_sql_txt.write(isql_txt)
# flush_and_close( f_sql_txt )
#
#
# f_sql_log=open(os.path.join(context['temp_directory'],'tmp_2493_isql.log'), 'w' )
# f_sql_err=open(os.path.join(context['temp_directory'],'tmp_2493_isql.err'), 'w' )
#
#
# p_isql=Popen( [ context['isql_path'], dsn, "-i", f_sql_txt.name ], stdout=f_sql_log, stderr=f_sql_err
# )
# time.sleep(3)
#
#
# p_isql.terminate()
#
#
# flush_and_close( f_sql_log )
# flush_and_close( f_sql_err )
#
#
# f_sql_txt=open(os.path.join(context['temp_directory'],'tmp_2493_isql.sql'), 'w')
# f_sql_txt.write("set heading off; select iif(gen_id(g,0) = 0, 'Trouble with subprocess: job was not started.', ip) as msg from log; quit;")
# flush_and_close( f_sql_txt )
#
#
# mon_ip=subprocess.check_output( [ context['isql_path'], dsn, '-i', f_sql_txt.name ]).split()[0]
#
#
# f_fblog_after=open(os.path.join(context['temp_directory'],'tmp_2493_fblog_after.txt'), 'w')
#
#
# svc_get_fb_log( engine, f_fblog_after )
#
#
# flush_and_close( f_fblog_after )
#
#
# oldfb=open(f_fblog_before.name, 'r')
# newfb=open(f_fblog_after.name, 'r')
#
#
# difftext = ''.join(difflib.unified_diff(
# oldfb.readlines(),
# oldfb.readlines(),
# newfb.readlines()
# ))
# oldfb.close()
# newfb.close()
#
#
# f_diff_txt=open( os.path.join(context['temp_directory'],'tmp_2493_diff.txt'), 'w')
# f_diff_txt.write(difftext)
# flush_and_close( f_diff_txt )
#
#
# inet_msg_words = []
# logged_err=0
# with open( f_diff_txt.name,'r') as f:
@ -241,61 +241,62 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# # DO NOT include ':' to the list of delimiters! It is involved in IPv6 address:
# inet_msg_words = line.replace(',',' ').replace('/',' ').replace('=',' ').split()
# break
#
#
# # Tokens, numerated from zero (NB: leftmost is "PLUS" sign and has index = 0)
# # ---------------------------------------------------------------------------
# # + INET inet_error read errno 10054 client host prog1 address 127.0.0.1 4417 user john ------- for IPv4
# # 0 1 2 3 4 5 6 7 8 9 10 11 12 13
# # + INET inet_error read errno 10054 client host prog2 address x::y:z:u:v 56831 user mick ------- for IPv6
#
#
# # + INET/inet_error: read errno = 10054, client host = csprog, address = fe80::fcf1:e33c:e924:969d%16/56883, user = zotov
# # 0 1 2 3 4 5 6 7 8 9 10 11 12 --> len() = 13
#
#
# n = len(inet_msg_words)
#
#
# parsing_problem_msg = 'Problem with parsing content of firebird.log'
# if len(inet_msg_words) == 0:
# print('%s: message with "inet_error" not found.' % parsing_problem_msg)
# elif len(inet_msg_words) < 4:
# print('%s: message with "inet_error" contains less than 4 tokens.' % parsing_problem_msg)
# else:
#
#
# #print('Fixed data: '+inet_msg_words[4]+' '+inet_msg_words[5]+' '+inet_msg_words[6]+' '+inet_msg_words[7])
#
#
# # http://stackoverflow.com/questions/4271740/how-can-i-use-python-to-get-the-system-hostname
#
#
# # commented 17.02.2017 due to 2.5.9 (no info about remote host there):
# #if inet_msg_words[8].upper()==socket.gethostname().upper():
# # print('Remote host: valid, passed socket.gethostname()')
# #else:
# # print('Invalid host=|'+inet_msg_words[8]+'|')
#
#
# # does not work on Python 3.4! >>> if is_valid_ipv4(inet_msg_words[10]) or is_valid_ipv6(inet_msg_words[10]):
# if inet_msg_words[n-4] + '/' + inet_msg_words[n-3] == mon_ip:
# print("String IP/port: valid, equal to 'CLIENT_ADDRESS'")
# else:
# print('Invalid IP/port=|'+inet_msg_words[n-4]+'/'+inet_msg_words[n-3]+'| - differ from mon_ip=|'+mon_ip+'|')
#
#
# if inet_msg_words[n-3].isdigit():
# print('Port value: valid, positive integer.')
# else:
# print('Invalid port=|'+inet_msg_words[n-3]+'|')
#
#
# if inet_msg_words[n-1].upper().split('.')[0] == getpass.getuser().upper():
# # 2.5.9: got 'ZOTOV.-1.-1' ==> must be kust of one word: 'ZOTOV'
# print('OS user: valid, passed getpass.getuser()')
# else:
# print('Invalid OS user=|'+inet_msg_words[n-1]+'|')
#
#
#
#
# # Cleanup.
# ##########
# time.sleep(1)
# cleanup( [i.name for i in (f_sql_txt,f_sql_log,f_sql_err,f_fblog_before,f_fblog_after,f_diff_txt) ] )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
String IP/port: valid, equal to 'CLIENT_ADDRESS'
@ -305,8 +306,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=2.5.9')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
pytest.skip("Requires changes to firebird.conf")

View File

@ -96,14 +96,12 @@ expected_stdout_1_b = """
def test_1(act_1: Action):
act_1.expected_stdout = expected_stdout_1_a
act_1.script = test_script_1
act_1.charset = 'UTF8'
act_1.execute()
act_1.execute(charset='UTF8')
assert act_1.clean_stdout == act_1.clean_expected_stdout
act_1.reset()
act_1.expected_stdout = expected_stdout_1_b
act_1.script = test_script_1
act_1.charset = 'SJIS_0208'
act_1.execute()
act_1.execute(charset='SJIS_0208')
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -462,7 +462,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -154,21 +154,6 @@ test_script_1 = """
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
# [pcisar] 20.10.2021
# This test fails on my system due to (unexpected) error output from test script:
# Statement failed, SQLSTATE = 42000
# Execute statement error at isc_dsql_execute2 :
# 335544321 : arithmetic exception, numeric overflow, or string truncation
# 335544381 : Implementation limit exceeded
# Statement : insert into test1 with recursive r as (select 0 i from rdb$database union all select r.i+1 from r where r.i<99) select rpad('', 32760, uuid_to_char(gen_uuid()) ) from r r1,r r2 rows 2000
# Data source : Firebird::localhost:/tmp/pytest-of-pcisar/pytest-7/test_1514/test.fdb
# -At procedure 'SP_FILL' line: 4, col: 9
#
# Also, the stdout from test script differs:
# MEASURE_RESULT WINS >= 3.8x
# MEASURE_RESULT LOOSES, 0.00x
# MEASURE_RESULT LOOSES, 0.00x
expected_stdout_1 = """
MEASURE_RESULT WINS >= 3.8x
MEASURE_RESULT WINS >= 3.8x
@ -177,7 +162,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -44,7 +44,7 @@ SQL>"""
@pytest.mark.version('>=2.1.5')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -58,7 +58,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=2.1.5')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -46,12 +46,15 @@
# 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.1
# resources: None
substitutions_1 = [('Data source : Firebird::localhost:.*', 'Data source : Firebird::localhost'), ('After line.*', ''), ('.*Killed by database administrator.*', ''), ('-At block line:.*', '-At block line'), ('Execute statement error at isc_dsql_(execute2|prepare)', 'Execute statement error at isc_dsql')]
substitutions_1 = [('Data source : Firebird::localhost:.*', 'Data source : Firebird::localhost'),
('After line.*', ''), ('.*Killed by database administrator.*', ''),
('-At block line:.*', '-At block line'),
('Execute statement error at isc_dsql_(execute2|prepare)', 'Execute statement error at isc_dsql')]
init_script_1 = """"""
@ -325,7 +328,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 = """
Point_A: starting EB with lock-conflict
@ -351,7 +355,7 @@ expected_stdout_1 = """
"""
@pytest.mark.version('>=2.5.1')
def test_1(db_1):
def test_1(act_1: Action):
pytest.skip("New implementation postponed")

View File

@ -2,32 +2,32 @@
#
# id: bugs.core_3511
# title: Unquoted role names with non-ASCII characters passed in DPB are upper-cased wrongly
# decription:
# decription:
# Test creates role with non-ascii characters and grants it to common user.
# Then we try to connect to database using this role and specify it WITHOUT double quotes.
#
#
# ::: NB ::: DIFFERENT CODE FOR LINUX vs WINDOWS :::
#
#
# Attribute 'test_type' can be 'ISQL' only under LINUX.
#
#
# As of Windows, only system code page can be used when ISQL passes user/role containing non-ascii characters
# (see letter from dimitr, 12-mar-2016, 19:14).
#
#
# Because of this, it was decided to use Pytthon FDB for connect with DPB that contains non-ascii data.
# FDB method connect() of class Connection has parameter 'utf8params' with possible values True | False.
# When this parameter is True, all info passed to DPB in UTF-8. Test uses this to form proper DPB and connect
# to database with non-ascii role. This role must be specified WITHOUT double quotes.
#
#
# Checked on Linux: 3.0.8.33445, 4.0.0.2437
# Checked on Windows 3.0.8.33452, 4.0.0.2436
#
# tracker_id:
#
# tracker_id:
# min_versions: ['3.0']
# versions: 3.0, 3.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, isql_act, python_act, Action
# version: 3.0
# resources: None
@ -101,9 +101,10 @@ expected_stdout_1 = """
PLAN (TEST NATURAL)
"""
@pytest.mark.version('>=3.0,<3.0')
@pytest.mark.version('>=3.0')
@pytest.mark.platform('Linux')
def test_1(act_1: Action):
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout
@ -119,43 +120,44 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# test_script_2
#---
#
#
# import os
#
#
# os.environ["ISC_USER"] = 'SYSDBA'
# os.environ["ISC_PASSWORD"] = 'masterkey'
#
#
# cur = db_conn.cursor()
# cur.execute("create or alter user tmp$c3511 password '123' using plugin Srp")
# cur.execute('create table test(id int)')
# cur.execute('create role "Groß"')
# db_conn.commit()
#
#
# cur.execute('grant "Groß" to tmp$c3511')
# cur.execute('grant select on test to "Groß"')
# db_conn.commit()
#
#
# # NB: do NOT enclose rolename Groß in double quotes here
# # (this was needed in FB 2.5.x only; should NOT be necessarry in FB 3.x+):
# con=fdb.connect(dsn = dsn, charset = 'utf8', utf8params = True, user = 'tmp$c3511', password = '123', role='Groß')
#
#
# cur=con.cursor()
# cur.execute("select * from test");
# for r in cur:
# pass
#
#
# print('Done.')
# cur.close()
# con.close()
#
#
# con=fdb.connect(dsn = dsn)
# con.execute_immediate('drop user tmp$c3511 using plugin Srp')
# con.commit()
# con.close()
#
#
#
#
#---
#act_2 = python_act('db_2', test_script_2, substitutions=substitutions_2)
act_2 = python_act('db_2', substitutions=substitutions_2)
expected_stdout_2 = """
Done.
@ -163,8 +165,7 @@ expected_stdout_2 = """
@pytest.mark.version('>=3.0')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_2(db_2):
def test_2(act_2: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -47,7 +47,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -27,7 +27,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.2
# resources: None
@ -191,7 +191,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 = """
Expected line found.
@ -201,5 +202,5 @@ Expected line found.
"""
@pytest.mark.version('>=2.5.2')
def test_1(db_1):
pytest.skip("Implementation is complicated, and IMHO not worth of realization")
def test_1(act_1: Action):
pytest.skip("Reimplementation is complicated, and IMHO not worth of realization")

View File

@ -242,7 +242,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=2.5.2')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -1,55 +0,0 @@
#coding:utf-8
#
# id: bugs.core_3860
# title: Trace API: Faulty database filter crashes server
# decription:
# Confirmed crash on 2.5.1.26351, got on console:
# ===
# Unable to complete network request to host "localhost".
# -Error reading data from the connection.
# ===
# For 2.5.x we prepare trace config with invalid pattern for database section, launch trace and do trivial query to some database table.
# Trace STDOUT (beside "Trace session ID 5 started") should contain several blocks like this:
# ===
# Error creating trace session for service manager attachment:
# error while parsing trace configuration
# line 8: expected closing element, got "database"
# ====
# We create array of patterns for each of these messages and search in it each line of trace STDOUT.
# Every line should be found in this patterns array, otherwise this is UNEXPECTED case.
# Finally, if every line will be found then we have no unexpected result and 'expected_stdout' should be EMPTY.
# Checked on:
# 2.5.8.27067: OK, 7.000s.
# 2.5.9.27107: OK, 6.438s.
# For 3.0+ we just remain test body empty (there is nothing to check because of changed trace config format).
#
# tracker_id: CORE-3860
# min_versions: ['2.5.2']
# versions: 3.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 3.0
# resources: None
substitutions_1 = []
init_script_1 = """"""
#db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
@pytest.mark.version('>=3.0')
def test_1():
# This test should PASS, as there is nothing to check because of changed trace config format
pass

View File

@ -114,7 +114,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -34,7 +34,7 @@ expected_stdout_1 = """1
@pytest.mark.version('>=2.1.6')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -44,7 +44,6 @@ expected_stderr_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stderr = expected_stderr_1
act_1.execute()
assert act_1.clean_expected_stderr == act_1.clean_stderr

View File

@ -51,7 +51,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -73,7 +73,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -135,9 +135,8 @@ expected_stdout_1 = """
"""
@pytest.mark.version('>=3.0')
@pytest.mark.slow
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -139,7 +139,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -2,29 +2,29 @@
#
# id: bugs.core_4439
# title: Raise the 1024 connections limit (FD_SETSIZE) on Windows SS/SC
# decription:
# decription:
# Test tries to establish MAX_CONN_CNT = 2047 connections and then close all of them.
# Connections are established with specifying 'buffers' parameter and its value if set to minimal allowed: 50
# (this reduces server memory consumption when check SuperClassic).
#
#
# Every result of establishing / closing connection is logged by writing messages:
# * Connection # %d of %d was established
# * Connection # %d of %d has been closed
#
#
# After processing all <MAX_CONN_CNT> iterations, test closes log and count lines from this log which match to
# apropriate pattern. Total number of lines must be equal 2*MAX_CONN_CNT.
#
#
# If any other messages present in the log or number of lines differs from 2*MAX_CONN_CNT then error message
# will be reported. Otherwise console output remains EMPTY.
#
#
# NOTE-1.
# if number of established connections is more than 2047 then 1st of them will not be served by network server
# (this is network server current implementation; it can be changed later, see letter from Vlad, 10.01.2021 15:40).
#
#
# NOTE-2.
# If current FB server mode is 'Classic' then test actually does nothing and console output also remains empty.
# Test in such case looks as 'always successful' but actually it does not performed!
#
#
# Checked on:
# 4.0.0.2324 SS: 80.987s. Peak memory: 2.4 Gb
# 4.0.0.2324 SC: 96.190s. Peak memory: 4.2 Gb
@ -32,14 +32,14 @@
# 3.0.8.33401 SC: 70.862s. Peak memory: 2.4 Gb
# 2.5.9.27152 SS: 30.047s.
# 2.5.9.27152 SC: 30.501s.
#
#
# tracker_id: CORE-4439
# min_versions: ['2.5.3']
# versions: 2.5.3
# 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.3
# resources: None
@ -52,40 +52,40 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import sys
# import re
# import subprocess
# import datetime as py_dt
# from datetime import datetime
#
#
# from fdb import services
#
#
# #-----------------------------
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
# fb_bins = fb_home + ('bin' if db_conn.engine_version == 2.5 else '')
#
#
# #--------------------------------------------
#
#
# 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()
# if file_handle.mode not in ('r', 'rb'):
# # 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 )):
@ -94,29 +94,29 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# if os.path.isfile( f_names_list[i]):
# print('ERROR: can not remove file ' + f_names_list[i])
# exit(1)
#
#
# #-----------------------------------------------
#
#
# def get_fb_arch(a_dsn):
# try:
# con1 = fdb.connect(dsn = a_dsn)
# con2 = fdb.connect(dsn = a_dsn)
#
#
# cur1 = con1.cursor()
#
#
# sql=(
# "select count(distinct a.mon$server_pid), min(a.mon$remote_protocol), max(iif(a.mon$remote_protocol is null,1,0))"
# +" from mon$attachments a"
# +" where a.mon$attachment_id in (%s, %s) or upper(a.mon$user) = upper('%s')"
# % (con1.attachment_id, con2.attachment_id, 'cache writer')
# )
#
#
# cur1.execute(sql)
# for r in cur1.fetchall():
# server_cnt=r[0]
# server_pro=r[1]
# cache_wrtr=r[2]
#
#
# if server_pro == None:
# fba='Embedded'
# elif cache_wrtr == 1:
@ -124,52 +124,52 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# elif server_cnt == 2:
# fba='CS'
# else:
#
#
# f1=con1.db_info(fdb.isc_info_fetches)
#
#
# cur2=con2.cursor()
# cur2.execute('select 1 from rdb$database')
# for r in cur2.fetchall():
# pass
#
#
# f2=con1.db_info(fdb.isc_info_fetches)
#
#
# fba = 'SC' if f1 ==f2 else 'SS'
#
#
# #print(fba, con1.engine_version, con1.version)
# return fba
#
#
# finally:
# con1.close()
# con2.close()
#
#
# #-------------------------------------------------
#
#
# MAX_CONN_CNT=2047
#
#
# DB_NAME=db_conn.database_name
# db_conn.close()
#
#
# fb_arch= get_fb_arch(dsn)
#
#
# if fb_arch in ('SS', 'SC'):
# f_this_log = open( os.path.join(context['temp_directory'],'tmp_c4439.log'), 'w')
# con_list=[]
# for i in range(0,MAX_CONN_CNT):
# con_list.append( fdb.connect( dsn = dsn, buffers = 50 ) )
# f_this_log.write('Connection # %d of %d was established\\n' % (i+1, MAX_CONN_CNT) )
#
#
# # subprocess.call( [ os.path.join( fb_bins, 'fb_lock_print' ), '-c', '-d', DB_NAME ], stdout = f_this_log, stderr = subprocess.STDOUT )
#
#
# for i, c in enumerate(con_list):
# c.close()
# f_this_log.write('Connection # %d of %d has been closed\\n' % (i+1, MAX_CONN_CNT) )
#
#
# subprocess.call( [ os.path.join( fb_bins, 'gfix' ), '-shut', 'full', '-force', '0', dsn ], stdout = f_this_log, stderr = subprocess.STDOUT )
# subprocess.call( [ os.path.join( fb_bins, 'gfix' ), '-online', dsn ], stdout = f_this_log, stderr = subprocess.STDOUT )
#
#
# flush_and_close( f_this_log )
#
#
# # Parse log: we must find <MAX_CONN_CNT> lines in it with text like 'Connection ... was established'
# # and same number of lines with text like 'Connection ... closed'. All other messages must be considered
# # as unexpected.
@ -182,28 +182,29 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# n_matches += 1
# else:
# print('UNEXPECTED OUTPUT: '+line)
#
#
# if n_matches == 2 * MAX_CONN_CNT:
# # do NOT print anything if all OK!
# pass
# else:
# print('Number of matches: %d - NOT EQUAL to expected: %d' % (n_matches, 2 * MAX_CONN_CNT) )
#
#
# cleanup( (f_this_log.name,) )
#
#
# else:
# # Classic server: we must NOT check this mode.
# pass
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
@pytest.mark.version('>=2.5.3')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -2,47 +2,47 @@
#
# id: bugs.core_4462
# title: Make it possible to restore compressed .nbk files without explicitly decompressing them
# decription:
# decription:
# Test uses three preliminarily created .zip files:
# 1. 7zip-standalone-binary.zip -- contains standalone console utility 7za.exe
# 2. zstd-standalone-binary.zip -- contains standalone console utility zstd.exe
# 3. standard_sample_databases.zip -- contains SQL statements for Firebird EMPLOYEE and Oracle "HR" schema.
#
#
# We extract files from all of these .zip archives and do following:
# * apply Firebird SQL script which creates the same DB as standard EMPLOYEE;
# * invoke "nbackup -b 0 ..." and use Python PIPE mechanism for redirecting STDOUT to 7za.exe utility which,
# in turn, will accept data from this stream and compress them to .7z file.
# This eventually creates .7z file with compressed .nbk0 file.
#
#
# * apply SQL script from Oracle "HR" schema which adds several other tables and data;
# * invoke "nbackup -b 1 ..." and use again Python PIPE mechanism for redirecting STDOUT to 7za.exe utility.
# This will create one more .7z file with compressed .nbk1 file.
# * invoke "nbackup -decompress ..." with specifying command for running 7za.exe which will extract every file
# from those which are specified in the command, i.e:
#
#
# nbackup -decompress "c:\\path oz.exe x -y" <fdb_for_restoring> <compressed_7z_with_nbk0> <compressed_7z_with_nbk1>
#
#
# * validate just restored database and check content of firebird.log: it should NOT contain any errors or warnings.
#
#
# ::: NB :::
#
#
# This is *initial* implementation! We use trivial database with ascii-only metadata and data.
# Also, we use only 7za.exe compressor and zstd.exe is not yet used.
#
#
# Later this test may be expanded for check non-ascii metadata and/or data.
# Checked on:
# 4.0.0.1713 SS: 7.094s.
# 4.0.0.1691 CS: 9.969s.
# 3.0.5.33218 SS: 4.750s.
# 3.0.5.33212 CS: 6.976s.
#
#
# tracker_id: CORE-4462
# min_versions: ['3.0.5']
# versions: 3.0.5
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.5
# resources: None
@ -55,7 +55,7 @@ db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import sys
# import zipfile
@ -65,14 +65,14 @@ db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
# import subprocess
# from subprocess import PIPE
# from fdb import services
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# #--------------------------------------------
#
#
# def svc_get_fb_log( fb_home, f_fb_log ):
#
#
# global subprocess
# subprocess.call( [ fb_home + "fbsvcmgr",
# "localhost:service_mgr",
@ -81,7 +81,7 @@ db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
# stdout=f_fb_log, stderr=subprocess.STDOUT
# )
# return
#
#
# #--------------------------------------------
# def cleanup( f_names_list ):
# global os
@ -89,37 +89,37 @@ db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
# if os.path.isfile( f_names_list[i]):
# os.remove( f_names_list[i] )
# #--------------------------------------------
#
#
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
# this_db = db_conn.database_name
#
#
# fdb_for_restore = os.path.join(context['temp_directory'],'tmp_4462_restored.fdb')
# nbk0_name = '.'.join( (os.path.splitext( this_db )[0], 'nbk0') )
# nbk1_name = '.'.join( (os.path.splitext( this_db )[0], 'nbk1') )
# zip0_name = nbk0_name + '.7z'
# zip1_name = nbk1_name + '.7z'
#
#
# f_list = ( fdb_for_restore, nbk0_name, nbk1_name, zip0_name, zip1_name )
# cleanup( f_list )
#
#
# db_conn.close()
#
#
# for z in ( '7zip-standalone-binary.zip', 'zstd-standalone-binary.zip', 'standard_sample_databases.zip'):
# zf = zipfile.ZipFile( os.path.join(context['files_location'], z ) )
# zf.extractall( context['temp_directory'] )
# zf.close()
# # Result: scripts sample-DB_-_firebird.sql, sample-DB_-_oracle.sql and
# # Result: scripts sample-DB_-_firebird.sql, sample-DB_-_oracle.sql and
# # standalone binaries for 7-zip and zstd have been extracted into context['temp_directory']
#
#
# p7z_exe = os.path.join(context['temp_directory'],'7za.exe')
# zstd_exe = os.path.join(context['temp_directory'],'zstd.exe')
#
#
# ################################################################################################################
#
#
# f_sql_log=open( os.path.join(context['temp_directory'],'tmp_4462_init.log'), 'w', buffering = 0)
# subprocess.call( [ fb_home + 'isql', dsn, '-i', os.path.join(context['temp_directory'],'sample-DB_-_firebird.sql') ], stdout = f_sql_log, stderr = subprocess.STDOUT)
# f_sql_log.close()
#
#
# # https://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline
# # output=`dmesg | grep hda`
# # becomes:
@ -127,116 +127,116 @@ db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
# # p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
# # p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
# # output = p2.communicate()[0]
#
#
# # nbackup.exe -b 0 employee stdout | 7za u -siemployee.nbk0 C:\\FBSS\\employee.nbk0.7z
#
#
# p_sender = subprocess.Popen( [ fb_home+'nbackup', '-b', '0', this_db, 'stdout' ], stdout=PIPE)
# p_getter = subprocess.Popen( [ os.path.join(context['temp_directory'],'7za.exe'), 'u', '-bb3', '-bt', '-bse2', '-si' + os.path.split(nbk0_name)[1], zip0_name ], stdin = p_sender.stdout, stdout = PIPE )
# p_sender.stdout.close()
# p_getter_stdout, p_getter_stderr = p_getter.communicate()
#
#
# # result: file with name = %FBT_REPO% mp\\BUGS.CORE_4462.nbk0.7z must be created at this point
#
#
# f_nbk0_to_7z_log = open( os.path.join(context['temp_directory'],'tmp_4462_nbk0_to_7z.log'), 'w', buffering = 0)
# f_nbk0_to_7z_log.write( p_getter_stdout if p_getter_stdout else '' )
# f_nbk0_to_7z_log.write( p_getter_stderr if p_getter_stderr else '' )
# f_nbk0_to_7z_log.close()
#
#
# ################################################################################################################
#
#
# f_sql_log=open( os.path.join(context['temp_directory'],'tmp_4462_init.log'), 'a', buffering = 0)
# subprocess.call( [ fb_home + 'isql', dsn, '-i', os.path.join(context['temp_directory'],'sample-DB_-_oracle.sql') ], stdout = f_sql_log, stderr = subprocess.STDOUT)
# f_sql_log.close()
#
#
# p_sender = subprocess.Popen( [ fb_home+'nbackup', '-b', '1', this_db, 'stdout' ], stdout=PIPE)
# p_getter = subprocess.Popen( [ os.path.join(context['temp_directory'],'7za.exe'), 'u', '-bb3', '-bt', '-bse2', '-si' + os.path.split(nbk1_name)[1], zip1_name ], stdin = p_sender.stdout, stdout = PIPE )
# p_sender.stdout.close()
# p_getter_stdout, p_getter_stderr = p_getter.communicate()
#
#
# # result: file with name = %FBT_REPO% mp\\BUGS.CORE_4462.nbk1.7z must be created at this point
#
#
#
#
# f_nbk1_to_7z_log = open( os.path.join(context['temp_directory'],'tmp_4462_nbk1_to_7z.log'), 'w', buffering = 0)
# f_nbk1_to_7z_log.write( p_getter_stdout if p_getter_stdout else '' )
# f_nbk1_to_7z_log.write( p_getter_stderr if p_getter_stderr else '' )
# f_nbk1_to_7z_log.close()
#
#
# ################################################################################################################
#
#
# # Now we can restore database from compressed .7z files by invocation of nbackup with '-de[compress]' command key:
# # nbackup -decompress "7za x -so" -r C:\\FBSS\\examples\\emp-restored\\employee-from-7z.fdb C:\\compressed_backup\\employee.nbk0.7z C:\\compressed_backup\\employee.nbk1.7z
#
# # nbackup -decompress "7za x -so" -r C:\\FBSS\\examples\\emp-restored\\employee-from-7z.fdb C:\\compressed_backup\\employee.nbk0.7z C:\\compressed_backup\\employee.nbk1.7z
#
# f_restore_log=open( os.path.join(context['temp_directory'],'tmp_4462_nbackup_restore_from_7z.log'), 'w', buffering = 0)
# subprocess.call( [ fb_home + 'nbackup', '-decompress', ' '.join( (p7z_exe,'x', '-y', '-so') ), '-r', fdb_for_restore, zip0_name, zip1_name ], stdout = f_restore_log, stderr = subprocess.STDOUT)
# f_restore_log.close()
#
#
#
#
# # Get firebird.log content BEFORE running validation:
# #################################
# f_fblog_before=open( os.path.join(context['temp_directory'],'tmp_4462_fblog_before.txt'), 'w', buffering = 0)
# svc_get_fb_log( fb_home, f_fblog_before )
# f_fblog_before.close()
#
#
#
#
# # Run VALIDATION of just restored database:
# ################
# f_validation_log=open( os.path.join(context['temp_directory'],'tmp_4462_gfix_validate.log'), 'w', buffering = 0)
# subprocess.call( [ fb_home + 'gfix', '-v', '-full', fdb_for_restore], stdout=f_validation_log, stderr=subprocess.STDOUT)
# f_validation_log.close()
#
#
#
#
# # Get firebird.log content AFTER running validation:
# ################################
# f_fblog_after=open( os.path.join(context['temp_directory'],'tmp_4462_fblog_after.txt'), 'w', buffering = 0)
# svc_get_fb_log( fb_home, f_fblog_after )
# f_fblog_after.close()
#
#
# oldfb=open(f_fblog_before.name, 'r')
# newfb=open(f_fblog_after.name, 'r')
#
#
# difftext = ''.join(difflib.unified_diff(
# oldfb.readlines(),
# oldfb.readlines(),
# newfb.readlines()
# ))
# oldfb.close()
# newfb.close()
#
#
# f_diff_fblog=open( os.path.join(context['temp_directory'],'tmp_4462_fblog_diff.txt'), 'w', buffering = 0)
# f_diff_fblog.write(difftext)
# f_diff_fblog.close()
#
#
# pattern = re.compile('.*VALIDATION.*|.*ERROR:.*')
#
# # NB: difflib.unified_diff() can show line(s) that present in both files, without marking that line(s) with "+".
#
# # NB: difflib.unified_diff() can show line(s) that present in both files, without marking that line(s) with "+".
# # Usually these are 1-2 lines that placed just BEFORE difference starts.
# # So we have to check output before display diff content: lines that are really differ must start with "+".
#
# # Check: difference between old and new firebird.log should contain
#
# # Check: difference between old and new firebird.log should contain
# # only lines about validation start and finish, without errors:
# ###############################################################
#
#
# with open( f_diff_fblog.name,'r') as f:
# for line in f:
# if line.startswith('+'):
# if pattern.match(line.upper()):
# print( ' '.join(line.split()).upper() )
#
#
# # Final checks:
# ###############
# # tmp_4462_gfix_validate.log tmp_4462_nbackup_restore_from_7z.log
# # tmp_4462_gfix_validate.log tmp_4462_nbackup_restore_from_7z.log
# # Log for "nbackup -decompress -r ..." must be EMPTY:
# with open( f_restore_log.name,'r') as f:
# for line in f:
# if line:
# print('UNEXPECTED ERROR IN ' + f_restore_log.name + ': ' + line )
#
#
# # Log of "gfix -v -full" must be EMPTY (this means that no errors and no warning were found):
# with open( f_validation_log.name,'r') as f:
# for line in f:
# if line:
# print('UNEXPECTED ERROR IN ' + f_validation_log.name + ': ' + line )
#
#
#
#
# f_list = [
# fdb_for_restore
# ,nbk0_name
@ -246,15 +246,16 @@ db_1 = db_factory(charset='UTF8', sql_dialect=3, init=init_script_1)
# ,p7z_exe
# ,zstd_exe
# ,os.path.join(context['temp_directory'],'sample-DB_-_firebird.sql')
# ,os.path.join(context['temp_directory'],'sample-DB_-_oracle.sql')
# ,os.path.join(context['temp_directory'],'sample-DB_-_oracle.sql')
# ]
#
#
# f_list += [ i.name for i in (f_sql_log, f_nbk0_to_7z_log,f_nbk1_to_7z_log,f_restore_log,f_fblog_before,f_fblog_after,f_validation_log,f_diff_fblog) ]
#
#
# cleanup( f_list )
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
+ VALIDATION STARTED
@ -265,6 +266,5 @@ expected_stdout_1 = """
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
# This test should be reimplemnted in platform independent way!
pytest.fail("Test not IMPLEMENTED")

View File

@ -42,7 +42,7 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
@ -347,7 +347,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 = """
12192682 aa0bba FOUND.
@ -372,6 +373,5 @@ expected_stdout_1 = """
"""
@pytest.mark.version('>=4.0')
def test_1(db_1):
def test_1(act_1: Action):
pytest.skip("Requires encryption plugin")
#pytest.fail("Test not IMPLEMENTED")

View File

@ -2,34 +2,34 @@
#
# id: bugs.core_4571
# title: Can't select from table with ICU column when database (.FDB) is created on LINUX with icu 4.2.1 and then copied to WINDOWS
# decription:
# Database for this test was created beforehand on Linux host.
# decription:
# Database for this test was created beforehand on Linux host.
# DDL:
# create collation nums_coll for utf8 from unicode case insensitive 'NUMERIC-SORT=1';
# create domain dm_nums as varchar(20) character set utf8 collate nums_coll;
# recreate table wares(id bigint generated by default as identity, numb dm_nums unique using index wares_numb_unq);
#
# Table 'wares' then filled-up with some utf8 data and then *raw* .fdb file was copied on Windows host.
#
#
# Table 'wares' then filled-up with some utf8 data and then *raw* .fdb file was copied on Windows host.
#
# insert into wares(numb) values('lengéscsillapító');
# insert into wares(numb) values('viselő');
# insert into wares(numb) values('bærende');
# insert into wares(numb) values('ρουλεμάν');
# insert into wares(numb) values('αμορτισέρ');
# insert into wares(numb) values('støtdemper');
#
#
# Connect to this database without repairing ICU and querying table WARES will produce error:
# ===
# SQL> select * from wares;
# Statement failed, SQLSTATE = 22021
# COLLATION NUMS_COLL for CHARACTER SET UTF8 is not installed
# COLLATION NUMS_COLL for CHARACTER SET UTF8 is not installed
# ===
#
#
# This test makes unzip of 'raw' .fdb and run fbsvcmgr with key 'rpr_icu' in order to fix ICU incompatibility.
# Result of fbsvcmgr (STDOUT and STDERR) should be empty.
# Than we run ISQL and query table with UTF8 data - several rows with varchar field which is filled by text
# from Hungarian, Norwegian and Greek languages.
#
#
# WARNING! 'Raw' database should be recreated in case of changing ODS structure, otherwise one may get:
# ===
# File "c:
@ -37,30 +37,30 @@
# btest
# btest.py", line 827, in run
# exec substitute_macros(self.test_script) in global_ns, local_ns
#
# File "", line 29, in
#
#
# File "", line 29, in
#
# File "c:\\python27\\lib\\subprocess.py", line 540, in check_call
# raise CalledProcessError(retcode, cmd)
# raise CalledProcessError(retcode, cmd)
# ===
#
#
# Linux ICU info:
# $ rpm -qa | grep icu
# icu4j-eclipse-4.2.1-5.el6.x86_64
# libicu-4.2.1-9.1.el6_2.x86_64
#
# libicu-4.2.1-9.1.el6_2.x86_64
#
# Database initially was created on LI-V3.0.0.32239, then re-created 20.10.2016 on LI-T4.0.0.419 because ODS was changed.
# Checked on OS = Windows XP: WI-V3.0.1.32570, WI-T4.0.0.321
# 20.10.2016: checked on WI-T4.0.0.420
# 22.04.2020: checked on WI-T4.0.0.1920 - updated .fdb because of new system tables.
#
#
# tracker_id: CORE-4571
# min_versions: ['3.0']
# 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
# version: 3.0
# resources: None
@ -77,47 +77,47 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import time
# import zipfile
# import subprocess
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# # Obtain ODS major version:
# cur1 = db_conn.cursor()
# cur1.execute("select mon$ods_major as ods from mon$database")
# for row in cur1:
# ods = str(row[0])
# db_conn.close()
#
#
# zf = zipfile.ZipFile( os.path.join(context['files_location'],'core_4571.zip') )
# tmpfdb = 'core_4571-ods'+ods+'.fdb'
# zf.extract( tmpfdb, '$(DATABASE_LOCATION)')
# zf.close()
#
#
# tmpfdb='$(DATABASE_LOCATION)'+tmpfdb
#
#
# f_svc_rpr=open( os.path.join(context['temp_directory'],'tmp_icu_repair_4571.log'), 'w')
# subprocess.check_call(["fbsvcmgr","localhost:service_mgr",
# "action_repair",
# "dbname",tmpfdb,
# "rpr_icu"],
# stdout=f_svc_rpr,
# stdout=f_svc_rpr,
# stderr=subprocess.STDOUT)
# f_svc_rpr.close()
#
#
# sqltxt='''set list on; select id, numb from wares order by numb;'''
#
#
# f_sql_log=open( os.path.join(context['temp_directory'],'tmp_isql_4571.log'), 'w')
# f_sql_log.close()
# runProgram('isql', ['localhost:'+tmpfdb,'-q', '-o',f_sql_log.name], sqltxt)
#
#
# with open( f_svc_rpr.name,'r') as f:
# print(f.read())
# f.close()
#
#
# with open( f_sql_log.name,'r') as f:
# print(f.read())
# f.close()
#
#
# # Checked result on Linux:
# # ID NUMB
# # == ===================
@ -127,23 +127,24 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# # 2 viselő
# # 5 αμορτισέρ
# # 4 ρουλεμάν
#
#
# #####################################################################
# # Cleanup:
#
# # do NOT remove this pause otherwise some of logs will not be enable for deletion and test will finish with
#
# # do NOT remove this pause otherwise some of logs will not be enable for deletion and test will finish with
# # Exception raised while executing Python test script. exception: WindowsError: 32
# time.sleep(1)
#
#
# f_list=[f_svc_rpr, f_sql_log]
# for i in range(len(f_list)):
# if os.path.isfile(f_list[i].name):
# os.remove(f_list[i].name)
# os.remove(tmpfdb)
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
ID 3
@ -157,13 +158,13 @@ expected_stdout_1 = """
ID 5
NUMB αμορτισέρ
ID 4
NUMB ρουλεμάν
NUMB ρουλεμάν
"""
@pytest.mark.version('>=3.0')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -2,21 +2,21 @@
#
# id: bugs.core_4578
# title: INPUT file not properly closed
# decription:
# decription:
# Confirmed bug in ISQL 3.0.0.31374 (Beta1 release): script that has been performed by "IN" command
# is NOT deleted by "shell del ..." and can be used again, so the output will be:
# ID 1
# <path> mp_4578_in.sql
# ID 1
#
#
#
#
# tracker_id: CORE-4578
# min_versions: ['2.5.4']
# versions: 2.5.4
# 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.4
# resources: None
@ -29,13 +29,13 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import subprocess
# import time
#
#
# db_conn.close()
#
#
# txt_in = '''set list on;
# recreate table test(id int);
# commit;
@ -46,36 +46,37 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# tmp_input_sql=open( os.path.join(context['temp_directory'],'tmp_4578_in.sql'), 'w')
# tmp_input_sql.write(txt_in)
# tmp_input_sql.close()
#
#
# sql_main_file=open( os.path.join(context['temp_directory'],'tmp_4578_go.sql'), 'w')
#
#
# sql_main_file.write("set bail on;\\n" )
# sql_main_file.write("in "+tmp_input_sql.name+";\\n" )
# sql_main_file.write("shell del "+tmp_input_sql.name+" 2>nul;\\n" )
# sql_main_file.write("in "+tmp_input_sql.name+";\\n" )
#
#
# sql_main_file.close()
#
#
# sql_main_log=open( os.path.join(context['temp_directory'],'tmp_isql_4578.log'), 'w')
# p_isql = subprocess.call([ "isql" , dsn, "-user" , "SYSDBA" , "-password", "masterkey", "-i", sql_main_file.name ], stdout=sql_main_log, stderr=subprocess.STDOUT)
# sql_main_log.close()
#
#
# time.sleep(1)
#
#
# with open( sql_main_log.name,'r') as f:
# print(f.read())
# f.close()
#
# # do NOT remove this pause otherwise log of trace will not be enable for deletion and test will finish with
#
# # do NOT remove this pause otherwise log of trace will not be enable for deletion and test will finish with
# # Exception raised while executing Python test script. exception: WindowsError: 32
# time.sleep(1)
#
#
# os.remove(sql_main_log.name)
# os.remove(sql_main_file.name)
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
ID 1
@ -85,7 +86,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=2.5.4')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -77,7 +77,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.expected_stdout = expected_stdout_1
#act_1.expected_stderr = expected_stderr_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -720,7 +720,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -71,7 +71,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -30,7 +30,7 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0
# resources: None
@ -149,7 +149,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 = """
MON$SEC_DATABASE Self
@ -162,5 +163,5 @@ expected_stdout_1 = """
"""
@pytest.mark.version('>=3.0')
def test_1(db_1):
def test_1(act_1: Action):
pytest.skip("Requires changes to databases.conf")

View File

@ -101,7 +101,7 @@ def test_1(act_1: Action, fbk_file_1: Path):
act_1.reset()
# This was in original test, but it makes no sense as it overwites att_log content
# from backup that does not contain any data on v4.0.0.2496
# It's not important to test the issue anyway
# It's IMHO not important to test the issue anyway
#act_1.gbak(switches=['-rep', str(fbk_file_1), act_1.db.dsn])
#act_1.reset()
# Check

View File

@ -50,7 +50,7 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0
# resources: None
@ -248,7 +248,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 = """
CLIENT_MSG: 'ERROR WHILE CONNECTING TO DATABASE:\\N- SQLCODE: -902\\N- ERROR OCCURRED DURING LOGIN, PLEASE CHECK SERVER FIREBIRD.LOG FOR DETAILS'
@ -259,5 +260,5 @@ expected_stdout_1 = """
"""
@pytest.mark.version('>=3.0')
def test_1(db_1):
def test_1(act_1: Action):
pytest.skip("Requires changes to databases.conf")

View File

@ -38,7 +38,7 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0
# resources: None
@ -228,12 +228,12 @@ 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)
@pytest.mark.version('>=3.0')
def test_1(db_1):
pytest.skip("Test requires manipulation with firebird.conf")
#pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
pytest.skip("Requires changes to firebird.conf")

View File

@ -32,7 +32,7 @@
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0
# resources: None
@ -166,7 +166,8 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# cleanup( ( f_isql_log, f_isql_err, f_isql_cmd, f_dbshut_log,tmpfdb ) )
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
DATABASE ENCRYPTED
@ -175,4 +176,3 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(db_1):
pytest.skip("Requires encryption plugin")
#pytest.fail("Test not IMPLEMENTED")

View File

@ -326,11 +326,10 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
#
#
#---
#act_2 = python_act('db_2', test_script_2, substitutions=substitutions_2)
act_2 = python_act('db_2', substitutions=substitutions_2)
@pytest.mark.version('>=4.0')
def test_2(db_2):
pytest.skip("Requires changed firebird.conf [ReadConsistency=0]")
def test_2(act_2: Action):
pytest.skip("Requires changes to firebird.conf")

View File

@ -55,7 +55,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0.1')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -112,7 +112,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -59,8 +59,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0.1')
def test_1(act_1: Action):
act_1.charset = 'WIN1251'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
act_1.execute(charset='WIN1251')
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -18,7 +18,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.7
# resources: None
@ -134,11 +134,10 @@ 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)
@pytest.mark.version('>=2.5.7')
def test_1(db_1):
def test_1(act_1: Action):
pytest.skip("Requires direct changes to firebird.log")

View File

@ -2,19 +2,19 @@
#
# id: bugs.core_5470_addi
# title: Additional check for trace log when user issues statement with character that can not be transliterated
# decription:
# decription:
# It was detected that trace can stop any writing to its log if client issues query with character
# that can NOT transliterated between character sets. Such statement and *any* other statements
# that go after will NOT be reflected in the trace if its config contain include_filter with any
# that can NOT transliterated between character sets. Such statement and *any* other statements
# that go after will NOT be reflected in the trace if its config contain include_filter with any
# rule (even such trivial as: include_filter = "%").
#
#
# Initial discuss: july-2019, subj: "... fbtrace returned error on call trace_dsql_execute" (mailbox: pz@ibase.ru).
# Letter with example how to reproduce: 16.07.19 22:08.
# Finally this bug was fixed 26.03.2020:
# https://github.com/FirebirdSQL/firebird/commit/70ed61cba88ad70bd868079016cde3b338073db8
# ::: NB :::
# Problem was found only in FB 3.0; 4.x works OK because of new regexp mechanism in it.
#
#
# Test uses SQL script with two correct statements ('point-1' and 'point-2') and invalid character literal between them.
# This SQL can not be prepared in fbtest because of strict checks related to characters matching to unicode charsets.
# Then we prepare tempopary BATCH file which does:
@ -22,17 +22,17 @@
# run ISQL with applying this script.
# After this, we launch trace with config that contains trivial include_filter and run this temp batch.
# Expected result: trace must contain lines with ALL THREE executed statements.
#
#
# Confirmed bug on 3.0.6.33273: only 'point-1' appears in the trace. No further statements at all.
# All fine on 3.0.6.33276: all three statements can be seen in the trace.
#
#
# tracker_id: CORE-5470
# min_versions: ['3.0.6']
# versions: 3.0.6
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.6
# resources: None
@ -45,52 +45,52 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import subprocess
# import time
# from fdb import services
# from subprocess import Popen
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# #--------------------------------------------
#
#
# 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] )
#
#
# #--------------------------------------------
#
#
# # Obtain engine version:
# engine = str(db_conn.engine_version) # convert to text because 'float' object has no attribute 'startswith'
# db_conn.close()
#
# # NB, 06.12.2016: as of fdb 1.6.1 one need to EXPLICITLY specify user+password pair when doing connect
#
# # NB, 06.12.2016: as of fdb 1.6.1 one need to EXPLICITLY specify user+password pair when doing connect
# # via to FB services API by services.connect() - see FB tracker, PYFB-69
# # ("Can not connect to FB services if set ISC_USER & ISC_PASSWORD by os.environ[ ... ]")
#
#
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
# # fb_home = services.connect(host='localhost').get_home_directory()
#
#
# fb_isql = fb_home+'isql'
# sql_chk = os.path.join(context['files_location'],'core_5470_addi.sql')
# sql_chk = os.path.join(context['files_location'],'core_5470_addi.sql')
# tmp_log = os.path.join(context['temp_directory'],'core_5470_addi.log')
#
#
# txt = '''@echo off
# chcp 1251>nul
# %(fb_isql)s %(dsn)s -ch win1251 -user %(user_name)s -pas %(user_password)s -i %(sql_chk)s 1>%(tmp_log)s 2>&1
# ''' % dict(globals(), **locals())
#
#
# f_tmp_bat=open( os.path.join(context['temp_directory'],'tmp_run_5470.bat'), 'w', buffering = 0)
# f_tmp_bat.write(txt)
# f_tmp_bat.close()
#
#
# #--------------------------------------------------
#
#
# txt = '''# Generated auto, do not edit!
# database=%[\\\\\\\\/]security?.fdb
# {
@ -100,45 +100,45 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# {
# enabled = true
# time_threshold = 0
#
#
# log_initfini = false
# log_warnings = false
# log_errors = true
#
#
# log_statement_finish = true
#
#
# include_filter = "%"
#
#
# }
# '''
#
#
# f_trc_cfg=open( os.path.join(context['temp_directory'],'tmp_trace_5470.cfg'), 'w', buffering = 0)
# f_trc_cfg.write(txt)
# f_trc_cfg.close()
#
#
# # ##############################################################
# # S T A R T T R A C E i n S E P A R A T E P R O C E S S
# # ##############################################################
#
#
# f_trc_log=open( os.path.join(context['temp_directory'],'tmp_trace_5470.log'), "w", buffering = 0)
# f_trc_err=open( os.path.join(context['temp_directory'],'tmp_trace_5470.err'), "w", buffering = 0)
#
#
# p_trace = Popen( [ fb_home+'fbsvcmgr', 'localhost:service_mgr', 'action_trace_start' , 'trc_cfg', f_trc_cfg.name],stdout=f_trc_log,stderr=f_trc_err)
#
#
# time.sleep(1)
#
#
# # ####################################################
# # G E T A C T I V E T R A C E S E S S I O N I D
# # ####################################################
# # Save active trace session info into file for further parsing it and obtain session_id back (for stop):
#
#
# f_trc_lst = open( os.path.join(context['temp_directory'],'tmp_trace_5470.lst'), 'w', buffering = 0)
# subprocess.call([fb_home+'fbsvcmgr', 'localhost:service_mgr', 'action_trace_list'], stdout=f_trc_lst)
# f_trc_lst.close()
#
#
# # !!! DO NOT REMOVE THIS LINE !!!
# time.sleep(1)
#
#
# trcssn=0
# with open( f_trc_lst.name,'r') as f:
# for line in f:
@ -151,15 +151,15 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# break
# f.close()
# # Result: `trcssn` is ID of active trace session. Now we have to terminate it:
#
#
# #------------------------------------------------
# # Run auxiliary batch:
# subprocess.call( [ f_tmp_bat.name ] )
# #------------------------------------------------
#
#
# # Let trace log to be entirely written on disk:
# time.sleep(1)
#
#
# # ####################################################
# # S E N D R E Q U E S T T R A C E T O S T O P
# # ####################################################
@ -169,23 +169,24 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# fn_nul.close()
# # DO NOT REMOVE THIS LINE:
# time.sleep(2)
#
#
# p_trace.terminate()
# f_trc_log.close()
# f_trc_err.close()
#
#
# time.sleep(1)
#
#
# with open(f_trc_log.name, 'r') as f:
# for line in f:
# if line.startswith( "select 'point-" ):
# print(line)
#
#
# cleanup( [ i.name for i in ( f_trc_log, f_trc_err, f_trc_cfg, f_trc_lst, f_tmp_bat ) ] + [tmp_log,] ) # DO NOT ADD 'sql_chk' here!
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
select 'point-1' from rdb$database
@ -197,5 +198,3 @@ expected_stdout_1 = """
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")

View File

@ -2,25 +2,25 @@
#
# id: bugs.core_5477
# title: Trace duplicates asci_char(13) in its output (Windows only)
# decription:
# decription:
# We launch trace and create connect to DB with statement line 'select 1 from rdb$database'.
# Trace log should contain several lines related to connection, transaction and statement.
# These lines should be separated by standard Windows PAIR of characters: CR + NL.
# Count of these chars should be equal (ideally; actually 1st line in trace has EOL = single NL
# Count of these chars should be equal (ideally; actually 1st line in trace has EOL = single NL
# rather than pair CR+NL).
# We then open trace log as binary file and read all its content into dict of Counter type,
# thus we can get number of occurences for each character, including CR and NL.
# Finally, we compare number of occurences of CR and NL. Difference has to be no more than 1.
#
#
# Checked on 2.5.7.27048, 3.0.2.32685, 4.0.0.531 - all fine.
#
#
# tracker_id: CORE-5477
# min_versions: ['2.5.7']
# versions: 2.5.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.7
# resources: None
@ -33,36 +33,36 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import subprocess
# import time
# from fdb import services
# from subprocess import Popen
# from collections import Counter
#
#
# 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()
#
# # NB, 06.12.2016: as of fdb 1.6.1 one need to EXPLICITLY specify user+password pair when doing connect
#
# # NB, 06.12.2016: as of fdb 1.6.1 one need to EXPLICITLY specify user+password pair when doing connect
# # via to FB services API by services.connect() - see FB tracker, PYFB-69
# # ("Can not connect to FB services if set ISC_USER & ISC_PASSWORD by os.environ[ ... ]")
#
#
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
# # fb_home = services.connect(host='localhost').get_home_directory()
#
#
# if engine.startswith('2.5'):
# fb_home = fb_home + 'bin'+os.sep
# txt = '''# Generated auto, do not edit!
# <database %[\\\\\\\\/]security?.fdb>
# enabled false
# </database>
#
#
# <database %[\\\\\\\\/]bugs.core_5477.fdb>
# enabled true
# time_threshold 0
@ -91,30 +91,30 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# f_trc_cfg=open( os.path.join(context['temp_directory'],'tmp_trc_5477.cfg'), 'w')
# f_trc_cfg.write(txt)
# f_trc_cfg.close()
#
#
# # ##############################################################
# # S T A R T T R A C E i n S E P A R A T E P R O C E S S
# # ##############################################################
#
#
# f_trc_log=open( os.path.join(context['temp_directory'],'tmp_trc_5477.log'), "w")
# f_trc_err=open( os.path.join(context['temp_directory'],'tmp_trc_5477.err'), "w")
#
#
# p_trace = Popen( [ fb_home+'fbsvcmgr', 'localhost:service_mgr', 'action_trace_start' , 'trc_cfg', f_trc_cfg.name],stdout=f_trc_log,stderr=f_trc_err)
#
#
# time.sleep(1)
#
#
# # ####################################################
# # G E T A C T I V E T R A C E S E S S I O N I D
# # ####################################################
# # Save active trace session info into file for further parsing it and obtain session_id back (for stop):
#
#
# f_trc_lst = open( os.path.join(context['temp_directory'],'tmp_trace_5477.lst'), 'w')
# subprocess.call([fb_home+'fbsvcmgr', 'localhost:service_mgr', 'action_trace_list'], stdout=f_trc_lst)
# f_trc_lst.close()
#
#
# # !!! DO NOT REMOVE THIS LINE !!!
# time.sleep(1)
#
#
# trcssn=0
# with open( f_trc_lst.name,'r') as f:
# for line in f:
@ -127,17 +127,17 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# break
# f.close()
# # Result: `trcssn` is ID of active trace session. Now we have to terminate it:
#
#
# con1 = fdb.connect(dsn=dsn)
# cur1=con1.cursor()
# cur1.execute('select 1 from rdb$database')
# for r in cur1:
# pass
# con1.close()
#
#
# # Let trace log to be entirely written on disk:
# time.sleep(2)
#
#
# # ####################################################
# # S E N D R E Q U E S T T R A C E T O S T O P
# # ####################################################
@ -147,14 +147,14 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# fn_nul.close()
# # DO NOT REMOVE THIS LINE:
# time.sleep(2)
#
#
# p_trace.terminate()
# f_trc_log.close()
# f_trc_err.close()
#
#
# # Following file should be EMPTY:
# ################
#
#
# f_list=(f_trc_err,)
# for i in range(len(f_list)):
# f_name=f_list[i].name
@ -162,26 +162,27 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# with open( f_name,'r') as f:
# for line in f:
# print("Unexpected STDERR, file "+f_name+": "+line)
#
#
# letters_dict={}
# with open( f_trc_log.name,'rb') as f:
# letters_dict = Counter(f.read())
#
#
# nl_count = letters_dict['\\n']
# cr_count = letters_dict['\\r']
#
#
# print( 'EXPECTED.' if nl_count >= 1 and abs(nl_count - cr_count) <= 1 else 'FAIL: empty log or NL count differ than CR.' )
#
#
# # CLEANUP
# #########
# f_list=(f_trc_cfg, f_trc_lst, f_trc_log, f_trc_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)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
EXPECTED.
@ -190,7 +191,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=2.5.7')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -60,7 +60,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -138,7 +138,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_5691
# title: File description on Firebird executables should be specific
# decription:
# decription:
# ::: NB :::
# We can not obtain 'File description' property using Python.
# Also this property is not accessible for WMIC interface.
@ -11,19 +11,19 @@
# VB script accepts full path and filename as single mandatory argument.
# We run this script for each widely-used FB binaries (executables and DLLs).
# Its output must contain only FILE name (w/o disk and path) and its 'File description' property value.
#
#
# Home directory for currently used FB instance (i.e. prefix for each of files) can be found by
# invocation of FDB services.get_home_directory() method.
#
#
# Checked on 4.0.0.1710 SS: 1.407s.
#
#
# tracker_id: CORE-5691
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
@ -40,10 +40,10 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import os
# import subprocess
# from fdb import services
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# #--------------------------------------------
# def cleanup( f_names_list ):
# global os
@ -51,71 +51,71 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# if os.path.isfile( f_names_list[i]):
# os.remove( f_names_list[i] )
# #--------------------------------------------
#
#
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
# db_conn.close()
#
#
#
#
# vbs_cmd = open( os.path.join(context['temp_directory'],'tmp_5691_get_file_descr.vbs'), 'w', buffering = 0)
#
#
# vbs_source = \\
# r'''
# Option Explicit
#
#
# if wscript.arguments.count = 0 then
# wscript.echo "Missed fully qualified file name, i.e.: drive + path + file_name"
# wscript.quit
# end if
#
#
# dim fullname
# dim getDetails
#
#
# fullname = wscript.arguments(0)
#
#
# rem https://www.tek-tips.com/viewthread.cfm?qid=1402419
#
#
# getDetails = GetFileDetails( fullName )
#
#
#
#
# function GetFileDetails(fullName)
#
#
# on error resume next
#
#
# dim fso
# dim objFile
#
#
# set fso = CreateObject("Scripting.FileSystemObject")
# set objFile = fso.GetFile(fullName)
#
#
# if not fso.FileExists(fullName) Then
# wscript.echo "File '" & fullName & "' does not exist."
# wscript.Quit
# end if
#
#
# dim fileName
# dim folderName
#
#
# fileName = objFile.Name
# folderName = objFile.Path
# folderName = Left(folderName, Len(folderName)-Len(fileName))
#
#
# set objFile = Nothing
# set fso = Nothing
#
#
# dim objShell
# dim objFolder
#
#
# rem https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/bb776890(v=vs.85)
# rem The Windows Shell provides a powerful set of automation objects <...>
# rem You can use these objects to access <...> the file system, launch programs, and change system settings.
#
#
# set objShell = CreateObject("Shell.Application")
# set objFolder = objShell.NameSpace(folderName)
#
#
# dim i
# dim fdescr_idx
# dim propertyName
#
#
# i = 0
# fdescr_idx = 0
# do
@ -127,7 +127,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# fdescr_idx = i
# exit do
# end if
#
#
# if propertyName = vbNullString then
# exit do
# end if
@ -135,41 +135,41 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# loop
# propertyName = Nothing
# rem wscript.echo "fdescr_idx=",fdescr_idx
#
#
# dim objFolderItem
# set objFolderItem = objFolder.ParseName(fileName)
#
#
# if (not objFolderItem Is Nothing) then
# dim attribName
# dim objInfo
# attribName = objFolder.GetDetailsOf(objFolder.Items, fdescr_idx)
# objInfo = objFolder.GetDetailsOf(objFolderItem, fdescr_idx)
#
#
# wscript.echo "'" & fileName & "' " & LCase(attribName) & ":", LCase(objInfo)
#
#
# attribName = Nothing
# objInfo = Nothing
# end if
#
#
# set objFolderItem = Nothing
# set objFolder = Nothing
# set objShell = Nothing
# end function
# '''
#
#
# vbs_cmd.write(vbs_source)
# vbs_cmd.close()
#
#
# vbs_log = open( os.path.join(context['temp_directory'],'tmp_5691_get_file_descr.log'), 'w', buffering = 0)
# vbs_err = open( os.path.join(context['temp_directory'],'tmp_5691_get_file_descr.err'), 'w', buffering = 0)
#
#
# f_list = ( 'fbclient.dll',
# 'gbak.exe',
# 'gfix.exe',
# 'gstat.exe',
# 'gbak.exe',
# 'gfix.exe',
# 'gstat.exe',
# 'fbguard.exe',
# 'isql.exe',
# 'fb_lock_print.exe',
# 'fb_lock_print.exe',
# 'firebird.exe',
# 'nbackup.exe',
# 'fbtracemgr.exe',
@ -184,25 +184,26 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# )
# for x in sorted(f_list):
# subprocess.call( [ 'cscript', '//nologo', vbs_cmd.name, ''.join( (fb_home, x) ) ], stdout = vbs_log, stderr = vbs_err )
#
#
# vbs_log.close()
# vbs_err.close()
#
#
# with open( vbs_err.name,'r') as f:
# for line in f:
# print("Unexpected STDERR, file "+vbs_err.name+": " + line)
#
#
# with open( vbs_log.name,'r') as f:
# for line in f:
# print( line.lower() )
#
#
# os.remove( vbs_log.name )
# os.remove( vbs_err.name )
# os.remove( vbs_cmd.name )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
'fb_lock_print.exe' file description: firebird lock print tool (64-bit)
@ -228,7 +229,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_5887_trusted_role
# title: Allow the use of management statements in PSQL blocks: check only TRUSTED ROLE
# decription:
# decription:
# Role can be set as TRUSTED when following conditions are true:
# * BOTH AuthServer and AuthClient parameters from firebird.conf contain 'Win_Sspi' as plugin, in any place;
# * current OS user has admin rights;
@ -10,25 +10,25 @@
# * Two mappings are created (both uses plugin win_sspi):
# ** from any user to user;
# ** from predefined_group domain_any_rid_admins to role <role_to_be_trusted>
#
#
# Connect to database should be done in form: CONNECT '<computername>:<our_database>' role <role_to_be_trusted>',
# and after this we can user 'SET TRUSTED ROLE' statement.
#
#
# This test checks that statement 'SET TRUSTED ROLE' can be used within PSQL block rather than as DSQL.
#
#
# Checked on: 4.0.0.1457: OK, 2.602s.
# 25.04.2020: added command to obtain %FB_HOME% folder in order to make call of ISQL as fully qualified executable.
# Checked on 4.0.0.1935 SS/CS (both on Windows 8.1 (IMAGE-PC1) and Windows-2008 R2 (IBSurgeon-2008) hosts).
#
#
# Thanks to Alex for suggestions.
#
#
# tracker_id: CORE-5887
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
@ -49,23 +49,23 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# from fdb import services
# import socket
# import getpass
#
#
# #---------------------------------------------
#
#
# 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 )):
@ -73,9 +73,9 @@ 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])
#
#
# #--------------------------------------------
#
#
# # 23.08.2020: !!! REMOVING OS-VARIABLE ISC_USER IS MANDATORY HERE !!!
# # This variable could be set by other .fbts which was performed before current within batch mode (i.e. when fbt_run is called from <rundaily>)
# # NB: os.unsetenv('ISC_USER') actually does NOT affect on content of os.environ dictionary, see: https://docs.python.org/2/library/os.html
@ -85,21 +85,21 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# del os.environ["ISC_USER"]
# except KeyError as e:
# pass
#
#
#
#
# THIS_DBA_USER=user_name
# THIS_DBA_PSWD=user_password
#
#
# THIS_COMPUTER_NAME = socket.gethostname()
# CURRENT_WIN_ADMIN = getpass.getuser()
#
#
# THIS_FDB = db_conn.database_name
# db_conn.close()
#
#
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
#
#
# f_sql_cmd = open( os.path.join(context['temp_directory'],'tmp_check_5887.sql'), 'w', buffering=0)
#
#
# f_sql_txt='''
# set bail on;
# -- set echo on;
@ -108,25 +108,25 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# commit;
# grant tmp$role_5887 to "%(THIS_COMPUTER_NAME)s\\%(CURRENT_WIN_ADMIN)s";
# commit;
#
#
# -- We have to use here "create mapping trusted_auth ... from any user to user" otherwise get
# -- Statement failed, SQLSTATE = 28000 /Missing security context for C:\\FBTESTING\\QA\\MISC\\C5887.FDB
# -- on connect statement which specifies COMPUTERNAME:USERNAME instead path to DB:
# create or alter mapping trusted_auth using plugin win_sspi from any user to user;
#
#
# -- We have to use here "create mapping win_admins ... DOMAIN_ANY_RID_ADMINS" otherwise get
# -- Statement failed, SQLSTATE = 0P000 / Your attachment has no trusted role
#
#
# create or alter mapping win_admins using plugin win_sspi from predefined_group domain_any_rid_admins to role tmp$role_5887;
# commit;
#
#
# connect '%(THIS_COMPUTER_NAME)s:%(THIS_FDB)s' role tmp$role_5887;
#
#
# --show mapping;
#
#
# set list on;
# select 'point-1' as msg, a.mon$role,a.mon$auth_method from mon$attachments a where mon$attachment_id = current_connection;
#
#
# set term ^;
# execute block as
# begin
@ -135,12 +135,12 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# ^
# set term ;^
# commit;
#
#
# connect '%(THIS_COMPUTER_NAME)s:%(THIS_FDB)s';
#
#
# select 'point-2' as msg, a.mon$role, a.mon$auth_method from mon$attachments a where mon$attachment_id = current_connection;
# commit;
#
#
# connect 'localhost:%(THIS_FDB)s' user %(THIS_DBA_USER)s password '%(THIS_DBA_PSWD)s';
# drop mapping trusted_auth;
# drop mapping WIN_ADMINS;
@ -148,33 +148,34 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# --set bail off;
# --show mapping;
# ''' % locals()
#
#
# f_sql_cmd.write(f_sql_txt)
# flush_and_close( f_sql_cmd )
#
#
#
#
# f_sql_log=open( os.path.join(context['temp_directory'],'tmp_5887_trusted_role.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "isql", "-q", "-i", f_sql_cmd.name ], stdout=f_sql_log, stderr=subprocess.STDOUT )
# flush_and_close( f_sql_log )
#
#
# with open( f_sql_log.name,'r') as f:
# for line in f:
# print(line)
#
#
# cleanup( [x.name for x in (f_sql_cmd, f_sql_log)] )
#
#
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
MSG point-1
MON$ROLE TMP$ROLE_5887
MON$ROLE TMP$ROLE_5887
MON$AUTH_METHOD Mapped from Win_Sspi
MSG point-2
MON$ROLE TMP$ROLE_5887
MON$ROLE TMP$ROLE_5887
MON$AUTH_METHOD Mapped from Win_Sspi
"""
@ -182,7 +183,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_5948
# title: Make WIN_SSPI plugin produce keys for wirecrypt plugin
# decription:
# decription:
# We create mapping from current Windows user to SYSBDBA and then make following
# changes in the firebird.conf:
# * AuthClient = Win_Sspi
@ -12,26 +12,26 @@
# and we check that our attachment actualy uses wire encryption (by querying mon$ table).
# Finally, we return original firebird.conf back and create connect using common pair
# SYSDBA/masterkey. This is needed for drop mapping.
#
#
# Confirmed problem on 4.0.0.1227 (date of build: 01.10.2018): attempt to connect
# using Win_SSPI leads to:
# Statement failed, SQLSTATE = 28000
# Client attempted to attach unencrypted but wire encryption is required
#
#
# Discussed with Alex, letters 23.06.2020.
# Checked on 4.0.0.1346 (date of build: 17.12.2018), SS/SC/CS - works fine.
# Checked on 3.0.6.33222, SS/SC/CS -- all OK.
#
#
# ::: NB ::: Test has separate code for 3.0.x and 4.0 because there is no column
# mon$attachments.mon$wire_encrypted in FB 3.x
#
#
# tracker_id: CORE-5948
# min_versions: ['3.0.5']
# versions: 3.0.5, 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.5
# resources: None
@ -44,7 +44,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import sys
# import os
# import shutil
@ -54,7 +54,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import datetime
# import subprocess
# from fdb import services
#
#
# # 23.08.2020: !!! REMOVING OS-VARIABLE ISC_USER IS MANDATORY HERE !!!
# # This variable could be set by other .fbts which was performed before current within batch mode (i.e. when fbt_run is called from <rundaily>)
# # NB: os.unsetenv('ISC_USER') actually does NOT affect on content of os.environ dictionary, see: https://docs.python.org/2/library/os.html
@ -64,13 +64,13 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# del os.environ["ISC_USER"]
# except KeyError as e:
# pass
#
#
#
#
# THIS_COMPUTER_NAME = socket.gethostname()
# CURRENT_WIN_ADMIN = getpass.getuser()
#
#
# #--------------------------------------------
#
#
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
@ -78,23 +78,23 @@ 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])
#
#
# #--------------------------------------------
#
#
# db_conn.close()
# fb_home = services.connect(host='localhost', user=user_name, password=user_password).get_home_directory()
#
#
# dts = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
#
#
# fbconf_cur = os.path.join(fb_home, 'firebird.conf')
# fbconf_bak = os.path.join(context['temp_directory'], 'firebird_'+dts+'.bak')
#
#
# sql_pre='''
# set bail on;
# set list on;
# set count on;
# -- set echo on;
#
#
# recreate view v_map_info as
# select
# rdb$map_name -- test_wmap
@ -109,25 +109,25 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# from rdb$database
# left join rdb$auth_mapping on rdb$map_name = upper('test_wmap')
# ;
#
#
# create or alter mapping test_wmap using plugin win_sspi from user "%(THIS_COMPUTER_NAME)s\\%(CURRENT_WIN_ADMIN)s" to user %(user_name)s;
# commit;
#
#
# select * from v_map_info
# ;
#
#
# ''' % dict(globals(), **locals())
#
#
# f_prepare_sql = open( os.path.join(context['temp_directory'],'tmp_winsspi_prepare.sql'), 'w', buffering=0)
# f_prepare_sql.write(sql_pre)
# f_prepare_sql.close()
#
#
# f_prepare_log=open( os.path.join(context['temp_directory'],'tmp_winsspi_prepare.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "isql", dsn, "-user", user_name, "-pas", user_password, "-q", "-i", f_prepare_sql.name ], stdout=f_prepare_log, stderr=subprocess.STDOUT )
# f_prepare_log.close()
#
#
# shutil.copy2( fbconf_cur, fbconf_bak )
#
#
# f_fbconf=open( fbconf_cur, 'r')
# fbconf_content=f_fbconf.readlines()
# f_fbconf.close()
@ -135,49 +135,49 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# line = s.lower().lstrip()
# if line.startswith( 'wirecrypt'.lower() ):
# fbconf_content[i] = '# [temply commented] ' + s
#
#
# if line.startswith( 'AuthClient'.lower() ):
# fbconf_content[i] = '# [temply commented] ' + s
#
#
#
#
# text2app='''
# ### TEMPORARY CHANGED BY FBTEST FRAMEWORK ###
# AuthClient = Win_Sspi
# WireCrypt = Required
# ##############################################
# '''
#
#
# fbconf_content += [ '\\n' + x for x in text2app.split('\\n') ]
#
#
# f_fbconf=open( fbconf_cur, 'w', buffering = 0)
# f_fbconf.writelines( fbconf_content )
# f_fbconf.close()
#
#
# sql_run='''
# set wng off;
# set bail on;
# set list on;
# -- set echo on;
#
#
# connect '%(dsn)s';
# select
# mon$auth_method as auth_method -- mapped from win_sspi
# from mon$attachments where mon$attachment_id = current_connection;
# commit;
# ''' % dict(globals(), **locals())
#
#
# f_connect_sql = open( os.path.join(context['temp_directory'],'tmp_winsspi_connect.sql'), 'w', buffering=0)
# f_connect_sql.write(sql_run)
# f_connect_sql.close()
#
#
# f_connect_log=open( os.path.join(context['temp_directory'],'tmp_winsspi_connect.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "isql", "-q", "-i", f_connect_sql.name ], stdout=f_connect_log, stderr=subprocess.STDOUT )
# f_connect_log.close()
#
#
#
#
# # RESTORE previous content of firebird.conf. This must be done BEFORE drop mapping!
# shutil.copy2( fbconf_bak, fbconf_cur )
#
#
# # DROP mapping. NB: this connect will use Srp plugin because attempt to connect using WinSSPI could failed:
# sql_end='''
# drop mapping test_wmap;
@ -186,43 +186,44 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# set count on;
# select * from v_map_info;
# '''
#
#
# f_cleanup_sql = open( os.path.join(context['temp_directory'],'tmp_winsspi_cleanup.sql'), 'w', buffering=0)
# f_cleanup_sql.write(sql_end)
# f_cleanup_sql.close()
#
#
# f_cleanup_log=open( os.path.join(context['temp_directory'],'tmp_winsspi_cleanup.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "isql", dsn, "-user", user_name, "-pas", user_password, "-q", "-i", f_cleanup_sql.name ], stdout=f_cleanup_log, stderr=subprocess.STDOUT )
# f_cleanup_log.close()
#
#
#
#
# with open(f_prepare_log.name, 'r') as f:
# for line in f:
# if line.split():
# print('PREPARE: ' + line)
#
#
# with open(f_connect_log.name, 'r') as f:
# for line in f:
# if line.split():
# print('CONNECT: ' + line)
#
#
# with open(f_cleanup_log.name, 'r') as f:
# for line in f:
# if line.split():
# print('CLEANUP: ' + line)
#
#
# time.sleep(1)
#
#
# f_list=( f_prepare_sql, f_prepare_log, f_connect_sql, f_connect_log, f_cleanup_sql, f_cleanup_log, )
#
#
# # Cleanup
# ##########
# cleanup( [ i.name for i in f_list ] + [fbconf_bak] )
#
#
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
PREPARE: RDB$MAP_NAME TEST_WMAP
@ -237,7 +238,7 @@ expected_stdout_1 = """
PREPARE: Records affected: 1
CONNECT: AUTH_METHOD Mapped from Win_Sspi
CLEANUP: RDB$MAP_NAME <null>
CLEANUP: RDB$MAP_USING <null>
CLEANUP: RDB$MAP_PLUGIN <null>
@ -252,9 +253,8 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0.5')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
pytest.skip("Requires changes to firebird.conf")
# version: 4.0
@ -268,7 +268,7 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# test_script_2
#---
#
#
# import sys
# import os
# import shutil
@ -278,7 +278,7 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# import datetime
# import subprocess
# from fdb import services
#
#
# # 23.08.2020: !!! REMOVING OS-VARIABLE ISC_USER IS MANDATORY HERE !!!
# # This variable could be set by other .fbts which was performed before current within batch mode (i.e. when fbt_run is called from <rundaily>)
# # NB: os.unsetenv('ISC_USER') actually does NOT affect on content of os.environ dictionary, see: https://docs.python.org/2/library/os.html
@ -288,12 +288,12 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# del os.environ["ISC_USER"]
# except KeyError as e:
# pass
#
#
# THIS_COMPUTER_NAME = socket.gethostname()
# CURRENT_WIN_ADMIN = getpass.getuser()
#
#
# #--------------------------------------------
#
#
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
@ -301,23 +301,23 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# os.remove( f_names_list[i] )
# if os.path.isfile( f_names_list[i]):
# print('ERROR: can not remove file ' + f_names_list[i])
#
#
# #--------------------------------------------
#
#
# db_conn.close()
# fb_home = services.connect(host='localhost', user=user_name, password=user_password).get_home_directory()
#
#
# dts = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
#
#
# fbconf_cur = os.path.join(fb_home, 'firebird.conf')
# fbconf_bak = os.path.join(context['temp_directory'], 'firebird_'+dts+'.bak')
#
#
# sql_pre='''
# set bail on;
# set list on;
# set count on;
# -- set echo on;
#
#
# recreate view v_map_info as
# select
# rdb$map_name -- test_wmap
@ -332,25 +332,25 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# from rdb$database
# left join rdb$auth_mapping on rdb$map_name = upper('test_wmap')
# ;
#
#
# create or alter mapping test_wmap using plugin win_sspi from user "%(THIS_COMPUTER_NAME)s\\%(CURRENT_WIN_ADMIN)s" to user %(user_name)s;
# commit;
#
#
# select * from v_map_info
# ;
#
#
# ''' % dict(globals(), **locals())
#
#
# f_prepare_sql = open( os.path.join(context['temp_directory'],'tmp_winsspi_prepare.sql'), 'w', buffering=0)
# f_prepare_sql.write(sql_pre)
# f_prepare_sql.close()
#
#
# f_prepare_log=open( os.path.join(context['temp_directory'],'tmp_winsspi_prepare.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "isql", dsn, "-user", user_name, "-pas", user_password, "-q", "-i", f_prepare_sql.name ], stdout=f_prepare_log, stderr=subprocess.STDOUT )
# f_prepare_log.close()
#
#
# shutil.copy2( fbconf_cur, fbconf_bak )
#
#
# f_fbconf=open( fbconf_cur, 'r')
# fbconf_content=f_fbconf.readlines()
# f_fbconf.close()
@ -358,30 +358,30 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# line = s.lower().lstrip()
# if line.startswith( 'wirecrypt'.lower() ):
# fbconf_content[i] = '# [temply commented] ' + s
#
#
# if line.startswith( 'AuthClient'.lower() ):
# fbconf_content[i] = '# [temply commented] ' + s
#
#
#
#
# text2app='''
# ### TEMPORARY CHANGED BY FBTEST FRAMEWORK ###
# AuthClient = Win_Sspi
# WireCrypt = Required
# ##############################################
# '''
#
#
# fbconf_content += [ '\\n' + x for x in text2app.split('\\n') ]
#
#
# f_fbconf=open( fbconf_cur, 'w', buffering = 0)
# f_fbconf.writelines( fbconf_content )
# f_fbconf.close()
#
#
# sql_run='''
# set wng off;
# set bail on;
# set list on;
# -- set echo on;
#
#
# connect '%(dsn)s';
# select
# mon$auth_method as auth_method -- mapped from win_sspi
@ -389,19 +389,19 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# from mon$attachments where mon$attachment_id = current_connection;
# commit;
# ''' % dict(globals(), **locals())
#
#
# f_connect_sql = open( os.path.join(context['temp_directory'],'tmp_winsspi_connect.sql'), 'w', buffering=0)
# f_connect_sql.write(sql_run)
# f_connect_sql.close()
#
#
# f_connect_log=open( os.path.join(context['temp_directory'],'tmp_winsspi_connect.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "isql", "-q", "-i", f_connect_sql.name ], stdout=f_connect_log, stderr=subprocess.STDOUT )
# f_connect_log.close()
#
#
#
#
# # RESTORE previous content of firebird.conf. This must be done BEFORE drop mapping!
# shutil.copy2( fbconf_bak, fbconf_cur )
#
#
# # DROP mapping. NB: this connect will use Srp plugin because attempt to connect using WinSSPI could failed:
# sql_end='''
# drop mapping test_wmap;
@ -410,43 +410,44 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# set count on;
# select * from v_map_info;
# '''
#
#
# f_cleanup_sql = open( os.path.join(context['temp_directory'],'tmp_winsspi_cleanup.sql'), 'w', buffering=0)
# f_cleanup_sql.write(sql_end)
# f_cleanup_sql.close()
#
#
# f_cleanup_log=open( os.path.join(context['temp_directory'],'tmp_winsspi_cleanup.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "isql", dsn, "-user", user_name, "-pas", user_password, "-q", "-i", f_cleanup_sql.name ], stdout=f_cleanup_log, stderr=subprocess.STDOUT )
# f_cleanup_log.close()
#
#
#
#
# with open(f_prepare_log.name, 'r') as f:
# for line in f:
# if line.split():
# print('PREPARE: ' + line)
#
#
# with open(f_connect_log.name, 'r') as f:
# for line in f:
# if line.split():
# print('CONNECT: ' + line)
#
#
# with open(f_cleanup_log.name, 'r') as f:
# for line in f:
# if line.split():
# print('CLEANUP: ' + line)
#
#
# time.sleep(1)
#
#
# f_list=( f_prepare_sql, f_prepare_log, f_connect_sql, f_connect_log, f_cleanup_sql, f_cleanup_log, )
#
#
# # Cleanup
# ##########
# cleanup( [ i.name for i in f_list ] + [fbconf_bak] )
#
#
#
#
#
#
#---
#act_2 = python_act('db_2', test_script_2, substitutions=substitutions_2)
act_2 = python_act('db_2', substitutions=substitutions_2)
expected_stdout_2 = """
PREPARE: RDB$MAP_NAME TEST_WMAP
@ -477,8 +478,7 @@ expected_stdout_2 = """
@pytest.mark.version('>=4.0')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_2(db_2):
pytest.fail("Test not IMPLEMENTED")
def test_2(act_2: Action):
pytest.skip("Requires changes to firebird.conf")

View File

@ -1391,7 +1391,7 @@ expected_stderr_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.expected_stderr = expected_stderr_1
act_1.execute()

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_6038
# title: Srp user manager sporadically creates users which can not attach
# decription:
# decription:
# Explanation of bug nature was provided by Alex, see letter 05-jun-19 13:51.
# Some iteration failed with probability equal to occurence of 0 (zero) in the
# highest BYTE of some number. Byte is 8 bit ==> this probability is 1/256.
@ -11,25 +11,25 @@
# Because of time (speed) it was decided to run only 256 iterations. If bug
# will be 'raised' somewhere then this number is enough to catch it after 2-3
# times of test run.
#
#
# Reproduced on WI-V3.0.5.33118, date: 11-apr-19 (got fails not late than on 250th iteration).
# Works fine on WI-V3.0.5.33139, date: 04-apr-19.
#
#
# :::NOTE:::
# A new bug was found during this test implementation, affected 4.0 Classic only: CORE-6080.
#
#
# Checked on:
# 3.0.5.33140, SS: OK, 14.864s.
# 4.0.0.1530, SS: OK, 22.478s.
# 4.0.0.1530, Cs: OK, 39.576s. -- NB: Classic mode failed until core-6080 was fixed
#
#
# tracker_id: CORE-6038
# min_versions: ['3.0.5']
# versions: 3.0.5
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action, User
# version: 3.0.5
# resources: None
@ -42,22 +42,22 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import fdb
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# N_LIMIT = 256
# # ^
# # | ###############################
# # +-------------------### number of iterations ###
# # ###############################
#
#
# CHECK_USR = 'tmp$c6038_srp'
# CHECK_PWD = 'QweRty#6038$='
#
#
# for i in range(0, N_LIMIT):
# db_conn.execute_immediate( "create or alter user %(CHECK_USR)s password '%(CHECK_PWD)s' using plugin Srp" % locals() )
# db_conn.commit()
@ -65,15 +65,22 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# con_check.close()
# db_conn.execute_immediate( "drop user %(CHECK_USR)s using plugin Srp" % locals() )
# db_conn.commit()
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
CHECK_USR = 'tmp$c6038_srp'
CHECK_PWD = 'QweRty#6038$='
@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):
N_LIMIT = 256
for i in range(N_LIMIT):
with User(act_1.db, name=CHECK_USR, password=CHECK_PWD, plugin='Srp', charset='utf8'):
with act_1.db.connect(user=CHECK_USR, password=CHECK_PWD):
pass
# Passed.

View File

@ -91,7 +91,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -2,18 +2,18 @@
#
# id: bugs.core_6071
# title: Restore of encrypted backup of database with SQL dialect 1 fails
# decription:
#
# decription:
#
# We create new database ('tmp_core_6071.fdb') and try to encrypt it using IBSurgeon Demo Encryption package
# ( https://ib-aid.com/download-demo-firebird-encryption-plugin/ ; https://ib-aid.com/download/crypt/CryptTest.zip )
# License file plugins\\dbcrypt.conf with unlimited expiration was provided by IBSurgeon to Firebird Foundation (FF).
# This file was preliminary stored in FF Test machine.
# Test assumes that this file and all neccessary libraries already were stored into FB_HOME and %FB_HOME%\\plugins.
#
#
# After test database will be created, we try to encrypt it using 'alter database encrypt with <plugin_name> ...' command
# (where <plugin_name> = dbcrypt - name of .dll in FB_HOME\\plugins\\ folder that implements encryption).
# Then we allow engine to complete this job - take delay about 1..2 seconds BEFORE detach from database.
#
#
# After this we:
# 1. Change temp DB state to full shutdown and bring it online - in order to be sure that we will able to drop this file later;
# 2. Make backup of this temp DB, using gbak utility and '-KEYHOLDER <name_of_key_holder>' command switch.
@ -21,15 +21,15 @@
# 3. Make restore from just created backup.
# 4. Make validation of just restored database by issuing command "gfix -v -full ..."
# ( i.e. validate both data and metadata rather than online val which can check user data only).
# 5. Check that NO errors occured on any above mentioned steps. Also check that backup and restore STDOUT logs contain expected
# 5. Check that NO errors occured on any above mentioned steps. Also check that backup and restore STDOUT logs contain expected
# text about successful completition
#
#
# Confirmed bug on 4.0.0.1485 (build date: 11-apr-2019), got error on restore:
# SQL error code = -817
# Metadata update statement is not allowed by the current database SQL dialect 1
#
#
# Works fine on 4.0.0.1524, time ~8s.
#
#
# 16.04.2021.
# Changed code: database is created in dialect 3, then encrypted and after this we apply 'gfix -sql_dialect 1' to it.
# Unfortunately, I could not find the way how to make it work on Linux: attempt to backup (gbak -KEYHOLDER ... -crypt ... ) fails with:
@ -38,16 +38,16 @@
# gbak: ERROR: Error loading plugin FBSAMPLEDBCRYPT
# gbak: ERROR: Module /var/tmp/fb40tmp/plugins/FBSAMPLEDBCRYPT does not contain plugin FBSAMPLEDBCRYPT type 9
# (after file libfbSampleDbCrypt.so was copied to libFBSAMPLEDBCRYPT.so)
#
#
# Test remains WINDOWS only.
#
#
# tracker_id: CORE-6071
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
@ -60,34 +60,34 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import time
# import subprocess
# import re
# import fdb
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
# db_conn.close()
#
#
# #--------------------------------------------
#
#
# def flush_and_close( file_handle ):
# # https://docs.python.org/2/library/os.html#os.fsync
# # If you're starting with a Python file object f,
# # first do f.flush(), and
# # then do os.fsync(f.fileno()), to ensure that all internal buffers associated with f are written to disk.
# global os
#
#
# file_handle.flush()
# if file_handle.mode not in ('r', 'rb') and file_handle.name != os.devnull:
# # otherwise: "OSError: [Errno 9] Bad file descriptor"!
# os.fsync(file_handle.fileno())
# file_handle.close()
#
#
# #--------------------------------------------
#
#
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
@ -99,23 +99,23 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# print('Unrecognized type of element:', f_names_list[i], ' - can not be treated as file.')
# print('type(f_names_list[i])=',type(f_names_list[i]))
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# tmpfdb='$(DATABASE_LOCATION)'+'tmp_core_6071.fdb'
# tmpbkp='$(DATABASE_LOCATION)'+'tmp_core_6071.fbk'
#
#
# gbak_backup_finish_ptn=re.compile('gbak:closing\\s+file,\\s+committing,\\s+and\\s+finishing.*', re.IGNORECASE)
# gbak_restore_finish_ptn=re.compile('gbak:adjusting\\s+the\\s+ONLINE\\s+and\\s+FORCED\\s+WRITES\\s+.*', re.IGNORECASE)
#
#
# cleanup( (tmpfdb,) )
#
#
# con = fdb.create_database( dsn = 'localhost:'+tmpfdb)
# cur = con.cursor()
#
#
# # 14.04.2021.
# # Name of encryption plugin depends on OS:
# # * for Windows we (currently) use plugin by IBSurgeon, its name is 'dbcrypt';
@ -125,7 +125,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# #
# PLUGIN_NAME = 'dbcrypt' if os.name == 'nt' else '"fbSampleDbCrypt"'
# KHOLDER_NAME = 'KeyHolder' if os.name == 'nt' else "fbSampleKeyHolder"
#
#
# ##############################################
# # WARNING! Do NOT use 'connection_obj.execute_immediate()' for ALTER DATABASE ENCRYPT... command!
# # There is bug in FB driver which leads this command to fail with 'token unknown' message
@ -135,28 +135,28 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# # See letter from Pavel Cisar, 20.01.20 10:36
# ##############################################
# cur.execute('alter database encrypt with %(PLUGIN_NAME)s key Red' % locals())
#
#
# con.commit()
# time.sleep(2)
# # ^
# # +-------- !! ALLOW BACKGROUND ENCRYPTION PROCESS TO COMPLETE ITS JOB !!
#
#
# con.close()
#
#
# #-------------------------- shutdown temp DB and bring it online --------------------
#
#
# f_gfix_log = open( os.path.join(context['temp_directory'],'tmp_dbshut_6071.log'), 'w')
# subprocess.call( [ context['gfix_path'], 'localhost:'+tmpfdb, "-sql_dialect", "1" ],
# stdout = f_gfix_log,
# stderr = subprocess.STDOUT
# )
# flush_and_close( f_gfix_log )
#
#
# #--------------------------- backup and restore --------------------------------------
# fn_bkp_log=open( os.path.join(context['temp_directory'],'tmp_backup_6071.log'), 'w')
# fn_bkp_err=open( os.path.join(context['temp_directory'],'tmp_backup_6071.err'), 'w')
#
#
#
#
# subprocess.call([ context['gbak_path']
# ,"-b"
# ,"-v"
@ -166,14 +166,14 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# ,tmpbkp
# ],
# stdout=fn_bkp_log, stderr=fn_bkp_err)
#
#
# flush_and_close( fn_bkp_log )
# flush_and_close( fn_bkp_err )
#
#
#
#
# fn_res_log=open( os.path.join(context['temp_directory'],'tmp_restore_6071.log'), 'w')
# fn_res_err=open( os.path.join(context['temp_directory'],'tmp_restore_6071.err'), 'w')
#
#
# # C:\\FB SS\\gbak.exe -rep -KEYHOLDER KeyHolder C:\\FBTESTING\\qa\\misc\\C6071.fbk /:C:\\FBTESTING\\qa\\misc\\c6071.restored.FDB
# subprocess.call([ context['gbak_path']
# ,"-rep"
@ -183,48 +183,48 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# ,'localhost:' + tmpfdb
# ],
# stdout=fn_res_log, stderr=fn_res_err)
#
#
# flush_and_close( fn_res_log )
# flush_and_close( fn_res_err )
#
#
# #-------------------------- validate just restored database --------------------
#
#
# f_valid_log = open( os.path.join(context['temp_directory'],'tmp_valid_6071.log'), 'w')
# subprocess.call( [ context['gfix_path'], 'localhost:'+tmpfdb, "-v", "-full" ],
# stdout = f_valid_log,
# stderr = subprocess.STDOUT
# )
# flush_and_close( f_valid_log )
#
#
# #-----------------------------------------------
#
#
# # Check that all was fine:
#
#
# with open(f_gfix_log.name,'r') as f:
# for line in f:
# print('UNEXPECTED GFIX OUTPUT: ' + line)
#
#
# with open(fn_bkp_err.name,'r') as f:
# for line in f:
# print('UNEXPECTED BACKUP STDERR: ' + line)
#
#
# with open(fn_res_err.name,'r') as f:
# for line in f:
# print('UNEXPECTED RESTORE STDERR: ' + line)
#
#
# with open(f_gfix_log.name,'r') as f:
# for line in f:
# print('UNEXPECTED VALIDATION OUTPUT: ' + line)
#
#
# # gbak -b should finish with line:
# # gbak:closing file, committing, and finishing. 512 bytes written
# with open(fn_bkp_log.name,'r') as f:
# for line in f:
# if gbak_backup_finish_ptn.search(line):
# print('EXPECTED BACKUP FINISH FOUND: '+line.upper() )
#
#
# #gbak_backup_finish_ptn=re.compile('gbak:closing\\s+file,\\s+committing,\\s+and\\s+finishing.*', re.IGNORECASE)
#
#
# # gbak -c should finish with lines:
# # gbak:finishing, closing, and going home
# # gbak:adjusting the ONLINE and FORCED WRITES flags
@ -233,16 +233,17 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# for line in f:
# if gbak_restore_finish_ptn.search(line):
# print('EXPECTED RESTORE FINISH FOUND: '+line.upper() )
#
#
#
#
# # cleanup
# ##########
# time.sleep(1)
# cleanup( ( f_gfix_log, fn_bkp_log, fn_bkp_err, fn_res_log, fn_res_err, f_valid_log, tmpfdb, tmpbkp ) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
EXPECTED BACKUP FINISH FOUND: GBAK:CLOSING FILE, COMMITTING, AND FINISHING.
@ -251,8 +252,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
pytest.skip("Requires encryption plugin")

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_6097
# title: Connection does not see itself in the MON$ATTACHMENTS when Domain/Username (using SSPI) is 31 bytes long
# decription:
# decription:
# Could not reproduce bug on WI-V3.0.4.33054, discussed this with dimitr and alex.
# Problem can appear randomly when some byte in memory contains value not equal to 0x0.
# It was decided to implement test that
@ -19,15 +19,15 @@
# 4.0.0.1564: OK, 3.910s.
# 4.0.0.1535: OK, 4.052s.
# 3.0.5.33160: OK, 1.971s.
# 3.0.5.33152: OK, 3.860s.
#
# 3.0.5.33152: OK, 3.860s.
#
# tracker_id: CORE-6097
# min_versions: ['3.0.5']
# versions: 3.0.5
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.5
# resources: None
@ -40,19 +40,19 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import subprocess
# import time
# import fdb
# from fdb import services
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
# db_conn.close()
#
#
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
#
#
# sql_txt='''
# -- fb_home = %s
# set bail on;
@ -64,68 +64,69 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# select sec$user_name, octet_length(trim(sec$user_name)) as octets_in_name from sec$users where sec$user_name = 'Ковалевский_Олег';
# commit;
# ''' % (fb_home,)
#
#
# f_init_sql=open( os.path.join(context['temp_directory'],'tmp_6097_prepare.sql'), 'w')
# f_init_sql.write( sql_txt )
# f_init_sql.close()
#
#
# f_init_log=open( os.path.join(context['temp_directory'],'tmp_6097_prepare.log'), 'w')
#
#
# subprocess.call([ fb_home+"isql", dsn, "-q", "-ch", "utf8", "-i", f_init_sql.name], stdout=f_init_log, stderr=subprocess.STDOUT)
# f_init_log.close()
#
# # does not work, raises 'invalid user/password':
#
# # does not work, raises 'invalid user/password':
# #runProgram( fb_home+'isql', [dsn, "-q", "-user", "Ковалевский_Олег", "-pas", "123" ], 'set list on; set count on; select * from mon$attachments where mon$attachment_id = current_connection;')
#
#
# f_check_sql=open( os.path.join(context['temp_directory'],'tmp_6097_check.sql'), 'w')
# #f_check_sql.write( 'set list on; select count(*) as "Can_i_see_myself ?" from mon$attachments where mon$attachment_id = current_connection;' )
# f_check_sql.write( 'set count on; set list on; select mon$user as who_am_i, left(mon$remote_protocol,3) as mon_protocol, mon$auth_method as mon_auth_method from mon$attachments where mon$attachment_id = current_connection;' )
# f_check_sql.close()
#
#
# f_bat_text='''
# @echo off
# chcp 65001 1>nul
# %s %s -user "Ковалевский_Олег" -pas 123 -ch utf8 -q -i %s
# ''' % ( fb_home+'isql.exe', dsn, f_check_sql.name )
# #''' % ( fb_home+'isql.exe', 'localhost:employee', f_check_sql.name )
#
#
# f_check_bat=open( os.path.join(context['temp_directory'],'tmp_6097_check.bat'), 'w')
# f_check_bat.write( f_bat_text )
# f_check_bat.close()
#
#
# f_check_log=open( os.path.join(context['temp_directory'],'tmp_6097_check.log'), 'w')
# # does not work, raises 'invalid user/password': subprocess.call(["isql", dsn, "-q", "-user", "Ковалевский_Олег", "-pas", "123", "-ch", "utf8", "-i", f_check_sql.name], stdout=f_run_log, stderr=subprocess.STDOUT)
# subprocess.call([f_check_bat.name], stdout=f_check_log, stderr=subprocess.STDOUT)
# f_check_log.close()
#
#
# # Let redirected output of isql be flushed on disk:
# time.sleep(1)
#
#
# with open( f_init_log.name,'r') as f:
# for line in f:
# print(line)
#
#
# with open( f_check_log.name,'r') as f:
# for line in f:
# print(line)
#
#
# # Cleanup.
# ##########
#
#
# f_list = (f_init_sql, f_init_log, f_check_sql, f_check_bat, f_check_log)
# 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)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
SEC$USER_NAME Ковалевский_Олег
OCTETS_IN_NAME 31
Records affected: 1
WHO_AM_I Ковалевский_Олег
MON_PROTOCOL TCP
MON_AUTH_METHOD Srp

View File

@ -2,34 +2,34 @@
#
# id: bugs.core_6142
# title: Error "connection lost to database" could happen when application creates few local attachments (using XNET) simultaneously
# decription:
# decription:
# Test uses 15 threads and each of them launches loop for 10 iterations with making attach/detach from DB.
# We use Python package with name "threading" here, but it should be declared as global inside class because of fbtest specific
# (otherwise test will failed with message "global name 'threading' is not defined").
# No such declaration is needed in normal way (i.e. when running code directly from Python, w/o using fbtest).
# Each instance of worker thread has dict() for storing its ID (as a key) and pair of values (success and fail count) as value.
#
#
# We have to ensure at the final point that for every of <THREADS_CNT> threads:
# * 1) number of SUCCESSFUL attempts is equal to limit that is declared here as LOOP_CNT.
# * 1) number of SUCCESSFUL attempts is equal to limit that is declared here as LOOP_CNT.
# * 2) number of FAILED attempts is ZERO.
#
# Confirmed bug on 4.0.0.1598, 3.0.5.33166 (checked both SS and CS).
#
# Confirmed bug on 4.0.0.1598, 3.0.5.33166 (checked both SS and CS).
# It was enough 3 threads (which tried to establish attachments at the same time) to get runtime error:
# "- SQLCODE: -901 / - connection lost to database".
#
# Checked on 4.0.0.1607, 3.0.5.33171.
# :: NB ::
#
# Checked on 4.0.0.1607, 3.0.5.33171.
# :: NB ::
# Execution time for this test strongly depends on major version and server mode:
# 4.0 Classic: ~9"; 3.0.5 Classic: ~5";
# 4.0 Super: ~5"; 3.0.5 Super: ~1".
#
#
# tracker_id: CORE-6142
# min_versions: ['3.0.5']
# versions: 3.0.5
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.5
# resources: None
@ -46,24 +46,24 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import threading
# import datetime as py_dt
# import time
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# db_conn.close()
#
#
# DB_PROT = 'xnet://'
# DB_NAME = os.path.join(context['temp_directory'],'bugs.core_6142.fdb')
# DB_USER = user_name
# DB_PSWD = user_password
#
#
# LOOP_CNT=10
# THREADS_CNT=15
#
#
# def showtime():
# global py_dt
# return ''.join( (py_dt.datetime.now().strftime("%H:%M:%S.%f")[:11],'.') )
#
#
# class workerThread(threading.Thread):
# global threading, showtime, make_db_attach
# def __init__(self, threadID, name, num_of_iterations):
@ -74,77 +74,78 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# self.results_dict = { threadID : [0,0] }
# def run(self):
# print( showtime(), "Starting " + self.name )
#
#
# make_db_attach( self.threadID, self.name, self.num_of_iterations, self.results_dict )
#
#
# print( showtime(), "Exiting " + self.name)
#
#
# def show_results(self):
# for k,v in sorted( self.results_dict.items() ):
# print( "ID of thread: %3d. OVERALL RESULT: PASSED=%d, FAILED=%d" % ( k, v[0], v[1] ) )
#
#
# def make_db_attach( threadID, threadName, num_of_iterations, results_dict ):
# global DB_PROT, DB_NAME, DB_USER, DB_PSWD, FB_CLNT
# global showtime
# i = 1
# while i<= num_of_iterations:
#
#
# con = None
# att = 0
# #print( showtime(), "%(threadName)s, iter %(i)s" % locals(), " - trying to: fdb.connect( dsn = '%(DB_PROT)s%(DB_NAME)s', user = '%(DB_USER)s', password = %(DB_PSWD)s, fb_library_name = '%(FB_CLNT)s' ) \\n" % globals() )
# print( showtime(), "%(threadName)s, iter %(i)s" % locals(), " - trying to: fdb.connect( dsn = '%(DB_PROT)s%(DB_NAME)s' )\\n" % globals() )
#
#
# try:
# #con = fdb.connect( dsn = DB_PROT + DB_NAME, user = DB_USER, password = DB_PSWD, fb_library_name = FB_CLNT )
# con = fdb.connect( dsn = DB_PROT + DB_NAME, user = DB_USER, password = DB_PSWD )
# att = con.attachment_id
# fbv = con.firebird_version
# print( showtime(), "%(threadName)s, iter %(i)s: attach_id=%(att)s has been created FB version: %(fbv)s.\\n" % locals() )
#
#
# if False:
# cur = con.cursor()
# cur.execute('select count(*) from ( select 1 x from rdb$types a,rdb$types b,(select 1 i from rdb$types rows ( 30+rand()*30 ) ) )' )
# for r in cur:
# pass
# cur.close()
#
#
# print( showtime(), "%(threadName)s, iter %(i)s: attach_id=%(att)s is to be closed.\\n" % locals() )
# con.close()
# print( showtime(), "%(threadName)s, iter %(i)s: attach_id=%(att)s has been closed.\\n" % locals() )
# results_dict[ threadID ][0] += 1
#
#
# except Exception,e:
# results_dict[ threadID ][1] += 1
# for k,x in enumerate(e):
# print( showtime(), "%(threadName)s, iter %(i)s: exception occured:\\n%(x)s\\n" % locals() )
#
#
# i += 1
#
#
#
#
# # Create new threads:
# # ###################
# threads_list=[]
# for i in range(0, THREADS_CNT):
# threads_list.append( workerThread( i+1, "Thread-%d" % (i+1), LOOP_CNT) )
#
#
# # Start new Threads
# # #################
# for t in threads_list:
# t.start()
#
#
#
#
# # Wait for all threads to complete
# for t in threads_list:
# t.join()
#
#
# for t in threads_list:
# t.show_results()
#
#
# print( showtime(), "##### Exiting Main Thread #####\\n")
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
ID of thread: 1. OVERALL RESULT: PASSED=10, FAILED=0
@ -167,7 +168,5 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0.5')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -43,7 +43,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -76,7 +76,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.db.set_async_write()
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -58,7 +58,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -2,22 +2,22 @@
#
# id: bugs.core_6264
# title: gbak with PIPE to stdout: invalid content if user '-se <host>:service_mgr' command switch
# decription:
# decription:
# NB: bug can be reproduced only if we create batch file and run it from Python using shell invocation,
# i.e. via subprocess.call(). Python builtin PIPE mechanism does not show any errors.
# For this reason, we create temp batch scenario, add necessary commands there and run it.
# Currently this scenario exists only for Windows. It will be implemented for POSIX later.
#
#
# Confirmed bug on 3.0.6.33276, 4.0.0.1850.
# Works fine on 3.0.6.33277, 4.0.0.1854
#
#
# tracker_id: CORE-6264
# min_versions: ['3.0.6']
# versions: 3.0.6
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.6
# resources: None
@ -36,32 +36,32 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import subprocess
# from subprocess import PIPE
# from fdb import services
#
#
# #--------------------------------------------
#
#
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
# if os.path.isfile( f_names_list[i]):
# os.remove( f_names_list[i] )
#
#
# #--------------------------------------------
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
# this_db = db_conn.database_name
# db_conn.close()
#
#
# tmp4restore=os.path.join(context['temp_directory'],'tmp_6264_check_restore.tmp')
#
#
# cleanup( (tmp4restore,) )
#
#
#
#
# # BACKUP-RESTORE:
# # C:\\FB SS\\gbak.exe -b -se localhost:service_mgr employee stdout | C:\\FB SS\\gbak -c stdin C: emp\\employee.check-restore.tmp
#
# # C:\\FB SS\\gbak.exe -b -se localhost:service_mgr employee stdout | C:\\FB SS\\gbak -c stdin C: emp\\employee.check-restore.tmp
#
# fb_gbak = fb_home+'gbak'
# fb_gfix = fb_home+'gfix'
# txt = '''
@ -80,14 +80,14 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# %(fb_gfix)s -shut full -force 0 localhost:%(tmp4restore)s
# del %(tmp4restore)s
# )
#
#
# )
# ''' % dict(globals(), **locals())
#
#
# f_tmp_bat=open( os.path.join(context['temp_directory'],'tmp_run_6264.bat'), 'w', buffering = 0)
# f_tmp_bat.write(txt)
# f_tmp_bat.close()
#
#
# #####################
# # DOES NOT WORK HERE:
# #####################
@ -99,39 +99,40 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# #print('p_getter_stdout:', p_getter_stdout) -- returns EMPTY string
# #print('p_getter_stderr:', p_getter_stderr) -- returns None.
# ######################
#
#
# f_bat_log=open( os.path.join(context['temp_directory'],'tmp_c6264.log'), "w", buffering = 0)
# f_bat_err=open( os.path.join(context['temp_directory'],'tmp_c6264.err'), "w", buffering = 0)
#
#
# subprocess.call( [ f_tmp_bat.name ], stdout=f_bat_log, stderr=f_bat_err)
#
#
# f_bat_log.close()
# f_bat_err.close()
#
#
# # Both STDOUT and STDERR results must be empty, which means no errors:
# ########################
# with open(f_bat_log.name, 'r') as f:
# for line in f:
# if line.split():
# print( ''.join( ( 'UNEXPECTED STDOUT: ', line.strip() ) ) )
#
#
# with open(f_bat_err.name, 'r') as f:
# for line in f:
# if line.split():
# print( ''.join( ( 'UNEXPECTED STDERR: ', line.strip() ) ) )
#
#
# cleanup( [ i.name for i in ( f_tmp_bat,f_bat_log,f_bat_err ) ] + [tmp4restore,] )
#
#
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
@pytest.mark.version('>=3.0.6')
@pytest.mark.platform('Windows')
#@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -50,7 +50,6 @@ expected_stdout_1 = """
@pytest.mark.version('>=4.0')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -2,19 +2,19 @@
#
# id: bugs.core_6329
# title: GBAK with service_mgr and WinSSPI authentication for Windows SYSTEM user producing error in clumplet API
# decription:
# Confirmed bug on 4.0.0.2035 SS: got
# decription:
# Confirmed bug on 4.0.0.2035 SS: got
# "gbak: ERROR:Internal error when using clumplet API: attempt to store 866 bytes in a clumplet with maximum size 255 bytes"
#
#
# Checked on 4.0.0.2066 SS/CS, 3.0.6.33212 SS/CS.
#
#
# tracker_id: CORE-6329
# min_versions: ['3.0.6']
# versions: 3.0.6
# qmid:
# qmid:
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.6
# resources: None
@ -27,7 +27,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import sys
# import os
# import re
@ -36,20 +36,20 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# from fdb import services
# import socket
# import getpass
#
#
# THIS_DBA_USER=user_name
# THIS_DBA_PSWD=user_password
#
#
# THIS_COMPUTER_NAME = socket.gethostname()
# CURRENT_WIN_ADMIN = getpass.getuser()
#
#
# ##########################################
# THIS_FDB = db_conn.database_name
# THIS_FBK=os.path.join(context['temp_directory'],'tmp_6329.fbk')
# ##########################################
#
#
# #--------------------------------------------
#
#
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
@ -57,67 +57,67 @@ 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])
#
#
# #--------------------------------------------
#
#
#
#
# fb_home = services.connect(host='localhost', user= THIS_DBA_USER, password= THIS_DBA_PSWD).get_home_directory()
#
#
# f_sql_make_map = open( os.path.join(context['temp_directory'],'tmp_6329.sql'), 'w', buffering=0)
# f_sql_txt='''
# set bail on;
# connect 'localhost:%(THIS_FDB)s' user %(THIS_DBA_USER)s password '%(THIS_DBA_PSWD)s';
#
#
# create or alter global mapping win_system using plugin win_sspi from user "%(THIS_COMPUTER_NAME)s\\%(CURRENT_WIN_ADMIN)s" to user %(THIS_DBA_USER)s;
# commit;
# ''' % locals()
#
#
# f_sql_make_map.write(f_sql_txt)
# f_sql_make_map.close()
#
#
# # do NOT remove this delay otherwise can get 'Windows error 2: file not found'.
# time.sleep(1)
#
#
# f_prepare_log=open( os.path.join(context['temp_directory'],'tmp_6329_prepare.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "isql", "-q", "-i", f_sql_make_map.name ], stdout=f_prepare_log, stderr=subprocess.STDOUT )
# f_prepare_log.close()
#
#
# f_backup_log=open( os.path.join(context['temp_directory'],'tmp_6329_backup.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "gbak", "-v", "-b", "-se", "localhost:service_mgr", THIS_FDB, THIS_FBK], stdout=f_backup_log, stderr=subprocess.STDOUT )
# f_backup_log.close()
#
#
#
#
# # Remove global mapping:
# ########################
#
#
# f_sql_drop_map = open( os.path.join(context['temp_directory'],'tmp_6329_cleanup.sql'), 'w', buffering=0)
# f_sql_txt='''
# set bail on;
# connect 'localhost:%(THIS_FDB)s' user %(THIS_DBA_USER)s password '%(THIS_DBA_PSWD)s';
#
#
# drop global mapping win_system;
# commit;
# ''' % locals()
# f_sql_drop_map.write(f_sql_txt)
# f_sql_drop_map.close()
#
#
# f_cleanup_log = open( os.path.join(context['temp_directory'],'tmp_6329_cleanup.log'), 'w', buffering=0)
# subprocess.call( [ fb_home + "isql", "-q", "-i", f_sql_drop_map.name ], stdout=f_cleanup_log, stderr=subprocess.STDOUT )
# f_cleanup_log.close()
#
#
# # Checks:
# #########
#
#
# with open( f_prepare_log.name,'r') as f:
# for line in f:
# if line.split():
# print('UNEXPECTED OUTPUT in '+f_prepare_log.name+': '+line)
#
#
#
#
# allowed_patterns = (
# re.compile('gbak:.*closing.*commit.*finish',re.IGNORECASE),
# )
#
#
# with open( f_backup_log.name,'r') as f:
# for line in f:
# if 'ERROR' in line:
@ -126,28 +126,29 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# match2some = filter( None, [ p.search(line) for p in allowed_patterns ] )
# if match2some:
# print('EXPECTED output found in the backup log')
#
#
# with open( f_cleanup_log.name,'r') as f:
# for line in f:
# if line.split():
# print('UNEXPECTED OUTPUT in '+f_cleanup_log.name+': '+line)
#
#
# # Cleanup:
# ##########
#
# # do NOT remove this pause otherwise some of logs will not be enable for deletion and test will finish with
#
# # do NOT remove this pause otherwise some of logs will not be enable for deletion and test will finish with
# # Exception raised while executing Python test script. exception: WindowsError: 32
# time.sleep(1)
#
#
# f_list=( f_sql_make_map, f_sql_drop_map, f_prepare_log, f_backup_log, f_cleanup_log )
# cleanup( [ i.name for i in f_list ] )
#
#
# os.remove(THIS_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 = """
EXPECTED output found in the backup log
@ -156,7 +157,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0.6')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

File diff suppressed because it is too large Load Diff

View File

@ -586,7 +586,6 @@ RESULT 'q '
@pytest.mark.version('>=3.0.6')
def test_1(act_1: Action):
act_1.charset = 'NONE'
act_1.expected_stdout = expected_stdout_1
act_1.execute()
assert act_1.clean_expected_stdout == act_1.clean_stdout

View File

@ -2,51 +2,51 @@
#
# id: bugs.core_6348
# title: Wire compression causes freezes
# decription:
# decription:
# Test does TWO measures related to speed of loading big blob into database:
# 1) when WireCompression = true
# 2) when WireCompression = false
# (see below usage of 'WIRE_COMPRESSION_VALUE' variable)
# Then we compare elapsed time (stored in milliseconds) between these two measures.
#
#
# Time of loading when WireCompression = true will be greater than time for WireCompression = false.
# RATIO (i.e. <wc_ON> / <wc_OFF>) instead of absolute values is used as criteria for passing this test.
# This ratio must not exceed threshold that was defined beforehand
# I ran this test five times for each server mode, for FB 3.x and 4.x, both on Windows and Linux.
#
#
# Results depend primarily on OS: about 3.05 for Windows and 1.48 for Linux.
# This difference looks strange and may be it is a good idea to discussed this with FB developers.
# CURRENTLY threshold is set to approx. double value of maximal detected ratio (see 'MAX_RATIO_THRESHOLD').
#
#
# NOTE-1
# Test temporary changes firebird.conf, so any abnormal termination of it can cause
# problems for other tests (which are to be executed after current).
#
#
# NOTE-2
# EXTERNAL script for execution by Python is created here!
# Otherwise one can not reproduce problem described in the ticket if original firebird.conf
# We have to launch NEW (child) Python process which will run fully separately from current.
#
#
# NOTE-3
# Test uses pre-created large binary file which can not be compressed: it is compressed trace log
# with original size about 2.2 Gb which was processed by 7-Zip with '-mx9 -mfb273' switches.
#
#
# Confirmed bug on 4.0.0.1994: blob loading time is more than 120s.
# Checked on 4.0.0.2089.
#
#
#
#
# 15.04.2021. Adapted for run both on Windows and Linux. Checked on:
# Windows: 3.0.8.33445 SS/CS, 4.0.0.2422 SS/CS
# Linux: 3.0.8.33445 SS/CS, 4.0.0.2422 SS/CS
#
#
#
#
# tracker_id: CORE-6348
# min_versions: ['3.0.6']
# versions: 3.0.6
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.6
# resources: None
@ -69,39 +69,39 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# from fdb import services
# from datetime import datetime as dt
# from datetime import timedelta
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# #############################
# ### T H R E S H O L D ###
# #############################
# MAX_SECONDS_FOR_LOAD = 15
#
#
# db_conn.close()
#
#
# #-----------------------------------
# def showtime():
# global dt
# return ''.join( (dt.now().strftime("%H:%M:%S.%f")[:11],'.') )
#
#
# #--------------------------------------------
#
#
# 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 )):
@ -113,38 +113,38 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# print('Unrecognized type of element:', f_names_list[i], ' - can not be treated as file.')
# print('type(f_names_list[i])=',type(f_names_list[i]))
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
#
#
# FB_HOME = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
# # Resut: FB_HOME is full path to FB instance home (with trailing slash).
#
#
# if os.name == 'nt':
# # For Windows we assume that client library is always in FB_HOME dir:
# FB_CLNT=os.path.join(FB_HOME, 'fbclient.dll')
# else:
# # For Linux client library will be searched in 'lib' subdirectory of FB_HOME:
# FB_CLNT=os.path.join(FB_HOME, 'lib', 'libfbclient.so' )
#
#
#
#
# dts = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
#
#
# fbconf_cur = os.path.join( FB_HOME, 'firebird.conf')
# fbconf_bak = os.path.join( FB_HOME, 'firebird'+dts+'.bak')
#
#
# shutil.copy2( fbconf_cur, fbconf_bak )
#
#
# blob_load_elapsed_time = {}
#
#
# for iter in (1,2):
# # Restore original content of firebird.conf:
# ##################
# shutil.copy2( fbconf_bak, fbconf_cur )
#
#
# f_fbconf=open( fbconf_cur, 'r')
# fbconf_content=f_fbconf.readlines()
# f_fbconf.close()
@ -152,25 +152,25 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# line = s.lower().lstrip()
# if line.startswith( 'wirecompression'.lower() ):
# fbconf_content[i] = '# [temply commented by fbtest for core_6348.fbt] ' + s
#
#
#
#
# WIRE_COMPRESSION_VALUE = 'true' if iter == 1 else 'false'
#
#
# text2app= '''
# ### TEMPORARY CHANGED FOR CORE_6348.FBT ###
# WireCompression = %(WIRE_COMPRESSION_VALUE)s
# ##############################################
# ''' % locals()
#
#
# fbconf_content += [ os.linesep + x for x in text2app.split( os.linesep ) ]
#
#
# f_fbconf=open( fbconf_cur, 'w', buffering = 0)
# f_fbconf.writelines( fbconf_content )
# flush_and_close( f_fbconf )
#
#
#
#
# BLOB_FILE = os.path.join(context['files_location'],'core_6348.bin')
#
#
# external_python_code=''' from __future__ import print_function
# from datetime import datetime as dt
# from datetime import timedelta
@ -178,52 +178,52 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# con = fdb.connect( dsn = r'%(dsn)s', user='%(user_name)s', password='%(user_password)s', fb_library_name = r'%(FB_CLNT)s' )
# con.execute_immediate('recreate table test(b blob)')
# con.commit()
#
#
# cur=con.cursor()
# blob_src = r'%(BLOB_FILE)s'
# blob_handle = open( blob_src, 'rb')
#
#
# da = dt.now()
# cur.execute('insert into test(b) values(?)',[blob_handle])
# db = dt.now()
#
#
# blob_handle.close()
# diff_ms = (db-da).seconds*1000 + (db-da).microseconds//1000
# print( str(diff_ms) )
#
#
# cur.close()
# con.commit()
# con.close()
# ''' % dict(globals(), **locals())
#
#
# f_extern_py = open( os.path.join(context['temp_directory'],'tmp_6348.' + str(iter) + '.py'), 'w')
# f_extern_py.write( '\\n'.join( [i.strip() for i in external_python_code.split('\\n')] ) )
# flush_and_close( f_extern_py )
# # f_extern_py.close()
#
#
# f_external_py_log = open( os.path.join(context['temp_directory'],'tmp_6348_py.' + str(iter) + '.log' ), 'w')
# subprocess.call( [sys.executable, f_extern_py.name], stdout = f_external_py_log, stderr = subprocess.STDOUT )
# flush_and_close( f_external_py_log )
#
#
# with open(f_external_py_log.name,'r') as f:
# blob_load_elapsed_time[ WIRE_COMPRESSION_VALUE ] = int(f.read().strip())
# cleanup( ( f_extern_py, f_external_py_log ) )
#
#
# # Restore original content of firebird.conf:
# ##################
# shutil.move( fbconf_bak, fbconf_cur )
#
#
# #print(blob_load_elapsed_time)
# #print( 1.00 * blob_load_elapsed_time['true'] / blob_load_elapsed_time['false'] )
#
#
# # 4.0.0.1994 SC: {'false': 2036, 'true': 126711}, ratio: 62.24
# # 4.0.0.2422 SS: {'false': 831, 'true': 3722}, ratio: 4.48 // LINUX: 3.42; 3.11; 3.49; 3.44; 3.45
# # 4.0.0.2422 CS: {'false': 2088, 'true': 6903}, ratio: 3.31 // LINUX: 1.46; 1.46; 1.48; 1.46; 1.51
# # 3.0.8.33445 SS: {'false': 1135, 'true': 3862}, ratio: 3.40 // LINUX: 1.52; 1.63; 1.52; 1.48; 1.51
# # 3.0.8.33445 CS: {'false': 2160, 'true': 7675}, ratio: 3.55 // LINUX: 1.56; 1.61; 1.56; 1.55; 1.54
#
#
# ratio = 1.00 * blob_load_elapsed_time['true'] / blob_load_elapsed_time['false']
#
#
# if os.name == 'nt':
# MAX_RATIO_THRESHOLD = 7
# else:
@ -234,31 +234,31 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# # ##################
# # ### THRESHOLD ####
# # ##################
#
# msg = 'Ratio is acceptable.' if ratio < MAX_RATIO_THRESHOLD else (
#
# msg = 'Ratio is acceptable.' if ratio < MAX_RATIO_THRESHOLD else (
# 'Performance degradation when WireCompression = true is too high. ' +
# 'Without compression: %15.2f, with compression: %15.2f, ratio is %15.2f - more than max. threshold = %3d' % ( blob_load_elapsed_time['false'], blob_load_elapsed_time['true'], ratio, MAX_RATIO_THRESHOLD)
# 'Without compression: %15.2f, with compression: %15.2f, ratio is %15.2f - more than max. threshold = %3d' % ( blob_load_elapsed_time['false'], blob_load_elapsed_time['true'], ratio, MAX_RATIO_THRESHOLD)
# )
#
#
# print(msg)
#
#
# # Cleanup
# #########
# time.sleep(1)
# f_list=( f_extern_py, f_external_py_log )
# cleanup( [ i.name for i in f_list ] )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
Ratio is acceptable.
"""
"""
@pytest.mark.version('>=3.0.6')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
pytest.skip("Requires changes to firebird.conf")

View File

@ -2,27 +2,27 @@
#
# id: bugs.core_6362
# title: Better diagnostic when 'Missing security context'
# decription:
# decription:
# ::: NB :::
# List of AuthClient plugins must contain Win_Sspi in order to reproduce this test expected results.
# Otherwise firebird.log will not contain any message like "Available context(s): ..."
#
#
# Checked on 3.0.7.33348, 4.0.0.2119 (SS/CS): OK.
#
#
# 01-mar-2021: attribute 'platform' was restricted to 'Windows'.
# 05-mar-2021: list of plugins specified in AuthServer *also* must contain Win_Sspi.
#
#
# 11-mar-2021. As of FB 3.x, messages appears in the firebird.log more than one time.
# Because of this, we are interested only for at least one occurence of each message
# rather than for each of them (see 'found_patterns', type: set()).
#
#
# tracker_id: CORE-6362
# min_versions: ['3.0.7']
# versions: 3.0.7
# qmid:
# qmid:
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.7
# resources: None
@ -35,35 +35,35 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import subprocess
# import re
# import difflib
# from fdb import services
# import time
#
#
# os.unsetenv("ISC_USER")
# os.unsetenv("ISC_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()
# 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 f in f_names_list:
@ -74,14 +74,14 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# def svc_get_fb_log( f_fb_log ):
#
#
# global subprocess
# subprocess.call( [ context['fbsvcmgr_path'],
# "localhost:service_mgr",
@ -92,79 +92,80 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# stdout=f_fb_log, stderr=subprocess.STDOUT
# )
# return
#
#
# #--------------------------------------------
#
#
# # Get FB log *before* unsuccessful attempt to obtain server version:
# #####################
#
#
# f_fblog_before=open( os.path.join(context['temp_directory'],'tmp_6362_fblog_before.txt'), 'w')
# svc_get_fb_log( f_fblog_before )
# flush_and_close( f_fblog_before )
#
#
# f_svc_log=open( os.path.join(context['temp_directory'],'tmp_6362_info_server.log'), 'w')
# f_svc_err=open( os.path.join(context['temp_directory'],'tmp_6362_info_server.err'), 'w')
#
#
# # This must FAIL because we do not specify user/password pair and there absent in OS env.:
# ################
# subprocess.call( [context['fbsvcmgr_path'], 'localhost:service_mgr', 'info_server_version'], stdout=f_svc_log, stderr=f_svc_err )
# flush_and_close( f_svc_log )
# flush_and_close( f_svc_err )
#
#
# # Get FB log *after* unsuccessful attempt to obtain server version:
# ####################
# f_fblog_after=open( os.path.join(context['temp_directory'],'tmp_6362_fblog_after.txt'), 'w')
# svc_get_fb_log( f_fblog_after )
# flush_and_close( f_fblog_after )
#
#
# old_fb_log=open(f_fblog_before.name, 'r')
# new_fb_log=open(f_fblog_after.name, 'r')
#
#
# fb_log_diff = ''.join(difflib.unified_diff(
# old_fb_log.readlines(),
# old_fb_log.readlines(),
# new_fb_log.readlines()
# ))
# old_fb_log.close()
# new_fb_log.close()
#
#
# f_diff=open( os.path.join(context['temp_directory'],'tmp_6362_fblog_diff.txt'), 'w')
# f_diff.write(fb_log_diff)
# flush_and_close( f_diff )
#
#
# # Missing security context required for C:\\FB SS\\SECURITY4.FDB
# # Available context(s): USER IMAGE-PC1\\PASHAZ plugin Win_Sspi
#
#
# allowed_patterns = (
# re.compile('Missing\\s+security\\s+context\\.*', re.IGNORECASE)
# ,re.compile('Available context\\.*', re.IGNORECASE)
# )
# found_patterns = set()
#
#
# print('Error message on attempt to get server version w/o user/password and ISC_USER/ISC_PASSWORD:')
# with open( f_svc_err.name,'r') as f:
# for line in f:
# print(line)
#
#
# with open( f_diff.name,'r') as f:
# for line in f:
# if line.startswith('+'):
# for p in allowed_patterns:
# if p.search(line):
# found_patterns.add( p.pattern )
#
#
# print('Found patterns in firebird.log diff file:')
# for p in sorted(found_patterns):
# print(p)
#
#
#
#
# # Cleanup.
# ##########
# time.sleep(1)
# cleanup( (f_svc_log, f_svc_err, f_fblog_before, f_fblog_after, f_diff) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
Error message on attempt to get server version w/o user/password and ISC_USER/ISC_PASSWORD:
@ -178,7 +179,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0.7')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -2,21 +2,23 @@
#
# id: bugs.core_6377
# title: Unable to restore database with tables using GENERATED ALWAYS AS IDENTITY columns (ERROR:OVERRIDING SYSTEM VALUE should be used)
# decription:
# decription:
# Confirmed on 4.0.0.2126, got in STDERR when restore:
# gbak: ERROR:OVERRIDING SYSTEM VALUE should be used to override the value of an identity column defined as 'GENERATED ALWAYS' in table/view IDENTITY_ALWAYS
# gbak: ERROR:gds_$compile_request failed
# gbak:Exiting before completion due to errors
#
#
# Checked on 4.0.0.2170 SS/CS -- all fine.
#
# tracker_id:
#
# tracker_id:
# min_versions: ['4.0']
# versions: 4.0
# qmid:
# qmid:
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
# version: 4.0
# resources: None
@ -25,44 +27,44 @@ substitutions_1 = []
init_script_1 = """
create table identity_always(id bigint generated always as identity constraint pk_identity_always primary key);
insert into identity_always default values;
insert into identity_always default values;
commit;
"""
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import sys
# import subprocess
# from subprocess import PIPE
# from fdb import services
# import time
#
#
# 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()
# 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 f in f_names_list:
@ -73,48 +75,54 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# # https://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline
#
#
# tmp_restdb = os.path.join(context['temp_directory'],'tmp_6377_rest.fdb')
# cleanup( (tmp_restdb,) )
#
#
# f_br_err=open( os.path.join(context['temp_directory'],'tmp_6377_br.err'), 'w')
# p_sender = subprocess.Popen( [ context['gbak_path'], '-b', dsn, 'stdout' ], stdout=PIPE)
# p_getter = subprocess.Popen( [ context['gbak_path'], '-rep', 'stdin', 'localhost:' + tmp_restdb ], stdin = p_sender.stdout, stdout = PIPE, stderr = f_br_err)
# p_sender.stdout.close()
# p_getter_stdout, p_getter_stderr = p_getter.communicate()
#
#
# flush_and_close(f_br_err)
#
#
# # This must PASS without errors:
# runProgram('isql', [ 'localhost:' + tmp_restdb ], 'insert into identity_always default values;')
#
#
# # CHECK RESULTS
# ###############
# with open(f_br_err.name,'r') as g:
# for line in g:
# if line:
# print( 'UNEXPECTED STDERR IN ' + g.name + ':' + line)
#
#
# # Cleanup.
# ##########
# time.sleep(1)
# cleanup( (f_br_err,tmp_restdb ) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
fdb_file = temp_file('tmp_6377_rest.fdb')
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, fdb_file: Path):
backup = BytesIO()
with act_1.connect_server() as srv:
srv.database.local_backup(database=act_1.db.db_path, backup_stream=backup)
backup.seek(0)
srv.database.local_restore(backup_stream=backup, database=fdb_file)
# This should pass without error
act_1.isql(switches=[act_1.get_dsn(fdb_file)], connect_db=False,
input='insert into identity_always default values;')

View File

@ -2,12 +2,12 @@
#
# id: bugs.core_6379
# title: Bugcheck 179
# decription:
# decription:
# Could not reproduce with scenario described in the ticket.
# Test uses steps described by letter from me to Vlad, date: 15-JUL-2020 10:53 (subj: "read consistency tests").
# Scripts for initial test can be found here:
# https://drive.google.com/drive/folders/1CEOSVfOMHzlZ1F3Gi0Jv3TEbvWLs9DPR?usp=sharing
#
#
# Reproduced problem on 4.0.0.2108 SS:
# 1. Content of firebird.log:
# deadlock
@ -17,62 +17,86 @@
# 2. Client gets:
# Statement failed, SQLSTATE 08006
# Error reading data from the connection.
#
#
# Statement failed, SQLSTATE 08006
# Error writing data to the connection.
# -send_packet/send
#
#
# Checked on 4.0.0.2170 SS/CS - all fine.
#
# tracker_id:
#
# tracker_id:
# min_versions: ['4.0']
# versions: 4.0
# qmid:
# qmid:
import pytest
from firebird.qa import db_factory, isql_act, Action
import subprocess
import time
from pathlib import Path
from firebird.qa import db_factory, python_act, Action, temp_file
# version: 4.0
# resources: None
substitutions_1 = [('=', ''), ('[ \t]+', ' ')]
init_script_1 = """"""
init_script_1 = """
set echo on ;
set bail on ;
create table test(id int generated by default as identity, x int, s varchar(32765) ) ;
set term ^ ;
execute block as
declare n_limit int = 1000 ;
declare i int = 1 ;
begin
rdb$set_context('USER_SESSION', 'N_LIMIT', n_limit) ;
while (i <= n_limit) do
begin
insert into test (x, s) values (0, lpad('', 32700, uuid_to_char(gen_uuid()))) ;
i = i + 1 ;
end
end ^
set term ^ ;
commit ;
db_1 = db_factory(sql_dialect=3, init=init_script_1)
delete from test order by id rows (cast(rdb$get_context('USER_SESSION', 'N_LIMIT') as int) - 13) ;
commit ;
"""
db_1 = db_factory(sql_dialect=3) # We run init_script_1 manually
# test_script_1
#---
#
#
# import os
# import sys
# import subprocess
# from subprocess import Popen
# from fdb import services
# import time
#
#
# 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()
# 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 f in f_names_list:
@ -83,12 +107,12 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# sql_init='''
# create table test(id int generated by default as identity, x int, s varchar(32765) );
# set term ^;
@ -106,22 +130,22 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# ^
# set term ^;
# commit;
#
#
# delete from test order by id rows ( cast( rdb$get_context('USER_SESSION', 'N_LIMIT') as int) - 13 );
# commit;
# '''
# runProgram('isql', [ dsn, '-q' ], sql_init)
#
#
# con_lock_1 = fdb.connect( dsn = dsn )
# con_lock_2 = fdb.connect( dsn = dsn )
#
#
#
#
# #########################
# ### L O C K E R - 1 ###
# #########################
# con_lock_1.execute_immediate( 'update test set x = -1111 order by id rows 6 to 6' )
#
#
#
#
# # Scenario for WORKER:
# ######################
# sql_text='''
@ -130,82 +154,122 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# commit;
# set transaction read committed read consistency;
# set count on;
#
#
# set bail on;
# delete from test;
#
#
# set heading on;
# select rdb$db_key, id, x from test order by rdb$db_key;
# ''' % dict(globals(), **locals())
#
#
# f_worker_sql=open( os.path.join(context['temp_directory'],'tmp_6379.sql'), 'w')
# f_worker_sql.write(sql_text)
# flush_and_close(f_worker_sql)
#
#
# f_worker_log=open( ''.join( ( os.path.splitext(f_worker_sql.name)[0], '.log') ), 'w')
# f_worker_err=open( ''.join( ( os.path.splitext(f_worker_log.name)[0], '.err') ), 'w')
#
#
# ############################################################################
# ### L A U N C H W O R K E R U S I N G I S Q L, A S Y N C. ###
# ############################################################################
#
#
# p_worker = Popen( [ context['isql_path'], '-pag', '9999', '-q', '-i', f_worker_sql.name ],stdout=f_worker_log, stderr=f_worker_err)
# time.sleep(1)
#
#
# #########################
# ### L O C K E R - 2 ###
# #########################
# con_lock_2.execute_immediate( 'insert into test(x) values(3333)' )
# con_lock_2.commit()
#
#
#
#
# #########################
# ### L O C K E R - 1 ###
# #########################
# con_lock_1.commit()
# con_lock_2.commit()
#
#
# # Here we wait for ISQL complete its mission:
# p_worker.wait()
#
#
# flush_and_close(f_worker_log)
# flush_and_close(f_worker_err)
#
#
# # Close lockers:
# ################
# for c in (con_lock_1, con_lock_2):
# c.close()
#
#
#
#
# # CHECK RESULTS
# ###############
# with open(f_worker_log.name,'r') as f:
# for line in f:
# print(line)
#
#
# with open(f_worker_err.name,'r') as g:
# for line in g:
# if line:
# print( 'UNEXPECTED STDERR IN ' + g.name + ':' + line)
#
#
#
#
# # Cleanup.
# ##########
# time.sleep(1)
# cleanup( (f_worker_sql, f_worker_log, f_worker_err) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
Records affected: 14
Records affected: 0
"""
"""
worker_script = temp_file('core_6379.sql')
worker_output = temp_file('core_6379.out')
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, worker_script: Path, worker_output: Path):
act_1.db.set_async_write()
worker_script.write_text("""
set autoddl off;
commit;
set transaction read committed read consistency;
set count on;
set bail on;
delete from test;
set heading on;
select rdb$db_key, id, x from test order by rdb$db_key;
""")
# Run init_script
act_1.isql(switches=[], input=init_script_1)
#
with act_1.db.connect() as con_lock_1, act_1.db.connect() as con_lock_2:
# Locker 1
con_lock_1.execute_immediate('update test set x = -1111 order by id rows 6 to 6')
# Scenario for WORKER
with open(worker_output, mode='w') as worker_out:
p_worker_sql = subprocess.Popen([act_1.vars['isql'], '-pag', '9999', '-q',
'-i', str(worker_script),
'-user', act_1.db.user,
'-password', act_1.db.password, act_1.db.dsn],
stdout=worker_out, stderr=subprocess.STDOUT)
try:
time.sleep(2)
# Locker 2
con_lock_2.execute_immediate('insert into test (x) values (3333)')
con_lock_2.commit()
# Locker 1
con_lock_1.commit()
finally:
# Here we wait for ISQL complete its mission
p_worker_sql.wait()
# Check
act_1.expected_stdout = expected_stdout_1
act_1.stdout = worker_output.read_text()
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,31 +2,32 @@
#
# id: bugs.core_6382
# title: FK-trigger accessing a table prevents concurrent DDL command from dropping that table
# decription:
# decription:
# Test creates two tables which are linked by master-detail relationship.
# We add one record into the main table and then update it with issuing further COMMIT.
# After this we try to DROP this table in another connect.
#
#
# If this connect started WAIT transaction (i.e. without lock timeout) then it can hang forever if case of
# regression of this fix. Because of this, we change its waiting mode by adding lock_timeout parameter to
# regression of this fix. Because of this, we change its waiting mode by adding lock_timeout parameter to
# TPB and set it to 1 second.
#
#
# BEFORE fix this lead to:
# DatabaseError: / Error while commiting transaction: / - SQLCODE: -901
# - lock time-out on wait transaction / - unsuccessful metadata update
# - object TABLE "T_DETL" is in use / -901 / 335544510
#
#
# AFTER fix this DROP TABLE statement must pass without any error.
#
#
# Checked on 4.0.0.2141.
#
#
# tracker_id: CORE-6382
# min_versions: ['4.0']
# versions: 4.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 tpb, Isolation
# version: 4.0
# resources: None
@ -40,37 +41,37 @@ init_script_1 = """
commit;
insert into t_main values(123);
commit;
"""
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import fdb
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# db_conn.close()
#
#
# custom_tpb = fdb.TPB()
# custom_tpb.lock_resolution = fdb.isc_tpb_wait
#
#
# # NB: adding this timeout does NOT change WAIT-nature of transaction as it is considered by engine.
# # (in other words: such transaction will not became 'no wait' which must not be used in this test):
# custom_tpb.lock_timeout = 1
#
#
# con1 = fdb.connect( dsn = dsn, isolation_level = custom_tpb)
# con2 = fdb.connect( dsn = dsn, isolation_level = custom_tpb)
#
#
# con1.execute_immediate('update t_main set id=-id')
# con1.commit()
#
#
# con2.execute_immediate('drop table t_detl')
# con2.commit()
#
#
# cur=con2.cursor()
# cur.execute( "select r.rdb$relation_name from rdb$database d left join rdb$relations r on r.rdb$relation_name = upper('t_detl')" )
# for r in cur:
@ -78,20 +79,40 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# cur.close()
# con2.close()
# con1.close()
#
#
# print('Passed.')
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
None
Passed.
"""
"""
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, capsys):
# # NB: adding this timeout does NOT change WAIT-nature of transaction as it is considered by engine.
# # (in other words: such transaction will not became 'no wait' which must not be used in this test):
custom_tpb = tpb(isolation=Isolation.SNAPSHOT, lock_timeout=5)
#
with act_1.db.connect() as con1, act_1.db.connect() as con2:
con1.main_transaction.default_tpb = custom_tpb
con2.main_transaction.default_tpb = custom_tpb
#
con1.execute_immediate('update t_main set id=-id')
con1.commit()
con2.execute_immediate('drop table t_detl')
con2.commit()
cur = con2.cursor()
cur.execute("select r.rdb$relation_name from rdb$database d left join rdb$relations r on r.rdb$relation_name = upper('t_detl')")
for r in cur:
print(r[0])
print('Passed.')
# Check
act_1.expected_stdout = expected_stdout_1
act_1.stdout = capsys.readouterr().out
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_6392
# title: Space in database path prevent working gbak -se ... -b "pat to/database" backup
# decription:
# decription:
# Test creates windows BATCH file for main job:
# * create folder with spaces and some non-alphabetic characters (use "[", "]", "(", ")" etc);
# * create .sql script which will make database with spaces and non-alphabetic characters in this folder;
@ -11,21 +11,21 @@
# * try to backup and restore using services manager.
# Batch output is redirected to log and then we parse this log with expectation to find there messages
# which prove successful results for each action.
#
#
# Confirmed bug on 4.0.0.2173.
# Checked on 3.0.7.33358; 4.0.0.2180 SS/SC/CS: all fine.
#
#
# ::: NOTE :::
# Some problem still exists when DB file or folder has name which last character is '.' or ' ' (dot or space).
# Database will be created but attempt to backup raises: "gbak: ERROR:cannot open backup file ..."
#
#
# tracker_id: CORE-6392
# min_versions: ['3.0.7']
# versions: 3.0.7
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.7
# resources: None
@ -38,84 +38,84 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import sys
# import time
# import subprocess
# import re
# from fdb import services
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# #---------------------------------------------
#
#
# 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()
# if file_handle.mode not in ('r', 'rb'):
# # 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 os.path.isfile( f_names_list[i]):
# os.remove( f_names_list[i] )
# #--------------------------------------------
#
#
# fb_home = os.path.split( services.connect(host='localhost', user= user_name, password= user_password).get_home_directory() )[0]
# db_conn.close()
#
#
# # tmpdir='c:\\\\temp\\\\folder with spaces '
# # gbak: ERROR:cannot open backup file c: emp
# older with spaces \\db with spaces. . .fbk
#
#
# # tmpdir='c:\\\\temp\\\\folder with spaces..'
# # gbak: ERROR:cannot open backup file c: emp
# older with spaces..\\db with spaces. . .fbk
#
#
# #tmpdir='c:\\\\temp\\\\^!very strange^! folder with (many) spaces; created temporary, only for core-6392^! '
#
#
# #dbname='(strange name^!) DB with #lot# of excessive spaces; created temporary, only for core-6392^!. . .fdb'
# # gbak: ERROR:cannot open backup file // but database is created OK.
#
#
# #dbname='(strange name^!) DB with #lot# of excessive spaces, created temporary, only for core-6392^!. . .fdb'
# # gbak: ERROR:cannot open backup file // but database is created OK.
#
#
# tmpdir='c:\\\\temp\\\\ [[[ strange ]]] folder with {{{ lot of }}} spaces^!'
# dbname='DB with very^! ))) strange ((( name; created for core-6392.fdb'
#
#
# bkname=( '.'.join( dbname.split('.')[:-1] )+'.fbk' if '.' in dbname else dbname+'.fbk' )
#
#
# extbat=os.path.join(context['temp_directory'],'tmp_6392.bat')
# extlog=os.path.splitext(extbat)[0]+'.log'
# exterr=os.path.splitext(extbat)[0]+'.err'
#
#
# chksql="iif( upper(mon$database_name) = upper( q'{%(tmpdir)s\\%(dbname)s}' ), 'SUCCESS.', '### ERROR: DB HAS DIFFERENT NAME ###')" % locals()
# chksql=chksql.replace('^', '^^').replace(')', '^)')
# # echo select 'c: emp\\ [[[ strange ]]] folder with {{{ lot of }}} spaces^^!\\DB with very^^! ^)^)^) strange ((( name; created for core-6392.fdb' from rdb$database;
#
#
# runcmd='''
# @echo off
# setlocal enabledelayedexpansion enableextensions
# set ISC_USER=%(user_name)s
# set ISC_PASSWORD=%(user_password)s
# set FB_HOME=%(fb_home)s\\\\
#
#
# set tmpsql=%%~dpn0.sql
#
#
# del %(extlog)s 2>nul
#
#
# mkdir "%(tmpdir)s" 2>nul
# if exist "%(tmpdir)s" (
# echo Directory created OK.
@ -123,28 +123,28 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# echo Could NOT create directory "%(tmpdir)s". ABEND.
# goto :final
# )
#
#
# if exist "%(tmpdir)s\\%(dbname)s" del "%(tmpdir)s\\%(dbname)s"
#
#
# (
# echo set bail on;
# echo create database "%(tmpdir)s\\%(dbname)s";
# echo set list on;
# echo select %(chksql)s as "CHECK POINT. Result:" from mon$database;
# ) > !tmpsql!
#
#
# echo CHECK POINT. Trying to create database.
# !FB_HOME!isql.exe -q -i !tmpsql!
#
#
# del !tmpsql!
#
#
# echo CHECK POINT. Trying to BACKUP without "-se" switch.
# !FB_HOME!gbak.exe -b -verbi 999999 -st tdrw localhost:"%(tmpdir)s\\%(dbname)s" "%(tmpdir)s\\%(bkname)s"
# if exist "%(tmpdir)s\\%(bkname)s" (
# echo CHECK POINT. Trying to restore without "-se".
# !FB_HOME!gbak.exe -rep -verbi 999999 -st tdrw "%(tmpdir)s\\%(bkname)s" localhost:"%(tmpdir)s\\%(dbname)s"
# )
#
#
# echo.
# echo CHECK POINT. Trying to backup using gbak WITH "-se" switch.
# if exist "%(tmpdir)s\\%(bkname)s" del "%(tmpdir)s\\%(bkname)s"
@ -153,40 +153,40 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# echo CHECK POINT. Trying to restore using gbak WITH "-se" switch.
# !FB_HOME!gbak.exe -rep -verbi 999999 -st tdrw -se localhost:service_mgr "%(tmpdir)s\\%(bkname)s" "%(tmpdir)s\\%(dbname)s"
# )
#
#
# echo.
# echo CHECK POINT. Trying to backup using fbsvcmgr.
# if exist "%(tmpdir)s\\%(bkname)s" del "%(tmpdir)s\\%(bkname)s"
#
#
# !FB_HOME!fbsvcmgr.exe localhost:service_mgr action_backup dbname "%(tmpdir)s\\%(dbname)s" bkp_file "%(tmpdir)s\\%(bkname)s" verbint 999999 bkp_stat tdrw
# if exist "%(tmpdir)s\\%(bkname)s" (
# echo CHECK POINT. Trying to restore using fbsvcmgr.
# !FB_HOME!fbsvcmgr.exe localhost:service_mgr action_restore res_replace bkp_file "%(tmpdir)s\\%(bkname)s" dbname "%(tmpdir)s\\%(dbname)s" verbint 999999 res_stat tdrw
# )
#
#
# :final
# if exist "%(tmpdir)s\\%(dbname)s" del "%(tmpdir)s\\%(dbname)s"
# if exist "%(tmpdir)s\\%(bkname)s" del "%(tmpdir)s\\%(bkname)s"
# rmdir "%(tmpdir)s"
# echo Bye-bye from %%~f0
# ''' % dict(globals(), **locals())
#
#
# f_extbat=open( extbat, 'w' )
# f_extbat.write(runcmd)
# flush_and_close(f_extbat)
#
#
# f_extlog=open( extlog, 'w' )
# subprocess.call( [ extbat ], stdout = f_extlog, stderr = subprocess.STDOUT )
# flush_and_close(f_extlog)
#
# allowed_patterns = [ re.compile(p, re.IGNORECASE) for p in
#
# allowed_patterns = [ re.compile(p, re.IGNORECASE) for p in
# (
# 'check\\s+point'
# ,'closing\\s+file(,)?\\s+committing(,)?\\s+.*finishing'
# ,'finishing(,)?\\s+closing(,)?\\s+.*going\\s+home'
# )
# ]
#
#
# with open(f_extlog.name, 'r') as f:
# for line in f:
# if 'gbak: ERROR' in line:
@ -195,14 +195,15 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# for p in allowed_patterns:
# if p.search(line):
# print( (line if 'CHECK POINT' in line else p.search(line).group() ) )
#
#
# # CLEANUP
# #########
# time.sleep(1)
# #cleanup( [extbat, extlog] )
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
CHECK POINT. Trying to create database.
@ -230,7 +231,7 @@ expected_stdout_1 = """
@pytest.mark.version('>=3.0.7')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
def test_1(act_1: Action):
pytest.fail("Test not IMPLEMENTED")

View File

@ -2,33 +2,33 @@
#
# id: bugs.core_6395
# title: Allow usage of time zone displacement in config DefaultTimeZone
# decription:
# decription:
# We make backup of current firebird.conf for changing it two times:
# 1. Add line with DefaultTimeZone = -7:00 and get local time by making *LOCAL* connect to current DB;
# 2. Restore previous firebird.conf from its .bak-copy do second change: add line with DefaultTimeZone = 7:00.
# Then we run second local connect.
#
#
# Each connect will ask FB to return CURRENT_TIME value (with casting it to '%H:%M:%S' format).
# Expected result: values must change from 1st to 2nd run for 14 hours (840 minutes).
#
#
# ::: NB :::
# 1. Affect of changed parameter DefaultTimeZone can be seen only if DB is attached using LOCAL protocol.
# 2. FDB driver loads client library only *once* before this test launch and, in turn, this library reads firebird.conf.
# For this reason we have to launch separate (child) process two times, which will be forced to load firebird.conf
# every launch. This is why subprocess.call(['isql', ...]) is needed here rather than just query DB using cursor of
# pre-existing db_conn connection (see routine 'get_local_time').
#
#
# Confirmed improvement on 4.0.0.2185.
# Value of time did not differ on previous builds (checked 4..0.2170).
#
#
#
#
# tracker_id: CORE-6395
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
@ -41,7 +41,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import sys
# import os
# import shutil
@ -52,26 +52,26 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# from datetime import timedelta
# import subprocess
# from fdb import services
#
#
# db_name=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
# # 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 f in f_names_list:
@ -82,105 +82,103 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# def get_local_time( fb_home, db_name ):
#
#
# global flush_and_close
# global subprocess
# global cleanup
#
#
# sql_chk='select substring( cast(cast(current_time as time) as varchar(13)) from 1 for 8) from rdb$database'
#
#
# f_connect_sql = open( os.path.join(context['temp_directory'],'tmp_6396_check.sql'), 'w')
# f_connect_sql.write('set heading off; ' + sql_chk + ';' )
# flush_and_close( f_connect_sql )
#
#
# f_connect_log=open( os.path.join(context['temp_directory'],'tmp_6396_check.log'), 'w')
# subprocess.call( [ context['isql_path'], db_name, "-i", f_connect_sql.name ], stdout=f_connect_log, stderr=subprocess.STDOUT )
# flush_and_close( f_connect_log )
#
#
# changed_time = '00:00:00'
# with open(f_connect_log.name,'r') as f:
# for line in f:
# if line.split():
# changed_time = line.strip()
#
#
# cleanup( [x.name for x in (f_connect_sql, f_connect_log)] )
# return changed_time
#
#
# #---------------------------------------------
#
#
# svc = services.connect(host='localhost', user=user_name, password=user_password)
# fb_home = svc.get_home_directory()
# svc.close()
#
#
# dts = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
#
#
# fbconf_cur = os.path.join(fb_home, 'firebird.conf')
# fbconf_bak = os.path.join(context['temp_directory'], 'firebird_'+dts+'.bak')
#
#
# shutil.copy2( fbconf_cur, fbconf_bak )
#
#
# f_fbconf=open( fbconf_cur, 'r')
# fbconf_content=f_fbconf.readlines()
# flush_and_close( f_fbconf )
#
#
# for i,s in enumerate( fbconf_content ):
# line = s.lower().lstrip()
# if line.startswith( 'DefaultTimeZone'.lower() ):
# fbconf_content[i] = '# [temply commented] ' + s
#
#
# text2app='''
# ### TEMPORARY CHANGED BY FBTEST FRAMEWORK ###
# DefaultTimeZone = -7:00
# ##############################################
# '''
#
#
# f_fbconf=open( fbconf_cur, 'w')
# f_fbconf.writelines( fbconf_content + [ '\\n' + x for x in text2app.split('\\n') ] )
# flush_and_close( f_fbconf )
# #..........................................
#
#
# changed_time1 = get_local_time( fb_home, db_name )
#
#
# # RESTORE previous content of firebird.conf. This must be done BEFORE drop mapping!
# shutil.copy2( fbconf_bak, fbconf_cur )
#
#
# ##################################################
#
#
# text2app='''
# ### TEMPORARY CHANGED BY FBTEST FRAMEWORK ###
# DefaultTimeZone = +7:00
# ##############################################
# '''
#
#
# f_fbconf=open( fbconf_cur, 'w')
# f_fbconf.writelines( fbconf_content + [ '\\n' + x for x in text2app.split('\\n') ] )
# flush_and_close( f_fbconf )
#
#
# changed_time2 = get_local_time( fb_home, db_name )
#
#
# # RESTORE previous content of firebird.conf. This must be done BEFORE drop mapping!
# shutil.move( fbconf_bak, fbconf_cur )
#
#
# print( (datetime.datetime.strptime(changed_time2, '%H:%M:%S') - datetime.datetime.strptime(changed_time1, '%H:%M:%S')).seconds // 60 )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
840
"""
"""
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
pytest.skip("Requires changes to firebird.conf")

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_6403
# title: Some PSQL statements may lead to exceptions report wrong line/column
# decription:
# decription:
# We make list of strings, each of them is a multi-line statement starting with 'EXECUTE BLOCK ...'.
# Inside every EB one of following loops is checked:
# * while (<expr>) do ...
@ -11,17 +11,17 @@
# In the BEGIN ... END block we have several lines of code which operates with arguments (see ticket examples).
# When <expr> fails then we catch error stack and parse it by searching line '- At block line: N, col: C'.
# These values (N and C) are compared later with those which are expected.
#
#
# In order to proper evaluate expected values of (N,C) we split source expression onto separate lines and numerate them.
# Also, within each line we search special marker: "/*!*/" (without qoutes).
# If line contains this marker then we find its position and subtract 5 from it (this is length of "while" word).
# NB: this requer that betwee "for" and "/*!*/" we must put two space characters (see below).
#
# NB: this requires that between "for" and "/*!*/" we must put two space characters (see below).
#
# Finally, we compare values in two dictionaries:
# source_expr_positions_map - K = sequential number of exprerssion in the "main list"; V = line/col of token that causes problem;
# actual_stack_positions_map - K = the same as in source_expr_positions_map; V = line/col values that were parsed from error stack.
# All pairs for apropriate expressions must be equal.
#
#
# If some difference will be found then we show this error stack, expected line/col coordinates and actual ones, as in this example:
# ==================
# 3 UNEXPECTED MISMATCH between expected and actual values of line/col:
@ -49,46 +49,49 @@
# 11 : end
# 12 : end
# ==================
#
#
# Confirmed bug on 4.0.0.2195.
# Checked 4.0.0.2204: all fine.
#
#
# tracker_id: CORE-6403
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
import re
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
substitutions_1 = []
init_script_1 = """"""
init_script_1 = """
recreate table test (x int) ;
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
# from __future__ import print_function
#
#
# import os
# import sys
# import re
# import string
#
#
# #import fdb
# #FB_CLNT=sys.argv[1]
# #con=fdb.connect(dsn='localhost:e40', fb_library_name = FB_CLNT)
# #print(con.firebird_version)
#
#
# DEBUG_FLAG=0
#
#
# db_conn.execute_immediate('recreate table test(x int)')
# db_conn.commit()
#
#
# sttm_list = [
# '''execute block
# as
@ -161,7 +164,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# end
# end'''
# ]
#
#
# sttm_map = {}
# source_expr_positions_map = {}
# for i,s in enumerate(sttm_list):
@ -171,23 +174,23 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# sttm_map[ i, j+1 ] = ( line, 1 + problematic_expr_position )
# if problematic_expr_position>=0:
# source_expr_positions_map[ i ] = (j+1, 1 + problematic_expr_position )
#
#
# if DEBUG_FLAG:
# for k,v in sorted(sttm_map.items()):
# print(k,':::',v)
#
#
# for k,v in sorted(source_expr_positions_map.items()):
# print(k,':::',v)
#
#
#
#
# # - At block line: 3, col: 1
# p=re.compile( '(- )?At\\s+block\\s+line(:)?\\s+\\d+(,)?\\s+col(:)?\\s+\\d+', re.IGNORECASE)
#
#
# allchars=string.maketrans('','')
# nodigits=allchars.translate(allchars, string.digits + string.whitespace)
#
#
# actual_stack_positions_map = {}
#
#
# for i,s in enumerate(sttm_list):
# if DEBUG_FLAG:
# print('execute ',i)
@ -206,11 +209,11 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# # '- At block line: 3, col: 1' ==> ' 3 1'
# line_col_pair = msg.translate(allchars, nodigits).split()
# actual_stack_positions_map[ i ] = ( int(line_col_pair[0]), int(line_col_pair[1]), e[0] )
#
#
# if DEBUG_FLAG:
# for k,v in sorted(actual_stack_positions_map.items()):
# print(k,'###',v)
#
#
# for k,v in sorted(source_expr_positions_map.items()):
# w = actual_stack_positions_map.get(k)
# if w and v[:2] == w[:2]:
@ -225,17 +228,18 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# print( ' ' * 8, i )
# else:
# print(' * actual: NONE')
#
#
# print('Expression:')
# for i,s in enumerate( sttm_list[k].splitlines() ):
# if i == 0:
# print( '%s %s' % (" " * 6, ''.join( [ '....:....' + str(j) for j in range(1,9)] ) ) )
# print( '%s : %s' % ( " " * 4, "1234567890" * 8) )
# print( '%s : %s' % ( "{:4g}".format(i+1), s) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
Test 0 PASSED
@ -243,11 +247,133 @@ expected_stdout_1 = """
Test 2 PASSED
Test 3 PASSED
Test 4 PASSED
"""
"""
sttm_list = [
"""execute block
as
declare n integer = 0;
begin
while/*!*/ (1 / n > 0)
do
begin
n = n - 1;
end
end
""",
"""execute
block as declare n integer = 1; begin
while/*!*/
(
1 / n > 0
)
do
begin
n
= n - 1;
end
end
""",
"""execute block
as
begin
while/*!*/ ( (select coalesce(t.x,0) from rdb$database r left join test t on 1=1) <= 1 )
do
begin
insert into test(x) values(1);
insert into test(x) values(2);
insert into test(x) values(3);
end
end
""",
"""execute block
as
declare n int = 5;
declare c int;
begin
for /*!*/ select 100/:n from rdb$types into c
-- ^^ NB: two spaces here.
do begin
insert into test(x) values(sqrt(:n));
n = n - 1;
end
end
""",
"""execute block
as
declare n int = 5;
declare c int;
begin
delete from test;
while ( n >= 0 ) do
begin
for /*!*/ execute statement (
'select 100 / cast(? as int)
from rdb$database
'
) ( n ) into c
-- ^^ NB: two spaces here.
do begin
-- insert into test(x) values(sqrt(:n));
insert into test(x) values( :n );
end
n = n - 1;
end
end
"""
]
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, capsys):
sttm_map = {}
source_expr_positions_map = {}
for i, stm in enumerate(sttm_list):
sttm_lines = stm.splitlines()
for j, line in enumerate(sttm_lines):
problematic_expr_position = line.find('/*!*/') - 5
sttm_map[i, j+1] = (line, 1 + problematic_expr_position)
if problematic_expr_position >= 0:
source_expr_positions_map[i] = (j+1, 1 + problematic_expr_position)
#
# - At block line: 3, col: 1
pattern = re.compile('(-)?At\\s+block\\s+line(:)?\\s+\\d+(,)?\\s+col(:)?\\s+\\d+', re.IGNORECASE)
#
actual_stack_positions_map = {}
#
with act_1.db.connect() as con:
for i, cmd in enumerate(sttm_list):
try:
con.execute_immediate(cmd)
except Exception as e:
for msg in e.args[0].splitlines():
if pattern.match(msg):
# '- At block line: 3, col: 1' ==> ' 3 1'
line_col_pair = ''.join([s if s.isdigit() else ' ' for s in msg]).split()
actual_stack_positions_map[i] = (int(line_col_pair[0]), int(line_col_pair[1]), e.args[0])
#
for k, v in sorted(source_expr_positions_map.items()):
w = actual_stack_positions_map.get(k)
if w and v[:2] == w[:2]:
print(f'Test {k} PASSED') # expected line/col in source code matches error stack pair.
else:
print(f'{k} UNEXPECTED MISMATCH between expected and actual values of line/col:')
print(f' * expected (position of problematic token): {v[0]}, {v[1]}')
if w:
print(f' * actual (result of error message parsing): {w[0]}, {w[1]}')
print(' * source message of error:')
for i in w[2].splitlines():
print(' ' * 8, i)
else:
print(' * actual: NONE')
print('Expression:')
for i, s in enumerate(sttm_list[k].splitlines()):
if i == 0:
print(f'| {"".join(["....:...." + str(j) for j in range(1, 9)])}')
print(f'| : {"1234567890" * 8}')
print(f'|{"{:4g}".format(i+1)}: {s}')
# Check
act_1.expected_stdout = expected_stdout_1
act_1.stdout = capsys.readouterr().out
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_6411
# title: FB crashes on attempt to create table with number of fields greater than 5460
# decription:
# decription:
# It was found that maximal number of fields with type = BIGINT that could fit in a table DDL is 8066.
# If this limit is exeeded then FB raises "new record size of N bytes is too big" (where N >= 65536).
# We use for-loop with two iterations, each of them does following:
@ -16,17 +16,17 @@
# Statement failed, SQLSTATE = 54000
# unsuccessful metadata update
# -new record size of 65536 bytes is too big
#
#
# Confirmed bug on 4.0.0.2204: got crash when N=8065 (but still "new record size of 65536 bytes is too big" when N=8066).
# Checked on 3.0.7.33368, 4.0.0.2214 - all OK.
#
#
# tracker_id: CORE-6411
# min_versions: ['3.0.7']
# versions: 3.0.7
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.7
# resources: None
@ -43,30 +43,30 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import sys
# import subprocess
# import time
#
#
# db_file=db_conn.database_name
# db_conn.close()
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# #--------------------------------------------
#
#
# 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()
# 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 f in f_names_list:
@ -77,34 +77,34 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# subprocess.call([ context['fbsvcmgr_path'], "localhost:service_mgr",
# "action_properties", "prp_write_mode", "prp_wm_async",
# "dbname", db_file ]
# )
# #--------------------------------------------
#
#
# for iter in range(0,2):
# FLD_COUNT = 8064 + iter
#
#
# ddl_init = 'recreate table tdata(id bigint primary key'
# ddl_addi = '\\n'.join( (',f%d bigint' %i for i in range(1,FLD_COUNT)) )
# ddl_expr = ''.join( ( ddl_init, ddl_addi, ')' ) )
#
#
# upd_init = 'update or insert into tdata values( 1'
# upd_addi = '\\n'.join( ( ',' + str(i) for i in range(1,FLD_COUNT)) )
# upd_expr = ''.join( ( upd_init, upd_addi, ') matching(id)' ) )
#
#
#
#
# sel_init = 'select '
# sel_addi = '+'.join( ( str(i) for i in range(0,FLD_COUNT)) )
# sel_expr = ''.join( ( sel_init, sel_addi, ' as fields_total from tdata' ) )
#
#
# sql_expr= '''
# set bail on;
# %(ddl_expr)s;
@ -115,45 +115,81 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# %(sel_expr)s;
# quit;
# ''' % dict(globals(), **locals())
#
#
# f_run_sql = open( os.path.join(context['temp_directory'],'tmp_run_6411.sql'), 'w')
# f_run_sql.write(sql_expr)
# f_run_sql.close()
#
#
# f_run_log = open( os.path.join(context['temp_directory'],'tmp_run_6411.log'), 'w')
#
#
# p_hanged_isql=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.strip():
# print('iter: %(iter)s, FLD_COUNT: %(FLD_COUNT)s, result: %(line)s' % locals())
# #< for iter in range(0,2)
#
#
# # Cleanup.
# ##########
# time.sleep(1)
# cleanup( (f_run_sql, f_run_log) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
iter: 0, FLD_COUNT: 8064, result: FIELDS_TOTAL 32510016
iter: 1, FLD_COUNT: 8065, result: Statement failed, SQLSTATE = 54000
iter: 1, FLD_COUNT: 8065, result: unsuccessful metadata update
iter: 1, FLD_COUNT: 8065, result: -new record size of 65536 bytes is too big
iter: 1, FLD_COUNT: 8065, result: -TABLE TDATA
"""
step: 0, FLD_COUNT: 8064, result: FIELDS_TOTAL 32510016
step: 1, FLD_COUNT: 8065, result: Statement failed, SQLSTATE = 54000
step: 1, FLD_COUNT: 8065, result: unsuccessful metadata update
step: 1, FLD_COUNT: 8065, result: -new record size of 65536 bytes is too big
step: 1, FLD_COUNT: 8065, result: -TABLE TDATA
"""
@pytest.mark.version('>=3.0.7')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, capsys):
act_1.db.set_async_write()
#
for step in range(2):
FLD_COUNT = 8064 + step
ddl_init = 'recreate table tdata (id bigint primary key'
ddl_addi = '\n'.join([f',f{i} bigint' for i in range(1,FLD_COUNT)])
ddl_expr = ''.join([ddl_init, ddl_addi, ')'])
upd_init = 'update or insert into tdata values(1'
upd_addi = '\n'.join( [f',{i}' for i in range(1,FLD_COUNT)])
upd_expr = ''.join([upd_init, upd_addi, ') matching(id)'])
sel_init = 'select '
sel_addi = '+'.join([str(i) for i in range(0,FLD_COUNT)])
sel_expr = ''.join([sel_init, sel_addi, ' as fields_total from tdata'])
sql_expr= f"""
set bail on ;
{ddl_expr} ;
commit;
connect '{act_1.db.dsn}' user {act_1.db.user} password '{act_1.db.password}' ;
{upd_expr} ;
set list on ;
{sel_expr} ;
quit ;
"""
#
act_1.reset()
act_1.isql(switches=[], input=sql_expr, combine_output=True)
for line in act_1.stdout.splitlines():
if line.strip():
print(f'step: {step}, FLD_COUNT: {FLD_COUNT}, result: {line}')
# Check
act_1.reset()
act_1.expected_stdout = expected_stdout_1
act_1.stdout = capsys.readouterr().out
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,28 +2,28 @@
#
# id: bugs.core_6412
# title: Firebird is freezing when trying to manage users via triggers
# decription:
# decription:
# Confirmed hang on 4.0.0.2214
#
#
# Checked on 4.0.0.2249 - no hang, but if this test runs in loop, w/o pauses for at least ~4s, then starting from 2nd run following fail raises:
# Statement failed, SQLSTATE = 08006
# Error occurred during login, please check server firebird.log for details
# Error occurred during login, please check server firebird.log for details
# This was because of: http://tracker.firebirdsql.org/browse/CORE-6441 (fixed).
#
#
# Content of firebird.log will be added with following lines:
# Srp Server
# connection shutdown
# Database is shutdown.
# Sent report to Alex et al, 09.11.2020.
#
#
# tracker_id: CORE-6412
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
@ -36,7 +36,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import sys
# import time
@ -44,23 +44,23 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import shutil
# import uuid
# from fdb import services
#
#
# svc = services.connect(host='localhost', user = user_name, password = user_password)
# fb_home=svc.get_home_directory()
# svc.close()
#
#
# dbconf = os.path.join(fb_home,'databases.conf')
# dbcbak = os.path.join(fb_home,'databases.bak')
#
#
# try:
# del os.environ["ISC_USER"]
# except KeyError as e:
# pass
#
#
# #--------------------------------------------
#
#
# def svc_get_fb_log( fb_home, f_fb_log ):
#
#
# global subprocess
# subprocess.call( [ fb_home + "fbsvcmgr",
# "localhost:service_mgr",
@ -69,24 +69,24 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# stdout=f_fb_log, stderr=subprocess.STDOUT
# )
# return
#
#
# #--------------------------------------------
#
#
# 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()
# if file_handle.mode not in ('r', 'rb'):
# # 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 )):
@ -94,54 +94,54 @@ 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])
#
#
# #--------------------------------------------
#
#
# fdb_test = os.path.join(context['temp_directory'],'tmp_6412.fdb')
#
#
#
#
# # NB: fb_home is full path to FB instance home (with trailing slash).
# shutil.copy2( dbconf, dbcbak )
#
#
# tmp_alias = 'self_security_6412'
#
#
# alias_data='''
#
#
# # Added temporarily for executing test core_6412.fbt
# %(tmp_alias)s = %(fdb_test)s {
# # RemoteAccess = true
# SecurityDatabase = %(tmp_alias)s
# }
# ''' % locals()
#
#
# f_dbconf=open(fb_home+'databases.conf','a')
# f_dbconf.seek(0, 2)
# f_dbconf.write( alias_data )
# flush_and_close( f_dbconf )
#
#
# cleanup( (fdb_test,) )
#
#
# sql_init='''
# set bail on;
# create database '%(tmp_alias)s';
# alter database set linger to 0;
# create user SYSDBA password 'QweRty' using plugin Srp;
# commit;
#
#
# connect 'localhost:%(tmp_alias)s' user sysdba password 'QweRty';
#
#
# set list on;
# select a.mon$remote_protocol,
# d.mon$sec_database
# from mon$attachments a cross join mon$database d
# where a.mon$attachment_id = current_connection;
#
#
# CREATE TABLE USERS
# (
# AUTHENTICATION VARCHAR(32) CHARACTER SET WIN1252 COLLATE WIN_PTBR
# );
# COMMIT;
#
#
# SET TERM ^ ;
# CREATE TRIGGER USERS_AI_AU_AD FOR USERS
# ACTIVE AFTER INSERT OR UPDATE OR DELETE POSITION 0
@ -152,7 +152,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# EXECUTE STATEMENT 'REVOKE RDB$ADMIN FROM "' || OLD.AUTHENTICATION || '" GRANTED BY "SYSDBA"';
# EXECUTE STATEMENT 'DROP USER "' || OLD.AUTHENTICATION || '" USING PLUGIN SRP';
# END
#
#
# IF ((NEW.AUTHENTICATION IS NOT NULL) AND ((OLD.AUTHENTICATION IS NULL) OR (OLD.AUTHENTICATION<>NEW.AUTHENTICATION))) THEN
# BEGIN
# EXECUTE STATEMENT 'GRANT RDB$ADMIN TO "' || NEW.AUTHENTICATION || '" GRANTED BY "SYSDBA"';
@ -160,28 +160,28 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# END
# END^
# SET TERM ; ^
# COMMIT;
#
# COMMIT;
#
# INSERT INTO USERS (AUTHENTICATION) VALUES ('AAA');
# COMMIT;
#
#
# COMMIT;
#
#
# UPDATE USERS SET AUTHENTICATION='BBB' WHERE AUTHENTICATION='AAA';
# COMMIT;
#
# COMMIT;
#
# set list on;
# select 'Completed' as result from rdb$database;
# quit;
#
#
# ''' % locals()
#
#
# runProgram( 'isql',[ '-q' ], sql_init)
# runProgram( 'gfix',[ '-shut', 'full', '-force', '0', 'localhost:' + fdb_test, '-user', 'SYSDBA', '-pas', 'QweRty' ])
#
#
# shutil.move( dbcbak, dbconf )
#
#
# cleanup( (fdb_test,) )
#
#
# # This delay is necessary for running this test multiple times (in loop) on SS and SC.
# # Otherwise we get runtime error "SQLSTATE = 08006 / Error occurred during login, please check server firebird.log"
# # and firebird.log will be filled with: "Srp Server / connection shutdown / Database is shutdown."
@ -189,20 +189,20 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# #############
# # 03-mar-2021: can be deleted (related to CORE-6441) >>> time.sleep(4)
# #############
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
MON$REMOTE_PROTOCOL TCPv6
MON$SEC_DATABASE Self
RESULT Completed
"""
"""
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
pytest.skip("Requires change to databases.conf")

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_6437
# title: gfix cannot set big value for buffers
# decription:
# decription:
# New database must be created in THIS code rather than "outside" (in fbtest) for reproducing bug.
# Confirmed bug on 4.0.0.2225.
# Checked on Windows:
@ -10,7 +10,7 @@
# 3.0.2.32703 SS: 2.645s.
# 3.0.7.33387 SS: 3.301s.
# 3.0.6.33328 CS: 6.145s.
#
#
# ::: NB :::
# On build 4.0.0.2225 attempt to change buffers via gfix failed when value was >= 524337 for DB with page_size=8192.
# Perhaps this was related to allocating memory more than 2Gb plus small addition (exact value: 2.00018692 Gb).
@ -23,19 +23,20 @@
# Test creates database with page size = 8192 and tries to run 'gfix -buffers 524337', with further checking that:
# * output of gfix is empty;
# * page buffers has been changed and equals to this new value.
#
#
# DO NOT change this value to some "really too big" value otherwise it will fail with "unable to allocate memory"!
# Checked again (15.03.2021) on:
# * Windows: 4.0.0.2387, 3.0.8.33426
# * Linux: 4.0.0.2387, 3.0.8.33426
#
#
# tracker_id: CORE-6437
# min_versions: ['3.0.8']
# versions: 3.0.8
# qmid: None
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
# version: 3.0.8
# resources: None
@ -48,33 +49,33 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import subprocess
# from fdb import services
# import time
#
#
# 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()
# 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 f in f_names_list:
@ -85,43 +86,52 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# db_name = os.path.join(context['temp_directory'],'tmp_gfix_6437.fdb')
#
#
# cleanup( (db_name,) )
#
#
# runProgram('isql',[ '-q' ], "create database '%(db_name)s' page_size 8192;" % locals())
#
#
# f_run_log=open( os.path.join(context['temp_directory'],'tmp_gfix_6437.log'), 'w')
# subprocess.call( [ context['gfix_path'], db_name, "-buffers", "524337" ], stdout=f_run_log, stderr=subprocess.STDOUT )
# flush_and_close(f_run_log)
#
#
# time.sleep(1)
# with open(f_run_log.name,'r') as f:
# for line in f:
# print('UNEXPECTED GFIX OUTPUT: ' + line)
#
#
# runProgram('gstat',[ '-h', db_name ])
#
#
# cleanup( (db_name, f_run_log,) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
Page size 8192
Page buffers 524337
"""
"""
test_db = temp_file('tmp_gfix_6437.fdb')
@pytest.mark.version('>=3.0.8')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, test_db: Path):
act_1.isql(switches=['-q'], connect_db=False,
input=f"create database '{test_db}' page_size 8192;")
#
act_1.reset()
act_1.gfix(switches=[str(test_db), '-buffers', '524337'])
act_1.reset()
#
act_1.expected_stdout = expected_stdout_1
act_1.gstat(switches=['-h', str(test_db)], connect_db=False)
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,19 +2,19 @@
#
# id: bugs.core_6438
# title: ISQL: bad headers when text columns has >= 80 characters
# decription:
# decription:
# Test creates .sql script with query that contains literal (similar to descriped in the ticket, but much longer).
# Then we parse result of this query and compare length of header and data. They both must be equal to the same value.
# Confirmed truncated length of header on 4.0.0.2225
# Checked on 4.0.0.2249 - all fine.
#
#
# tracker_id: CORE-6438
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
@ -27,34 +27,34 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import sys
# import os
# import time
# import subprocess
# from fdb import services
#
#
# 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()
# 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 f in f_names_list:
@ -65,23 +65,23 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# data = '1' * 65533
# sql_run = '''select '%(data)s' as " ", 1 as " " from rdb$database;''' % locals()
#
#
# f_run_sql = open( os.path.join(context['temp_directory'],'tmp_6438.sql'), 'w')
# f_run_sql.write(sql_run)
# flush_and_close(f_run_sql)
#
#
# f_run_log=open( os.path.join(context['temp_directory'],'tmp_6438.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)
#
#
# hdr_len, txt_len = 0,0
# with open(f_run_log.name,'r') as f:
# for line in f:
@ -89,26 +89,37 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# hdr_len = len(line.split()[0])
# elif line.startswith('1'):
# txt_len = len(line.split()[0])
#
#
# print('hdr_len:', hdr_len)
# print('txt_len:', txt_len)
#
#
# # Cleanup
# ##########
# cleanup( ( f_run_sql, f_run_log ) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
hdr_len: 65533
txt_len: 65533
"""
"""
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, capsys):
data = '1' * 65533
act_1.isql(switches=[], input=f'''select '{data}' as " ", 1 as " " from rdb$database;''')
for line in act_1.stdout.splitlines():
if line.startswith('='):
hdr_len = len(line.split()[0])
elif line.startswith('1'):
txt_len = len(line.split()[0])
print('hdr_len:', hdr_len)
print('txt_len:', txt_len)
#
act_1.reset()
act_1.expected_stdout = expected_stdout_1
act_1.stdout = capsys.readouterr().out
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,37 +2,37 @@
#
# id: bugs.core_6441
# title: Srp plugin keeps connection after database has been removed for ~10 seconds (SS and SC).
# decription:
# decription:
# Test is based on CORE-6412, but instead of complex DDL it only creates DB and makes connection.
# Then it leaves ISQL and 'main' code changes DB state to full shutdown and removes database.
# After this, test immediatelly starts next iteration with the same actions. All of them must pass.
# Total number of iterations = 3.
#
#
# Confirmed bug on 4.0.0.2265:
# Statement failed, SQLSTATE = 08006
# Error occurred during login, please check server firebird.log for details
# Error occurred during login, please check server firebird.log for details
#
#
# NB. Content of firebird.log will be added with following lines:
# Srp Server
# connection shutdown
# Database is shutdown.
# This is expected (got reply from Alex, e-mail 19.11.2020 11:12).
#
#
# Checked on 3.0.8.33392 SS/SC, 4.0.0.2269 SC/SS - all fine.
#
#
# 03-mar-2021: fixed call syntax in runProgram() macros.
# Checked on:
# * WINDOWS: 335544344 : I/O error during "CreateFile (open)" operation ...
# * LINUX: 335544344 : I/O error during "open" operation ...
#
#
# tracker_id: CORE-6441
# min_versions: ['3.0.8']
# versions: 3.0.8
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.8
# resources: None
@ -45,45 +45,45 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import sys
# import time
# import subprocess
# import shutil
# from fdb import services
#
#
# from fdb import services
#
#
# svc = services.connect(host='localhost', user = user_name, password = user_password)
# fb_home=svc.get_home_directory()
# svc.close()
#
#
# dbconf = os.path.join(fb_home,'databases.conf')
# dbcbak = os.path.join(fb_home,'databases.bak')
#
#
# try:
# del os.environ["ISC_USER"]
# except KeyError as e:
# pass
#
#
# #--------------------------------------------
#
#
# 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 )):
@ -94,50 +94,50 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# 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 )
#
#
# #--------------------------------------------
#
#
#
#
# fdb_test = os.path.join(context['temp_directory'],'tmp_6441.fdb')
#
#
# shutil.copy2( dbconf, dbcbak )
# tmp_alias = 'self_security_6441'
#
#
# alias_data='''
#
#
# # Added temporarily for executing test core_6441.fbt
# %(tmp_alias)s = %(fdb_test)s {
# # RemoteAccess = true
# SecurityDatabase = %(tmp_alias)s
# }
# ''' % locals()
#
#
# f_dbconf=open( dbconf, 'a')
# f_dbconf.seek(0, 2)
# f_dbconf.write( alias_data )
# flush_and_close( f_dbconf )
#
#
# cleanup( (fdb_test,) )
#
#
# sql_init='''
# set bail on;
# set list on;
#
#
# create database '%(tmp_alias)s';
#
#
# select %(i)s as iteration_no, 'DB creation completed OK.' as msg from rdb$database;
#
#
# alter database set linger to 0;
# create user SYSDBA password 'QweRty' using plugin Srp;
# commit;
#
#
# connect 'localhost:%(tmp_alias)s' user sysdba password 'QweRty';
#
#
# select %(i)s as iteration_no, 'Remote connection established OK.' as msg from rdb$database;
#
#
# set term ^;
# execute block as
# declare v_dummy varchar(20);
@ -151,16 +151,17 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# set term ;^
# quit;
# '''
#
#
# for i in range(0,3):
# runProgram('isql',[ '-q' ], sql_init % locals() )
# runProgram('gfix',[ '-shut', 'full', '-force', '0', 'localhost:' + fdb_test, '-user', 'SYSDBA', '-pas', 'QweRty' ])
# cleanup( (fdb_test,) )
#
#
# shutil.move( dbcbak, dbconf )
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
ITERATION_NO 0
@ -177,11 +178,10 @@ expected_stdout_1 = """
MSG DB creation completed OK.
ITERATION_NO 2
MSG Remote connection established OK.
"""
"""
@pytest.mark.version('>=3.0.8')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
pytest.skip("Requires change to databases.conf")

View File

@ -2,64 +2,64 @@
#
# id: bugs.core_6444
# title: Ability to query Firebird configuration using SQL
# decription:
# decription:
# Test found FB_HOME directory and makes copy its firebird.conf and database.conf files.
# Then:
# * for Windows it founds free TCP port and overwrites content of firebird.conf: this new port
# * for Windows it founds free TCP port and overwrites content of firebird.conf: this new port
# will be specified for RemoveServicePort and some other parameters also will be added.
# * for Linux it will use local protocol rather than TCP (it is not possible to connect to
# any database using TCP if new FB instance is launched using subprocess.Popen('firebird');
# the reason of this is unknown)
#
#
# File <FB_HOME>\\databases.conf is also changed: we add new alias for database that will
# be self-security and specify lot of per-database parameters for it.
#
#
# Some numeric parameters intentionally will be assigned to huge bigint values, namely:
# * FileSystemCacheThreshold
# * TempCacheLimit
# Their huge values do not affect on actual work; this is done only for check proper
# interpretation of them.
# ServerMode is set to SuperClassic.
#
#
# After this test:
# * for Windows: launches Firebird as application (see async. call of Popen()) and make
# connect to new database by launching ISQL.
# * for Linux: makes connection to database using local (embedded) protocol.
#
#
# When connect is established, we query RDB$CONFIG table two times:
# * as SYSDBA (in this case all config parameters and their actual values must be seen);
# * as NON-privileged user (zero rows must be issued for query to RDB$CONFIG).
#
#
# Finally (after return from ISQL, and only for Windows) test terminates Firebird application process.
#
#
# ::: CAUTION-1 :::
# This test will fail if new parameter will appear in firebird.conf or if old one removed from there.
# One need to adjust expected_stdout in this case.
#
#
# ::: CAUTION-2 :::
# Windows Firewall can block attempt to launch FB as application (dialog window appears in this case).
# One may need to configure Firewall so that process <FB_HOME>
# irebird.exe is enable to operate on any port.
#
#
# Perhaps, following command will be useful: netsh advfirewall set privateprofile state off
#
#
# ::: CAUTION-3 :::
# Default values for some parameters differ on Windows and Linux.
# They are: IpcName, MaxUnflushed* and OutputRedirectionFile.
#
#
# Because of such valuable differences, it was decided to make code for Windows and Linux separate.
#
#
# Initially checked on 4.0.0.2365 (Windows only).
# Checked on 4.0.0.2422 - after adapted for work both Windows and Linux.
# Checked on 4.0.0.2436 - parameter 'TempTableDirectory' appeared.
#
#
# tracker_id: CORE-6444
# min_versions: ['4.0']
# versions: 4.0, 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
@ -72,7 +72,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import sys
# import os
# import shutil
@ -81,24 +81,24 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import tempfile
# import subprocess
# from fdb import services
#
#
# #--------------------------------------------
#
#
# 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()
# if file_handle.mode not in ('r', 'rb'):
# # 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 )):
@ -110,17 +110,17 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# print('Unrecognized type of element:', f_names_list[i], ' - can not be treated as file.')
# print('type(f_names_list[i])=',type(f_names_list[i]))
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# def find_free_port():
# import socket
# from contextlib import closing
# # AF_INET - constant represent the address (and protocol) families, used for the first argument to socket()
# # A pair (host, port) is used for the AF_INET address family, where host is a string representing either a
# # A pair (host, port) is used for the AF_INET address family, where host is a string representing either a
# # hostname in Internet domain notation like 'daring.cwi.nl' or an IPv4 address like '100.50.200.5', and port is an integer.
# # SOCK_STREAM means that it is a TCP socket.
# # SOCK_DGRAM means that it is a UDP socket.
@ -128,37 +128,37 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# s.bind(('', 0))
# s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# return s.getsockname()[1]
#
#
# #--------------------------------------------
#
#
# FB_HOME = services.connect(host='localhost', user=user_name, password=user_password).get_home_directory()
# FB_BINS = os.path.join(FB_HOME, 'bin') # we are in LINUX branch. Windows see in separate section, not here!
#
#
# fb_vers = str(db_conn.engine_version)[:1] # character for security.db file: engine = 4.0 --> '4'
# sec_db = os.path.join( FB_HOME, 'security' + fb_vers+ '.fdb')
#
#
# db_conn.close()
#
#
# fdb_test = os.path.join(context['temp_directory'],'tmp_c6444.fdb')
#
#
# dts = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
#
#
# fbconf_cur = os.path.join(FB_HOME, 'firebird.conf')
# fbconf_bak = os.path.join(context['temp_directory'], 'firebird_'+dts+'.bak')
#
#
# dbconf_cur = os.path.join(FB_HOME, 'databases.conf')
# dbconf_bak = os.path.join(context['temp_directory'], 'databases_'+dts+'.bak')
#
#
# shutil.copy2( fbconf_cur, fbconf_bak )
# shutil.copy2( dbconf_cur, dbconf_bak )
#
#
# shutil.copy2( sec_db, fdb_test )
#
#
# TEMP_DIRECTORIES_VALUE = os.path.normpath( os.path.join(FB_HOME, 'examples') )
# TTABLE_DIRECTORY_VALUE = os.path.normpath( context['temp_directory'] )
#
#
# TMP_FREE_PORT = find_free_port()
#
#
# cfg_params_to_change= {
# 'AllowEncryptedSecurityDatabase' : 'true'
# ,'AuthClient' : 'Srp'
@ -198,49 +198,49 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# ,'WireCompression' : 'true'
# ,'WireCrypt' : 'Required'
# ,'WireCryptPlugin' : 'Arc4'
#
#
# }
#
#
# f_fbconf=open( fbconf_cur, 'w')
# for k,v in sorted(cfg_params_to_change.items()):
# f_fbconf.write( ''.join( (k, ' = ', v, '\\n') ) )
# flush_and_close( f_fbconf )
#
#
# alias_data='''
# # Added temporarily for executing test core_6444.fbt
# tmp_6444 = %(fdb_test)s {
#
#
# SecurityDatabase = tmp_6444
#
#
# RemoteAccess = true
# DatabaseGrowthIncrement = 123m
# DataTypeCompatibility = 3.0
# DefaultDbCachePages = 4321
# ClearGTTAtRetaining = 1
#
#
# # Set number of minutes after which idle attachment will be disconnected by the engine. Zero means no timeout is set.
# ConnectionIdleTimeout = 99
#
#
# ExternalFileAccess = Full
#
#
# LockHashSlots = 49999
# LockMemSize = 29m
#
#
# MaxIdentifierByteLength = 31
# MaxIdentifierCharLength = 31
# MaxUnflushedWrites = 111
# MaxUnflushedWriteTime = 15
#
#
# Providers = Engine13, Remote
#
#
# SnapshotsMemSize = 99m
#
#
# # Set number of seconds after which statement execution will be automatically cancelled by the engine. Zero means no timeout is set.
# StatementTimeout = 999
#
#
# TempBlockSize = 3m
# TempCacheLimit = 8589934591G
#
#
# ###############################
# # Appeared since 4.0.0.2436, 21.04.2021; per-database:
# # ~~~~~~~~~~~~~~~~~~~~~~~~~
@ -252,20 +252,20 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# #TempTableDirectory =
# ###############################
# TempTableDirectory = %(TTABLE_DIRECTORY_VALUE)s
#
#
# TipCacheBlockSize = 3m
#
#
# UserManager = Legacy_UserManager, Srp
# }
# ''' % locals()
#
#
# f_dbconf=open( dbconf_cur, 'w')
# f_dbconf.write(alias_data)
# flush_and_close( f_dbconf )
#
#
# # LINUX: we use local protocol rather than remote (as on Windows):
# CONN_STR = 'tmp_6444'
#
#
# sql_text='''
# -- set echo on;
# set wng off;
@ -294,22 +294,22 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# commit;
# grant select on v_config to tmp$c6444;
# commit;
#
#
# connect '%(CONN_STR)s' user %(user_name)s password '%(user_password)s';
#
#
# set count on;
# set width param_name 50;
# set width param_value 64;
# set width param_default 64;
# set width param_source 64;
#
#
# select * from v_config; -- SYSDBA: must see all parameters with their effective values
#
#
# commit;
# connect '%(CONN_STR)s' user tmp$c6444 password '123';
#
#
# select * from v_config; -- NON-PRIVILEGED user: must see 0 rows
#
#
# /*
# -- for debug only:
# set list on;
@ -330,135 +330,135 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# where a.mon$attachment_id = current_connection
# ;
# --*/
#
#
# commit;
# connect '%(CONN_STR)s' user sysdba password 'masterkey';
# drop user tmp$c6444 using plugin Srp;
# commit;
#
#
# ''' % dict(globals(), **locals())
#
#
# f_sql_cmd = open( os.path.join(context['temp_directory'],'tmp_c6444.sql'), 'w')
# f_sql_cmd.write( sql_text )
# flush_and_close( f_sql_cmd )
#
#
# f_sql_log=open( os.path.join(context['temp_directory'],'tmp_c6444.log'), 'w')
# f_sql_err=open( os.path.join(context['temp_directory'],'tmp_c6444.err'), 'w')
#
#
# subprocess.call( [context['isql_path'], '-q', '-pag', '999999', '-i', f_sql_cmd.name, '-user', 'SYSDBA'], stdout=f_sql_log, stderr=f_sql_err )
#
#
# flush_and_close( f_sql_log )
# flush_and_close( f_sql_err )
#
#
# shutil.move( fbconf_bak, fbconf_cur )
# shutil.move( dbconf_bak, dbconf_cur )
#
#
# with open(f_sql_err.name, 'r') as f:
# for line in f:
# if line.split():
# print('UNEXPECTED STDERR: ' + line)
#
#
# with open(f_sql_log.name, 'r') as f:
# for line in f:
# if line.split():
# print(line)
#
#
# time.sleep(1)
#
#
# f_list=( f_sql_log, f_sql_err, f_sql_cmd )
#
#
# # Cleanup
# ##########
# # cleanup( [ i.name for i in f_list ] + [fdb_test] )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
PARAM_NAME PARAM_VALUE PARAM_DEFAULT PARAM_IS_SET PARAM_SOURCE
================================================== ================================================================ ================================================================ ============ ================================================================
AllowEncryptedSecurityDatabase true false <true> firebird.conf
AuditTraceConfigFile [empty] [empty] <false> <null>
AuthClient Srp Srp256, Srp, Legacy_Auth <true> firebird.conf
AuthServer Legacy_Auth, Srp Srp256 <true> firebird.conf
BugcheckAbort true false <true> firebird.conf
ClearGTTAtRetaining true false <true> databases.conf
ClientBatchBuffer 262144 131072 <true> firebird.conf
ConnectionIdleTimeout 99 0 <true> databases.conf
ConnectionTimeout 123 180 <true> firebird.conf
CpuAffinityMask 0 0 <false> <null>
DataTypeCompatibility 3.0 <null> <true> databases.conf
DatabaseAccess None Full <true> firebird.conf
DatabaseGrowthIncrement 128974848 134217728 <true> databases.conf
DeadlockTimeout 15 10 <true> firebird.conf
DefaultDbCachePages 4321 2048 <true> databases.conf
DefaultTimeZone -7:00 <null> <true> firebird.conf
DummyPacketInterval 11 0 <true> firebird.conf
EventMemSize 12321 65536 <true> firebird.conf
ExtConnPoolLifeTime 1212 7200 <true> firebird.conf
ExtConnPoolSize 123 0 <true> firebird.conf
ExternalFileAccess Full None <true> databases.conf
FileSystemCacheSize 0 0 <false> <null>
FileSystemCacheThreshold 9223372035781033984 65536 <true> firebird.conf
GCPolicy combined combined <false> <null>
GuardianOption 1 1 <false> <null>
IPv6V6Only true false <true> firebird.conf
PARAM_NAME PARAM_VALUE PARAM_DEFAULT PARAM_IS_SET PARAM_SOURCE
================================================== ================================================================ ================================================================ ============ ================================================================
AllowEncryptedSecurityDatabase true false <true> firebird.conf
AuditTraceConfigFile [empty] [empty] <false> <null>
AuthClient Srp Srp256, Srp, Legacy_Auth <true> firebird.conf
AuthServer Legacy_Auth, Srp Srp256 <true> firebird.conf
BugcheckAbort true false <true> firebird.conf
ClearGTTAtRetaining true false <true> databases.conf
ClientBatchBuffer 262144 131072 <true> firebird.conf
ConnectionIdleTimeout 99 0 <true> databases.conf
ConnectionTimeout 123 180 <true> firebird.conf
CpuAffinityMask 0 0 <false> <null>
DataTypeCompatibility 3.0 <null> <true> databases.conf
DatabaseAccess None Full <true> firebird.conf
DatabaseGrowthIncrement 128974848 134217728 <true> databases.conf
DeadlockTimeout 15 10 <true> firebird.conf
DefaultDbCachePages 4321 2048 <true> databases.conf
DefaultTimeZone -7:00 <null> <true> firebird.conf
DummyPacketInterval 11 0 <true> firebird.conf
EventMemSize 12321 65536 <true> firebird.conf
ExtConnPoolLifeTime 1212 7200 <true> firebird.conf
ExtConnPoolSize 123 0 <true> firebird.conf
ExternalFileAccess Full None <true> databases.conf
FileSystemCacheSize 0 0 <false> <null>
FileSystemCacheThreshold 9223372035781033984 65536 <true> firebird.conf
GCPolicy combined combined <false> <null>
GuardianOption 1 1 <false> <null>
IPv6V6Only true false <true> firebird.conf
InlineSortThreshold 8192 1000 <true> firebird.conf
IpcName fb4x_tmp_c6444 FirebirdIPI <true> firebird.conf
KeyHolderPlugin [empty] [empty] <false> <null>
LegacyHash true true <false> <null>
LockAcquireSpins 0 0 <false> <null>
LockHashSlots 49999 8191 <true> databases.conf
LockMemSize 30408704 1048576 <true> databases.conf
MaxIdentifierByteLength 31 252 <true> databases.conf
MaxIdentifierCharLength 31 63 <true> databases.conf
MaxUnflushedWriteTime 15 -1 <true> databases.conf
MaxUnflushedWrites 111 -1 <true> databases.conf
MaxUserTraceLogSize 100 10 <true> firebird.conf
OutputRedirectionFile /dev/null /dev/null <false> <null>
ProcessPriorityLevel 0 0 <false> <null>
Providers Engine13, Remote Remote, Engine13, Loopback <true> databases.conf
ReadConsistency false true <true> firebird.conf
Redirection false false <false> <null>
RelaxedAliasChecking false false <false> <null>
RemoteAccess true true <true> databases.conf
RemoteAuxPort 0 0 <false> <null>
RemoteBindAddress <null> <null> <false> <null>
RemoteFileOpenAbility false false <false> <null>
RemotePipeName interbas interbas <false> <null>
RemoteServiceName tmp_fbs_6444 gds_db <true> firebird.conf
RemoteServicePort [MATCHES] 0 <true> firebird.conf
SecurityDatabase tmp_6444 security4.fdb <true> databases.conf
ServerMode SuperClassic Super <true> firebird.conf
SnapshotsMemSize 103809024 65536 <true> databases.conf
StatementTimeout 999 0 <true> databases.conf
TcpLoopbackFastPath false true <true> firebird.conf
TcpNoNagle false true <true> firebird.conf
TcpRemoteBufferSize 5555 8192 <true> firebird.conf
TempBlockSize 5242880 1048576 <true> firebird.conf
TempCacheLimit 9223372035781033984 67108864 <true> databases.conf
TempDirectories [MATCHES] <null> <true> firebird.conf
TempTableDirectory [MATCHES] [empty] <true> databases.conf
TipCacheBlockSize 3145728 4194304 <true> databases.conf
TraceDSQL 0 0 <false> <null>
TracePlugin fbtrace fbtrace <false> <null>
UdfAccess Restrict UDF None <true> firebird.conf
UseFileSystemCache false true <true> firebird.conf
UserManager Legacy_UserManager, Srp Srp <true> databases.conf
WireCompression true false <true> firebird.conf
WireCrypt Required Required <true> firebird.conf
WireCryptPlugin Arc4 ChaCha, Arc4 <true> firebird.conf
IpcName fb4x_tmp_c6444 FirebirdIPI <true> firebird.conf
KeyHolderPlugin [empty] [empty] <false> <null>
LegacyHash true true <false> <null>
LockAcquireSpins 0 0 <false> <null>
LockHashSlots 49999 8191 <true> databases.conf
LockMemSize 30408704 1048576 <true> databases.conf
MaxIdentifierByteLength 31 252 <true> databases.conf
MaxIdentifierCharLength 31 63 <true> databases.conf
MaxUnflushedWriteTime 15 -1 <true> databases.conf
MaxUnflushedWrites 111 -1 <true> databases.conf
MaxUserTraceLogSize 100 10 <true> firebird.conf
OutputRedirectionFile /dev/null /dev/null <false> <null>
ProcessPriorityLevel 0 0 <false> <null>
Providers Engine13, Remote Remote, Engine13, Loopback <true> databases.conf
ReadConsistency false true <true> firebird.conf
Redirection false false <false> <null>
RelaxedAliasChecking false false <false> <null>
RemoteAccess true true <true> databases.conf
RemoteAuxPort 0 0 <false> <null>
RemoteBindAddress <null> <null> <false> <null>
RemoteFileOpenAbility false false <false> <null>
RemotePipeName interbas interbas <false> <null>
RemoteServiceName tmp_fbs_6444 gds_db <true> firebird.conf
RemoteServicePort [MATCHES] 0 <true> firebird.conf
SecurityDatabase tmp_6444 security4.fdb <true> databases.conf
ServerMode SuperClassic Super <true> firebird.conf
SnapshotsMemSize 103809024 65536 <true> databases.conf
StatementTimeout 999 0 <true> databases.conf
TcpLoopbackFastPath false true <true> firebird.conf
TcpNoNagle false true <true> firebird.conf
TcpRemoteBufferSize 5555 8192 <true> firebird.conf
TempBlockSize 5242880 1048576 <true> firebird.conf
TempCacheLimit 9223372035781033984 67108864 <true> databases.conf
TempDirectories [MATCHES] <null> <true> firebird.conf
TempTableDirectory [MATCHES] [empty] <true> databases.conf
TipCacheBlockSize 3145728 4194304 <true> databases.conf
TraceDSQL 0 0 <false> <null>
TracePlugin fbtrace fbtrace <false> <null>
UdfAccess Restrict UDF None <true> firebird.conf
UseFileSystemCache false true <true> firebird.conf
UserManager Legacy_UserManager, Srp Srp <true> databases.conf
WireCompression true false <true> firebird.conf
WireCrypt Required Required <true> firebird.conf
WireCryptPlugin Arc4 ChaCha, Arc4 <true> firebird.conf
Records affected: 71
Records affected: 0
"""
"""
@pytest.mark.version('>=4.0')
@pytest.mark.platform('Linux')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
pytest.skip("Requires change to databases.conf and firebird.conf")
# version: 4.0
@ -472,7 +472,7 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# test_script_2
#---
#
#
# import sys
# import os
# import shutil
@ -480,24 +480,24 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# import datetime
# import tempfile
# import subprocess
#
#
# #--------------------------------------------
#
#
# 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 )):
@ -509,17 +509,17 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# print('Unrecognized type of element:', f_names_list[i], ' - can not be treated as file.')
# print('type(f_names_list[i])=',type(f_names_list[i]))
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# def find_free_port():
# import socket
# from contextlib import closing
# # AF_INET - constant represent the address (and protocol) families, used for the first argument to socket()
# # A pair (host, port) is used for the AF_INET address family, where host is a string representing either a
# # A pair (host, port) is used for the AF_INET address family, where host is a string representing either a
# # hostname in Internet domain notation like 'daring.cwi.nl' or an IPv4 address like '100.50.200.5', and port is an integer.
# # SOCK_STREAM means that it is a TCP socket.
# # SOCK_DGRAM means that it is a UDP socket.
@ -527,39 +527,39 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# s.bind(('', 0))
# s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# return s.getsockname()[1]
#
#
# #--------------------------------------------
#
#
# svc = fdb.services.connect(host='localhost', user=user_name, password=user_password)
# FB_HOME = svc.get_home_directory()
# svc.close()
#
#
# fb_vers = str(db_conn.engine_version)[:1] # character for security.db file: engine = 4.0 --> '4'
# sec_db = os.path.join( FB_HOME, 'security' + fb_vers+ '.fdb')
#
#
# db_conn.close()
#
#
# fdb_test = os.path.join(context['temp_directory'],'tmp_c6444.fdb')
#
#
# dts = datetime.datetime.now().strftime("%y%m%d_%H%M%S")
#
#
# fbconf_cur = os.path.join(FB_HOME, 'firebird.conf')
# fbconf_bak = os.path.join(context['temp_directory'], 'firebird_'+dts+'.bak')
#
#
# dbconf_cur = os.path.join(FB_HOME, 'databases.conf')
# dbconf_bak = os.path.join(context['temp_directory'], 'databases_'+dts+'.bak')
#
#
# shutil.copy2( fbconf_cur, fbconf_bak )
# shutil.copy2( dbconf_cur, dbconf_bak )
#
#
# shutil.copy2( sec_db, fdb_test )
#
#
# TEMP_DIRECTORIES_VALUE = os.path.normpath( os.path.join(FB_HOME, 'examples') )
# TTABLE_DIRECTORY_VALUE = os.path.normpath( context['temp_directory'] )
#
#
# TMP_FREE_PORT = find_free_port()
# #TMP_FREE_PORT = 57456
#
#
# cfg_params_to_change= {
# 'AllowEncryptedSecurityDatabase' : 'true'
# ,'AuthClient' : 'Srp'
@ -599,49 +599,49 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# ,'WireCompression' : 'true'
# ,'WireCrypt' : 'Required'
# ,'WireCryptPlugin' : 'Arc4'
#
#
# }
#
#
# f_fbconf=open( fbconf_cur, 'w')
# for k,v in sorted(cfg_params_to_change.items()):
# f_fbconf.write( ''.join( (k, ' = ', v, '\\n') ) )
# flush_and_close( f_fbconf )
#
#
# alias_data='''
# # Added temporarily for executing test core_6444.fbt
# tmp_6444 = %(fdb_test)s {
#
#
# SecurityDatabase = tmp_6444
#
#
# RemoteAccess = true
# DatabaseGrowthIncrement = 123m
# DataTypeCompatibility = 3.0
# DefaultDbCachePages = 4321
# ClearGTTAtRetaining = 1
#
#
# # Set number of minutes after which idle attachment will be disconnected by the engine. Zero means no timeout is set.
# ConnectionIdleTimeout = 99
#
#
# ExternalFileAccess = Full
#
#
# LockHashSlots = 49999
# LockMemSize = 29m
#
#
# MaxIdentifierByteLength = 31
# MaxIdentifierCharLength = 31
# MaxUnflushedWrites = 111
# MaxUnflushedWriteTime = 15
#
#
# Providers = Engine13, Remote
#
#
# SnapshotsMemSize = 99m
#
#
# # Set number of seconds after which statement execution will be automatically cancelled by the engine. Zero means no timeout is set.
# StatementTimeout = 999
#
#
# TempBlockSize = 3m
# TempCacheLimit = 8589934591G
#
#
# ###############################
# # Appeared since 4.0.0.2436, 21.04.2021; per-database:
# # ~~~~~~~~~~~~~~~~~~~~~~~~~
@ -653,21 +653,21 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# #TempTableDirectory =
# ###############################
# TempTableDirectory = %(TTABLE_DIRECTORY_VALUE)s
#
#
# TipCacheBlockSize = 3m
#
#
# UserManager = Legacy_UserManager, Srp
# }
# ''' % locals()
#
#
# f_dbconf=open( dbconf_cur, 'w')
# f_dbconf.write(alias_data)
# flush_and_close( f_dbconf )
#
#
# p_tmp_fb_pid = subprocess.Popen( [ os.path.join( FB_HOME, 'firebird' ), '-a'] )
# time.sleep(2)
# CONN_STR = 'localhost/%(TMP_FREE_PORT)s:tmp_6444' % locals()
#
#
# sql_text='''
# -- set echo on;
# set wng off;
@ -696,22 +696,22 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# commit;
# grant select on v_config to tmp$c6444;
# commit;
#
#
# connect '%(CONN_STR)s' user %(user_name)s password '%(user_password)s';
#
#
# set count on;
# set width param_name 50;
# set width param_value 64;
# set width param_default 64;
# set width param_source 64;
#
#
# select * from v_config; -- SYSDBA: must see all parameters with their effective values
#
#
# commit;
# connect '%(CONN_STR)s' user tmp$c6444 password '123';
#
#
# select * from v_config; -- NON-PRIVILEGED user: must see 0 rows
#
#
# /*
# -- for debug only:
# set list on;
@ -732,136 +732,136 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# where a.mon$attachment_id = current_connection
# ;
# --*/
#
#
# commit;
# connect '%(CONN_STR)s' user sysdba password 'masterkey';
# drop user tmp$c6444 using plugin Srp;
# commit;
#
#
# ''' % dict(globals(), **locals())
#
#
# f_sql_cmd = open( os.path.join(context['temp_directory'],'tmp_c6444.sql'), 'w')
# f_sql_cmd.write( sql_text )
# flush_and_close( f_sql_cmd )
#
#
# f_sql_log=open( os.path.join(context['temp_directory'],'tmp_c6444.log'), 'w')
# f_sql_err=open( os.path.join(context['temp_directory'],'tmp_c6444.err'), 'w')
#
#
# #subprocess.call( [context['isql_path'], 'localhost/%(TMP_FREE_PORT)s:tmp_6444' % locals(), '-i', f_sql_cmd.name], stdout=f_sql_log, stderr=f_sql_err )
# subprocess.call( [context['isql_path'], '-q', '-pag', '999999', '-i', f_sql_cmd.name, '-user', 'SYSDBA'], stdout=f_sql_log, stderr=f_sql_err )
#
#
# flush_and_close( f_sql_log )
# flush_and_close( f_sql_err )
#
#
# if p_tmp_fb_pid:
# p_tmp_fb_pid.terminate()
#
#
# shutil.move( fbconf_bak, fbconf_cur )
# shutil.move( dbconf_bak, dbconf_cur )
#
#
# with open(f_sql_err.name, 'r') as f:
# for line in f:
# if line.split():
# print('UNEXPECTED STDERR: ' + line)
#
#
# with open(f_sql_log.name, 'r') as f:
# for line in f:
# if line.split():
# print(line)
#
#
#
#
# # Cleanup
# ##########
# time.sleep(1)
# cleanup( ( f_sql_log, f_sql_err, f_sql_cmd, fdb_test ) )
#
#
#
#
#---
#act_2 = python_act('db_2', test_script_2, substitutions=substitutions_2)
act_2 = python_act('db_2', substitutions=substitutions_2)
expected_stdout_2 = """
PARAM_NAME PARAM_VALUE PARAM_DEFAULT PARAM_IS_SET PARAM_SOURCE
================================================== ================================================================ ================================================================ ============ ================================================================
AllowEncryptedSecurityDatabase true false <true> firebird.conf
AuditTraceConfigFile [empty] [empty] <false> <null>
AuthClient Srp Srp256, Srp, Win_Sspi, Legacy_Auth <true> firebird.conf
AuthServer Legacy_Auth, Srp Srp256 <true> firebird.conf
BugcheckAbort true false <true> firebird.conf
ClearGTTAtRetaining true false <true> databases.conf
ClientBatchBuffer 262144 131072 <true> firebird.conf
ConnectionIdleTimeout 99 0 <true> databases.conf
ConnectionTimeout 123 180 <true> firebird.conf
CpuAffinityMask 0 0 <false> <null>
DataTypeCompatibility 3.0 <null> <true> databases.conf
DatabaseAccess None Full <true> firebird.conf
DatabaseGrowthIncrement 128974848 134217728 <true> databases.conf
DeadlockTimeout 15 10 <true> firebird.conf
DefaultDbCachePages 4321 2048 <true> databases.conf
DefaultTimeZone -7:00 <null> <true> firebird.conf
DummyPacketInterval 11 0 <true> firebird.conf
EventMemSize 12321 65536 <true> firebird.conf
ExtConnPoolLifeTime 1212 7200 <true> firebird.conf
ExtConnPoolSize 123 0 <true> firebird.conf
ExternalFileAccess Full None <true> databases.conf
FileSystemCacheSize 0 0 <false> <null>
FileSystemCacheThreshold 9223372035781033984 65536 <true> firebird.conf
GCPolicy combined combined <false> <null>
GuardianOption 1 1 <false> <null>
IPv6V6Only true false <true> firebird.conf
PARAM_NAME PARAM_VALUE PARAM_DEFAULT PARAM_IS_SET PARAM_SOURCE
================================================== ================================================================ ================================================================ ============ ================================================================
AllowEncryptedSecurityDatabase true false <true> firebird.conf
AuditTraceConfigFile [empty] [empty] <false> <null>
AuthClient Srp Srp256, Srp, Win_Sspi, Legacy_Auth <true> firebird.conf
AuthServer Legacy_Auth, Srp Srp256 <true> firebird.conf
BugcheckAbort true false <true> firebird.conf
ClearGTTAtRetaining true false <true> databases.conf
ClientBatchBuffer 262144 131072 <true> firebird.conf
ConnectionIdleTimeout 99 0 <true> databases.conf
ConnectionTimeout 123 180 <true> firebird.conf
CpuAffinityMask 0 0 <false> <null>
DataTypeCompatibility 3.0 <null> <true> databases.conf
DatabaseAccess None Full <true> firebird.conf
DatabaseGrowthIncrement 128974848 134217728 <true> databases.conf
DeadlockTimeout 15 10 <true> firebird.conf
DefaultDbCachePages 4321 2048 <true> databases.conf
DefaultTimeZone -7:00 <null> <true> firebird.conf
DummyPacketInterval 11 0 <true> firebird.conf
EventMemSize 12321 65536 <true> firebird.conf
ExtConnPoolLifeTime 1212 7200 <true> firebird.conf
ExtConnPoolSize 123 0 <true> firebird.conf
ExternalFileAccess Full None <true> databases.conf
FileSystemCacheSize 0 0 <false> <null>
FileSystemCacheThreshold 9223372035781033984 65536 <true> firebird.conf
GCPolicy combined combined <false> <null>
GuardianOption 1 1 <false> <null>
IPv6V6Only true false <true> firebird.conf
InlineSortThreshold 8192 1000 <true> firebird.conf
IpcName fb4x_tmp_c6444 FIREBIRD <true> firebird.conf
KeyHolderPlugin [empty] [empty] <false> <null>
LegacyHash true true <false> <null>
LockAcquireSpins 0 0 <false> <null>
LockHashSlots 49999 8191 <true> databases.conf
LockMemSize 30408704 1048576 <true> databases.conf
MaxIdentifierByteLength 31 252 <true> databases.conf
MaxIdentifierCharLength 31 63 <true> databases.conf
MaxUnflushedWriteTime 15 5 <true> databases.conf
MaxUnflushedWrites 111 100 <true> databases.conf
MaxUserTraceLogSize 100 10 <true> firebird.conf
OutputRedirectionFile nul nul <false> <null>
ProcessPriorityLevel 0 0 <false> <null>
Providers Engine13, Remote Remote, Engine13, Loopback <true> databases.conf
ReadConsistency false true <true> firebird.conf
Redirection false false <false> <null>
RelaxedAliasChecking false false <false> <null>
RemoteAccess true true <true> databases.conf
RemoteAuxPort 0 0 <false> <null>
RemoteBindAddress <null> <null> <false> <null>
RemoteFileOpenAbility false false <false> <null>
RemotePipeName interbas interbas <false> <null>
RemoteServiceName tmp_fbs_6444 gds_db <true> firebird.conf
RemoteServicePort [MATCHES] 0 <true> firebird.conf
SecurityDatabase tmp_6444 security4.fdb <true> databases.conf
ServerMode SuperClassic Super <true> firebird.conf
SnapshotsMemSize 103809024 65536 <true> databases.conf
StatementTimeout 999 0 <true> databases.conf
TcpLoopbackFastPath false true <true> firebird.conf
TcpNoNagle false true <true> firebird.conf
TcpRemoteBufferSize 5555 8192 <true> firebird.conf
TempBlockSize 5242880 1048576 <true> firebird.conf
TempCacheLimit 9223372035781033984 67108864 <true> databases.conf
TempDirectories [MATCHES] <null> <true> firebird.conf
TempTableDirectory [MATCHES] [empty] <true> databases.conf
TipCacheBlockSize 3145728 4194304 <true> databases.conf
TraceDSQL 0 0 <false> <null>
TracePlugin fbtrace fbtrace <false> <null>
UdfAccess Restrict UDF None <true> firebird.conf
UseFileSystemCache false true <true> firebird.conf
UserManager Legacy_UserManager, Srp Srp <true> databases.conf
WireCompression true false <true> firebird.conf
WireCrypt Required Required <true> firebird.conf
WireCryptPlugin Arc4 ChaCha, Arc4 <true> firebird.conf
IpcName fb4x_tmp_c6444 FIREBIRD <true> firebird.conf
KeyHolderPlugin [empty] [empty] <false> <null>
LegacyHash true true <false> <null>
LockAcquireSpins 0 0 <false> <null>
LockHashSlots 49999 8191 <true> databases.conf
LockMemSize 30408704 1048576 <true> databases.conf
MaxIdentifierByteLength 31 252 <true> databases.conf
MaxIdentifierCharLength 31 63 <true> databases.conf
MaxUnflushedWriteTime 15 5 <true> databases.conf
MaxUnflushedWrites 111 100 <true> databases.conf
MaxUserTraceLogSize 100 10 <true> firebird.conf
OutputRedirectionFile nul nul <false> <null>
ProcessPriorityLevel 0 0 <false> <null>
Providers Engine13, Remote Remote, Engine13, Loopback <true> databases.conf
ReadConsistency false true <true> firebird.conf
Redirection false false <false> <null>
RelaxedAliasChecking false false <false> <null>
RemoteAccess true true <true> databases.conf
RemoteAuxPort 0 0 <false> <null>
RemoteBindAddress <null> <null> <false> <null>
RemoteFileOpenAbility false false <false> <null>
RemotePipeName interbas interbas <false> <null>
RemoteServiceName tmp_fbs_6444 gds_db <true> firebird.conf
RemoteServicePort [MATCHES] 0 <true> firebird.conf
SecurityDatabase tmp_6444 security4.fdb <true> databases.conf
ServerMode SuperClassic Super <true> firebird.conf
SnapshotsMemSize 103809024 65536 <true> databases.conf
StatementTimeout 999 0 <true> databases.conf
TcpLoopbackFastPath false true <true> firebird.conf
TcpNoNagle false true <true> firebird.conf
TcpRemoteBufferSize 5555 8192 <true> firebird.conf
TempBlockSize 5242880 1048576 <true> firebird.conf
TempCacheLimit 9223372035781033984 67108864 <true> databases.conf
TempDirectories [MATCHES] <null> <true> firebird.conf
TempTableDirectory [MATCHES] [empty] <true> databases.conf
TipCacheBlockSize 3145728 4194304 <true> databases.conf
TraceDSQL 0 0 <false> <null>
TracePlugin fbtrace fbtrace <false> <null>
UdfAccess Restrict UDF None <true> firebird.conf
UseFileSystemCache false true <true> firebird.conf
UserManager Legacy_UserManager, Srp Srp <true> databases.conf
WireCompression true false <true> firebird.conf
WireCrypt Required Required <true> firebird.conf
WireCryptPlugin Arc4 ChaCha, Arc4 <true> firebird.conf
Records affected: 71
Records affected: 0
"""
"""
@pytest.mark.version('>=4.0')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_2(db_2):
pytest.fail("Test not IMPLEMENTED")
def test_2(act_2: Action):
pytest.skip("Requires change to databases.conf and firebird.conf")

View File

@ -2,44 +2,49 @@
#
# id: bugs.core_6458
# title: Regression: Cancel Query function no longer works
# decription:
# decription:
# We create .sql script with 'heavy query' that for sure will run more than several seconds.
# Then we launch asynchronous ISQL process to perform this query and take small pause for 1-2 second.
# After this we send signal CTRL_C_EVENT for emulating interruption that is done by pressing Ctrl-C.
# Then we wait for process finish (call wait() method) - this is necessary if ISQL will continue
# without interruprion (i.e. if something will be broken again).
#
#
# When method wait() will return control back, we can obtain info about whether child process was
# terminated or no (using method poll()). If yes (expected) then it must return 1.
#
#
# Finally, we check ISQL logs for STDOUT and STDERR. They must be as follows:
# * STDOUT -- must be empty
# * STDERR -- must contain (at least) two phrases:
# 1. Statement failed, SQLSTATE = HY008
# 2. operation was cancelled
#
#
# ::: NB :::
# Windows only: subprocess.Popen() must have argument: creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
# Otherwise we can not send signal Ctrl_C_EVENT to the child process.
# Linux: parameter 'creationflags' must be 0, signal.SIGINT is used instead of Ctrl_C_EVENT.
#
#
# See: https://docs.python.org/2.7/library/subprocess.html
#
#
# Confirmed bug on 4.0.0.2307: query could NOT be interrupted and we had to wait until it completed.
# Checked on 4.0.0.2324 (SS/CS): works OK, query can be interrupted via sending Ctrl-C signal.
#
#
# 16.04.2021. Adapted for run both on Windows and Linux. Checked on:
# Windows: 4.0.0.2422 SS/CS
# Linux: 4.0.0.2422 SS/CS
#
#
#
#
# tracker_id: CORE-6458
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
import re
import signal
import subprocess
import time
from pathlib import Path
from firebird.qa import db_factory, python_act, Action, temp_file
# version: 4.0
# resources: None
@ -59,39 +64,39 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import datetime
# import time
# import re
#
#
# from fdb import services
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# db_conn.close()
#
#
# FB_HOME = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory()
# FB_BINS = os.path.join( FB_HOME, 'bin'+os.sep if platform.system() == 'Linux' else '' )
#
#
#
#
# #--------------------------------------------
# def showtime():
# global datetime
# return ''.join( (datetime.datetime.now().strftime("%H:%M:%S.%f")[:11],'.') )
# #--------------------------------------------
#
#
# 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()
# if file_handle.mode not in ('r', 'rb'):
# # 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 )):
@ -101,14 +106,14 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# print('ERROR: can not remove file ' + f_names_list[i])
# exit(1)
# #-------------------------------------------------
#
#
# f_sql_cmd = open( os.path.join(context['temp_directory'],'tmp-c6458.sql'),'w')
# f_sql_cmd.write("set list on; select count(*) as LONG_QUERY_RESULT from (select 1 i from rdb$types a,rdb$types b,rdb$types c);")
# flush_and_close( f_sql_cmd )
#
#
# f_sql_log = open( os.path.splitext(f_sql_cmd.name)[0] + '.log','w')
# f_sql_err = open( os.path.splitext(f_sql_cmd.name)[0] + '.err','w')
#
#
# try:
# # NB: subprocess.CREATE_NEW_PROCESS_GROUP is MANDATORY FOR SENDING CTRL_C SIGNAL on Windows:
# p_flag = 0 if platform.system() == 'Linux' else subprocess.CREATE_NEW_PROCESS_GROUP
@ -127,42 +132,74 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# flush_and_close( f_sql_log )
# flush_and_close( f_sql_err )
# #--------------------------------------------------
#
#
# with open(f_sql_log.name) as f:
# for line in f:
# if line.split():
# print('UNEXPECTED STDOUT: ', line)
#
#
# allowed_patterns = (
# re.compile('.*SQLSTATE\\s+=\\s+HY008', re.IGNORECASE)
# ,re.compile('operation\\s+(was\\s+)?cancelled', re.IGNORECASE)
# )
#
#
# with open(f_sql_err.name) as f:
# for line in f:
# if line.split():
# match2some = filter( None, [ p.search(line) for p in allowed_patterns ] )
# if match2some:
# print( (' '.join(line.split()).lower()) )
#
#
# # cleanup
# #########
# time.sleep(1)
# cleanup( [ i.name for i in (f_sql_cmd, f_sql_log, f_sql_err) ] )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
Was ISQL process terminated ? => 1
statement failed, sqlstate = hy008
operation was cancelled
"""
"""
heavy_script_1 = temp_file('heavy_script.sql')
heavy_stdout_1 = temp_file('heavy_script.out')
heavy_stderr_1 = temp_file('heavy_script.err')
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, heavy_script_1: Path, heavy_stdout_1: Path, heavy_stderr_1: Path,
capsys):
heavy_script_1.write_text("set list on; select count(*) as LONG_QUERY_RESULT from (select 1 i from rdb$types a,rdb$types b,rdb$types c);")
with open(heavy_stdout_1, mode='w') as heavy_out, open(heavy_stderr_1, mode='w') as heavy_err:
# NB: subprocess.CREATE_NEW_PROCESS_GROUP is MANDATORY FOR SENDING CTRL_C SIGNAL on Windows
flags = 0 if act_1.platform == 'Linux' else subprocess.CREATE_NEW_PROCESS_GROUP
p_heavy_sql = subprocess.Popen([act_1.vars['isql'], '-i', str(heavy_script_1),
'-user', act_1.db.user,
'-password', act_1.db.password, act_1.db.dsn],
stdout=heavy_out, stderr=heavy_err,
creationflags=flags)
try:
time.sleep(4)
p_heavy_sql.send_signal(signal.SIGINT if act_1.platform == 'Linux' else signal.CTRL_C_EVENT)
p_heavy_sql.wait()
print('Was ISQL process terminated ? => ', p_heavy_sql.poll())
except Exception as e:
print(e)
#
for line in heavy_stdout_1.read_text().splitlines():
if line.split():
print('UNEXPECTED STDOUT: ', line)
allowed_patterns = [re.compile('.*SQLSTATE\\s+=\\s+HY008', re.IGNORECASE),
re.compile('operation\\s+(was\\s+)?cancelled', re.IGNORECASE)]
for line in heavy_stderr_1.read_text().splitlines():
if line.split():
if act_1.match_any(line, allowed_patterns):
print(' '.join(line.split()).lower())
# Check
act_1.expected_stdout = expected_stdout_1
act_1.stdout = capsys.readouterr().out
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,7 +2,7 @@
#
# id: bugs.core_6466
# title: Comments before the first line of code are removed (when extract metadata)
# decription:
# decription:
# Lot of comments (multi-line blocks) are inserted before each clause/token of created SP
# (in its declaration of name, input and output parameters, sections of variables and after
# final 'end').
@ -11,20 +11,20 @@
# First comment _after_ 'AS' clause (and before 1st 'declare variable' statement) *must*
# be preserved.
# Comment after final 'end' of procedure must also be preserved.
#
#
# Confirmed bug on:
# * 4.0.0.2353 - final comment ('950' in this script) was not stored;
# * 3.0.8.33401 - comments before first declaration of variable ('900') and after final
# 'end' ('950') were not stored.
# Checked on 4.0.0.2365, 3.0.8.33415 -- all fine.
#
#
# tracker_id: CORE-6466
# min_versions: ['3.0.8']
# versions: 3.0.8
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 3.0.8
# resources: None
@ -37,7 +37,7 @@ init_script_1 = """
/*
comment-100
*/
(
(
/*
comment-150
*/
@ -57,11 +57,11 @@ init_script_1 = """
/*
comment-300
*/
returns
returns
/*
comment-400
*/
(
(
/*
comment-500
*/
@ -112,18 +112,19 @@ init_script_1 = """
^
commit
^
set term ;^
"""
set term ;^
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# runProgram('isql', [dsn, '-x', '-user', user_name, '-pas', user_password], )
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
comment-900
@ -132,11 +133,12 @@ expected_stdout_1 = """
comment-930
comment-940
comment-950
"""
"""
@pytest.mark.version('>=3.0.8')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action):
act_1.expected_stdout = expected_stdout_1
act_1.extract_meta()
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,13 +2,13 @@
#
# id: bugs.core_6469
# title: Provide ability to see in the trace log actions related to session management (e.g. ALTER SESSION RESET)
# decription:
# decription:
# Test verifies management statements which are specified in doc/sql.extensions/README.management_statements_psql.md
# We launch trace session before ISQL and stop it after its finish.
# Every management statement is expected to be found in the trace log.
#
#
# ATTENTION: TWO SEPARATE BRANCHES present in this test for different OS.
#
#
# NOTES FOR WINDOWS
# #################
# Statement 'SET TRUSTED ROLE' is verified for appearance in the trace log.
@ -19,14 +19,14 @@
# * Two mappings are created (both uses plugin win_sspi):
# ** from any user to user;
# ** from predefined_group domain_any_rid_admins to role <role_to_be_trusted>
#
#
# Connect to database should be done in form: CONNECT '<computername>:<our_database>' role <role_to_be_trusted>',
# and after this we can user 'SET TRUSTED ROLE' statement (see also: core_5887-trusted_role.fbt).
#
#
# ::: NOTE :::
# We have to remove OS-veriable 'ISC_USER' before any check of trusted role.
# This variable could be set by other .fbts which was performed before current within batch mode (i.e. when fbt_run is called from <rundaily>)
#
#
# NOTES FOR LINUX
# ###############
# Trusted role is not verified for this case.
@ -37,18 +37,21 @@
# NO such trouble in the Classic.
# The reason currently (03-mar-2021) remains unknown.
# Sent letter to Alex et al, 03-mar-2021.
#
#
# Checked on:
# * Windows: 4.0.0.2235, 4.0.0.2377 (both on SS/CS).
# * Linux: 4.0.0.2377 SS/CS.
#
#
# tracker_id: CORE-6469
# min_versions: ['4.0']
# versions: 4.0, 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
import re
import socket
import getpass
from firebird.qa import db_factory, python_act, Action, role_factory, Role
# version: 4.0
# resources: None
@ -61,7 +64,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import re
# import subprocess
@ -71,7 +74,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# import re
# from fdb import services
# from subprocess import Popen
#
#
# # REMOVING OS-VARIABLE ISC_USER IS MANDATORY HERE !!!
# # This variable could be set by other .fbts which was performed before current within batch mode (i.e. when fbt_run is called from <rundaily>)
# # NB: os.unsetenv('ISC_USER') actually does NOT affect on content of os.environ dictionary, see: https://docs.python.org/2/library/os.html
@ -81,34 +84,34 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# del os.environ["ISC_USER"]
# except KeyError as e:
# pass
#
#
#
#
# THIS_DBA_USER=user_name
# THIS_DBA_PSWD=user_password
#
#
# THIS_COMPUTER_NAME = socket.gethostname()
# CURRENT_WIN_ADMIN = getpass.getuser()
#
#
# THIS_FDB = 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 f in f_names_list:
@ -119,12 +122,12 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# sql='''
# set bail on;
# set list on;
@ -139,21 +142,21 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# ^
# set term ;^
# commit;
#
#
# create role TMP$R6469;
# grant tmp$r6469 to "%(THIS_COMPUTER_NAME)s\\%(CURRENT_WIN_ADMIN)s";
# commit;
#
#
# -- We have to use here "create mapping trusted_auth ... from any user to user" otherwise get
# -- Statement failed, SQLSTATE = 28000 /Missing security context for C:\\FBTESTING\\QA\\MISC\\C5887.FDB
# -- on connect statement which specifies COMPUTERNAME:USERNAME instead path to DB:
# create or alter mapping trusted_auth using plugin win_sspi from any user to user;
#
#
# -- We have to use here "create mapping win_admins ... DOMAIN_ANY_RID_ADMINS" otherwise get
# -- Statement failed, SQLSTATE = 0P000 / Your attachment has no trusted role
# create or alter mapping win_admins using plugin win_sspi from predefined_group domain_any_rid_admins to role tmp$r6469;
# commit;
#
#
# -- We have to GRANT ROLE, even to SYSDBA. Otherwise:
# -- Statement failed, SQLSTATE = 0P000
# -- Role TMP$R6469 is invalid or unavailable
@ -162,10 +165,10 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# show role;
# show grants;
# show mapping;
#
#
# set autoddl off;
# commit;
#
#
# -- Following management statements are taken from
# -- doc/sql.extensions/README.management_statements_psql.md:
# -- ########################################################
@ -178,25 +181,25 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# set time zone 'America/Sao_Paulo';
# set role tmp$r6469;
# commit;
#
#
# connect '%(THIS_COMPUTER_NAME)s:%(THIS_FDB)s' role tmp$r6469;
#
#
# select mon$user,mon$role,mon$auth_method from mon$attachments where mon$attachment_id = current_connection;
# commit;
#
#
# set trusted role;
# commit;
#
#
# connect 'localhost:%(THIS_FDB)s' user %(THIS_DBA_USER)s password '%(THIS_DBA_PSWD)s';
# drop mapping trusted_auth;
# drop mapping win_admins;
# commit;
# ''' % locals()
#
#
# f_sql_cmd=open( os.path.join(context['temp_directory'],'tmp_c6469_cmd.sql'), 'w')
# f_sql_cmd.write(sql)
# flush_and_close( f_sql_cmd )
#
#
# txt = '''# Generated auto, do not edit!
# database=%[\\\\\\\\/]security?.fdb
# {
@ -212,28 +215,28 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# log_statement_finish = true
# }
# '''
#
#
# f_trc_cfg=open( os.path.join(context['temp_directory'],'tmp_c6469_trc.cfg'), 'w')
# f_trc_cfg.write(txt)
# flush_and_close( f_trc_cfg )
#
#
# # ##############################################################
# # S T A R T T R A C E i n S E P A R A T E P R O C E S S
# # ##############################################################
#
#
# f_trc_log=open( os.path.join(context['temp_directory'],'tmp_c6469_trc.log'), "w")
# f_trc_err=open( os.path.join(context['temp_directory'],'tmp_c6469_trc.err'), "w")
#
#
# p_trace = Popen( [ context['fbsvcmgr_path'], 'localhost:service_mgr', 'user', user_name, 'password', user_password, 'action_trace_start', 'trc_cfg', f_trc_cfg.name],
# stdout=f_trc_log,
# stderr=f_trc_err
# )
#
#
# time.sleep(1)
#
#
# f_isql_log=open( os.path.join(context['temp_directory'],'tmp_c6469_run.log'), 'w')
# f_isql_err=open( os.path.join(context['temp_directory'],'tmp_c6469_run.err'), 'w')
#
#
# ######################
# # S T A R T I S Q L
# ######################
@ -244,17 +247,17 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# )
# flush_and_close( f_isql_log )
# flush_and_close( f_isql_err )
#
#
#
#
# # ####################################################
# # G E T A C T I V E T R A C E S E S S I O N I D
# # ####################################################
# # Save active trace session info into file for further parsing it and obtain session_id back (for stop):
#
#
# f_trc_lst = open( os.path.join(context['temp_directory'],'tmp_c6469_trc_session_idle.lst'), 'w')
# subprocess.call([context['fbsvcmgr_path'], 'localhost:service_mgr', 'user', user_name, 'password', user_password, 'action_trace_list' ], stdout=f_trc_lst)
# flush_and_close( f_trc_lst )
#
#
# trcssn=0
# with open( f_trc_lst.name,'r') as f:
# for line in f:
@ -265,10 +268,10 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# trcssn=word
# i=i+1
# break
#
#
# # Result: `trcssn` is ID of active trace session. Now we have to terminate it:
#
#
#
#
# # ####################################################
# # S E N D R E Q U E S T T R A C E T O S T O P
# # ####################################################
@ -278,12 +281,12 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# fn_nul.close()
# # DO NOT REMOVE THIS LINE:
# time.sleep(1)
#
#
# p_trace.terminate()
# flush_and_close( f_trc_log )
# flush_and_close( f_trc_err )
#
#
#
#
# # Following files must be EMPTY:
# #################
# f_list=(f_trc_err,f_isql_err,)
@ -293,8 +296,8 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# with open( f_name,'r') as f:
# for line in f:
# print("Unexpected TRCERR, file "+f_name+": "+line)
#
#
#
#
# allowed_patterns = (
# re.compile('alter session reset', re.IGNORECASE)
# ,re.compile('set session idle timeout', re.IGNORECASE)
@ -306,22 +309,23 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# ,re.compile('set role', re.IGNORECASE)
# ,re.compile('set trusted role', re.IGNORECASE)
# )
#
#
# with open(f_trc_log.name) as f:
# for line in f:
# if line.split():
# match2some = filter( None, [ p.search(line) for p in allowed_patterns ] )
# if match2some:
# print( (' '.join(line.split()).lower()) )
#
#
# # CLEANUP
# #########
# time.sleep(1)
# cleanup( (f_trc_cfg, f_trc_lst, f_trc_log, f_trc_err, f_sql_cmd, f_isql_log, f_isql_err ) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
alter session reset
@ -333,13 +337,102 @@ expected_stdout_1 = """
set time zone 'america/sao_paulo'
set role tmp$r6469
set trusted role
"""
"""
trace_1 = ['log_initfini = false',
'log_statement_finish = true',
'log_errors = true',
'time_threshold = 0',
]
patterns_1 = [re.compile('alter session reset', re.IGNORECASE),
re.compile('set session idle timeout', re.IGNORECASE),
re.compile('set statement timeout', re.IGNORECASE),
re.compile('set bind of decfloat to double precision', re.IGNORECASE),
re.compile('set decfloat round ceiling', re.IGNORECASE),
re.compile('set decfloat traps to Division_by_zero', re.IGNORECASE),
re.compile('set time zone', re.IGNORECASE),
re.compile('set role', re.IGNORECASE),
re.compile('set trusted role', re.IGNORECASE)]
test_role_1 = role_factory('db_2', name='TMP$R6469')
def run_script(act: Action):
__tracebackhide__ = True
THIS_COMPUTER_NAME = socket.gethostname()
CURRENT_WIN_ADMIN = getpass.getuser()
script = f"""
set bail on;
set list on;
set echo on;
grant tmp$r6469 to "{THIS_COMPUTER_NAME}\\{CURRENT_WIN_ADMIN}";
commit;
-- We have to use here "create mapping trusted_auth ... from any user to user" otherwise get
-- Statement failed, SQLSTATE = 28000 /Missing security context for C:\\FBTESTING\\QA\\MISC\\C5887.FDB
-- on connect statement which specifies COMPUTERNAME:USERNAME instead path to DB:
create or alter mapping trusted_auth using plugin win_sspi from any user to user;
-- We have to use here "create mapping win_admins ... DOMAIN_ANY_RID_ADMINS" otherwise get
-- Statement failed, SQLSTATE = 0P000 / Your attachment has no trusted role
create or alter mapping win_admins using plugin win_sspi from predefined_group domain_any_rid_admins to role tmp$r6469;
commit;
-- We have to GRANT ROLE, even to SYSDBA. Otherwise:
-- Statement failed, SQLSTATE = 0P000
-- Role TMP$R6469 is invalid or unavailable
grant TMP$R6469 to sysdba;
commit;
show role;
show grants;
show mapping;
set autoddl off;
commit;
-- Following management statements are taken from
-- doc/sql.extensions/README.management_statements_psql.md:
-- ########################################################
alter session reset;
set session idle timeout 1800 second;
set statement timeout 190 second;
set bind of decfloat to double precision;
set decfloat round ceiling;
set decfloat traps to Division_by_zero;
set time zone 'America/Sao_Paulo';
set role tmp$r6469;
commit;
connect '{THIS_COMPUTER_NAME}:{act.db.db_path}' role tmp$r6469;
#
select mon$user,mon$role,mon$auth_method from mon$attachments where mon$attachment_id = current_connection;
commit;
#
set trusted role;
commit;
#
connect '{act.db.dsn}' user {act.db.user} password '{act.db.password}';
drop mapping trusted_auth;
drop mapping win_admins;
commit;
"""
act.isql(switches=['-n'], input=script)
@pytest.mark.version('>=4.0')
@pytest.mark.platform('Windows')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, test_role_1: Role, capsys):
with act_1.trace(db_events=trace_1):
run_script()
# process trace
for line in act_1.trace_log:
if line.split():
if act_1.match_any(line, patterns_1):
print(' '.join(line.split()).lower())
# Check
act_1.expected_stdout = expected_stdout_2
act_1.stdout = capsys.readouterr().out
assert act_1.clean_stdout == act_1.clean_expected_stdout
# version: 4.0
@ -353,7 +446,7 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# test_script_2
#---
#
#
# import os
# import re
# import subprocess
@ -363,7 +456,7 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# import re
# from fdb import services
# from subprocess import Popen
#
#
# # REMOVING OS-VARIABLE ISC_USER IS MANDATORY HERE !!!
# # This variable could be set by other .fbts which was performed before current within batch mode (i.e. when fbt_run is called from <rundaily>)
# # NB: os.unsetenv('ISC_USER') actually does NOT affect on content of os.environ dictionary, see: https://docs.python.org/2/library/os.html
@ -373,34 +466,34 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# del os.environ["ISC_USER"]
# except KeyError as e:
# pass
#
#
#
#
# THIS_DBA_USER=user_name
# THIS_DBA_PSWD=user_password
#
#
# THIS_COMPUTER_NAME = socket.gethostname()
# CURRENT_WIN_ADMIN = getpass.getuser()
#
#
# THIS_FDB = 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 f in f_names_list:
@ -411,12 +504,12 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
# sql='''
# set bail on;
# set list on;
@ -430,21 +523,21 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# ^
# set term ;^
# commit;
#
#
# create role TMP$R6469;
# commit;
#
#
# -- We have to GRANT ROLE, even to SYSDBA. Otherwise:
# -- Statement failed, SQLSTATE = 0P000
# -- Role TMP$R6469 is invalid or unavailable
# grant TMP$R6469 to sysdba;
# commit;
#
#
# -- connect 'localhost:%(THIS_FDB)s' user %(THIS_DBA_USER)s password '%(THIS_DBA_PSWD)s';
# select current_user as who_ami, current_role as whats_my_role from rdb$database;
# set autoddl off;
# commit;
#
#
# -- Following management statements are taken from
# -- doc/sql.extensions/README.management_statements_psql.md:
# -- ########################################################
@ -460,11 +553,11 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# commit;
# select 'Completed' as msg from rdb$database;
# ''' % locals()
#
#
# f_sql_cmd=open( os.path.join(context['temp_directory'],'tmp_c6469_cmd.sql'), 'w')
# f_sql_cmd.write(sql)
# flush_and_close( f_sql_cmd )
#
#
# txt = '''# Generated auto, do not edit!
# database=%[\\\\\\\\/]security?.fdb
# {
@ -481,28 +574,28 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# log_statement_finish = true
# }
# '''
#
#
# f_trc_cfg=open( os.path.join(context['temp_directory'],'tmp_c6469_trc.cfg'), 'w')
# f_trc_cfg.write(txt)
# flush_and_close( f_trc_cfg )
#
#
# # ##############################################################
# # S T A R T T R A C E i n S E P A R A T E P R O C E S S
# # ##############################################################
#
#
# f_trc_log=open( os.path.join(context['temp_directory'],'tmp_c6469_trc.log'), "w")
# f_trc_err=open( os.path.join(context['temp_directory'],'tmp_c6469_trc.err'), "w")
#
#
# p_trace = Popen( [ context['fbsvcmgr_path'], 'localhost:service_mgr', 'user', user_name, 'password', user_password, 'action_trace_start', 'trc_cfg', f_trc_cfg.name],
# stdout=f_trc_log,
# stderr=f_trc_err
# )
#
#
# time.sleep(1)
#
#
# f_isql_log=open( os.path.join(context['temp_directory'],'tmp_c6469_run.log'), 'w')
# f_isql_err=open( os.path.join(context['temp_directory'],'tmp_c6469_run.err'), 'w')
#
#
# ######################
# # S T A R T I S Q L
# ######################
@ -513,19 +606,19 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# )
# flush_and_close( f_isql_log )
# flush_and_close( f_isql_err )
#
#
# # 04.03.2021: do NOT remove this delay!
# time.sleep(1)
#
#
# # ####################################################
# # G E T A C T I V E T R A C E S E S S I O N I D
# # ####################################################
# # Save active trace session info into file for further parsing it and obtain session_id back (for stop):
#
#
# f_trc_lst = open( os.path.join(context['temp_directory'],'tmp_c6469_trc_session_idle.lst'), 'w')
# subprocess.call([context['fbsvcmgr_path'], 'localhost:service_mgr', 'user', user_name, 'password', user_password, 'action_trace_list' ], stdout=f_trc_lst)
# flush_and_close( f_trc_lst )
#
#
# trcssn=0
# with open( f_trc_lst.name,'r') as f:
# for line in f:
@ -536,10 +629,10 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# trcssn=word
# i=i+1
# break
#
#
# # Result: `trcssn` is ID of active trace session. Now we have to terminate it:
#
#
#
#
# # ####################################################
# # S E N D R E Q U E S T T R A C E T O S T O P
# # ####################################################
@ -549,12 +642,12 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# fn_nul.close()
# # DO NOT REMOVE THIS LINE:
# time.sleep(1)
#
#
# p_trace.terminate()
# flush_and_close( f_trc_log )
# flush_and_close( f_trc_err )
#
#
#
#
# # Following files must be EMPTY:
# #################
# f_list=(f_trc_err,f_isql_err,)
@ -564,8 +657,8 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# with open( f_name,'r') as f:
# for line in f:
# print("Unexpected TRCERR, file "+f_name+": "+line)
#
#
#
#
# allowed_patterns = (
# re.compile('alter session reset', re.IGNORECASE)
# ,re.compile('set session idle timeout', re.IGNORECASE)
@ -576,22 +669,23 @@ db_2 = db_factory(sql_dialect=3, init=init_script_2)
# ,re.compile('set time zone', re.IGNORECASE)
# ,re.compile('set role', re.IGNORECASE)
# )
#
#
# with open(f_trc_log.name) as f:
# for line in f:
# if line.split():
# match2some = filter( None, [ p.search(line) for p in allowed_patterns ] )
# if match2some:
# print( (' '.join(line.split()).lower()) )
#
#
# # CLEANUP
# #########
# time.sleep(1)
# cleanup( (f_trc_cfg, f_trc_lst, f_trc_log, f_trc_err, f_sql_cmd, f_isql_log, f_isql_err ) )
#
#
#
#
#---
#act_2 = python_act('db_2', test_script_2, substitutions=substitutions_2)
act_2 = python_act('db_2', substitutions=substitutions_2)
expected_stdout_2 = """
alter session reset
@ -602,12 +696,67 @@ expected_stdout_2 = """
set decfloat traps to division_by_zero
set time zone 'america/sao_paulo'
set role tmp$r6469
"""
"""
test_script_2 = """
set bail on;
set list on;
-- We have to GRANT ROLE, even to SYSDBA. Otherwise:
-- Statement failed, SQLSTATE = 0P000
-- Role TMP$R6469 is invalid or unavailable
grant TMP$R6469 to sysdba;
commit;
select current_user as who_ami, current_role as whats_my_role from rdb$database;
set autoddl off;
commit;
-- Following management statements are taken from
-- doc/sql.extensions/README.management_statements_psql.md:
-- ########################################################
set echo on;
alter session reset;
set session idle timeout 1800 second;
set statement timeout 190 second;
set bind of decfloat to double precision;
set decfloat round ceiling;
set decfloat traps to Division_by_zero;
set time zone 'America/Sao_Paulo';
set role tmp$r6469;
commit;
select 'Completed' as msg from rdb$database;
"""
trace_2 = ['log_initfini = false',
'log_connections = true',
'log_statement_finish = true',
'log_errors = true',
'time_threshold = 0',
]
patterns_2 = [re.compile('alter session reset', re.IGNORECASE),
re.compile('set session idle timeout', re.IGNORECASE),
re.compile('set statement timeout', re.IGNORECASE),
re.compile('set bind of decfloat to double precision', re.IGNORECASE),
re.compile('set decfloat round ceiling', re.IGNORECASE),
re.compile('set decfloat traps to Division_by_zero', re.IGNORECASE),
re.compile('set time zone', re.IGNORECASE),
re.compile('set role', re.IGNORECASE)]
test_role_2 = role_factory('db_2', name='TMP$R6469')
@pytest.mark.version('>=4.0')
@pytest.mark.platform('Linux')
@pytest.mark.xfail
def test_2(db_2):
pytest.fail("Test not IMPLEMENTED")
def test_2(act_2: Action, test_role_2: Role, capsys):
with act_2.trace(db_events=trace_2):
act_2.isql(switches=['-n'], input=test_script_2)
# process trace
for line in act_2.trace_log:
if line.split():
if act_2.match_any(line, patterns_2):
print(' '.join(line.split()).lower())
# Check
act_2.expected_stdout = expected_stdout_2
act_2.stdout = capsys.readouterr().out
assert act_2.clean_stdout == act_2.clean_expected_stdout

View File

@ -2,11 +2,11 @@
#
# id: bugs.core_6499
# title: Regression: can not get statistics for selected table(s) via services, get "found unknown switch" error
# decription:
# decription:
# Test creates several tables and request statistics for one of them usin Services API.
# Output must contain for one and only one (selected) table - TEST_01 (and its index).
# All lines from output which do not include this name are ignored (see 'subst' section).
#
#
# Confirmed bug on 4.0.0.2377, 3.0.8.33420, got:
# Unable to perform the requested Service API action:
# - SQLCODE: -901
@ -14,19 +14,22 @@
# -901
# 336920577
# Checked on: 4.0.0.2384, 3.0.8.33424 -- all fine.
#
#
# tracker_id: CORE-6499
# min_versions: ['3.0.8']
# versions: 3.0.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 SrvStatFlag
# version: 3.0.8
# resources: None
substitutions_1 = [('^((?!TEST_01\\s+\\(|TEST_01_ID\\s+\\().)*$', ''), ('TEST_01\\s+\\(.*', 'TEST_01'), ('Index TEST_01_ID\\s+\\(.*', 'Index TEST_01_ID'), ('[ \t]+', ' ')]
substitutions_1 = [('^((?!TEST_01\\s+\\(|TEST_01_ID\\s+\\().)*$', ''),
('TEST_01\\s+\\(.*', 'TEST_01'),
('Index TEST_01_ID\\s+\\(.*', 'Index TEST_01_ID'), ('[ \t]+', ' ')]
init_script_1 = """
recreate table test_01(id int);
@ -37,7 +40,7 @@ init_script_1 = """
commit;
create index test_01_id on test_01(id);
commit;
"""
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
@ -45,12 +48,12 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
#---
# import os
# from fdb import services
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
# db_name=db_conn.database_name
# db_conn.close()
#
#
# svc = services.connect(host='localhost')
# # print(svc.get_server_version())
# svc.get_statistics(database = db_name, show_user_data_pages=1, show_user_index_pages=1, tables = 'TEST_01')
@ -59,19 +62,25 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# for r in info:
# print(r)
# svc.close()
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
TEST_01 (128)
Index TEST_01_ID (0)
"""
"""
@pytest.mark.version('>=3.0.8')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, capsys):
with act_1.connect_server() as srv:
srv.database.get_statistics(database=act_1.db.db_path, tables=['TEST_01'],
flags=SrvStatFlag.DATA_PAGES | SrvStatFlag.IDX_PAGES,
callback=act_1.print_callback)
act_1.expected_stdout = expected_stdout_1
act_1.stdout = capsys.readouterr().out
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,18 +2,19 @@
#
# id: bugs.core_6509
# title: Segfault when gfix requests for database page buffer more memory than available from OS
# decription:
# decription:
# Confirmed crash on 4.0.0.2377 (Windows and Linux)
# Checked on 4.0.0.2384 - all OK, get STDERR: "unable to allocate memory from operating system"
# NB: currently acceptable value for '-buffers' is limited from 50 to 2147483646.
#
#
# tracker_id: CORE-6509
# min_versions: ['4.0.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
import re
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
@ -30,32 +31,32 @@ db_1 = db_factory(page_size=32768, sql_dialect=3, init=init_script_1)
# import sys
# import re
# import time
#
#
# so=sys.stdout
# se=sys.stderr
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
# db_name = 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
# # 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 f in f_names_list:
@ -66,60 +67,82 @@ db_1 = db_factory(page_size=32768, sql_dialect=3, init=init_script_1)
# else:
# print('Unrecognized type of element:', f, ' - can not be treated as file.')
# del_name = None
#
#
# if del_name and os.path.isfile( del_name ):
# os.remove( del_name )
#
#
# #--------------------------------------------
#
#
#
#
# f_log = open( os.path.join(context['temp_directory'],'tmp_c6509.log'), 'w')
# f_err = open( os.path.join(context['temp_directory'],'tmp_c6509.err'), 'w')
# sys.stdout = f_log
# sys.stderr = f_err
#
#
# runProgram('gstat',[ '-h', db_name ])
# runProgram('gfix',[dsn,'-buffers','2147483646'])
# runProgram('gstat',[ '-h', db_name ])
#
#
# sys.stdout = so
# sys.stderr = se
#
#
# flush_and_close( f_log )
# flush_and_close( f_err )
#
#
# pattern_for_page_buffers = re.compile('\\s*Page\\s+buffers\\s+\\d+', re.IGNORECASE)
#
#
# buffers_set=set()
# with open(f_log.name,'r') as f:
# for line in f:
# if pattern_for_page_buffers.search(line):
# buffers_set.add( line.split()[2] )
# # print('gstat output:', line)
#
#
# print( 'Buffers value was ' + ('not changed (expected)' if len(buffers_set) == 1 else 'UNEXPECTEDLY changed: ' + (', '.join(buffers_set)) ) )
#
#
# with open(f_err.name,'r') as f:
# for line in f:
# print('STDERR in gfix:', line)
#
#
# # cleanup:
# ##########
# time.sleep(1)
# cleanup( (f_log,f_err) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
expected_stdout_1 = """
Buffers value was not changed (expected)
STDERR in gfix: unable to allocate memory from operating system
"""
"""
pattern_for_page_buffers = re.compile('\\s*Page\\s+buffers\\s+\\d+', re.IGNORECASE)
@pytest.mark.version('>=4.0')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, capsys):
act_1.gstat(switches=['-h'])
print(act_1.stdout)
act_1.reset()
act_1.expected_stderr = "We expect errors"
act_1.gfix(switches=[act_1.db.dsn, '-buffers', '2147483646'])
gfix_err = act_1.stderr
act_1.reset()
act_1.gstat(switches=['-h'])
print(act_1.stdout)
#
buffers_set = set()
for line in capsys.readouterr().out.splitlines():
if pattern_for_page_buffers.search(line):
buffers_set.add(line.split()[2])
result = 'not changed (expected)' if len(buffers_set) == 1 else 'UNEXPECTEDLY changed: ' + ', '.join(buffers_set)
print(f'Buffers value was {result}')
for line in gfix_err.splitlines():
print('STDERR in gfix:', line)
# Check
act_1.reset()
act_1.expected_stdout = expected_stdout_1
act_1.stdout = capsys.readouterr().out
assert act_1.clean_stdout == act_1.clean_expected_stdout

View File

@ -2,17 +2,18 @@
#
# id: bugs.core_6517
# title: Regression: CREATE DATABASE fails with 'Token unknown' error when DB name is enclosed in double quotes and 'DEFAULT CHARACTER SET' is specified after DB name
# decription:
# decription:
# Confirmed bug on 4.0.0.2394, 3.0.8.33426
# Checked on 4.0.0.2401, 3.0.8.33435 -- all OK.
#
#
# tracker_id: CORE-6517
# min_versions: ['3.0.8']
# versions: 3.0.8
# qmid: None
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
# version: 3.0.8
# resources: None
@ -25,18 +26,18 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# import os
# import time
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# temp_fdb = os.path.join( '$(DATABASE_LOCATION)', 'tmp_core_6517.tmp' )
# db_conn.close()
#
#
# #--------------------------------------------
#
#
# def cleanup( f_names_list ):
# global os
# for i in range(len( f_names_list )):
@ -47,30 +48,31 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# 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 )
#
#
# #--------------------------------------------
#
#
# cleanup( (temp_fdb,) )
# con = fdb.create_database('create database "%s" default character set utf8' % temp_fdb)
# # print( con.database_name )
# con.close()
#
#
# # CLEANUP
# #########
# time.sleep(1)
# cleanup( (temp_fdb,) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
test_db = temp_file('tmp_core_6517.fdb')
@pytest.mark.version('>=3.0.8')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, test_db: Path):
act_1.isql(switches=[], input=f'create database "{act_1.get_dsn(test_db)}" default character set utf8;',
connect_db=False)

View File

@ -2,61 +2,122 @@
#
# id: bugs.core_6527
# title: Regression: inline comment of SP parameter with closing parenthesis leads to incorrect SQL when trying to extract metadata
# decription:
# decription:
# Confirmed bug on 4.0.0.2394, 3.0.8.33426
# Checked on 4.0.0.2401, 3.0.8.33435 -- all OK.
#
#
# tracker_id: CORE-6527
# min_versions: ['3.0.8']
# versions: 3.0.8
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action, Database
# version: 3.0.8
# resources: None
substitutions_1 = []
init_script_1 = """"""
init_script_1 = """
set term ^;
create or alter procedure sp_test(
a_base_doc_id int,
a_base_doc_oper_id int default null -- (one of parameters to standalone procedure)
)
as
declare v_info varchar(100);
begin
db_1 = db_factory(sql_dialect=3, init=init_script_1)
v_info = 'base_doc='||a_base_doc_id;
end
^
create or alter function fn_test(
a_base_doc_id int,
a_base_doc_oper_id int default null -- (one of parameters to standalone function)
)
returns int
as
declare v_info varchar(100);
begin
v_info = 'base_doc='||a_base_doc_id;
return 1;
end
^
create or alter package pg_test as
begin
procedure sp_test(
a_base_doc_id int,
a_base_doc_oper_id int default null -- (one of parameters to packaged procedure)
);
function fn_test(
a_base_doc_id int,
a_base_doc_oper_id int default null -- (one of parameters to packaged procedure)
) returns int;
end
^
recreate package body pg_test as
begin
procedure sp_test(
a_base_doc_id int,
a_base_doc_oper_id int -- (one of parameters to packaged procedure)
) as
begin
-- nop --
end
function fn_test(
a_base_doc_id int,
a_base_doc_oper_id int -- (one of parameters to packaged procedure)
) returns int as
begin
return 1;
end
end
^
set term ;^
commit;
"""
db_1 = db_factory(sql_dialect=3) # We'll initialize it manually
db_1_b = db_factory(sql_dialect=3, filename='tmp_core_6527.fdb')
# test_script_1
#---
#
#
# import os
# import subprocess
# import shutil
# import time
#
#
# os.environ["ISC_USER"] = user_name
# os.environ["ISC_PASSWORD"] = user_password
#
#
# this_fdb = db_conn.database_name
# temp_fdb = os.path.join( '$(DATABASE_LOCATION)', 'tmp_core_6527.tmp' )
# db_conn.close()
#
#
# shutil.copy(this_fdb, temp_fdb)
#
#
# #--------------------------------------------
#
#
# 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 )):
@ -67,12 +128,12 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# 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 )
#
#
# #--------------------------------------------
#
#
# sql_ddl='''
# set term ^;
# create or alter procedure sp_test(
@ -82,7 +143,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# as
# declare v_info varchar(100);
# begin
#
#
# v_info = 'base_doc='||a_base_doc_id;
# end
# ^
@ -94,12 +155,12 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# as
# declare v_info varchar(100);
# begin
#
#
# v_info = 'base_doc='||a_base_doc_id;
# return 1;
# end
# ^
#
#
# create or alter package pg_test as
# begin
# procedure sp_test(
@ -121,7 +182,7 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# begin
# -- nop --
# end
#
#
# function fn_test(
# a_base_doc_id int,
# a_base_doc_oper_id int -- (one of parameters to packaged procedure)
@ -134,71 +195,73 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# set term ;^
# commit;
# '''
#
#
# f_init_sql = open( os.path.join(context['temp_directory'], 'tmp_6527_init.sql'), 'w' )
# f_init_sql.write( sql_ddl )
# flush_and_close( f_init_sql )
#
#
#
#
# f_init_log = open( os.path.join(context['temp_directory'], 'tmp_6527_init.log'), 'w' )
# f_init_err = open( os.path.join(context['temp_directory'], 'tmp_6527_init.err'), 'w' )
#
#
# subprocess.call( [ context['isql_path'], dsn, "-q", "-i", f_init_sql.name ],
# stdout = f_init_log,
# stderr = f_init_err
# )
#
#
# flush_and_close( f_init_log )
# flush_and_close( f_init_err )
#
#
# f_meta_sql = open( os.path.join(context['temp_directory'],'tmp_meta_6527.sql'), 'w')
# f_meta_err = open( os.path.join(context['temp_directory'],'tmp_meta_6527.err'), 'w')
#
#
# subprocess.call( [ context['isql_path'], "-x", dsn],
# stdout = f_meta_sql,
# stderr = f_meta_err
# )
#
#
# flush_and_close( f_meta_sql )
# flush_and_close( f_meta_err )
#
#
# f_apply_log = open( os.path.join(context['temp_directory'],'tmp_apply_6527.log'), 'w')
# f_apply_err = open( os.path.join(context['temp_directory'],'tmp_apply_6527.err'), 'w')
#
#
# subprocess.call( [ context['isql_path'], 'localhost:'+temp_fdb, "-i", f_meta_sql.name ],
# stdout = f_apply_log,
# stderr = f_apply_err
# )
#
#
# flush_and_close( f_apply_log )
# flush_and_close( f_apply_err )
#
#
# # Check:
# ########
#
#
# # Output must be empty:
# with open( f_meta_err.name,'r') as f:
# for line in f:
# print("METADATA EXTRACTION PROBLEM, STDERR: "+line)
#
#
# # Output must be empty:
# with open( f_apply_err.name,'r') as f:
# for line in f:
# print("METADATA APPLYING PROBLEM, STDERR: "+line)
#
#
# # CLEANUP
# #########
# time.sleep(1)
# cleanup( (f_init_sql, f_init_log, f_init_err,f_meta_sql, f_meta_err, f_apply_log, f_apply_err, temp_fdb) )
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
act_1 = python_act('db_1', substitutions=substitutions_1)
@pytest.mark.version('>=3.0.8')
@pytest.mark.xfail
def test_1(db_1):
pytest.fail("Test not IMPLEMENTED")
def test_1(act_1: Action, db_1_b: Database):
act_1.isql(switches=[], input=init_script_1)
meta = act_1.extract_meta()
act_1.reset()
act_1.isql(switches=[], use_db=db_1_b, input=meta)

View File

@ -2,39 +2,41 @@
#
# id: bugs.core_6529
# title: Error "no current record for fetch operation" when sorting by a international string
# decription:
# decription:
# Confirmed bug on 4.0.0.2394, got:
# - SQLCODE: -508 / - no current record for fetch operation / -508 / 335544348
# Checked on 4.0.0.2401 - all OK.
#
#
# tracker_id: CORE-6529
# min_versions: ['4.0']
# versions: 4.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
from firebird.qa import db_factory, python_act, Action
# version: 4.0
# resources: None
substitutions_1 = []
init_script_1 = """"""
init_script_1 = """
recreate table t (f varchar(32765) character set win1251) ;
"""
db_1 = db_factory(sql_dialect=3, init=init_script_1)
# test_script_1
#---
#
#
# db_conn.execute_immediate('recreate table t (f varchar(32765) character set win1251)')
# db_conn.commit()
#
#
# cur = db_conn.cursor()
#
#
# cur.execute( "insert into t(f) values(?)", ('W' * 1000,) )
# # no commit here!
#
#
# try:
# cur.execute('select f from t order by 1')
# for r in cur:
@ -49,18 +51,18 @@ db_1 = db_factory(sql_dialect=3, init=init_script_1)
# finally:
# cur.close()
# db_conn.close()
#
#
#
#
#---
#act_1 = python_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
Passed.
"""
act_1 = python_act('db_1', substitutions=substitutions_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):
with act_1.db.connect() as con:
c = con.cursor()
c.execute("insert into t(f) values(?)", ['W' * 1000])
# no commit here!
c.execute('select f from t order by 1')
c.fetchall()
# Passed.