testgres 1.14.0__tar.gz → 1.14.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {testgres-1.14.0/testgres.egg-info → testgres-1.14.1}/PKG-INFO +1 -1
- {testgres-1.14.0 → testgres-1.14.1}/src/__init__.py +5 -5
- {testgres-1.14.0 → testgres-1.14.1}/src/node.py +55 -24
- {testgres-1.14.0 → testgres-1.14.1/testgres.egg-info}/PKG-INFO +1 -1
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_testgres_common.py +47 -1
- {testgres-1.14.0 → testgres-1.14.1}/LICENSE +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/README.md +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/pyproject.toml +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/setup.cfg +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/api.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/backup.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/cache.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/config.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/connection.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/consts.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/decorators.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/defaults.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/enums.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/exceptions.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/impl/internal_utils.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/impl/platforms/internal_platform_utils.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/impl/platforms/internal_platform_utils_factory.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/impl/platforms/linux/internal_platform_utils.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/impl/platforms/win32/internal_platform_utils.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/impl/port_manager__generic.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/impl/port_manager__this_host.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/logger.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/node_app.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/port_manager.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/pubsub.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/raise_error.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/standby.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/src/utils.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/testgres.egg-info/SOURCES.txt +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/testgres.egg-info/dependency_links.txt +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/testgres.egg-info/requires.txt +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/testgres.egg-info/top_level.txt +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_api.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_config.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_os_ops_common.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_os_ops_local.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_os_ops_remote.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_raise_error.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_testgres_local.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_testgres_remote.py +0 -0
- {testgres-1.14.0 → testgres-1.14.1}/tests/test_utils.py +0 -0
|
@@ -56,7 +56,7 @@ from testgres.operations.os_ops import OsOperations, ConnectionParams
|
|
|
56
56
|
from testgres.operations.local_ops import LocalOperations
|
|
57
57
|
from testgres.operations.remote_ops import RemoteOperations
|
|
58
58
|
|
|
59
|
-
__version__ = "1.14.
|
|
59
|
+
__version__ = "1.14.1"
|
|
60
60
|
|
|
61
61
|
__all__ = [
|
|
62
62
|
"get_new_node",
|
|
@@ -65,12 +65,12 @@ __all__ = [
|
|
|
65
65
|
"TestgresConfig", "configure_testgres", "scoped_config", "push_config", "pop_config",
|
|
66
66
|
"NodeConnection", "DatabaseError", "InternalError", "ProgrammingError", "OperationalError",
|
|
67
67
|
"TestgresException", "ExecUtilException", "QueryException",
|
|
68
|
-
QueryTimeoutException
|
|
68
|
+
"QueryTimeoutException",
|
|
69
69
|
"TimeoutException", "CatchUpException", "StartNodeException", "InitNodeException", "BackupException", "InvalidOperationException",
|
|
70
70
|
"XLogMethod", "IsolationLevel", "NodeStatus", "ProcessType", "DumpFormat",
|
|
71
|
-
NodeApp
|
|
72
|
-
PostgresNode
|
|
73
|
-
PortManager
|
|
71
|
+
"NodeApp",
|
|
72
|
+
"PostgresNode",
|
|
73
|
+
"PortManager",
|
|
74
74
|
"reserve_port", "release_port", "bound_ports", "get_bin_path", "get_pg_config", "get_pg_version",
|
|
75
75
|
"First", "Any",
|
|
76
76
|
"OsOperations", "LocalOperations", "RemoteOperations", "ConnectionParams"
|
|
@@ -161,6 +161,7 @@ class PostgresNode(object):
|
|
|
161
161
|
_C_PM_PID__IS_NOT_DETECTED = -1
|
|
162
162
|
|
|
163
163
|
_name: typing.Optional[str]
|
|
164
|
+
_host: str
|
|
164
165
|
_port: typing.Optional[int]
|
|
165
166
|
_bin_dir: str
|
|
166
167
|
_should_free_port: bool
|
|
@@ -168,14 +169,17 @@ class PostgresNode(object):
|
|
|
168
169
|
_port_manager: typing.Optional[PortManager]
|
|
169
170
|
_manually_started_pm_pid: typing.Optional[int]
|
|
170
171
|
|
|
171
|
-
def __init__(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
172
|
+
def __init__(
|
|
173
|
+
self,
|
|
174
|
+
name=None,
|
|
175
|
+
base_dir=None,
|
|
176
|
+
port: typing.Optional[int] = None,
|
|
177
|
+
bin_dir: typing.Optional[str] = None,
|
|
178
|
+
prefix=None,
|
|
179
|
+
os_ops: typing.Optional[OsOperations] = None,
|
|
180
|
+
port_manager: typing.Optional[PortManager] = None,
|
|
181
|
+
host: typing.Optional[str] = None,
|
|
182
|
+
):
|
|
179
183
|
"""
|
|
180
184
|
PostgresNode constructor.
|
|
181
185
|
|
|
@@ -186,11 +190,13 @@ class PostgresNode(object):
|
|
|
186
190
|
bin_dir: path to node's binary directory.
|
|
187
191
|
os_ops: None or correct OS operation object.
|
|
188
192
|
port_manager: None or correct port manager object.
|
|
193
|
+
host: None or valid address of node host.
|
|
189
194
|
"""
|
|
190
195
|
assert port is None or type(port) is int
|
|
191
196
|
assert bin_dir is None or type(bin_dir) is str
|
|
192
197
|
assert os_ops is None or isinstance(os_ops, OsOperations)
|
|
193
198
|
assert port_manager is None or isinstance(port_manager, PortManager)
|
|
199
|
+
assert host is None or type(host) is str
|
|
194
200
|
|
|
195
201
|
# private
|
|
196
202
|
if os_ops is None:
|
|
@@ -219,6 +225,16 @@ class PostgresNode(object):
|
|
|
219
225
|
# basic
|
|
220
226
|
self._name = name or generate_app_name()
|
|
221
227
|
|
|
228
|
+
if host is not None:
|
|
229
|
+
assert type(host) is str
|
|
230
|
+
self._host = host
|
|
231
|
+
else:
|
|
232
|
+
self._host = self._os_ops.host
|
|
233
|
+
assert type(self._host) is str
|
|
234
|
+
|
|
235
|
+
if self._host == "":
|
|
236
|
+
raise RuntimeError("PostgresNode host is empty.")
|
|
237
|
+
|
|
222
238
|
if port is not None:
|
|
223
239
|
assert type(port) is int
|
|
224
240
|
assert port_manager is None
|
|
@@ -249,10 +265,6 @@ class PostgresNode(object):
|
|
|
249
265
|
self.cleanup_on_bad_exit = testgres_config.node_cleanup_on_bad_exit
|
|
250
266
|
self.shutdown_max_attempts = 3
|
|
251
267
|
|
|
252
|
-
# NOTE: for compatibility
|
|
253
|
-
self.utils_log_name = self.utils_log_file
|
|
254
|
-
self.pg_log_name = self.pg_log_file
|
|
255
|
-
|
|
256
268
|
# Node state
|
|
257
269
|
self._manually_started_pm_pid = None
|
|
258
270
|
|
|
@@ -317,6 +329,7 @@ class PostgresNode(object):
|
|
|
317
329
|
assert isinstance(self._port_manager, PortManager)
|
|
318
330
|
assert self._os_ops is not None
|
|
319
331
|
assert isinstance(self._os_ops, OsOperations)
|
|
332
|
+
assert type(self._host) is str
|
|
320
333
|
|
|
321
334
|
node = PostgresNode(
|
|
322
335
|
name=name,
|
|
@@ -324,7 +337,9 @@ class PostgresNode(object):
|
|
|
324
337
|
bin_dir=self._bin_dir,
|
|
325
338
|
prefix=self._prefix,
|
|
326
339
|
os_ops=self._os_ops,
|
|
327
|
-
port_manager=self._port_manager
|
|
340
|
+
port_manager=self._port_manager,
|
|
341
|
+
host=self._host,
|
|
342
|
+
)
|
|
328
343
|
|
|
329
344
|
return node
|
|
330
345
|
|
|
@@ -348,9 +363,9 @@ class PostgresNode(object):
|
|
|
348
363
|
|
|
349
364
|
@property
|
|
350
365
|
def host(self) -> str:
|
|
351
|
-
assert self.
|
|
352
|
-
assert
|
|
353
|
-
return self.
|
|
366
|
+
assert self._host is not None
|
|
367
|
+
assert type(self._host) is str
|
|
368
|
+
return self._host
|
|
354
369
|
|
|
355
370
|
@property
|
|
356
371
|
def port(self) -> int:
|
|
@@ -467,7 +482,7 @@ class PostgresNode(object):
|
|
|
467
482
|
assert type(self.master) is PostgresNode
|
|
468
483
|
|
|
469
484
|
# master should be on the same host
|
|
470
|
-
assert self.master.host == self.
|
|
485
|
+
assert self.master.host == self._host
|
|
471
486
|
|
|
472
487
|
with self.master.connect() as con:
|
|
473
488
|
for row in con.execute(sql, self.name):
|
|
@@ -540,6 +555,16 @@ class PostgresNode(object):
|
|
|
540
555
|
assert type(path) is str
|
|
541
556
|
return path
|
|
542
557
|
|
|
558
|
+
# NOTE: for compatibility
|
|
559
|
+
@property
|
|
560
|
+
def utils_log_name(self) -> str:
|
|
561
|
+
return self.utils_log_file
|
|
562
|
+
|
|
563
|
+
# NOTE: for compatibility
|
|
564
|
+
@property
|
|
565
|
+
def pg_log_name(self) -> str:
|
|
566
|
+
return self.pg_log_file
|
|
567
|
+
|
|
543
568
|
@property
|
|
544
569
|
def version(self):
|
|
545
570
|
"""
|
|
@@ -838,7 +863,7 @@ class PostgresNode(object):
|
|
|
838
863
|
self.append_conf(fsync=fsync,
|
|
839
864
|
max_worker_processes=MAX_WORKER_PROCESSES,
|
|
840
865
|
log_statement=log_statement,
|
|
841
|
-
listen_addresses=self.
|
|
866
|
+
listen_addresses=self._host,
|
|
842
867
|
port=self.port) # yapf:disable
|
|
843
868
|
|
|
844
869
|
# common replication settings
|
|
@@ -929,6 +954,12 @@ class PostgresNode(object):
|
|
|
929
954
|
return x.node_status
|
|
930
955
|
|
|
931
956
|
def _get_node_state(self) -> utils.PostgresNodeState:
|
|
957
|
+
if self._base_dir is None:
|
|
958
|
+
return utils.PostgresNodeState(
|
|
959
|
+
node_status=NodeStatus.Uninitialized,
|
|
960
|
+
pid=None,
|
|
961
|
+
)
|
|
962
|
+
|
|
932
963
|
return utils.get_pg_node_state(
|
|
933
964
|
self._os_ops,
|
|
934
965
|
self.bin_dir,
|
|
@@ -1453,7 +1484,7 @@ class PostgresNode(object):
|
|
|
1453
1484
|
raise Exception("Input data must be None or bytes.")
|
|
1454
1485
|
|
|
1455
1486
|
if host is None:
|
|
1456
|
-
host = self.
|
|
1487
|
+
host = self._host
|
|
1457
1488
|
|
|
1458
1489
|
if port is None:
|
|
1459
1490
|
port = self.port
|
|
@@ -1580,7 +1611,7 @@ class PostgresNode(object):
|
|
|
1580
1611
|
_params = [
|
|
1581
1612
|
self._get_bin_path("pg_dump"),
|
|
1582
1613
|
"-p", str(self.port),
|
|
1583
|
-
"-h", self.
|
|
1614
|
+
"-h", self._host,
|
|
1584
1615
|
"-f", filename,
|
|
1585
1616
|
"-U", username or self._os_ops.username,
|
|
1586
1617
|
"-d", dbname or default_dbname(),
|
|
@@ -1612,7 +1643,7 @@ class PostgresNode(object):
|
|
|
1612
1643
|
_params = [
|
|
1613
1644
|
self._get_bin_path("pg_restore"),
|
|
1614
1645
|
"-p", str(self.port),
|
|
1615
|
-
"-h", self.
|
|
1646
|
+
"-h", self._host,
|
|
1616
1647
|
"-U", username,
|
|
1617
1648
|
"-d", dbname,
|
|
1618
1649
|
filename
|
|
@@ -1620,7 +1651,7 @@ class PostgresNode(object):
|
|
|
1620
1651
|
|
|
1621
1652
|
# try pg_restore if dump is binary format, and psql if not
|
|
1622
1653
|
try:
|
|
1623
|
-
execute_utility2(self._os_ops, _params, self.
|
|
1654
|
+
execute_utility2(self._os_ops, _params, self.utils_log_file)
|
|
1624
1655
|
except ExecUtilException:
|
|
1625
1656
|
self.psql(filename=filename, dbname=dbname, username=username)
|
|
1626
1657
|
|
|
@@ -1888,7 +1919,7 @@ class PostgresNode(object):
|
|
|
1888
1919
|
_params = [
|
|
1889
1920
|
self._get_bin_path("pgbench"),
|
|
1890
1921
|
"-p", str(self.port),
|
|
1891
|
-
"-h", self.
|
|
1922
|
+
"-h", self._host,
|
|
1892
1923
|
"-U", username or self._os_ops.username
|
|
1893
1924
|
] + options # yapf: disable
|
|
1894
1925
|
|
|
@@ -1961,7 +1992,7 @@ class PostgresNode(object):
|
|
|
1961
1992
|
_params = [
|
|
1962
1993
|
self._get_bin_path("pgbench"),
|
|
1963
1994
|
"-p", str(self.port),
|
|
1964
|
-
"-h", self.
|
|
1995
|
+
"-h", self._host,
|
|
1965
1996
|
"-U", username or self._os_ops.username
|
|
1966
1997
|
] + options # yapf: disable
|
|
1967
1998
|
|
|
@@ -95,7 +95,7 @@ class TestTestgresCommon:
|
|
|
95
95
|
# Author: Mark G.
|
|
96
96
|
assert v.major == 1
|
|
97
97
|
assert v.minor == 14
|
|
98
|
-
assert v.micro ==
|
|
98
|
+
assert v.micro == 1
|
|
99
99
|
|
|
100
100
|
assert str(v) == testgres_version
|
|
101
101
|
return
|
|
@@ -132,7 +132,53 @@ class TestTestgresCommon:
|
|
|
132
132
|
assert (isinstance(node.version, PgVer))
|
|
133
133
|
assert (node.version == PgVer(version))
|
|
134
134
|
|
|
135
|
+
def test_node_constructor__default(self):
|
|
136
|
+
node = PostgresNode()
|
|
137
|
+
assert node._os_ops is not None
|
|
138
|
+
assert isinstance(node._os_ops, OsOperations)
|
|
139
|
+
assert node._port_manager is not None
|
|
140
|
+
assert isinstance(node._port_manager, PortManager)
|
|
141
|
+
assert node._name is not None
|
|
142
|
+
assert type(node._name) is str
|
|
143
|
+
assert node._name != ""
|
|
144
|
+
assert node._base_dir is None
|
|
145
|
+
return
|
|
146
|
+
|
|
147
|
+
def test_node_constructor__host(self):
|
|
148
|
+
C_HOST = "AbCdE"
|
|
149
|
+
|
|
150
|
+
unique_id = uuid.uuid4().hex
|
|
151
|
+
|
|
152
|
+
with PostgresNode(host=C_HOST) as node:
|
|
153
|
+
assert node._host == C_HOST
|
|
154
|
+
assert node.host == C_HOST
|
|
155
|
+
assert isinstance(node.os_ops, OsOperations)
|
|
156
|
+
|
|
157
|
+
tmpdir = node.os_ops.get_tempdir()
|
|
158
|
+
nodedir2 = node.os_ops.build_path(tmpdir, "node2--" + unique_id)
|
|
159
|
+
|
|
160
|
+
C_NODE2_NAME = "node2"
|
|
161
|
+
|
|
162
|
+
with node.clone_with_new_name_and_base_dir(
|
|
163
|
+
name=C_NODE2_NAME,
|
|
164
|
+
base_dir=nodedir2,
|
|
165
|
+
) as node2:
|
|
166
|
+
assert node2 is not None
|
|
167
|
+
assert node2 is not node
|
|
168
|
+
|
|
169
|
+
assert node2._host == C_HOST
|
|
170
|
+
assert node2.host == C_HOST
|
|
171
|
+
|
|
172
|
+
assert node2._name == C_NODE2_NAME
|
|
173
|
+
assert node2._base_dir == nodedir2
|
|
174
|
+
assert node2._port != node._port
|
|
175
|
+
assert node2._os_ops is node._os_ops
|
|
176
|
+
assert node2._port_manager is node._port_manager
|
|
177
|
+
return
|
|
178
|
+
|
|
135
179
|
def test_node_repr(self, node_svc: PostgresNodeService):
|
|
180
|
+
assert isinstance(node_svc, PostgresNodeService)
|
|
181
|
+
|
|
136
182
|
with __class__.helper__get_node(node_svc).init() as node:
|
|
137
183
|
pattern = r"PostgresNode\(name='.+', port=.+, base_dir='.+'\)"
|
|
138
184
|
assert re.match(pattern, str(node)) is not None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|