2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-25 22:55:48 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: issue-5728
|
|
|
|
ISSUE: 5728
|
|
|
|
TITLE: Bugcheck 167 (invalid SEND request)
|
|
|
|
DESCRIPTION:
|
|
|
|
Test extracts content of firebird.log, then runs scenario which earlier led to "invalid SEND request (167)"
|
|
|
|
and then again get firebird.log for comparing with its previous content.
|
|
|
|
The only new record in firebird.log must be:
|
|
|
|
"Modifying procedure SP_CALC_VAL which is currently in use by active user requests"
|
|
|
|
JIRA: CORE-5457
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_5457
|
2022-01-25 22:55:48 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2021-12-07 20:09:36 +01:00
|
|
|
import time
|
|
|
|
import re
|
|
|
|
from difflib import unified_diff
|
2022-01-25 22:55:48 +01:00
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
act = python_act('db')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-12-07 20:09:36 +01:00
|
|
|
@pytest.mark.version('>=3.0.2')
|
2022-01-25 22:55:48 +01:00
|
|
|
def test_1(act: Action, capsys):
|
|
|
|
log_before = act.get_firebird_log()
|
2021-12-07 20:09:36 +01:00
|
|
|
#
|
2022-01-25 22:55:48 +01:00
|
|
|
with act.db.connect() as con:
|
2021-12-07 20:09:36 +01:00
|
|
|
sp_test_ddl = """
|
|
|
|
create procedure sp_calc_val(a_id int) returns(val int) as
|
|
|
|
begin
|
|
|
|
val = a_id * 10;
|
|
|
|
suspend;
|
|
|
|
end
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-12-07 20:09:36 +01:00
|
|
|
con.execute_immediate(sp_test_ddl)
|
|
|
|
con.commit()
|
|
|
|
test_table_ddl = """
|
|
|
|
create table test(
|
|
|
|
id int primary key,
|
|
|
|
txt varchar(80),
|
|
|
|
calc_val computed by ((select val from sp_calc_val(test.id)))
|
|
|
|
)
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-12-07 20:09:36 +01:00
|
|
|
con.execute_immediate(test_table_ddl)
|
|
|
|
con.commit()
|
|
|
|
#
|
|
|
|
c = con.cursor()
|
|
|
|
c.execute('insert into test select row_number()over(), ascii_char(96 + row_number()over()) from rdb$types rows 7')
|
|
|
|
con.commit()
|
|
|
|
#
|
|
|
|
c.execute('select count(*), sum(calc_val) from test').fetchall()
|
|
|
|
#
|
|
|
|
sp_alter_ddl = """
|
|
|
|
alter procedure sp_calc_val (a_id int) returns (val int) as
|
|
|
|
begin
|
|
|
|
val = a_id * 7;
|
|
|
|
suspend;
|
|
|
|
end
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-12-07 20:09:36 +01:00
|
|
|
con.execute_immediate(sp_alter_ddl)
|
|
|
|
c.execute('select count(*), sum(calc_val) from test').fetchall()
|
|
|
|
con.commit()
|
|
|
|
c.execute('select count(*), sum(calc_val) from test').fetchall()
|
|
|
|
#
|
|
|
|
time.sleep(1)
|
|
|
|
#
|
2022-01-25 22:55:48 +01:00
|
|
|
log_after = act.get_firebird_log()
|
2021-12-07 20:09:36 +01:00
|
|
|
unexpected_patterns = [re.compile('\\s+internal\\s+Firebird\\s+consistency\\s+check', re.IGNORECASE)]
|
|
|
|
for line in unified_diff(log_before, log_after):
|
|
|
|
if line.startswith('+'):
|
|
|
|
match2some = list(filter(None, [p.search(line) for p in unexpected_patterns]))
|
|
|
|
if match2some:
|
|
|
|
print(f'UNEXPECTED: {line}')
|
|
|
|
#
|
2022-01-25 22:55:48 +01:00
|
|
|
act.expected_stdout = ''
|
|
|
|
act.stdout = capsys.readouterr().out
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|