6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_5330_test.py

102 lines
2.7 KiB
Python

#coding:utf-8
"""
ID: issue-5606
ISSUE: 5606
TITLE: Trace session leads FB 4.0 to hang after 2nd launch of trivial .sql script. Neither attach to any database nor regular restart of FB service can be done.
DESCRIPTION:
Ticket issue was reproduced on trivial trace config with single line ("enabled = true").
We prepare such config, launch trace session in async mode and run THREE times isql with logging its output.
Then we stop trace session and open isql log - it should contain three 'packets' of table records.
If FB becomes unavaliable, this (and all subsequent) test will not finish at all.
JIRA: CORE-5330
FBTEST: bugs.core_5330
"""
import pytest
from firebird.qa import *
db = db_factory()
act = python_act('db')
test_script = """
recreate table ttt(id int generated by default as identity, x int, y int);
commit;
set term ^;
execute block as
declare s varchar(200) = 'insert into ttt(x, y) values(?, ?)';
declare n int = 3;
begin
while (n>0) do
begin
execute statement (s) (:n, :n * 2);
n = n - 1;
end
end
^
set term ;^
commit;
set list on;
select * from ttt;
"""
expected_stdout = """
ID 1
X 3
Y 6
ID 2
X 2
Y 4
ID 3
X 1
Y 2
ID 1
X 3
Y 6
ID 2
X 2
Y 4
ID 3
X 1
Y 2
ID 1
X 3
Y 6
ID 2
X 2
Y 4
ID 3
X 1
Y 2
"""
trace = ['database=',
'{',
'enabled = true',
'}']
@pytest.mark.trace
@pytest.mark.version('>=4.0')
def test_1(act: Action, capsys):
with act.trace(config=trace, keep_log=False):
for i in range(3, 0, -1):
act.reset()
act.isql(switches=[], input=test_script)
print(act.stdout)
# Check
act.reset()
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout