Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf6de273

Browse files
Merge pull request#157 from dmitry-lipetsk/D20241206_001--make_simple
NodeApp::make_simple is refactored (tempfile.gettempdir)
2 parents5e9ecbc +1d44628 commitf6de273

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
importsignal
66
importsubprocess
77
importthreading
8+
importtempfile
89
fromqueueimportQueue
910

1011
importtime
@@ -1761,6 +1762,8 @@ def make_simple(
17611762
pg_options={},
17621763
checksum=True,
17631764
bin_dir=None):
1765+
asserttype(pg_options)==dict# noqa: E721
1766+
17641767
ifchecksumand'--data-checksums'notininitdb_params:
17651768
initdb_params.append('--data-checksums')
17661769
node=self.make_empty(base_dir,port,bin_dir=bin_dir)
@@ -1773,20 +1776,22 @@ def make_simple(
17731776
node.major_version=float(node.major_version_str)
17741777

17751778
# Set default parameters
1776-
options= {'max_connections':100,
1777-
'shared_buffers':'10MB',
1778-
'fsync':'off',
1779-
'wal_level':'logical',
1780-
'hot_standby':'off',
1781-
'log_line_prefix':'%t [%p]: [%l-1] ',
1782-
'log_statement':'none',
1783-
'log_duration':'on',
1784-
'log_min_duration_statement':0,
1785-
'log_connections':'on',
1786-
'log_disconnections':'on',
1787-
'restart_after_crash':'off',
1788-
'autovacuum':'off',
1789-
'unix_socket_directories':'/tmp'}
1779+
options= {
1780+
'max_connections':100,
1781+
'shared_buffers':'10MB',
1782+
'fsync':'off',
1783+
'wal_level':'logical',
1784+
'hot_standby':'off',
1785+
'log_line_prefix':'%t [%p]: [%l-1] ',
1786+
'log_statement':'none',
1787+
'log_duration':'on',
1788+
'log_min_duration_statement':0,
1789+
'log_connections':'on',
1790+
'log_disconnections':'on',
1791+
'restart_after_crash':'off',
1792+
'autovacuum':'off',
1793+
# unix_socket_directories will be defined later
1794+
}
17901795

17911796
# Allow replication in pg_hba.conf
17921797
ifset_replication:
@@ -1801,11 +1806,16 @@ def make_simple(
18011806
else:
18021807
options['wal_keep_segments']='12'
18031808

1804-
# set default values
1805-
node.set_auto_conf(options)
1806-
18071809
# Apply given parameters
1808-
node.set_auto_conf(pg_options)
1810+
foroption_name,option_valueiniteritems(pg_options):
1811+
options[option_name]=option_value
1812+
1813+
# Define delayed propertyes
1814+
ifnot ("unix_socket_directories"inoptions.keys()):
1815+
options["unix_socket_directories"]=__class__._gettempdir()
1816+
1817+
# Set config values
1818+
node.set_auto_conf(options)
18091819

18101820
# kludge for testgres
18111821
# https://github.com/postgrespro/testgres/issues/54
@@ -1814,3 +1824,26 @@ def make_simple(
18141824
node.set_auto_conf({},'postgresql.conf', ['wal_keep_segments'])
18151825

18161826
returnnode
1827+
1828+
def_gettempdir():
1829+
v=tempfile.gettempdir()
1830+
1831+
#
1832+
# Paranoid checks
1833+
#
1834+
iftype(v)!=str:# noqa: E721
1835+
__class__._raise_bugcheck("tempfile.gettempdir returned a value with type {0}.".format(type(v).__name__))
1836+
1837+
ifv=="":
1838+
__class__._raise_bugcheck("tempfile.gettempdir returned an empty string.")
1839+
1840+
ifnotos.path.exists(v):
1841+
__class__._raise_bugcheck("tempfile.gettempdir returned a not exist path [{0}].".format(v))
1842+
1843+
# OK
1844+
returnv
1845+
1846+
def_raise_bugcheck(msg):
1847+
asserttype(msg)==str# noqa: E721
1848+
assertmsg!=""
1849+
raiseException("[BUG CHECK] "+msg)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp