Skip to content

[#247] PortManager__Generic uses lock-dirs for reserved ports #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
99e645e
[#247] PortManager__Generic uses lock-dirs for reserved ports
dmitry-lipetsk May 6, 2025
c6f4b4d
PortManager__Generic is refactored
dmitry-lipetsk May 7, 2025
f085b70
[#256] A used port range is [1024 ... 65535]
dmitry-lipetsk May 7, 2025
c9b4bbf
PortManager__Generic is refactored [consts, asserts]
dmitry-lipetsk May 7, 2025
862c79f
Merge branch 'master' into master-fix247--v001
dmitry-lipetsk May 7, 2025
b5e6f25
Merge branch 'master' into master-fix247--v001
dmitry-lipetsk May 7, 2025
be3cc11
Merge branch 'master' into master-fix247--v001
dmitry-lipetsk May 12, 2025
cc8333c
Merge branch 'master' into master-fix247--v001
dmitry-lipetsk May 12, 2025
d15ecdb
PortManager__Generic sends debug messages about its operations.
dmitry-lipetsk May 29, 2025
8e0869d
[attention] OsOperations::create_lock_fs_obj is added
dmitry-lipetsk May 31, 2025
82b46b3
Code style is fixed
dmitry-lipetsk Jun 1, 2025
a188a63
Merge branch 'master' into master-fix247--v001
dmitry-lipetsk Jun 22, 2025
597f699
PortManager__Generic is synchronized with master
dmitry-lipetsk Jun 24, 2025
b34837e
[FIX] PortManager__Generic::release_port sends a debug message under …
dmitry-lipetsk Jun 24, 2025
0648926
PortManager__Generic::reserve_port is updated (reordered)
dmitry-lipetsk Jun 24, 2025
8c5e340
PortManager__Generic::helper__send_debug_msg is corrected (assert)
dmitry-lipetsk Jun 24, 2025
ea25215
PortManager__Generic::reserve_port is updated (comment)
dmitry-lipetsk Jun 24, 2025
aa677d2
PortManager__Generic::__init__ is updated
dmitry-lipetsk Jun 24, 2025
1dfac90
Merge remote-tracking branch 'pgpro/master' into master-fix247--v001
dmitry-lipetsk Jun 24, 2025
8aa790a
Merge branch 'master' into master-fix247--v001
dmitry-lipetsk Jun 26, 2025
e63c603
Merge branch 'master' into master-fix247--v001
dmitry-lipetsk Jun 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PortManager__Generic is synchronized with master
- _C_MIN_PORT_NUMBER
- _C_MAX_PORT_NUMBER
  • Loading branch information
dmitry-lipetsk committed Jun 24, 2025
commit 597f699b1fa236261a4a0df5ac30bc78607b71a6
18 changes: 9 additions & 9 deletions testgres/impl/port_manager__generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


class PortManager__Generic(PortManager):
C_MIN_PORT_NUMBER = 1024
C_MAX_PORT_NUMBER = 65535
_C_MIN_PORT_NUMBER = 1024
_C_MAX_PORT_NUMBER = 65535

_os_ops: OsOperations
_guard: object
Expand All @@ -25,18 +25,18 @@ class PortManager__Generic(PortManager):
_lock_dir: str

def __init__(self, os_ops: OsOperations):
assert __class__.C_MIN_PORT_NUMBER <= __class__.C_MAX_PORT_NUMBER
assert __class__._C_MIN_PORT_NUMBER <= __class__._C_MAX_PORT_NUMBER

assert os_ops is not None
assert isinstance(os_ops, OsOperations)
self._os_ops = os_ops
self._guard = threading.Lock()

self._available_ports = set(
range(__class__.C_MIN_PORT_NUMBER, __class__.C_MAX_PORT_NUMBER + 1)
range(__class__._C_MIN_PORT_NUMBER, __class__._C_MAX_PORT_NUMBER + 1)
)
assert len(self._available_ports) == (
(__class__.C_MAX_PORT_NUMBER - __class__.C_MIN_PORT_NUMBER) + 1
(__class__._C_MAX_PORT_NUMBER - __class__._C_MIN_PORT_NUMBER) + 1
)

self._reserved_ports = dict()
Expand Down Expand Up @@ -70,8 +70,8 @@ def reserve_port(self) -> int:
assert not (port in self._reserved_ports)
assert port in self._available_ports

assert port >= __class__.C_MIN_PORT_NUMBER
assert port <= __class__.C_MAX_PORT_NUMBER
assert port >= __class__._C_MIN_PORT_NUMBER
assert port <= __class__._C_MAX_PORT_NUMBER

if not self._os_ops.is_port_free(port):
continue
Expand Down Expand Up @@ -102,8 +102,8 @@ def reserve_port(self) -> int:

def release_port(self, number: int) -> None:
assert type(number) == int # noqa: E721
assert number >= __class__.C_MIN_PORT_NUMBER
assert number <= __class__.C_MAX_PORT_NUMBER
assert number >= __class__._C_MIN_PORT_NUMBER
assert number <= __class__._C_MAX_PORT_NUMBER

assert self._guard is not None
assert type(self._reserved_ports) == dict # noqa: E721
Expand Down