Commit f54c31b6 authored by Jérome Perrin's avatar Jérome Perrin

recipe/postgres: fix regression with empty port

32fbf0d4 (recipe/postgres: support non standard port, 2021-11-12)
broke support for empty port, it was generating config file with
`port = ` , which is an invalid config file syntax for postgresql.
parent 4b3a547f
Pipeline #18619 failed with stage
...@@ -147,7 +147,7 @@ class Recipe(GenericBaseRecipe): ...@@ -147,7 +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 %s
logging_collector = on logging_collector = on
log_rotation_size = 50MB log_rotation_size = 50MB
max_connections = 100 max_connections = 100
...@@ -163,7 +163,7 @@ class Recipe(GenericBaseRecipe): ...@@ -163,7 +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'], 'port = %s' % self.options['port'] if self.options['port'] else '',
pgdata, pgdata,
))) )))
......
import os import os
import shutil import shutil
import tempfile import tempfile
import textwrap
import time import time
import unittest import unittest
...@@ -54,7 +53,7 @@ class PostgresTest(unittest.TestCase): ...@@ -54,7 +53,7 @@ class PostgresTest(unittest.TestCase):
self.addCleanup(server_process.terminate) self.addCleanup(server_process.terminate)
# wait for server to accept connections # wait for server to accept connections
for i in range(60): for i in range(10):
time.sleep(i) time.sleep(i)
try: try:
psycopg2.connect(self.buildout['postgres']['url']).close() psycopg2.connect(self.buildout['postgres']['url']).close()
...@@ -114,3 +113,7 @@ class PostgresTest(unittest.TestCase): ...@@ -114,3 +113,7 @@ class PostgresTest(unittest.TestCase):
class PostgresTestNonStandardPort(PostgresTest): class PostgresTestNonStandardPort(PostgresTest):
port = 5433 port = 5433
class PostgresTestEmptyPort(PostgresTest):
port = ''
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