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

[#264] New property PostgresNode::port_manager#269

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 fromall commits
Commits
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
7 changes: 6 additions & 1 deletiontestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -146,7 +146,7 @@ class PostgresNode(object):
_port: typing.Optional[int]
_should_free_port: bool
_os_ops: OsOperations
_port_manager: PortManager
_port_manager:typing.Optional[PortManager]

def __init__(self,
name=None,
Expand DownExpand Up@@ -313,6 +313,11 @@ def os_ops(self) -> OsOperations:
assert isinstance(self._os_ops, OsOperations)
return self._os_ops

@property
def port_manager(self) -> typing.Optional[PortManager]:
assert self._port_manager is None or isinstance(self._port_manager, PortManager)
return self._port_manager

@property
def name(self) -> str:
if self._name is None:
Expand Down
82 changes: 82 additions & 0 deletionstests/test_testgres_common.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1503,6 +1503,88 @@ def test_try_to_start_node_after_free_manual_port(self, node_svc: PostgresNodeSe
):
node2.start()

def test_node__os_ops(self, node_svc: PostgresNodeService):
assert type(node_svc) == PostgresNodeService # noqa: E721

assert node_svc.os_ops is not None
assert isinstance(node_svc.os_ops, OsOperations)

with PostgresNode(name="node", os_ops=node_svc.os_ops, port_manager=node_svc.port_manager) as node:
# retest
assert node_svc.os_ops is not None
assert isinstance(node_svc.os_ops, OsOperations)

assert node.os_ops is node_svc.os_ops
# one more time
assert node.os_ops is node_svc.os_ops

def test_node__port_manager(self, node_svc: PostgresNodeService):
assert type(node_svc) == PostgresNodeService # noqa: E721

assert node_svc.port_manager is not None
assert isinstance(node_svc.port_manager, PortManager)

with PostgresNode(name="node", os_ops=node_svc.os_ops, port_manager=node_svc.port_manager) as node:
# retest
assert node_svc.port_manager is not None
assert isinstance(node_svc.port_manager, PortManager)

assert node.port_manager is node_svc.port_manager
# one more time
assert node.port_manager is node_svc.port_manager

def test_node__port_manager_and_explicit_port(self, node_svc: PostgresNodeService):
assert type(node_svc) == PostgresNodeService # noqa: E721

assert isinstance(node_svc.os_ops, OsOperations)
assert node_svc.port_manager is not None
assert isinstance(node_svc.port_manager, PortManager)

port = node_svc.port_manager.reserve_port()
assert type(port) == int # noqa: E721

try:
with PostgresNode(name="node", port=port, os_ops=node_svc.os_ops) as node:
# retest
assert isinstance(node_svc.os_ops, OsOperations)
assert node_svc.port_manager is not None
assert isinstance(node_svc.port_manager, PortManager)

assert node.port_manager is None
assert node.os_ops is node_svc.os_ops

# one more time
assert node.port_manager is None
assert node.os_ops is node_svc.os_ops
finally:
node_svc.port_manager.release_port(port)

def test_node__no_port_manager(self, node_svc: PostgresNodeService):
assert type(node_svc) == PostgresNodeService # noqa: E721

assert isinstance(node_svc.os_ops, OsOperations)
assert node_svc.port_manager is not None
assert isinstance(node_svc.port_manager, PortManager)

port = node_svc.port_manager.reserve_port()
assert type(port) == int # noqa: E721

try:
with PostgresNode(name="node", port=port, os_ops=node_svc.os_ops, port_manager=None) as node:
# retest
assert isinstance(node_svc.os_ops, OsOperations)
assert node_svc.port_manager is not None
assert isinstance(node_svc.port_manager, PortManager)

assert node.port_manager is None
assert node.os_ops is node_svc.os_ops

# one more time
assert node.port_manager is None
assert node.os_ops is node_svc.os_ops
finally:
node_svc.port_manager.release_port(port)

@staticmethod
def helper__get_node(
node_svc: PostgresNodeService,
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp