testgres 1.15.2__tar.gz → 1.16.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.15.2/testgres.egg-info → testgres-1.16.1}/PKG-INFO +2 -2
- {testgres-1.15.2 → testgres-1.16.1}/pyproject.toml +1 -1
- {testgres-1.15.2 → testgres-1.16.1}/src/__init__.py +8 -3
- {testgres-1.15.2 → testgres-1.16.1}/src/backup.py +9 -2
- {testgres-1.15.2 → testgres-1.16.1}/src/cache.py +14 -7
- {testgres-1.15.2 → testgres-1.16.1}/src/consts.py +3 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/exceptions.py +4 -2
- {testgres-1.15.2 → testgres-1.16.1}/src/impl/platforms/linux/internal_platform_utils.py +15 -18
- {testgres-1.15.2 → testgres-1.16.1}/src/node.py +414 -210
- {testgres-1.15.2 → testgres-1.16.1}/src/node_app.py +27 -19
- {testgres-1.15.2 → testgres-1.16.1}/src/pubsub.py +10 -8
- {testgres-1.15.2 → testgres-1.16.1}/src/raise_error.py +2 -2
- {testgres-1.15.2 → testgres-1.16.1}/src/utils.py +116 -54
- {testgres-1.15.2 → testgres-1.16.1/testgres.egg-info}/PKG-INFO +2 -2
- {testgres-1.15.2 → testgres-1.16.1}/testgres.egg-info/requires.txt +1 -1
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_os_ops_common.py +2747 -45
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_os_ops_local.py +14 -7
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_os_ops_remote.py +28 -5
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_testgres_common.py +2 -2
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_utils.py +3 -3
- {testgres-1.15.2 → testgres-1.16.1}/LICENSE +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/README.md +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/setup.cfg +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/api.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/config.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/connection.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/decorators.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/defaults.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/enums.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/impl/file_line_reader.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/impl/internal_utils.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/impl/platforms/internal_platform_utils.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/impl/platforms/internal_platform_utils_factory.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/impl/platforms/win32/internal_platform_utils.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/impl/port_manager__generic.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/impl/port_manager__generic2.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/impl/port_manager__this_host.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/logger.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/port_manager.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/src/standby.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/testgres.egg-info/SOURCES.txt +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/testgres.egg-info/dependency_links.txt +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/testgres.egg-info/top_level.txt +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_api.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_config.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_raise_error.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_testgres_local.py +0 -0
- {testgres-1.15.2 → testgres-1.16.1}/tests/test_testgres_remote.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: testgres
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.16.1
|
|
4
4
|
Summary: Testing utility for PostgreSQL and its extensions
|
|
5
5
|
Author-email: Postgres Professional <testgres@postgrespro.ru>
|
|
6
6
|
License: PostgreSQL
|
|
@@ -27,7 +27,7 @@ Requires-Dist: port-for>=0.4
|
|
|
27
27
|
Requires-Dist: six>=1.9.0
|
|
28
28
|
Requires-Dist: psutil
|
|
29
29
|
Requires-Dist: packaging
|
|
30
|
-
Requires-Dist: testgres.os_ops<4.0.0,>=3.
|
|
30
|
+
Requires-Dist: testgres.os_ops<4.0.0,>=3.3.0
|
|
31
31
|
Dynamic: license-file
|
|
32
32
|
|
|
33
33
|
[](https://github.com/postgrespro/testgres/actions/workflows/ci.yml)
|
|
@@ -18,6 +18,7 @@ from .connection import \
|
|
|
18
18
|
from .exceptions import \
|
|
19
19
|
TestgresException, \
|
|
20
20
|
ExecUtilException, \
|
|
21
|
+
ExecTimeoutException, \
|
|
21
22
|
QueryException, \
|
|
22
23
|
QueryTimeoutException, \
|
|
23
24
|
TimeoutException, \
|
|
@@ -53,11 +54,13 @@ from .standby import \
|
|
|
53
54
|
|
|
54
55
|
from .config import testgres_config
|
|
55
56
|
|
|
56
|
-
from testgres.operations.os_ops import OsOperations
|
|
57
|
+
from testgres.operations.os_ops import OsOperations
|
|
58
|
+
from testgres.operations.os_ops import ConnectionParams
|
|
59
|
+
from testgres.operations.os_ops import OsProcessController
|
|
57
60
|
from testgres.operations.local_ops import LocalOperations
|
|
58
61
|
from testgres.operations.remote_ops import RemoteOperations
|
|
59
62
|
|
|
60
|
-
__version__ = "1.
|
|
63
|
+
__version__ = "1.16.1"
|
|
61
64
|
|
|
62
65
|
__all__ = [
|
|
63
66
|
"get_new_node",
|
|
@@ -66,6 +69,7 @@ __all__ = [
|
|
|
66
69
|
"TestgresConfig", "configure_testgres", "scoped_config", "push_config", "pop_config",
|
|
67
70
|
"NodeConnection", "DatabaseError", "InternalError", "ProgrammingError", "OperationalError",
|
|
68
71
|
"TestgresException", "ExecUtilException", "QueryException",
|
|
72
|
+
"ExecTimeoutException",
|
|
69
73
|
"QueryTimeoutException",
|
|
70
74
|
"TimeoutException", "CatchUpException", "StartNodeException", "InitNodeException", "BackupException", "InvalidOperationException",
|
|
71
75
|
"XLogMethod", "IsolationLevel", "NodeStatus", "ProcessType", "DumpFormat",
|
|
@@ -74,5 +78,6 @@ __all__ = [
|
|
|
74
78
|
"PortManager",
|
|
75
79
|
"reserve_port", "release_port", "get_bin_path", "get_bin_dir", "get_pg_config", "get_pg_version", "parse_pg_version",
|
|
76
80
|
"First", "Any",
|
|
77
|
-
"OsOperations", "LocalOperations", "RemoteOperations", "ConnectionParams"
|
|
81
|
+
"OsOperations", "LocalOperations", "RemoteOperations", "ConnectionParams",
|
|
82
|
+
"OsProcessController",
|
|
78
83
|
]
|
|
@@ -15,9 +15,10 @@ from .exceptions import BackupException
|
|
|
15
15
|
|
|
16
16
|
from testgres.operations.os_ops import OsOperations
|
|
17
17
|
|
|
18
|
+
from . import utils
|
|
19
|
+
|
|
18
20
|
from .utils import \
|
|
19
21
|
get_bin_path2, \
|
|
20
|
-
execute_utility2, \
|
|
21
22
|
clean_on_error
|
|
22
23
|
|
|
23
24
|
|
|
@@ -86,7 +87,13 @@ class NodeBackup(object):
|
|
|
86
87
|
"-X", xlog_method.value
|
|
87
88
|
] # yapf: disable
|
|
88
89
|
_params += options
|
|
89
|
-
|
|
90
|
+
|
|
91
|
+
utils.execute_utility3(
|
|
92
|
+
self.os_ops,
|
|
93
|
+
_params,
|
|
94
|
+
self.log_file,
|
|
95
|
+
)
|
|
96
|
+
return
|
|
90
97
|
|
|
91
98
|
def __enter__(self):
|
|
92
99
|
return self
|
|
@@ -8,14 +8,12 @@ from .consts import XLOG_CONTROL_FILE
|
|
|
8
8
|
|
|
9
9
|
from .defaults import generate_system_id
|
|
10
10
|
|
|
11
|
+
from . import utils
|
|
12
|
+
|
|
11
13
|
from .exceptions import \
|
|
12
14
|
InitNodeException, \
|
|
13
15
|
ExecUtilException
|
|
14
16
|
|
|
15
|
-
from .utils import \
|
|
16
|
-
get_bin_path2, \
|
|
17
|
-
execute_utility2
|
|
18
|
-
|
|
19
17
|
from testgres.operations.local_ops import LocalOperations
|
|
20
18
|
from testgres.operations.os_ops import OsOperations
|
|
21
19
|
|
|
@@ -39,13 +37,17 @@ def cached_initdb(data_dir, logfile=None, params=None, os_ops: OsOperations = No
|
|
|
39
37
|
if bin_path:
|
|
40
38
|
return os_ops.build_path(bin_path, name)
|
|
41
39
|
|
|
42
|
-
return get_bin_path2(os_ops, name)
|
|
40
|
+
return utils.get_bin_path2(os_ops, name)
|
|
43
41
|
|
|
44
42
|
def call_initdb(initdb_dir, log=logfile):
|
|
45
43
|
try:
|
|
46
44
|
initdb_path = make_utility_path("initdb")
|
|
47
45
|
_params = [initdb_path, "-D", initdb_dir, "-N"]
|
|
48
|
-
|
|
46
|
+
utils.execute_utility3(
|
|
47
|
+
os_ops,
|
|
48
|
+
_params + (params or []),
|
|
49
|
+
log,
|
|
50
|
+
)
|
|
49
51
|
except ExecUtilException as e:
|
|
50
52
|
raise_from(InitNodeException("Failed to run initdb"), e)
|
|
51
53
|
|
|
@@ -78,7 +80,12 @@ def cached_initdb(data_dir, logfile=None, params=None, os_ops: OsOperations = No
|
|
|
78
80
|
|
|
79
81
|
# XXX: build new WAL segment with our system id
|
|
80
82
|
_params = [make_utility_path("pg_resetwal"), "-D", data_dir, "-f"]
|
|
81
|
-
|
|
83
|
+
|
|
84
|
+
utils.execute_utility3(
|
|
85
|
+
os_ops,
|
|
86
|
+
_params,
|
|
87
|
+
logfile,
|
|
88
|
+
)
|
|
82
89
|
|
|
83
90
|
except ExecUtilException as e:
|
|
84
91
|
msg = "Failed to reset WAL for system id"
|
|
@@ -6,6 +6,7 @@ import typing
|
|
|
6
6
|
from testgres.operations.exceptions import TestgresException
|
|
7
7
|
from testgres.operations.exceptions import ExecUtilException
|
|
8
8
|
from testgres.operations.exceptions import InvalidOperationException
|
|
9
|
+
from testgres.operations.exceptions import ExecTimeoutException
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class PortForException(TestgresException):
|
|
@@ -112,7 +113,7 @@ class QueryTimeoutException(QueryException):
|
|
|
112
113
|
def __init__(
|
|
113
114
|
self,
|
|
114
115
|
message: typing.Optional[str] = None,
|
|
115
|
-
query: typing.Optional[str] = None
|
|
116
|
+
query: typing.Optional[str] = None,
|
|
116
117
|
):
|
|
117
118
|
assert message is None or type(message) is str
|
|
118
119
|
assert query is None or type(query) is str
|
|
@@ -169,7 +170,7 @@ class StartNodeException(TestgresException):
|
|
|
169
170
|
def __init__(
|
|
170
171
|
self,
|
|
171
172
|
message: typing.Optional[str] = None,
|
|
172
|
-
files: typing.Optional[typing.Iterable] = None
|
|
173
|
+
files: typing.Optional[typing.Iterable] = None,
|
|
173
174
|
):
|
|
174
175
|
assert message is None or type(message) is str
|
|
175
176
|
assert files is None or isinstance(files, typing.Iterable)
|
|
@@ -298,3 +299,4 @@ class BackupException(TestgresException):
|
|
|
298
299
|
|
|
299
300
|
assert ExecUtilException.__name__ == "ExecUtilException"
|
|
300
301
|
assert InvalidOperationException.__name__ == "InvalidOperationException"
|
|
302
|
+
assert ExecTimeoutException.__name__ == "ExecTimeoutException"
|
|
@@ -5,7 +5,9 @@ from ... import internal_utils
|
|
|
5
5
|
from ....raise_error import RaiseError
|
|
6
6
|
|
|
7
7
|
from testgres.operations.os_ops import OsOperations
|
|
8
|
+
from testgres.operations.os_ops import OsCommandResult
|
|
8
9
|
from testgres.operations.exceptions import ExecUtilException
|
|
10
|
+
from testgres.operations.types import T_OS_EXEC_ENV
|
|
9
11
|
|
|
10
12
|
import re
|
|
11
13
|
import shlex
|
|
@@ -17,7 +19,7 @@ class InternalPlatformUtils(base.InternalPlatformUtils):
|
|
|
17
19
|
C_MAX_FIND_POSTMASTER_ATTEMPTS = 5
|
|
18
20
|
C_BASH_EXE = "/bin/bash"
|
|
19
21
|
|
|
20
|
-
sm_exec_env = {
|
|
22
|
+
sm_exec_env: T_OS_EXEC_ENV = {
|
|
21
23
|
"LANG": "en_US.UTF-8",
|
|
22
24
|
"LC_ALL": "en_US.UTF-8",
|
|
23
25
|
}
|
|
@@ -113,37 +115,32 @@ class InternalPlatformUtils(base.InternalPlatformUtils):
|
|
|
113
115
|
"ps -ewwo \"pid=,ppid=,args=\" | grep -E " + shlex.quote(regexp),
|
|
114
116
|
]
|
|
115
117
|
|
|
116
|
-
exec_r = os_ops.
|
|
118
|
+
exec_r = os_ops.run(
|
|
117
119
|
cmd=cmd,
|
|
118
|
-
|
|
119
|
-
verbose=True,
|
|
120
|
+
check=False,
|
|
120
121
|
exec_env=__class__.sm_exec_env,
|
|
121
122
|
)
|
|
122
123
|
|
|
123
|
-
assert type(exec_r) is
|
|
124
|
-
assert
|
|
124
|
+
assert type(exec_r) is OsCommandResult
|
|
125
|
+
assert type(exec_r.returncode) is int
|
|
126
|
+
assert type(exec_r.stdout) is bytes
|
|
127
|
+
assert type(exec_r.stderr) is bytes
|
|
125
128
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
assert type(exit_status) is int
|
|
129
|
-
assert type(output_b) is bytes
|
|
130
|
-
assert type(error_b) is bytes
|
|
131
|
-
|
|
132
|
-
if exit_status == 1:
|
|
129
|
+
if exec_r.returncode == 1:
|
|
133
130
|
return None
|
|
134
131
|
|
|
135
|
-
output =
|
|
136
|
-
error =
|
|
132
|
+
output = exec_r.stdout.decode("utf-8")
|
|
133
|
+
error = exec_r.stderr.decode("utf-8")
|
|
137
134
|
|
|
138
135
|
assert type(output) is str
|
|
139
136
|
assert type(error) is str
|
|
140
137
|
|
|
141
|
-
if
|
|
142
|
-
errMsg = f"test command returned an unexpected exit code: {
|
|
138
|
+
if exec_r.returncode != 0:
|
|
139
|
+
errMsg = f"test command returned an unexpected exit code: {exec_r.returncode}"
|
|
143
140
|
raise ExecUtilException(
|
|
144
141
|
message=errMsg,
|
|
145
142
|
command=cmd,
|
|
146
|
-
exit_code=
|
|
143
|
+
exit_code=exec_r.returncode,
|
|
147
144
|
out=output,
|
|
148
145
|
error=error,
|
|
149
146
|
)
|