testgres-pg-probackup2 0.9.0__tar.gz → 0.9.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_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/PKG-INFO +1 -1
- testgres_pg_probackup2-0.9.1/pg_probackup2/__init__.py +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/pg_probackup2/init_helpers.py +218 -25
- testgres_pg_probackup2-0.9.1/pg_probackup2/storage/__init__.py +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/setup.py +1 -1
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/testgres_pg_probackup2.egg-info/PKG-INFO +1 -1
- testgres_pg_probackup2-0.9.0/pg_probackup2/__init__.py +0 -1
- testgres_pg_probackup2-0.9.0/pg_probackup2/storage/__init__.py +0 -1
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/README.md +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/pg_probackup2/app.py +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/pg_probackup2/gdb.py +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/pg_probackup2/storage/fs_backup.py +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/setup.cfg +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/testgres_pg_probackup2.egg-info/SOURCES.txt +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/testgres_pg_probackup2.egg-info/dependency_links.txt +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/testgres_pg_probackup2.egg-info/requires.txt +0 -0
- {testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/testgres_pg_probackup2.egg-info/top_level.txt +0 -0
|
File without changes
|
|
@@ -9,7 +9,7 @@ import subprocess
|
|
|
9
9
|
import sys
|
|
10
10
|
import traceback
|
|
11
11
|
import testgres
|
|
12
|
-
|
|
12
|
+
import typing
|
|
13
13
|
|
|
14
14
|
try:
|
|
15
15
|
import lz4.frame # noqa: F401
|
|
@@ -38,7 +38,46 @@ except Exception as e:
|
|
|
38
38
|
logging.warning("Can't configure testgres: {0}".format(e))
|
|
39
39
|
|
|
40
40
|
|
|
41
|
+
class InitData_ServerProps:
|
|
42
|
+
pgpro_edition: typing.Optional[str]
|
|
43
|
+
num_version: int
|
|
44
|
+
|
|
45
|
+
def __init__(
|
|
46
|
+
self,
|
|
47
|
+
pgpro_edition: typing.Optional[str],
|
|
48
|
+
num_version: int,
|
|
49
|
+
):
|
|
50
|
+
assert pgpro_edition is None or type(pgpro_edition) is str
|
|
51
|
+
assert type(num_version) is int
|
|
52
|
+
self.pgpro_edition = pgpro_edition
|
|
53
|
+
self.num_version = num_version
|
|
54
|
+
return
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class InitData_BinaryName:
|
|
58
|
+
pg_config: str
|
|
59
|
+
postgres: str
|
|
60
|
+
initdb: str
|
|
61
|
+
|
|
62
|
+
def __init__(
|
|
63
|
+
self,
|
|
64
|
+
pg_config: str,
|
|
65
|
+
initdb: str,
|
|
66
|
+
postgres: str,
|
|
67
|
+
):
|
|
68
|
+
assert type(pg_config) is str
|
|
69
|
+
assert type(postgres) is str
|
|
70
|
+
assert type(initdb) is str
|
|
71
|
+
|
|
72
|
+
self.pg_config = pg_config
|
|
73
|
+
self.postgres = postgres
|
|
74
|
+
self.initdb = initdb
|
|
75
|
+
return
|
|
76
|
+
|
|
77
|
+
|
|
41
78
|
class Init(object):
|
|
79
|
+
_server_props: InitData_ServerProps
|
|
80
|
+
|
|
42
81
|
def __init__(self):
|
|
43
82
|
if '-v' in sys.argv or '--verbose' in sys.argv:
|
|
44
83
|
self.verbose = True
|
|
@@ -50,21 +89,38 @@ class Init(object):
|
|
|
50
89
|
|
|
51
90
|
pg_bin = testgres.get_bin_dir(os_ops)
|
|
52
91
|
if pg_bin is None:
|
|
53
|
-
raise InvalidOperationException(
|
|
54
|
-
"Failed to determine the Postgres binary directory. Specify the path to the directory in PG_BIN or put it into the system PATH."
|
|
55
|
-
|
|
92
|
+
raise testgres.InvalidOperationException(
|
|
93
|
+
"Failed to determine the Postgres binary directory. Specify the path to the directory in PG_BIN or put it into the system PATH.",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
if not os_ops.path_exists(pg_bin):
|
|
97
|
+
raise testgres.InvalidOperationException(
|
|
98
|
+
"Path [{}] is not found.".format(pg_bin),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
pg_config_path = os_ops.build_path(
|
|
102
|
+
pg_bin,
|
|
103
|
+
__class__._get_binary_names(os_ops).pg_config,
|
|
104
|
+
)
|
|
56
105
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
106
|
+
assert type(pg_config_path) is str
|
|
107
|
+
|
|
108
|
+
if os_ops.path_exists(pg_config_path):
|
|
109
|
+
self._server_props = __class__._init__get_server_props__via_pg_config(
|
|
110
|
+
os_ops,
|
|
111
|
+
pg_config_path,
|
|
112
|
+
)
|
|
113
|
+
else:
|
|
114
|
+
self._server_props = __class__._init__get_server_props__via_server(
|
|
115
|
+
os_ops,
|
|
116
|
+
pg_bin,
|
|
117
|
+
)
|
|
64
118
|
|
|
65
119
|
# TODO: Always test with NLS support and remove this flag
|
|
66
120
|
self.is_nls_enabled = True
|
|
67
121
|
|
|
122
|
+
postgres = os_ops.build_path(pg_bin, 'postgres.exe' if os_name == 'nt' else 'postgres')
|
|
123
|
+
|
|
68
124
|
if os_name == 'posix':
|
|
69
125
|
ldd = os_ops.exec_command(
|
|
70
126
|
['ldd', postgres],
|
|
@@ -81,19 +137,11 @@ class Init(object):
|
|
|
81
137
|
break
|
|
82
138
|
else:
|
|
83
139
|
# Fall back to trying to determine lz4 support via pg_config
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
encoding='utf-8')
|
|
90
|
-
server_version = testgres.parse_pg_version(server_version_out)
|
|
91
|
-
parts = [*server_version.split('.'), '0', '0'][:3]
|
|
92
|
-
parts[0] = re.match(r'\d+', parts[0]).group()
|
|
93
|
-
# Server_version consists of two fields (x.y) so num_version always ends with 00
|
|
94
|
-
num_version = reduce(lambda v, x: v * 100 + int(x), parts, 0)
|
|
95
|
-
# For backward compatibility
|
|
96
|
-
self.pg_config_version = num_version
|
|
140
|
+
pg_config_data = testgres.utils.get_pg_config2(
|
|
141
|
+
pg_config_path=pg_config_path,
|
|
142
|
+
os_ops=os_ops,
|
|
143
|
+
)
|
|
144
|
+
self.is_lz4_enabled = '-llz4' in pg_config_data['LIBS']
|
|
97
145
|
|
|
98
146
|
os.environ['LANGUAGE'] = 'en' # set default locale language to en. All messages will use this locale
|
|
99
147
|
test_env = os.environ.copy()
|
|
@@ -210,7 +258,7 @@ class Init(object):
|
|
|
210
258
|
self.old_probackup_version = match.group(0) if match else None
|
|
211
259
|
|
|
212
260
|
self.remote = test_env.get('PGPROBACKUP_SSH_REMOTE', None) == 'ON'
|
|
213
|
-
self.ptrack = test_env.get('PG_PROBACKUP_PTRACK', None) == 'ON' and num_version >= 110000
|
|
261
|
+
self.ptrack = test_env.get('PG_PROBACKUP_PTRACK', None) == 'ON' and self._server_props.num_version >= 110000
|
|
214
262
|
self.wal_tree_enabled = test_env.get('PG_PROBACKUP_WAL_TREE_ENABLED', None) == 'ON'
|
|
215
263
|
|
|
216
264
|
self.bckp_source = test_env.get('PG_PROBACKUP_SOURCE', 'pro').lower()
|
|
@@ -262,6 +310,151 @@ class Init(object):
|
|
|
262
310
|
def test_env(self):
|
|
263
311
|
return self._test_env.copy()
|
|
264
312
|
|
|
313
|
+
@property
|
|
314
|
+
def is_enterprise(self) -> bool:
|
|
315
|
+
assert type(self._server_props) is InitData_ServerProps
|
|
316
|
+
return self._server_props.pgpro_edition == 'enterprise'
|
|
317
|
+
|
|
318
|
+
@property
|
|
319
|
+
def is_shardman(self) -> bool:
|
|
320
|
+
assert type(self._server_props) is InitData_ServerProps
|
|
321
|
+
return self._server_props.pgpro_edition == 'shardman'
|
|
322
|
+
|
|
323
|
+
@property
|
|
324
|
+
def is_pgpro(self) -> bool:
|
|
325
|
+
assert type(self._server_props) is InitData_ServerProps
|
|
326
|
+
return self._server_props.pgpro_edition is not None
|
|
327
|
+
|
|
328
|
+
@property
|
|
329
|
+
def pg_config_version(self) -> int:
|
|
330
|
+
assert type(self._server_props) is InitData_ServerProps
|
|
331
|
+
return self._server_props.num_version
|
|
332
|
+
|
|
333
|
+
@staticmethod
|
|
334
|
+
def _init__get_server_props__via_pg_config(
|
|
335
|
+
os_ops: testgres.OsOperations,
|
|
336
|
+
pg_config_path: str,
|
|
337
|
+
) -> InitData_ServerProps:
|
|
338
|
+
assert isinstance(os_ops, testgres.OsOperations)
|
|
339
|
+
assert type(pg_config_path) is str
|
|
340
|
+
|
|
341
|
+
pg_config = testgres.utils.get_pg_config2(
|
|
342
|
+
pg_config_path=pg_config_path,
|
|
343
|
+
os_ops=os_ops,
|
|
344
|
+
)
|
|
345
|
+
assert type(pg_config) is dict
|
|
346
|
+
|
|
347
|
+
pgpro_edition = pg_config.get('PGPRO_EDITION')
|
|
348
|
+
assert pgpro_edition is None or type(pgpro_edition) is str
|
|
349
|
+
|
|
350
|
+
version_str = pg_config.get('VERSION', '')
|
|
351
|
+
assert type(version_str) is str
|
|
352
|
+
|
|
353
|
+
if not version_str:
|
|
354
|
+
raise RuntimeError("Field 'VERSION' not found in pg_config output")
|
|
355
|
+
|
|
356
|
+
version_num = testgres.parse_pg_version(version_str)
|
|
357
|
+
parts = [*version_num.split('.'), '0', '0'][:3]
|
|
358
|
+
parts[0] = re.match(r'\d+', parts[0]).group()
|
|
359
|
+
|
|
360
|
+
num_version = reduce(lambda v, x: v * 100 + int(x), parts, 0)
|
|
361
|
+
assert type(num_version) is int
|
|
362
|
+
|
|
363
|
+
return InitData_ServerProps(
|
|
364
|
+
pgpro_edition=pgpro_edition,
|
|
365
|
+
num_version=num_version,
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
@staticmethod
|
|
369
|
+
def _init__get_server_props__via_server(
|
|
370
|
+
os_ops: testgres.OsOperations,
|
|
371
|
+
pg_bin_dir: str,
|
|
372
|
+
) -> InitData_ServerProps:
|
|
373
|
+
assert isinstance(os_ops, testgres.OsOperations)
|
|
374
|
+
assert type(pg_bin_dir) is str
|
|
375
|
+
|
|
376
|
+
tmpdir = os_ops.mkdtemp()
|
|
377
|
+
assert type(tmpdir) is str
|
|
378
|
+
assert os_ops.path_exists(tmpdir)
|
|
379
|
+
assert os_ops.is_abs_path(tmpdir)
|
|
380
|
+
|
|
381
|
+
try:
|
|
382
|
+
initdb = os_ops.build_path(
|
|
383
|
+
pg_bin_dir,
|
|
384
|
+
__class__._get_binary_names(os_ops).initdb,
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
os_ops.exec_command(
|
|
388
|
+
[initdb, "-D", tmpdir],
|
|
389
|
+
encoding='utf-8',
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
postgres = os_ops.build_path(
|
|
393
|
+
pg_bin_dir,
|
|
394
|
+
__class__._get_binary_names(os_ops).postgres,
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
pgpro_edition_out: typing.Optional[str] = None
|
|
398
|
+
try:
|
|
399
|
+
exec_r = os_ops.exec_command(
|
|
400
|
+
[postgres, "-C", "pgpro_edition", "-D", tmpdir],
|
|
401
|
+
encoding='utf-8',
|
|
402
|
+
)
|
|
403
|
+
assert type(exec_r) is str
|
|
404
|
+
pgpro_edition_out = exec_r.strip()
|
|
405
|
+
except testgres.ExecUtilException as e:
|
|
406
|
+
assert e.exit_code != 0
|
|
407
|
+
|
|
408
|
+
logging.debug("Exception ({}): {}".format(
|
|
409
|
+
type(e).__name__,
|
|
410
|
+
e,
|
|
411
|
+
))
|
|
412
|
+
|
|
413
|
+
assert pgpro_edition_out is None or type(pgpro_edition_out) is str
|
|
414
|
+
pgpro_edition = pgpro_edition_out
|
|
415
|
+
|
|
416
|
+
server_version_out = os_ops.exec_command(
|
|
417
|
+
[postgres, "-C", "server_version", "-D", tmpdir],
|
|
418
|
+
encoding='utf-8'
|
|
419
|
+
)
|
|
420
|
+
assert type(server_version_out) is str
|
|
421
|
+
server_version = testgres.parse_pg_version(server_version_out)
|
|
422
|
+
parts = [*server_version.split('.'), '0', '0'][:3]
|
|
423
|
+
parts[0] = re.match(r'\d+', parts[0]).group()
|
|
424
|
+
# Server_version consists of two fields (x.y) so num_version always ends with 00
|
|
425
|
+
pg_config_version = reduce(lambda v, x: v * 100 + int(x), parts, 0)
|
|
426
|
+
finally:
|
|
427
|
+
os_ops.rmdirs(tmpdir)
|
|
428
|
+
|
|
429
|
+
return InitData_ServerProps(
|
|
430
|
+
pgpro_edition=pgpro_edition,
|
|
431
|
+
num_version=pg_config_version,
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
sm_binary_names__win32 = InitData_BinaryName(
|
|
435
|
+
pg_config="pg_config.exe",
|
|
436
|
+
initdb="initdb.exe",
|
|
437
|
+
postgres="postgres.exe",
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
sm_binary_names__linux = InitData_BinaryName(
|
|
441
|
+
pg_config="pg_config",
|
|
442
|
+
initdb="initdb",
|
|
443
|
+
postgres="postgres",
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
@staticmethod
|
|
447
|
+
def _get_binary_names(
|
|
448
|
+
os_ops: testgres.OsOperations,
|
|
449
|
+
) -> InitData_BinaryName:
|
|
450
|
+
assert isinstance(os_ops, testgres.OsOperations)
|
|
451
|
+
|
|
452
|
+
platform_name = os_ops.get_platform()
|
|
453
|
+
if platform_name == "win32":
|
|
454
|
+
return __class__.sm_binary_names__win32
|
|
455
|
+
|
|
456
|
+
return __class__.sm_binary_names__linux
|
|
457
|
+
|
|
265
458
|
|
|
266
459
|
try:
|
|
267
460
|
init_params = Init()
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{testgres_pg_probackup2-0.9.0 → testgres_pg_probackup2-0.9.1}/pg_probackup2/storage/fs_backup.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|