6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_5229_test.py

103 lines
4.0 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5508
ISSUE: 5508
TITLE: Allow to enforce IPv4 or IPv6 in URL-like connection strings
DESCRIPTION:
2022-02-04 19:05:19 +01:00
NOTES:
[04.02.2022] pcisar
Test may fail with IPv6.
For example it fails on my Linux OpenSuSE Tumbleweed with regular setup (IPv6 should not be disabled).
Test should IMHO check IPv4/IPv6 availability on test host before runs inet6:// check.
2022-01-25 22:55:48 +01:00
JIRA: CORE-5229
FBTEST: bugs.core_5229
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory()
2021-12-06 19:23:35 +01:00
2022-01-25 22:55:48 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
PROCOTOL_WHEN_CONNECT_FROM_OS TCPv4
PROCOTOL_WHEN_CONNECT_FROM_ISQL TCPv4
PROTOCOL_WHEN_CONNECT_BY_ES_EDS TCPv4
PROCOTOL_WHEN_CONNECT_FROM_ISQL TCPv6
PROTOCOL_WHEN_CONNECT_BY_ES_EDS TCPv6
2021-12-06 19:23:35 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
@pytest.mark.skip("FIXME: see notes")
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.1')
2022-01-25 22:55:48 +01:00
def test_1(act: Action):
2021-12-06 19:23:35 +01:00
sql_chk = f"""
set list on;
select mon$remote_protocol as procotol_when_connect_from_os
from mon$attachments where mon$attachment_id = current_connection;
commit;
2022-01-25 22:55:48 +01:00
connect 'inet4://{act.db.db_path}';
2021-12-06 19:23:35 +01:00
select mon$remote_protocol as procotol_when_connect_from_isql
from mon$attachments where mon$attachment_id = current_connection;
set term ^;
execute block returns(protocol_when_connect_by_es_eds varchar(20) ) as
declare stt varchar(255) = 'select mon$remote_protocol from mon$attachments where mon$attachment_id = current_connection';
begin
for
execute statement (stt)
2022-01-25 22:55:48 +01:00
on external 'inet4://{act.db.db_path}'
as user '{act.db.user}' password '{act.db.password}'
2021-12-06 19:23:35 +01:00
into protocol_when_connect_by_es_eds
do
suspend;
end
^
set term ;^
commit;
-- since 27.10.2019:
2022-01-25 22:55:48 +01:00
connect 'inet6://{act.db.db_path}';
2021-12-06 19:23:35 +01:00
select mon$remote_protocol as procotol_when_connect_from_isql
from mon$attachments where mon$attachment_id = current_connection;
set term ^;
execute block returns(protocol_when_connect_by_es_eds varchar(20) ) as
declare stt varchar(255) = 'select mon$remote_protocol from mon$attachments where mon$attachment_id = current_connection';
begin
for
execute statement (stt)
2022-01-25 22:55:48 +01:00
on external 'inet6://{act.db.db_path}'
as user '{act.db.user}' password '{act.db.password}'
2021-12-06 19:23:35 +01:00
into protocol_when_connect_by_es_eds
do
suspend;
end
^
set term ;^
commit;
2021-04-26 20:07:00 +02:00
2021-12-06 19:23:35 +01:00
-- ||||||||||||||||||||||||||||
-- ###################################||| FB 4.0+, SS and SC |||##############################
-- ||||||||||||||||||||||||||||
-- If we check SS or SC and ExtConnPoolLifeTime > 0 (config parameter FB 4.0+) then current
-- DB (bugs.core_NNNN.fdb) will be 'captured' by firebird.exe process and fbt_run utility
-- will not able to drop this database at the final point of test.
-- Moreover, DB file will be hold until all activity in firebird.exe completed and AFTER this
-- we have to wait for <ExtConnPoolLifeTime> seconds after it (discussion and small test see
-- in the letter to hvlad and dimitr 13.10.2019 11:10).
-- This means that one need to kill all connections to prevent from exception on cleanup phase:
-- SQLCODE: -901 / lock time-out on wait transaction / object <this_test_DB> is in use
-- #############################################################################################
delete from mon$attachments where mon$attachment_id != current_connection;
commit;
2022-01-25 22:55:48 +01:00
"""
act.expected_stdout = expected_stdout
act.isql(switches=['-q', f'inet4://{act.db.db_path}'], input=sql_chk, connect_db=False)
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00