Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PortManager#234

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
32 commits
Select commitHold shift + click to select a range
09dab31
PostgresNode refactoring [PostgresNodePortManager and RO-properties]
dmitry-lipetskApr 3, 2025
ef095d3
[FIX] clone_with_new_name_and_base_dir did not respect port_manager
dmitry-lipetskApr 4, 2025
0f842fd
PostgresNodePortManager__ThisHost is defined (was: PostgresNodePortMa…
dmitry-lipetskApr 4, 2025
e1e609e
PostgresNodePortManager__Generic is added
dmitry-lipetskApr 4, 2025
285e5b7
PostgresNodePortManager is added in public API
dmitry-lipetskApr 4, 2025
a974866
Test structures were refactored (local, local2, remote)
dmitry-lipetskApr 4, 2025
110947d
CI files are updated
dmitry-lipetskApr 4, 2025
4f49dde
TestTestgresCommon.test_pgbench is added
dmitry-lipetskApr 4, 2025
4fbf51d
PostgresNodePortManager is updated [error messages]
dmitry-lipetskApr 4, 2025
17c73cb
PostgresNodePortManager(+company) was moved in own file - port_manage…
dmitry-lipetskApr 4, 2025
b1cee19
PortManager was deleted [amen]
dmitry-lipetskApr 4, 2025
c5ad907
PostgresNodePortManager was renamed with PortManager
dmitry-lipetskApr 4, 2025
0967057
TestTestgresCommon.test_unix_sockets is added
dmitry-lipetskApr 4, 2025
1d450b2
TestTestgresCommon.test_the_same_port is added
dmitry-lipetskApr 4, 2025
4a38b35
[TestTestgresCommon] New tests are added
dmitry-lipetskApr 4, 2025
322fb23
RemoteOperations::is_port_free is updated
dmitry-lipetskApr 4, 2025
94da63e
Tests for OsOps::is_port_free are added
dmitry-lipetskApr 4, 2025
88f9b73
TestTestgresCommon is corrected [python problems]
dmitry-lipetskApr 4, 2025
d9558ce
The call of RaiseError.CommandExecutionError is fixed [message, not m…
dmitry-lipetskApr 4, 2025
0da4c21
[CI] ubuntu 24.04 does not have nc
dmitry-lipetskApr 4, 2025
0058508
RemoteOperations is update [private method names]
dmitry-lipetskApr 5, 2025
8f3a566
test_is_port_free__true is updated
dmitry-lipetskApr 5, 2025
d8ebdb7
RemoteOperations::is_port_free is updated (comments)
dmitry-lipetskApr 5, 2025
30e472c
setup.py is updated [testgres.helpers was deleted]
dmitry-lipetskApr 5, 2025
c94bbb5
Comment in node.py is updated
dmitry-lipetskApr 5, 2025
04f88c7
PostgresNode::_node was deleted [use self._os_ops.host]
dmitry-lipetskApr 5, 2025
0a3442a
PostgresNode::start is corrected [error message]
dmitry-lipetskApr 5, 2025
30124f3
Merge branch 'master' into D20250403_001--port_manager
dmitry-lipetskApr 5, 2025
13e71d8
[FIX] PostgresNode.__init__ must not test "os_ops.host" attribute.
dmitry-lipetskApr 5, 2025
9e14f4a
PostgresNode.free_port always set a port to None
dmitry-lipetskApr 6, 2025
739ef61
[FIX] flake8 (noqa: E721)
dmitry-lipetskApr 6, 2025
696cc1e
PortManager__Generic is refactored
dmitry-lipetskApr 6, 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
PrevPrevious commit
NextNext commit
PostgresNodePortManager was renamed with PortManager
  • Loading branch information
@dmitry-lipetsk
dmitry-lipetsk committedApr 4, 2025
commitc5ad9078e98495ae904f23cba8b86a6c6e9ddceb
4 changes: 2 additions & 2 deletionstestgres/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@
DumpFormat

from .node import PostgresNode, NodeApp
from .node importPostgresNodePortManager
from .node importPortManager

from .utils import \
reserve_port, \
Expand DownExpand Up@@ -63,7 +63,7 @@
"TestgresException", "ExecUtilException", "QueryException", "TimeoutException", "CatchUpException", "StartNodeException", "InitNodeException", "BackupException", "InvalidOperationException",
"XLogMethod", "IsolationLevel", "NodeStatus", "ProcessType", "DumpFormat",
"PostgresNode", "NodeApp",
"PostgresNodePortManager",
"PortManager",
"reserve_port", "release_port", "bound_ports", "get_bin_path", "get_pg_config", "get_pg_version",
"First", "Any",
"OsOperations", "LocalOperations", "RemoteOperations", "ConnectionParams"
Expand Down
28 changes: 14 additions & 14 deletionstestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -83,9 +83,9 @@
BackupException, \
InvalidOperationException

from .port_manager importPostgresNodePortManager
from .port_manager importPostgresNodePortManager__ThisHost
from .port_manager importPostgresNodePortManager__Generic
from .port_manager importPortManager
from .port_manager importPortManager__ThisHost
from .port_manager importPortManager__Generic

from .logger import TestgresLogger

Expand DownExpand Up@@ -146,7 +146,7 @@ class PostgresNode(object):
_port: typing.Optional[int]
_should_free_port: bool
_os_ops: OsOperations
_port_manager:PostgresNodePortManager
_port_manager:PortManager

def __init__(self,
name=None,
Expand All@@ -156,7 +156,7 @@ def __init__(self,
bin_dir=None,
prefix=None,
os_ops: typing.Optional[OsOperations] = None,
port_manager: typing.Optional[PostgresNodePortManager] = None):
port_manager: typing.Optional[PortManager] = None):
"""
PostgresNode constructor.

Expand All@@ -170,7 +170,7 @@ def __init__(self,
"""
assert port is None or type(port) == int # noqa: E721
assert os_ops is None or isinstance(os_ops, OsOperations)
assert port_manager is None or isinstance(port_manager,PostgresNodePortManager)
assert port_manager is None or isinstance(port_manager,PortManager)

# private
if os_ops is None:
Expand DownExpand Up@@ -203,13 +203,13 @@ def __init__(self,
self._port_manager = None
else:
if port_manager is not None:
assert isinstance(port_manager,PostgresNodePortManager)
assert isinstance(port_manager,PortManager)
self._port_manager = port_manager
else:
self._port_manager = __class__._get_port_manager(self._os_ops)

assert self._port_manager is not None
assert isinstance(self._port_manager,PostgresNodePortManager)
assert isinstance(self._port_manager,PortManager)

self._port = self._port_manager.reserve_port() # raises
assert type(self._port) == int # noqa: E721
Expand DownExpand Up@@ -269,15 +269,15 @@ def _get_os_ops(conn_params: ConnectionParams) -> OsOperations:
return LocalOperations(conn_params)

@staticmethod
def _get_port_manager(os_ops: OsOperations) ->PostgresNodePortManager:
def _get_port_manager(os_ops: OsOperations) ->PortManager:
assert os_ops is not None
assert isinstance(os_ops, OsOperations)

if isinstance(os_ops, LocalOperations):
returnPostgresNodePortManager__ThisHost()
returnPortManager__ThisHost()

# TODO: Throw exception "Please define a port manager."
returnPostgresNodePortManager__Generic(os_ops)
returnPortManager__Generic(os_ops)

def clone_with_new_name_and_base_dir(self, name: str, base_dir: str):
assert name is None or type(name) == str # noqa: E721
Expand All@@ -289,7 +289,7 @@ def clone_with_new_name_and_base_dir(self, name: str, base_dir: str):
raise InvalidOperationException("PostgresNode without PortManager can't be cloned.")

assert self._port_manager is not None
assert isinstance(self._port_manager,PostgresNodePortManager)
assert isinstance(self._port_manager,PortManager)
assert self._os_ops is not None
assert isinstance(self._os_ops, OsOperations)

Expand DownExpand Up@@ -1124,7 +1124,7 @@ def LOCAL__raise_cannot_start_node__std(from_exception):
else:
assert self._should_free_port
assert self._port_manager is not None
assert isinstance(self._port_manager,PostgresNodePortManager)
assert isinstance(self._port_manager,PortManager)
assert __class__._C_MAX_START_ATEMPTS > 1

log_files0 = self._collect_log_files()
Expand DownExpand Up@@ -1331,7 +1331,7 @@ def free_port(self):
assert type(self._port) == int # noqa: E721

assert self._port_manager is not None
assert isinstance(self._port_manager,PostgresNodePortManager)
assert isinstance(self._port_manager,PortManager)

port = self._port
self._should_free_port = False
Expand Down
16 changes: 8 additions & 8 deletionstestgres/port_manager.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,27 +8,27 @@
import random


classPostgresNodePortManager:
classPortManager:
def __init__(self):
super().__init__()

def reserve_port(self) -> int:
raise NotImplementedError("PostgresNodePortManager::reserve_port is not implemented.")
raise NotImplementedError("PortManager::reserve_port is not implemented.")

def release_port(self, number: int) -> None:
assert type(number) == int # noqa: E721
raise NotImplementedError("PostgresNodePortManager::release_port is not implemented.")
raise NotImplementedError("PortManager::release_port is not implemented.")


classPostgresNodePortManager__ThisHost(PostgresNodePortManager):
sm_single_instance:PostgresNodePortManager = None
classPortManager__ThisHost(PortManager):
sm_single_instance:PortManager = None
sm_single_instance_guard = threading.Lock()

def __init__(self):
pass

def __new__(cls) ->PostgresNodePortManager:
assert __class__ ==PostgresNodePortManager__ThisHost
def __new__(cls) ->PortManager:
assert __class__ ==PortManager__ThisHost
assert __class__.sm_single_instance_guard is not None

if __class__.sm_single_instance is None:
Expand All@@ -46,7 +46,7 @@ def release_port(self, number: int) -> None:
return utils.release_port(number)


classPostgresNodePortManager__Generic(PostgresNodePortManager):
classPortManager__Generic(PortManager):
_os_ops: OsOperations
_allocated_ports_guard: object
_allocated_ports: set[int]
Expand Down
3 changes: 3 additions & 0 deletionstestgres/utils.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,9 @@ def internal__release_port(port):
Free port provided by reserve_port().
"""

assert type(port) == int # noqa: E721
assert port in bound_ports

bound_ports.discard(port)


Expand Down
18 changes: 9 additions & 9 deletionstests/helpers/global_data.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,9 +3,9 @@
from ...testgres.operations.local_ops import LocalOperations
from ...testgres.operations.remote_ops import RemoteOperations

from ...testgres.node importPostgresNodePortManager
from ...testgres.node importPostgresNodePortManager__ThisHost
from ...testgres.node importPostgresNodePortManager__Generic
from ...testgres.node importPortManager
from ...testgres.node importPortManager__ThisHost
from ...testgres.node importPortManager__Generic

import os

Expand DownExpand Up@@ -37,22 +37,22 @@ class OsOpsDescrs:


class PortManagers:
sm_remote_port_manager =PostgresNodePortManager__Generic(OsOpsDescrs.sm_remote_os_ops)
sm_remote_port_manager =PortManager__Generic(OsOpsDescrs.sm_remote_os_ops)

sm_local_port_manager =PostgresNodePortManager__ThisHost()
sm_local_port_manager =PortManager__ThisHost()

sm_local2_port_manager =PostgresNodePortManager__Generic(OsOpsDescrs.sm_local_os_ops)
sm_local2_port_manager =PortManager__Generic(OsOpsDescrs.sm_local_os_ops)


class PostgresNodeService:
sign: str
os_ops: OsOperations
port_manager:PostgresNodePortManager
port_manager:PortManager

def __init__(self, sign: str, os_ops: OsOperations, port_manager:PostgresNodePortManager):
def __init__(self, sign: str, os_ops: OsOperations, port_manager:PortManager):
assert type(sign) == str # noqa: E721
assert isinstance(os_ops, OsOperations)
assert isinstance(port_manager,PostgresNodePortManager)
assert isinstance(port_manager,PortManager)
self.sign = sign
self.os_ops = os_ops
self.port_manager = port_manager
Expand Down
6 changes: 3 additions & 3 deletionstests/test_testgres_common.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
from .helpers.global_data import PostgresNodeService
from .helpers.global_data import PostgresNodeServices
from .helpers.global_data import OsOperations
from .helpers.global_data importPostgresNodePortManager
from .helpers.global_data importPortManager

from ..testgres.node import PgVer
from ..testgres.node import PostgresNode
Expand DownExpand Up@@ -70,7 +70,7 @@ def node_svc(self, request: pytest.FixtureRequest) -> PostgresNodeService:
assert isinstance(request, pytest.FixtureRequest)
assert isinstance(request.param, PostgresNodeService)
assert isinstance(request.param.os_ops, OsOperations)
assert isinstance(request.param.port_manager,PostgresNodePortManager)
assert isinstance(request.param.port_manager,PortManager)
return request.param

def test_version_management(self, node_svc: PostgresNodeService):
Expand DownExpand Up@@ -1125,7 +1125,7 @@ def test_pgbench(self, node_svc: PostgresNodeService):
def helper__get_node(node_svc: PostgresNodeService, name=None):
assert isinstance(node_svc, PostgresNodeService)
assert isinstance(node_svc.os_ops, OsOperations)
assert isinstance(node_svc.port_manager,PostgresNodePortManager)
assert isinstance(node_svc.port_manager,PortManager)
return PostgresNode(
name,
conn_params=None,
Expand Down
2 changes: 1 addition & 1 deletiontests/test_testgres_remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -246,7 +246,7 @@ def helper__get_node(name=None):

assert isinstance(svc, PostgresNodeService)
assert isinstance(svc.os_ops, testgres.OsOperations)
assert isinstance(svc.port_manager, testgres.PostgresNodePortManager)
assert isinstance(svc.port_manager, testgres.PortManager)

return testgres.PostgresNode(
name,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp