Skip to content

Commit 30af983

Browse files
committed
introduce default_conf()
1 parent 901f0ec commit 30af983

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

Diff for: testgres/testgres.py

+23-5
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ def init(self, allow_streaming=False, fsync=False, initdb_params=[]):
475475
"""
476476

477477
postgres_conf = os.path.join(self.data_dir, "postgresql.conf")
478-
hba_conf = os.path.join(self.data_dir, "pg_hba.conf")
479478

480479
# We don't have to reinit it if data directory exists
481480
if os.path.isfile(postgres_conf):
@@ -485,6 +484,26 @@ def init(self, allow_streaming=False, fsync=False, initdb_params=[]):
485484
initdb_log = os.path.join(self.logs_dir, "initdb.log")
486485
_cached_initdb(self.data_dir, initdb_log, initdb_params)
487486

487+
# initialize default config files
488+
self.default_conf(fsync=fsync)
489+
490+
return self
491+
492+
def default_conf(self, allow_streaming=True, fsync=False):
493+
"""
494+
Apply default settings to this node.
495+
496+
Args:
497+
allow_streaming: should this node add a hba entry for replication?
498+
fsync: should this node use fsync to keep data safe?
499+
500+
Returns:
501+
This instance of PostgresNode.
502+
"""
503+
504+
postgres_conf = os.path.join(self.data_dir, "postgresql.conf")
505+
hba_conf = os.path.join(self.data_dir, "pg_hba.conf")
506+
488507
# add parameters to hba file
489508
with open(hba_conf, "w") as conf:
490509
conf.write("# TYPE\tDATABASE\tUSER\tADDRESS\t\tMETHOD\n"
@@ -502,9 +521,9 @@ def init(self, allow_streaming=False, fsync=False, initdb_params=[]):
502521
conf.write("fsync = off\n")
503522

504523
conf.write("log_statement = all\n"
505-
"port = {}\n".format(self.port))
506-
507-
conf.write("listen_addresses = '{}'\n".format(self.host))
524+
"listen_addresses = '{}'\n"
525+
"port = {}\n".format(self.host,
526+
self.port))
508527

509528
if allow_streaming:
510529
cur_ver = LooseVersion(get_pg_config()["VERSION_NUM"])
@@ -516,7 +535,6 @@ def init(self, allow_streaming=False, fsync=False, initdb_params=[]):
516535
conf.write("max_wal_senders = 5\n"
517536
"wal_keep_segments = 20\n"
518537
"hot_standby = on\n"
519-
"max_connections = 10\n"
520538
"wal_level = {}\n".format(wal_level))
521539

522540
return self

0 commit comments

Comments
 (0)