Skip to content

Commit fb6205d

Browse files
Merge branch 'master' into skip-ssl-check
2 parents 547081e + f6de273 commit fb6205d

File tree

1 file changed

+51
-18
lines changed

1 file changed

+51
-18
lines changed

testgres/node.py

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import signal
66
import subprocess
77
import threading
8+
import tempfile
89
from queue import Queue
910

1011
import time
@@ -1781,6 +1782,8 @@ def make_simple(
17811782
pg_options={},
17821783
checksum=True,
17831784
bin_dir=None):
1785+
assert type(pg_options) == dict # noqa: E721
1786+
17841787
if checksum and '--data-checksums' not in initdb_params:
17851788
initdb_params.append('--data-checksums')
17861789
node = self.make_empty(base_dir, port, bin_dir=bin_dir)
@@ -1793,20 +1796,22 @@ def make_simple(
17931796
node.major_version = float(node.major_version_str)
17941797

17951798
# Set default parameters
1796-
options = {'max_connections': 100,
1797-
'shared_buffers': '10MB',
1798-
'fsync': 'off',
1799-
'wal_level': 'logical',
1800-
'hot_standby': 'off',
1801-
'log_line_prefix': '%t [%p]: [%l-1] ',
1802-
'log_statement': 'none',
1803-
'log_duration': 'on',
1804-
'log_min_duration_statement': 0,
1805-
'log_connections': 'on',
1806-
'log_disconnections': 'on',
1807-
'restart_after_crash': 'off',
1808-
'autovacuum': 'off',
1809-
'unix_socket_directories': '/tmp'}
1799+
options = {
1800+
'max_connections': 100,
1801+
'shared_buffers': '10MB',
1802+
'fsync': 'off',
1803+
'wal_level': 'logical',
1804+
'hot_standby': 'off',
1805+
'log_line_prefix': '%t [%p]: [%l-1] ',
1806+
'log_statement': 'none',
1807+
'log_duration': 'on',
1808+
'log_min_duration_statement': 0,
1809+
'log_connections': 'on',
1810+
'log_disconnections': 'on',
1811+
'restart_after_crash': 'off',
1812+
'autovacuum': 'off',
1813+
# unix_socket_directories will be defined later
1814+
}
18101815

18111816
# Allow replication in pg_hba.conf
18121817
if set_replication:
@@ -1821,11 +1826,16 @@ def make_simple(
18211826
else:
18221827
options['wal_keep_segments'] = '12'
18231828

1824-
# set default values
1825-
node.set_auto_conf(options)
1826-
18271829
# Apply given parameters
1828-
node.set_auto_conf(pg_options)
1830+
for option_name, option_value in iteritems(pg_options):
1831+
options[option_name] = option_value
1832+
1833+
# Define delayed propertyes
1834+
if not ("unix_socket_directories" in options.keys()):
1835+
options["unix_socket_directories"] = __class__._gettempdir()
1836+
1837+
# Set config values
1838+
node.set_auto_conf(options)
18291839

18301840
# kludge for testgres
18311841
# https://github.com/postgrespro/testgres/issues/54
@@ -1834,3 +1844,26 @@ def make_simple(
18341844
node.set_auto_conf({}, 'postgresql.conf', ['wal_keep_segments'])
18351845

18361846
return node
1847+
1848+
def _gettempdir():
1849+
v = tempfile.gettempdir()
1850+
1851+
#
1852+
# Paranoid checks
1853+
#
1854+
if type(v) != str: # noqa: E721
1855+
__class__._raise_bugcheck("tempfile.gettempdir returned a value with type {0}.".format(type(v).__name__))
1856+
1857+
if v == "":
1858+
__class__._raise_bugcheck("tempfile.gettempdir returned an empty string.")
1859+
1860+
if not os.path.exists(v):
1861+
__class__._raise_bugcheck("tempfile.gettempdir returned a not exist path [{0}].".format(v))
1862+
1863+
# OK
1864+
return v
1865+
1866+
def _raise_bugcheck(msg):
1867+
assert type(msg) == str # noqa: E721
1868+
assert msg != ""
1869+
raise Exception("[BUG CHECK] " + msg)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy