diff --git a/testgres/node.py b/testgres/node.py index d68f3d34..f93f8787 100644 --- a/testgres/node.py +++ b/testgres/node.py @@ -564,12 +564,13 @@ def get_control_data(self): return out_dict - def start(self, params=[]): + def start(self, params=[], wait=True): """ Start this node using pg_ctl. Args: params: additional arguments for pg_ctl. + wait: wait until operation completes. Returns: This instance of :class:`.PostgresNode`. @@ -579,7 +580,7 @@ def start(self, params=[]): get_bin_path("pg_ctl"), "-D", self.data_dir, "-l", self.pg_log_file, - "-w", # wait + "-w" if wait else '-W', # --wait or --no-wait "start" ] + params # yapf: disable @@ -594,12 +595,13 @@ def start(self, params=[]): return self - def stop(self, params=[]): + def stop(self, params=[], wait=True): """ Stop this node using pg_ctl. Args: params: additional arguments for pg_ctl. + wait: wait until operation completes. Returns: This instance of :class:`.PostgresNode`. @@ -608,7 +610,7 @@ def stop(self, params=[]): _params = [ get_bin_path("pg_ctl"), "-D", self.data_dir, - "-w", # wait + "-w" if wait else '-W', # --wait or --no-wait "stop" ] + params # yapf: disable diff --git a/tests/test_simple.py b/tests/test_simple.py index f639e92a..9818e6a3 100755 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -373,6 +373,18 @@ def test_backup_wrong_xlog_method(self): BackupException, msg='Invalid xlog_method "wrong"'): node.backup(xlog_method='wrong') + def test_pg_ctl_wait_option(self): + with get_new_node() as node: + node.init().start(wait=False) + while True: + try: + node.stop(wait=False) + break + except ExecUtilException: + # it's ok to get this exception here since node + # could be not started yet + pass + def test_replicate(self): with get_new_node() as node: node.init(allow_streaming=True).start()