From 666dba353cab4c9fdc8168fc3f494a290c1993fb Mon Sep 17 00:00:00 2001 From: Evgeniy Zayats Date: Mon, 11 Mar 2024 20:34:10 -0400 Subject: [PATCH 1/2] env: fix issue with the same port assignment, closes #94 Signed-off-by: Evgeniy Zayats --- src/neofs_testlib/env/env.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/neofs_testlib/env/env.py b/src/neofs_testlib/env/env.py index 84fbf68..ce69d41 100644 --- a/src/neofs_testlib/env/env.py +++ b/src/neofs_testlib/env/env.py @@ -41,6 +41,8 @@ class WalletType(Enum): class NeoFSEnv: + _busy_ports = [] + def __init__(self, neofs_env_config: dict = None): self.domain = "localhost" self.default_password = "password" @@ -288,13 +290,17 @@ def generate_config_file(config_template: str, config_path: str, custom=False, * with open(config_path, mode="w") as fp: fp.write(rendered_config) - @staticmethod - def get_available_port() -> str: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.bind(("", 0)) - addr = s.getsockname() - s.close() - return addr[1] + @classmethod + def get_available_port(cls) -> str: + for _ in range(len(cls._busy_ports) + 2): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.bind(("", 0)) + addr = s.getsockname() + s.close() + if addr[1] not in cls._busy_ports: + cls._busy_ports.append(addr[1]) + return addr[1] + raise AssertionError("Can not find an available port") @staticmethod def download_binary(repo: str, version: str, file: str, target: str): From b5aee052630e30199bcd26601aa0a84e5cc58ba7 Mon Sep 17 00:00:00 2001 From: Evgeniy Zayats Date: Mon, 11 Mar 2024 20:34:47 -0400 Subject: [PATCH 2/2] Bump version 1.1.21 -> 1.1.22 Signed-off-by: Evgeniy Zayats --- pyproject.toml | 4 ++-- src/neofs_testlib/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 84c384b..95969ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "neofs-testlib" -version = "1.1.21" +version = "1.1.22" description = "Building blocks and utilities to facilitate development of automated tests for NeoFS system" readme = "README.md" authors = [{ name = "NSPCC", email = "info@nspcc.ru" }] @@ -50,7 +50,7 @@ line-length = 100 target-version = ["py310"] [tool.bumpver] -current_version = "1.1.21" +current_version = "1.1.22" version_pattern = "MAJOR.MINOR.PATCH" commit_message = "Bump version {old_version} -> {new_version}" commit = true diff --git a/src/neofs_testlib/__init__.py b/src/neofs_testlib/__init__.py index 0785d9a..209742c 100644 --- a/src/neofs_testlib/__init__.py +++ b/src/neofs_testlib/__init__.py @@ -1 +1 @@ -__version__ = "1.1.21" +__version__ = "1.1.22"