2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-22 21:59:15 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: issue-3694
|
|
|
|
ISSUE: 3694
|
|
|
|
TITLE: Client writes error messages into firebird.log when database is shutted down
|
|
|
|
DESCRIPTION:
|
|
|
|
Difference between old and new firebird.log should _NOT_ contain lines with words 'gds__detach' or 'lost'.
|
|
|
|
If these words absent - all fine, actual and expected output both have to be empty.
|
|
|
|
JIRA: CORE-3328
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_3328
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2021-11-17 19:43:06 +01:00
|
|
|
import time
|
|
|
|
from difflib import unified_diff
|
|
|
|
from threading import Thread
|
2022-01-22 21:59:15 +01:00
|
|
|
from firebird.qa import *
|
2021-11-17 19:43:06 +01:00
|
|
|
from firebird.driver import ShutdownMethod, ShutdownMode
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
init_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
create table test(s varchar(36) unique);
|
|
|
|
commit;
|
2021-11-17 19:43:06 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
db = db_factory(init=init_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
act = python_act('db', substitutions=[('database.*shutdown', 'database shutdown')])
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
expected_stderr = """
|
2021-11-17 19:43:06 +01:00
|
|
|
Statement failed, SQLSTATE = HY000
|
|
|
|
database /tmp/pytest-of-pcisar/pytest-528/test_10/test.fdb shutdown
|
|
|
|
Statement failed, SQLSTATE = HY000
|
|
|
|
database /tmp/pytest-of-pcisar/pytest-528/test_10/test.fdb shutdown
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-11-17 19:43:06 +01:00
|
|
|
def run_work(act: Action):
|
|
|
|
test_script = """
|
|
|
|
show version;
|
|
|
|
set term ^;
|
|
|
|
execute block as
|
|
|
|
declare v_role varchar(31);
|
|
|
|
begin
|
|
|
|
v_role = left(replace( uuid_to_char(gen_uuid()), '-', ''), 31);
|
|
|
|
while (1=1) do
|
|
|
|
begin
|
|
|
|
insert into test(s) values( uuid_to_char( gen_uuid() ) );
|
|
|
|
end
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
|
|
|
act.expected_stderr = expected_stderr
|
2021-11-17 19:43:06 +01:00
|
|
|
act.isql(switches=['-n'], input=test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-11-17 19:43:06 +01:00
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-22 21:59:15 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
with act.connect_server() as srv:
|
2021-11-17 19:43:06 +01:00
|
|
|
srv.info.get_log()
|
|
|
|
log_before = srv.readlines()
|
|
|
|
#
|
2022-01-22 21:59:15 +01:00
|
|
|
work_thread = Thread(target=run_work, args=[act])
|
2021-11-17 19:43:06 +01:00
|
|
|
work_thread.start()
|
|
|
|
time.sleep(2)
|
|
|
|
#
|
2022-01-22 21:59:15 +01:00
|
|
|
srv.database.shutdown(database=act.db.db_path, mode=ShutdownMode.FULL,
|
2021-11-17 19:43:06 +01:00
|
|
|
method=ShutdownMethod.FORCED, timeout=0)
|
2022-01-22 21:59:15 +01:00
|
|
|
srv.database.bring_online(database=act.db.db_path)
|
2021-11-17 19:43:06 +01:00
|
|
|
#
|
|
|
|
srv.info.get_log()
|
|
|
|
log_after = srv.readlines()
|
|
|
|
#
|
|
|
|
work_thread.join(2)
|
|
|
|
if work_thread.is_alive():
|
|
|
|
pytest.fail('Work thread is still alive')
|
|
|
|
#
|
|
|
|
assert list(unified_diff(log_before, log_after)) == []
|
2022-01-22 21:59:15 +01:00
|
|
|
assert act.clean_stderr == act.clean_expected_stderr
|