6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_4889_test.py

78 lines
2.5 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID: issue-5183
ISSUE: 5183
TITLE: FBSVCMGR with `action_trace_start` prevents in 3.0 SuperServer from connecting using local protocol
DESCRIPTION:
2022-02-08 18:14:29 +01:00
NOTES:
This test fails on Windows with "FAILED to find text in trace related to EMBEDDED connect."
[08.03.2022] pzotov
Fail on Windows caused by 'select current_user from rdb$database' which issues '0 records' (instead of expected '1 records')
But there is no much sence to search this line ('... records fetched') because it is enough to detect only lines with
ATTACH and DETACH that were performed by embedded connect. Replaced code which did trace log parsing.
2022-01-24 20:27:02 +01:00
JIRA: CORE-4889
FBTEST: bugs.core_4889
2022-01-24 20:27:02 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
import pytest
2022-02-08 18:14:29 +01:00
import platform
2022-01-24 20:27:02 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
act = python_act('db')
2021-11-26 19:20:43 +01:00
2022-01-24 20:27:02 +01:00
isq_script = """
set list on;
set count on;
select
iif(a.mon$remote_protocol is null, 'internal', 'remote') as connection_protocol,
iif(a.mon$remote_process is null, 'internal', 'remote') as connection_process,
iif(a.mon$remote_pid is null, 'internal', 'remote') as connection_remote_pid,
a.mon$auth_method as auth_method -- should be: 'User name in DPB'
from rdb$database r
left join mon$attachments a on a.mon$attachment_id = current_connection and a.mon$system_flag = 0;
commit;
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
expected_stdout = """
Found embedded ATTACH
Found embedded DETACH
2021-04-26 20:07:00 +02:00
CONNECTION_PROTOCOL internal
CONNECTION_PROCESS internal
CONNECTION_REMOTE_PID internal
AUTH_METHOD User name in DPB
Records affected: 1
2021-11-26 19:20:43 +01:00
"""
2021-04-26 20:07:00 +02:00
trace = [
'log_connections = true',
2022-01-24 20:27:02 +01:00
'log_initfini = false',
'log_errors = true',
]
2021-04-26 20:07:00 +02:00
2021-11-26 19:20:43 +01:00
@pytest.mark.version('>=3.0')
2022-01-24 20:27:02 +01:00
def test_1(act: Action, capsys):
with act.trace(db_events=trace):
act.isql(switches=['-n', '-user', 'tmp$no$such$user$4889', str(act.db.db_path)],
connect_db=False, credentials=False, input=isq_script)
# Process trace log
lprev = ''
2022-01-24 20:27:02 +01:00
for line in act.trace_log:
if 'TMP$NO$SUCH$USER$4889:' in line:
if ') ATTACH_DATABASE' in lprev:
print('Found embedded ATTACH')
elif ') DETACH_DATABASE' in lprev:
print('Found embedded DETACH')
lprev = line
2022-01-24 20:27:02 +01:00
print(act.stdout if act.stdout else "FAILED to print log from EMBEDDED connect: log is EMPTY.")
2021-11-26 19:20:43 +01:00
# Check
2022-01-24 20:27:02 +01:00
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout