- Notifications
You must be signed in to change notification settings - Fork35
NodeApp::make_simple is refactored (tempfile.gettempdir)#157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
dmitry-lipetsk merged 3 commits intopostgrespro:masterfromdmitry-lipetsk:D20241206_001--make_simpleDec 6, 2024
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
69 changes: 51 additions & 18 deletionstestgres/node.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -5,6 +5,7 @@ | ||
import signal | ||
import subprocess | ||
import threading | ||
import tempfile | ||
from queue import Queue | ||
import time | ||
@@ -1761,6 +1762,8 @@ def make_simple( | ||
pg_options={}, | ||
checksum=True, | ||
bin_dir=None): | ||
assert type(pg_options) == dict # noqa: E721 | ||
dmitry-lipetsk marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if checksum and '--data-checksums' not in initdb_params: | ||
initdb_params.append('--data-checksums') | ||
node = self.make_empty(base_dir, port, bin_dir=bin_dir) | ||
@@ -1773,20 +1776,22 @@ def make_simple( | ||
node.major_version = float(node.major_version_str) | ||
# Set default parameters | ||
options = { | ||
'max_connections': 100, | ||
'shared_buffers': '10MB', | ||
'fsync': 'off', | ||
'wal_level': 'logical', | ||
'hot_standby': 'off', | ||
'log_line_prefix': '%t [%p]: [%l-1] ', | ||
'log_statement': 'none', | ||
'log_duration': 'on', | ||
'log_min_duration_statement': 0, | ||
'log_connections': 'on', | ||
'log_disconnections': 'on', | ||
'restart_after_crash': 'off', | ||
'autovacuum': 'off', | ||
# unix_socket_directories will be defined later | ||
} | ||
# Allow replication in pg_hba.conf | ||
if set_replication: | ||
@@ -1801,11 +1806,16 @@ def make_simple( | ||
else: | ||
options['wal_keep_segments'] = '12' | ||
# Apply given parameters | ||
for option_name, option_value in iteritems(pg_options): | ||
options[option_name] = option_value | ||
# Define delayed propertyes | ||
if not ("unix_socket_directories" in options.keys()): | ||
options["unix_socket_directories"] = __class__._gettempdir() | ||
# Set config values | ||
node.set_auto_conf(options) | ||
# kludge for testgres | ||
# https://github.com/postgrespro/testgres/issues/54 | ||
@@ -1814,3 +1824,26 @@ def make_simple( | ||
node.set_auto_conf({}, 'postgresql.conf', ['wal_keep_segments']) | ||
return node | ||
def _gettempdir(): | ||
v = tempfile.gettempdir() | ||
# | ||
# Paranoid checks | ||
# | ||
if type(v) != str: # noqa: E721 | ||
__class__._raise_bugcheck("tempfile.gettempdir returned a value with type {0}.".format(type(v).__name__)) | ||
if v == "": | ||
__class__._raise_bugcheck("tempfile.gettempdir returned an empty string.") | ||
if not os.path.exists(v): | ||
__class__._raise_bugcheck("tempfile.gettempdir returned a not exist path [{0}].".format(v)) | ||
# OK | ||
return v | ||
def _raise_bugcheck(msg): | ||
assert type(msg) == str # noqa: E721 | ||
assert msg != "" | ||
raise Exception("[BUG CHECK] " + msg) |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.