Commit 32fbf0d4 authored by Jérome Perrin's avatar Jérome Perrin

recipe/postgres: support non standard port

even though the recipe has a required option for port, it was not used
and server was always listening on default (5432) port
parent 90650d2c
Pipeline #18305 passed with stage
in 0 seconds
...@@ -147,6 +147,7 @@ class Recipe(GenericBaseRecipe): ...@@ -147,6 +147,7 @@ class Recipe(GenericBaseRecipe):
with open(postgres_conf, 'w') as cfg: with open(postgres_conf, 'w') as cfg:
cfg.write(textwrap.dedent("""\ cfg.write(textwrap.dedent("""\
listen_addresses = '%s' listen_addresses = '%s'
port = %s
logging_collector = on logging_collector = on
log_rotation_size = 50MB log_rotation_size = 50MB
max_connections = 100 max_connections = 100
...@@ -162,6 +163,7 @@ class Recipe(GenericBaseRecipe): ...@@ -162,6 +163,7 @@ class Recipe(GenericBaseRecipe):
unix_socket_permissions = 0700 unix_socket_permissions = 0700
""" % ( """ % (
','.join(set(ipv4).union(ipv6)), ','.join(set(ipv4).union(ipv6)),
self.options['port'],
pgdata, pgdata,
))) )))
...@@ -215,6 +217,7 @@ class Recipe(GenericBaseRecipe): ...@@ -215,6 +217,7 @@ class Recipe(GenericBaseRecipe):
p = subprocess.Popen([ p = subprocess.Popen([
psql_binary, psql_binary,
'-h', pgdata, '-h', pgdata,
'-p', self.options['port'],
'-U', user, '-U', user,
'-d', self.options['dbname'], '-d', self.options['dbname'],
], ],
......
...@@ -110,3 +110,7 @@ class PostgresTest(unittest.TestCase): ...@@ -110,3 +110,7 @@ class PostgresTest(unittest.TestCase):
'password authentication failed' 'password authentication failed'
): ):
psycopg2.connect(dsn) psycopg2.connect(dsn)
class PostgresTestNonStandardPort(PostgresTest):
port = 5433
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment