Skip to content

Commit f06e3c2

Browse files
fix: node_app::make_simple writes 'fsync' and 'log_statement' twice (#373)
It creates a problem when we use testgres.postgres_configuration. An experimental test "test_node_app__make_empty_and_pgconf" is added, too. It reads and checks a configuration of a created node via testgres.postgres_configuration.
1 parent 034bf6b commit f06e3c2

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

src/node_app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ def make_simple(
150150

151151
node.init(
152152
initdb_params=final_initdb_params,
153+
# params for node.default_conf
154+
fsync=False,
153155
allow_streaming=set_replication,
156+
log_statement="none",
154157
)
155158

156159
# set major version
@@ -164,11 +167,9 @@ def make_simple(
164167
options = {
165168
'max_connections': 100,
166169
'shared_buffers': '10MB',
167-
'fsync': 'off',
168170
'wal_level': 'logical',
169171
'hot_standby': 'off',
170172
'log_line_prefix': '%t [%p]: [%l-1] ',
171-
'log_statement': 'none',
172173
'log_duration': 'on',
173174
'log_min_duration_statement': 0,
174175
'log_connections': 'on',

tests/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ pytest-xdist
55
psycopg2
66
six
77
testgres.os_ops>=2.3.0,<3.0.0
8+
testgres.postgres_configuration>=0.2.2,<1.0.0

tests/test_testgres_common.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import typing
5252
import types
5353
import psutil
54+
import testgres.postgres_configuration as testgres_pgconf
5455

5556
from packaging.version import Version
5657

@@ -2760,6 +2761,56 @@ def test_node_app__make_empty_with_explicit_port(self, node_svc: PostgresNodeSer
27602761
node_svc.os_ops.rmdirs(tmp_dir)
27612762
return
27622763

2764+
def test_node_app__make_empty_and_pgconf(self, node_svc: PostgresNodeService):
2765+
assert type(node_svc) is PostgresNodeService
2766+
2767+
assert type(node_svc) is PostgresNodeService
2768+
2769+
assert isinstance(node_svc.os_ops, OsOperations)
2770+
assert node_svc.port_manager is not None
2771+
assert isinstance(node_svc.port_manager, PortManager)
2772+
2773+
tmp_dir = node_svc.os_ops.mkdtemp()
2774+
assert tmp_dir is not None
2775+
assert type(tmp_dir) is str
2776+
logging.info("temp directory is [{}]".format(tmp_dir))
2777+
2778+
# -----------
2779+
node_app = NodeApp(
2780+
test_path=tmp_dir,
2781+
os_ops=node_svc.os_ops,
2782+
port_manager=node_svc.port_manager
2783+
)
2784+
2785+
# TODO: We have to use node_svc.os_ops here
2786+
2787+
with node_app.make_simple("abc") as node:
2788+
node_conf = testgres_pgconf.PostgresConfiguration(node.data_dir)
2789+
2790+
logging.info("Configuration is readed ...")
2791+
testgres_pgconf.PostgresConfigurationReader.LoadConfiguration(node_conf)
2792+
2793+
logging.info("Configuration is checked ...")
2794+
prop__port = node_conf.GetOptionValue("port")
2795+
assert type(prop__port) is int
2796+
assert prop__port == node.port
2797+
# presets are checked
2798+
prop__fsync = node_conf.GetOptionValue("fsync")
2799+
assert prop__fsync == "off" or prop__fsync is False
2800+
prop__log_statement = node_conf.GetOptionValue("log_statement")
2801+
assert type(prop__log_statement) is str
2802+
assert prop__log_statement == "none"
2803+
prop__wal_level = node_conf.GetOptionValue("wal_level")
2804+
assert type(prop__wal_level) is str
2805+
assert prop__wal_level == "logical"
2806+
2807+
logging.info("Configuration is written ...")
2808+
testgres_pgconf.PostgresConfigurationWriter.WriteConfiguration(node_conf)
2809+
2810+
logging.info("Node is started ...")
2811+
node.slow_start()
2812+
return
2813+
27632814
@staticmethod
27642815
def helper__get_node(
27652816
node_svc: PostgresNodeService,

0 commit comments

Comments
 (0)