Skip to content

Commit 0b331e6

Browse files
Releasing of reserved port in tests (#248)
* [test] TestTestgresLocal.test_pg_ctl_wait_option is corrected Let's "release" all our test nodes correctly. * [test] TestTestgresLocal.test_simple_with_bin_dir is corrected Let's "release" all our test nodes correctly.
1 parent 5f8f5dd commit 0b331e6

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

tests/test_testgres_common.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -883,10 +883,20 @@ def test_backup_wrong_xlog_method(self, node_svc: PostgresNodeService):
883883

884884
def test_pg_ctl_wait_option(self, node_svc: PostgresNodeService):
885885
assert isinstance(node_svc, PostgresNodeService)
886-
C_MAX_ATTEMPTS = 50
886+
with __class__.helper__get_node(node_svc) as node:
887+
self.impl__test_pg_ctl_wait_option(node_svc, node)
887888

888-
node = __class__.helper__get_node(node_svc)
889+
def impl__test_pg_ctl_wait_option(
890+
self,
891+
node_svc: PostgresNodeService,
892+
node: PostgresNode
893+
) -> None:
894+
assert isinstance(node_svc, PostgresNodeService)
895+
assert isinstance(node, PostgresNode)
889896
assert node.status() == NodeStatus.Uninitialized
897+
898+
C_MAX_ATTEMPTS = 50
899+
890900
node.init()
891901
assert node.status() == NodeStatus.Stopped
892902
node.start(wait=False)
@@ -950,7 +960,6 @@ def test_pg_ctl_wait_option(self, node_svc: PostgresNodeService):
950960
raise Exception("Unexpected node status: {0}.".format(s1))
951961

952962
logging.info("OK. Node is stopped.")
953-
node.cleanup()
954963

955964
def test_replicate(self, node_svc: PostgresNodeService):
956965
assert isinstance(node_svc, PostgresNodeService)

tests/test_testgres_local.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,10 @@ def test_simple_with_bin_dir(self):
341341
bin_dir = node.bin_dir
342342

343343
app = NodeApp()
344-
correct_bin_dir = app.make_simple(base_dir=node.base_dir, bin_dir=bin_dir)
345-
correct_bin_dir.slow_start()
346-
correct_bin_dir.safe_psql("SELECT 1;")
347-
correct_bin_dir.stop()
344+
with app.make_simple(base_dir=node.base_dir, bin_dir=bin_dir) as correct_bin_dir:
345+
correct_bin_dir.slow_start()
346+
correct_bin_dir.safe_psql("SELECT 1;")
347+
correct_bin_dir.stop()
348348

349349
while True:
350350
try:

0 commit comments

Comments
 (0)