Skip to content

Commit a4055fc

Browse files
PostgresNode uses OsOps (#299)
* PostgresNode::kill uses os_ops.kill * PostgresNode::upgrade_from uses os_ops.path_exists
1 parent b31cdcd commit a4055fc

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/node.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,11 +1206,12 @@ def kill(self, someone=None):
12061206
If None, the main PostgreSQL node process will be killed. Defaults to None.
12071207
"""
12081208
if self.is_started:
1209+
assert isinstance(self._os_ops, OsOperations)
12091210
sig = signal.SIGKILL if os.name != 'nt' else signal.SIGBREAK
12101211
if someone is None:
1211-
os.kill(self.pid, sig)
1212+
self._os_ops.kill(self.pid, sig)
12121213
else:
1213-
os.kill(self.auxiliary_pids[someone][0], sig)
1214+
self._os_ops.kill(self.auxiliary_pids[someone][0], sig)
12141215
self.is_started = False
12151216

12161217
def restart(self, params=[]):
@@ -2119,18 +2120,19 @@ def upgrade_from(self, old_node, options=None, expect_error=False):
21192120
Args:
21202121
old_node: An instance of PostgresNode representing the old node.
21212122
"""
2122-
if not os.path.exists(old_node.data_dir):
2123+
assert isinstance(self._os_ops, OsOperations)
2124+
if not self._os_ops.path_exists(old_node.data_dir):
21232125
raise Exception("Old node must be initialized")
21242126

2125-
if not os.path.exists(self.data_dir):
2127+
if not self._os_ops.path_exists(self.data_dir):
21262128
self.init()
21272129

21282130
if not options:
21292131
options = []
21302132

21312133
pg_upgrade_binary = self._get_bin_path("pg_upgrade")
21322134

2133-
if not os.path.exists(pg_upgrade_binary):
2135+
if not self._os_ops.path_exists(pg_upgrade_binary):
21342136
raise Exception("pg_upgrade does not exist in the new node's binary path")
21352137

21362138
upgrade_command = [

0 commit comments

Comments
 (0)