Increase timeout for wait_for_port

Following up Squish advise:

In the wait_for_port.py, you are using socket.create_connection() where the timeout is set to 1.
Could you increase the timeout here and also put a check before to make sure that port is not in the use anymore, before proceeding to launch the AUT.
This commit is contained in:
Anastasiya Semenkevich 2024-01-19 21:34:16 +03:00 committed by Anastasiya
parent 7b188afd3e
commit e2f2a34a8b
2 changed files with 7 additions and 3 deletions

View File

@ -4,11 +4,13 @@ import logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def wait_for_port(host: str, port: int, timeout: int = 1, retries: int = 0):
def wait_for_port(host: str, port: int, timeout: int = 3, retries: int = 0):
for i in range(retries + 1): for i in range(retries + 1):
try: try:
LOG.debug('Checking TCP port: %s:%d', host, port) LOG.debug('Checking TCP port: %s:%d', host, port)
with socket.create_connection((host, port), timeout=timeout): with socket.create_connection((host, port), timeout=timeout):
if socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((host, port)) == 0:
return return
except OSError as err: except OSError as err:
LOG.debug('Connection error: %s', err) LOG.debug('Connection error: %s', err)

View File

@ -12,6 +12,8 @@ from constants.messaging import Messaging
from gui.main_window import MainWindow from gui.main_window import MainWindow
pytestmark = marks pytestmark = marks
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704611', 'Reply to identity request') @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704611', 'Reply to identity request')
@pytest.mark.case(704611) @pytest.mark.case(704611)
@pytest.mark.parametrize('user_data_one, user_data_two', [ @pytest.mark.parametrize('user_data_one, user_data_two', [