3030HBA_CONF_FILE , \
3131RECOVERY_CONF_FILE , \
3232PG_LOG_FILE , \
33- UTILS_LOG_FILE , \
34- DEFAULT_XLOG_METHOD
33+ UTILS_LOG_FILE
3534
3635from .decorators import \
3736method_decorator , \
@@ -112,7 +111,7 @@ def __enter__(self):
112111def __exit__ (self ,type ,value ,traceback ):
113112self .free_port ()
114113
115- # NOTE:ctrl +C does not count!
114+ # NOTE:Ctrl +C does not count!
116115got_exception = type is not None and type != KeyboardInterrupt
117116
118117c1 = self .cleanup_on_good_exit and not got_exception
@@ -254,19 +253,15 @@ def _collect_special_files(self):
254253
255254return result
256255
257- def init (self ,
258- fsync = False ,
259- unix_sockets = True ,
260- allow_streaming = True ,
261- initdb_params = None ):
256+ def init (self ,initdb_params = None ,** kwargs ):
262257"""
263258 Perform initdb for this node.
264259
265260 Args:
261+ initdb_params: parameters for initdb (list).
266262 fsync: should this node use fsync to keep data safe?
267263 unix_sockets: should we enable UNIX sockets?
268264 allow_streaming: should this node add a hba entry for replication?
269- initdb_params: parameters for initdb (list).
270265
271266 Returns:
272267 This instance of PostgresNode.
@@ -281,9 +276,7 @@ def init(self,
281276params = initdb_params )
282277
283278# initialize default config files
284- self .default_conf (fsync = fsync ,
285- unix_sockets = unix_sockets ,
286- allow_streaming = allow_streaming )
279+ self .default_conf (** kwargs )
287280
288281return self
289282
@@ -682,16 +675,13 @@ def psql(self,
682675return process .returncode ,out ,err
683676
684677@method_decorator (positional_args_hack (['dbname' ,'query' ]))
685- def safe_psql (self ,
686- query ,
687- dbname = None ,
688- username = None ,
689- input = None ):
678+ def safe_psql (self ,query = None ,** kwargs ):
690679"""
691680 Execute a query using psql.
692681
693682 Args:
694683 query: query to be executed.
684+ filename: file with a query.
695685 dbname: database name to connect to.
696686 username: database user name.
697687 input: raw input to be passed.
@@ -700,10 +690,7 @@ def safe_psql(self,
700690 psql's output as str.
701691 """
702692
703- ret ,out ,err = self .psql (query = query ,
704- dbname = dbname ,
705- username = username ,
706- input = input )
693+ ret ,out ,err = self .psql (query = query ,** kwargs )
707694if ret :
708695raise QueryException ((err or b'' ).decode ('utf-8' ),query )
709696
@@ -859,37 +846,34 @@ def execute(self,
859846
860847return res
861848
862- def backup (self ,username = None , xlog_method = DEFAULT_XLOG_METHOD ):
849+ def backup (self ,** kwargs ):
863850"""
864851 Perform pg_basebackup.
865852
866853 Args:
867854 username: database user name.
868855 xlog_method: a method for collecting the logs ('fetch' | 'stream').
856+ base_dir: the base directory for data files and logs
869857
870858 Returns:
871859 A smart object of type NodeBackup.
872860 """
873861
874862from .backup import NodeBackup
875- return NodeBackup (node = self ,
876- username = username ,
877- xlog_method = xlog_method )
863+ return NodeBackup (node = self ,** kwargs )
878864
879- def replicate (self ,
880- name = None ,
881- username = None ,
882- xlog_method = DEFAULT_XLOG_METHOD ):
865+ def replicate (self ,name = None ,** kwargs ):
883866"""
884867 Create a binary replica of this node.
885868
886869 Args:
887870 name: replica's application name.
888871 username: database user name.
889872 xlog_method: a method for collecting the logs ('fetch' | 'stream').
873+ base_dir: the base directory for data files and logs
890874 """
891875
892- backup = self .backup (username = username , xlog_method = xlog_method )
876+ backup = self .backup (** kwargs )
893877
894878# transform backup into a replica
895879return backup .spawn_replica (name = name ,destroy = True )