@@ -315,15 +315,7 @@ def logs_dir(self):
315
315
316
316
@property
317
317
def data_dir (self ):
318
- # NOTE: we can't run initdb without user's args
319
- if hasattr (self , '_data_dir' ):
320
- return self ._data_dir
321
- else :
322
- return os .path .join (self .base_dir , DATA_DIR )
323
-
324
- @data_dir .setter
325
- def data_dir (self , value ):
326
- self ._data_dir = value
318
+ return os .path .join (self .base_dir , DATA_DIR )
327
319
328
320
@property
329
321
def utils_log_file (self ):
@@ -726,7 +718,7 @@ def get_control_data(self):
726
718
727
719
return out_dict
728
720
729
- def slow_start (self , replica = False , dbname = 'template1' , username = None , max_attempts = 0 ):
721
+ def slow_start (self , replica = False , dbname = 'template1' , username = None , max_attempts = 0 , custom_data_dir = None ):
730
722
"""
731
723
Starts the PostgreSQL instance and then polls the instance
732
724
until it reaches the expected state (primary or replica). The state is checked
@@ -739,7 +731,7 @@ def slow_start(self, replica=False, dbname='template1', username=None, max_attem
739
731
If False, waits for the instance to be in primary mode. Default is False.
740
732
max_attempts:
741
733
"""
742
- self .start ()
734
+ self .start (custom_data_dir = custom_data_dir )
743
735
744
736
if replica :
745
737
query = 'SELECT pg_is_in_recovery()'
@@ -771,7 +763,7 @@ def _detect_port_conflict(self, log_files0, log_files1):
771
763
return True
772
764
return False
773
765
774
- def start (self , params = [], wait = True ):
766
+ def start (self , params = [], wait = True , custom_data_dir = None ):
775
767
"""
776
768
Starts the PostgreSQL node using pg_ctl if node has not been started.
777
769
By default, it waits for the operation to complete before returning.
@@ -792,7 +784,7 @@ def start(self, params=[], wait=True):
792
784
return self
793
785
794
786
_params = [self ._get_bin_path ("pg_ctl" ),
795
- "-D" , self .data_dir ,
787
+ "-D" , custom_data_dir if custom_data_dir else self .data_dir ,
796
788
"-l" , self .pg_log_file ,
797
789
"-w" if wait else '-W' , # --wait or --no-wait
798
790
"start" ] + params # yapf: disable
@@ -868,7 +860,7 @@ def LOCAL__raise_cannot_start_node__std(from_exception):
868
860
self .is_started = True
869
861
return self
870
862
871
- def stop (self , params = [], wait = True ):
863
+ def stop (self , params = [], wait = True , custom_data_dir = None ):
872
864
"""
873
865
Stops the PostgreSQL node using pg_ctl if the node has been started.
874
866
@@ -884,7 +876,7 @@ def stop(self, params=[], wait=True):
884
876
885
877
_params = [
886
878
self ._get_bin_path ("pg_ctl" ),
887
- "-D" , self .data_dir ,
879
+ "-D" , custom_data_dir if custom_data_dir else self .data_dir ,
888
880
"-w" if wait else '-W' , # --wait or --no-wait
889
881
"stop"
890
882
] + params # yapf: disable
0 commit comments