Skip to content

Commit 3d8decb

Browse files
authored
Merge pull request #45 from ildus/master
Add wait option to start and stop functions
2 parents 34fdee2 + 2dc0659 commit 3d8decb

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Diff for: testgres/node.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,13 @@ def get_control_data(self):
564564

565565
return out_dict
566566

567-
def start(self, params=[]):
567+
def start(self, params=[], wait=True):
568568
"""
569569
Start this node using pg_ctl.
570570
571571
Args:
572572
params: additional arguments for pg_ctl.
573+
wait: wait until operation completes.
573574
574575
Returns:
575576
This instance of :class:`.PostgresNode`.
@@ -579,7 +580,7 @@ def start(self, params=[]):
579580
get_bin_path("pg_ctl"),
580581
"-D", self.data_dir,
581582
"-l", self.pg_log_file,
582-
"-w", # wait
583+
"-w" if wait else '-W', # --wait or --no-wait
583584
"start"
584585
] + params # yapf: disable
585586

@@ -594,12 +595,13 @@ def start(self, params=[]):
594595

595596
return self
596597

597-
def stop(self, params=[]):
598+
def stop(self, params=[], wait=True):
598599
"""
599600
Stop this node using pg_ctl.
600601
601602
Args:
602603
params: additional arguments for pg_ctl.
604+
wait: wait until operation completes.
603605
604606
Returns:
605607
This instance of :class:`.PostgresNode`.
@@ -608,7 +610,7 @@ def stop(self, params=[]):
608610
_params = [
609611
get_bin_path("pg_ctl"),
610612
"-D", self.data_dir,
611-
"-w", # wait
613+
"-w" if wait else '-W', # --wait or --no-wait
612614
"stop"
613615
] + params # yapf: disable
614616

Diff for: tests/test_simple.py

+12
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,18 @@ def test_backup_wrong_xlog_method(self):
373373
BackupException, msg='Invalid xlog_method "wrong"'):
374374
node.backup(xlog_method='wrong')
375375

376+
def test_pg_ctl_wait_option(self):
377+
with get_new_node() as node:
378+
node.init().start(wait=False)
379+
while True:
380+
try:
381+
node.stop(wait=False)
382+
break
383+
except ExecUtilException:
384+
# it's ok to get this exception here since node
385+
# could be not started yet
386+
pass
387+
376388
def test_replicate(self):
377389
with get_new_node() as node:
378390
node.init(allow_streaming=True).start()

0 commit comments

Comments
 (0)