Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #95 from nspcc-dev/ezayats/env-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Mar 12, 2024
2 parents d2a5c65 + b5aee05 commit dccae12
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }]
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/neofs_testlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.21"
__version__ = "1.1.22"
20 changes: 13 additions & 7 deletions src/neofs_testlib/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit dccae12

Please sign in to comment.