Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3006ecf

Browse files
committed
small refactoring for NodeBackup
1 parent c055739 commit 3006ecf

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

testgres/testgres.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,15 @@ def __enter__(self):
294294
def __exit__(self, type, value, traceback):
295295
self.cleanup()
296296

297-
def spawn_primary(self, name, destroy=True):
297+
def _prepare_dir(self, destroy):
298298
"""
299-
Create a primary node from a backup.
299+
Provide a data directory for a copy of node.
300300
301301
Args:
302-
name: name for a new node (str).
303302
destroy: should we convert this backup into a node?
304303
305304
Returns:
306-
New instance of PostgresNode.
305+
Path to data directory.
307306
"""
308307

309308
if not self.available:
@@ -326,14 +325,32 @@ def spawn_primary(self, name, destroy=True):
326325
else:
327326
base_dir = self.base_dir
328327

328+
# update value
329+
self.available = available
330+
331+
return base_dir
332+
333+
def spawn_primary(self, name, destroy=True):
334+
"""
335+
Create a primary node from a backup.
336+
337+
Args:
338+
name: name for a new node (str).
339+
destroy: should we convert this backup into a node?
340+
341+
Returns:
342+
New instance of PostgresNode.
343+
"""
344+
345+
base_dir = self._prepare_dir(destroy)
346+
329347
# build a new PostgresNode
330348
node = PostgresNode(name=name,
331349
base_dir=base_dir,
332350
master=self.original_node)
333-
node.append_conf("postgresql.conf", "port = {}".format(node.port))
334351

335-
# record new status
336-
self.available = available
352+
node.append_conf("postgresql.conf", "\n")
353+
node.append_conf("postgresql.conf", "port = {}".format(node.port))
337354

338355
return node
339356

0 commit comments

Comments
 (0)