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_4439_test.py

72 lines
2.3 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4759
ISSUE: 4759
TITLE: Raise the 1024 connections limit (FD_SETSIZE) on Windows SS/SC
DESCRIPTION:
Test tries to establish MAX_CONN_CNT = 2047 connections and then close all of them.
When connection is establishes, its attachment_id is added to the Python set(),
and length of this set is compared with MAX_CONN_CNT when all we establish all connections.
Then test closes all connections.
2022-01-23 20:41:55 +01:00
NOTE-1.
if number of established connections is more than 2047 then 1st of them will not be served by network server
(this is network server current implementation; it can be changed later, see letter from Vlad, 10.01.2021 15:40).
NOTE-2.
If current FB server mode is 'Classic' then test actually does nothing and console output also remains empty.
Test in such case looks as 'always successful' but actually it does not performed!
JIRA: CORE-4439
FBTEST: bugs.core_4439
NOTES:
[28.05.2022] pzotov
Checked on 5.0.0.501, 4.0.1.2692, 3.0.8.33535 (SS/SC/CS)
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2022-01-23 20:41:55 +01:00
from firebird.qa import *
from firebird.driver.types import DatabaseError
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
@pytest.mark.version('>=3')
@pytest.mark.platform('Windows')
def test_1(act: Action, capsys):
if act.get_server_architecture() in ('SuperServer', 'SuperClassic'):
MAX_CONN_CNT=2047
con_list=[]
con_set=set()
con_fail=0
for i in range(0,MAX_CONN_CNT):
try:
con_list.append( act.db.connect() )
con_set.add( con_list[-1].info.id )
except DatabaseError as e:
print(f'Error on attempt to establish connection N {i+1} of {MAX_CONN_CNT+1}:')
print(e.__str__())
con_fail=1
if con_fail:
break
###################
print(len(con_set))
###################
for c in con_list:
try:
c.close()
except DatabaseError as e:
print(f'Error on attempt to close connection:')
print(e.__str__())
2021-04-26 20:07:00 +02:00
act.expected_stdout = str(MAX_CONN_CNT)
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout
else:
assert True