@@ -112,13 +112,20 @@ def utils_log_name(self):
112112 def pg_log_name (self ):
113113 return os .path .join (self .data_dir , _PG_LOG_FILE )
114114
115- @property
116- def connstr (self ):
117- return "port={}" .format (self .port )
115+ def _create_recovery_conf (self , username , master ):
116+ # yapf: disable
117+ conninfo = (
118+ u"user={} "
119+ u"port={} "
120+ u"host={} "
121+ u"application_name={}"
122+ ).format (username , master .port , master .host , master .name )
118123
119- def _create_recovery_conf (self , root_node ):
120- line = ("primary_conninfo='{} application_name={}'\n "
121- "standby_mode=on\n " ).format (root_node .connstr , self .name )
124+ # yapf: disable
125+ line = (
126+ "primary_conninfo='{}'\n "
127+ "standby_mode=on\n "
128+ ).format (conninfo )
122129
123130 self .append_conf ("recovery.conf" , line )
124131
@@ -175,13 +182,18 @@ def print_node_file(node_file):
175182
176183 return error_text
177184
178- def init (self , allow_streaming = False , fsync = False , initdb_params = []):
185+ def init (self ,
186+ fsync = False ,
187+ unix_sockets = True ,
188+ allow_streaming = False ,
189+ initdb_params = []):
179190 """
180191 Perform initdb for this node.
181192
182193 Args:
183- allow_streaming: should this node add a hba entry for replication?
184194 fsync: should this node use fsync to keep data safe?
195+ unix_sockets: should we enable UNIX sockets?
196+ allow_streaming: should this node add a hba entry for replication?
185197 initdb_params: parameters for initdb (list).
186198
187199 Returns:
@@ -196,22 +208,25 @@ def init(self, allow_streaming=False, fsync=False, initdb_params=[]):
196208 _cached_initdb (self .data_dir , initdb_log , initdb_params )
197209
198210 # initialize default config files
199- self .default_conf (allow_streaming = allow_streaming , fsync = fsync )
211+ self .default_conf (fsync = fsync ,
212+ unix_sockets = unix_sockets ,
213+ allow_streaming = allow_streaming )
200214
201215 return self
202216
203217 def default_conf (self ,
204- allow_streaming = False ,
205218 fsync = False ,
219+ unix_sockets = True ,
220+ allow_streaming = False ,
206221 log_statement = 'all' ):
207222 """
208223 Apply default settings to this node.
209224
210225 Args:
211- allow_streaming: should this node add a hba entry for replication?
212226 fsync: should this node use fsync to keep data safe?
213- log_statement: one of ('all', 'off', 'mod', 'ddl'), look at
214- PostgreSQL docs for more information
227+ unix_sockets: should we enable UNIX sockets?
228+ allow_streaming: should this node add a hba entry for replication?
229+ log_statement: one of ('all', 'off', 'mod', 'ddl').
215230
216231 Returns:
217232 This instance of PostgresNode.
@@ -258,6 +273,9 @@ def get_auth_method(t):
258273
259274 # overwrite postgresql.conf file
260275 with io .open (postgres_conf , "w" ) as conf :
276+ # remove old lines
277+ conf .truncate ()
278+
261279 if not fsync :
262280 conf .write (u"fsync = off\n " )
263281
@@ -287,6 +305,10 @@ def get_auth_method(t):
287305 wal_keep_segments ,
288306 wal_level ))
289307
308+ # disable UNIX sockets if asked to
309+ if not unix_sockets :
310+ conf .write (u"unix_socket_directories = ''\n " )
311+
290312 return self
291313
292314 def append_conf (self , filename , string ):
@@ -784,7 +806,7 @@ def replicate(self,
784806 """
785807
786808 backup = self .backup (username = username , xlog_method = xlog_method )
787- return backup .spawn_replica (name , use_logging = use_logging )
809+ return backup .spawn_replica (name = name , use_logging = use_logging )
788810
789811 def catchup (self , dbname = 'postgres' , username = None ):
790812 """
0 commit comments