@@ -440,15 +440,7 @@ def logs_dir(self):
440440
441441 @property
442442 def data_dir (self ):
443- # NOTE: we can't run initdb without user's args
444- if hasattr (self , '_data_dir' ):
445- return self ._data_dir
446- else :
447- return os .path .join (self .base_dir , DATA_DIR )
448-
449- @data_dir .setter
450- def data_dir (self , value ):
451- self ._data_dir = value
443+ return os .path .join (self .base_dir , DATA_DIR )
452444
453445 @property
454446 def utils_log_file (self ):
@@ -894,7 +886,7 @@ def get_control_data(self):
894886
895887 return out_dict
896888
897- def slow_start (self , replica = False , dbname = 'template1' , username = None , max_attempts = 0 ):
889+ def slow_start (self , replica = False , dbname = 'template1' , username = None , max_attempts = 0 , custom_data_dir = None ):
898890 """
899891 Starts the PostgreSQL instance and then polls the instance
900892 until it reaches the expected state (primary or replica). The state is checked
@@ -907,7 +899,7 @@ def slow_start(self, replica=False, dbname='template1', username=None, max_attem
907899 If False, waits for the instance to be in primary mode. Default is False.
908900 max_attempts:
909901 """
910- self .start ()
902+ self .start (custom_data_dir = custom_data_dir )
911903
912904 if replica :
913905 query = 'SELECT pg_is_in_recovery()'
@@ -939,7 +931,7 @@ def _detect_port_conflict(self, log_files0, log_files1):
939931 return True
940932 return False
941933
942- def start (self , params = [], wait = True ):
934+ def start (self , params = [], wait = True , custom_data_dir = None ):
943935 """
944936 Starts the PostgreSQL node using pg_ctl if node has not been started.
945937 By default, it waits for the operation to complete before returning.
@@ -960,7 +952,7 @@ def start(self, params=[], wait=True):
960952 return self
961953
962954 _params = [self ._get_bin_path ("pg_ctl" ),
963- "-D" , self .data_dir ,
955+ "-D" , custom_data_dir if custom_data_dir else self .data_dir ,
964956 "-l" , self .pg_log_file ,
965957 "-w" if wait else '-W' , # --wait or --no-wait
966958 "start" ] + params # yapf: disable
@@ -1035,7 +1027,7 @@ def LOCAL__raise_cannot_start_node__std(from_exception):
10351027 self .is_started = True
10361028 return self
10371029
1038- def stop (self , params = [], wait = True ):
1030+ def stop (self , params = [], wait = True , custom_data_dir = None ):
10391031 """
10401032 Stops the PostgreSQL node using pg_ctl if the node has been started.
10411033
@@ -1051,7 +1043,7 @@ def stop(self, params=[], wait=True):
10511043
10521044 _params = [
10531045 self ._get_bin_path ("pg_ctl" ),
1054- "-D" , self .data_dir ,
1046+ "-D" , custom_data_dir if custom_data_dir else self .data_dir ,
10551047 "-w" if wait else '-W' , # --wait or --no-wait
10561048 "stop"
10571049 ] + params # yapf: disable
0 commit comments