testgres-pg-probackup2 0.8.2__tar.gz → 0.9.0__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.
Files changed (15) hide show
  1. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/PKG-INFO +3 -2
  2. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/pg_probackup2/init_helpers.py +56 -14
  3. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/setup.py +7 -2
  4. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/testgres_pg_probackup2.egg-info/PKG-INFO +3 -2
  5. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/testgres_pg_probackup2.egg-info/requires.txt +2 -1
  6. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/README.md +0 -0
  7. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/pg_probackup2/__init__.py +0 -0
  8. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/pg_probackup2/app.py +0 -0
  9. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/pg_probackup2/gdb.py +0 -0
  10. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/pg_probackup2/storage/__init__.py +0 -0
  11. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/pg_probackup2/storage/fs_backup.py +0 -0
  12. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/setup.cfg +0 -0
  13. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/testgres_pg_probackup2.egg-info/SOURCES.txt +0 -0
  14. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/testgres_pg_probackup2.egg-info/dependency_links.txt +0 -0
  15. {testgres_pg_probackup2-0.8.2 → testgres_pg_probackup2-0.9.0}/testgres_pg_probackup2.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testgres_pg_probackup2
3
- Version: 0.8.2
3
+ Version: 0.9.0
4
4
  Summary: Plugin for testgres that manages pg_probackup2
5
5
  Home-page: https://github.com/postgrespro/testgres
6
6
  Author: Postgres Professional
@@ -8,9 +8,10 @@ Author-email: testgres@postgrespro.ru
8
8
  License: PostgreSQL
9
9
  Keywords: pg_probackup,testing,testgres
10
10
  Description-Content-Type: text/markdown
11
+ Requires-Dist: lz4
12
+ Requires-Dist: pefile
11
13
  Requires-Dist: testgres>=1.14.4
12
14
  Requires-Dist: zstd
13
- Requires-Dist: lz4
14
15
  Dynamic: author
15
16
  Dynamic: author-email
16
17
  Dynamic: description-content-type
@@ -2,11 +2,14 @@ import logging
2
2
  from functools import reduce
3
3
  import getpass
4
4
  import os
5
+ import pefile
5
6
  import re
6
7
  import shutil
7
8
  import subprocess
8
9
  import sys
10
+ import traceback
9
11
  import testgres
12
+ from testgres.operations.exceptions import InvalidOperationException
10
13
 
11
14
  try:
12
15
  import lz4.frame # noqa: F401
@@ -42,16 +45,55 @@ class Init(object):
42
45
  else:
43
46
  self.verbose = False
44
47
 
45
- self._pg_config = testgres.get_pg_config()
46
- self.is_enterprise = self._pg_config.get('PGPRO_EDITION', None) == 'enterprise'
47
- self.is_shardman = self._pg_config.get('PGPRO_EDITION', None) == 'shardman'
48
- self.is_pgpro = 'PGPRO_EDITION' in self._pg_config
49
- self.is_nls_enabled = 'enable-nls' in self._pg_config['CONFIGURE']
50
- self.is_lz4_enabled = '-llz4' in self._pg_config['LIBS']
51
- version_num = testgres.parse_pg_version(self._pg_config['VERSION'])
52
- parts = [*version_num.split('.'), '0', '0'][:3]
48
+ os_ops = testgres.LocalOperations()
49
+ os_name = os_ops.get_name()
50
+
51
+ pg_bin = testgres.get_bin_dir(os_ops)
52
+ 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
+ postgres = os_ops.build_path(pg_bin, 'postgres.exe' if os_name == 'nt' else 'postgres')
56
+
57
+ pgpro_edition = os_ops.exec_command(
58
+ [postgres, "-C", "pgpro_edition"],
59
+ encoding='utf-8',
60
+ ignore_errors=True).rstrip()
61
+ self.is_enterprise = pgpro_edition == 'enterprise'
62
+ self.is_shardman = pgpro_edition == 'shardman'
63
+ self.is_pgpro = pgpro_edition != ''
64
+
65
+ # TODO: Always test with NLS support and remove this flag
66
+ self.is_nls_enabled = True
67
+
68
+ if os_name == 'posix':
69
+ ldd = os_ops.exec_command(
70
+ ['ldd', postgres],
71
+ encoding='utf-8')
72
+ self.is_lz4_enabled = 'liblz4.so' in ldd
73
+ elif os_name == 'nt':
74
+ pe = pefile.PE(postgres, fast_load=True)
75
+ pe.parse_data_directories(directories=[
76
+ pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_IMPORT']])
77
+ self.is_lz4_enabled = False
78
+ for entry in pe.DIRECTORY_ENTRY_IMPORT:
79
+ if entry.dll.decode('utf-8') == 'liblz4.dll':
80
+ self.is_lz4_enabled = True
81
+ break
82
+ else:
83
+ # Fall back to trying to determine lz4 support via pg_config
84
+ pg_config = testgres.get_pg_config(os_ops=os_ops)
85
+ self.is_lz4_enabled = '-llz4' in pg_config['LIBS']
86
+
87
+ server_version_out = os_ops.exec_command(
88
+ [postgres, "-C", "server_version"],
89
+ encoding='utf-8')
90
+ server_version = testgres.parse_pg_version(server_version_out)
91
+ parts = [*server_version.split('.'), '0', '0'][:3]
53
92
  parts[0] = re.match(r'\d+', parts[0]).group()
54
- self.pg_config_version = reduce(lambda v, x: v * 100 + int(x), parts, 0)
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
55
97
 
56
98
  os.environ['LANGUAGE'] = 'en' # set default locale language to en. All messages will use this locale
57
99
  test_env = os.environ.copy()
@@ -101,8 +143,7 @@ class Init(object):
101
143
  test_env["PGPROBACKUPBIN"]))
102
144
 
103
145
  if not self.probackup_path:
104
- probackup_path_tmp = os.path.join(
105
- testgres.get_pg_config()['BINDIR'], 'pg_probackup')
146
+ probackup_path_tmp = os_ops.build_path(pg_bin, 'pg_probackup')
106
147
 
107
148
  if os.path.isfile(probackup_path_tmp):
108
149
  if not os.access(probackup_path_tmp, os.X_OK):
@@ -124,12 +165,12 @@ class Init(object):
124
165
  if not self.probackup_path:
125
166
  raise Exception('pg_probackup binary is not found')
126
167
 
127
- if os.name == 'posix':
168
+ if os_name == 'posix':
128
169
  self.EXTERNAL_DIRECTORY_DELIMITER = ':'
129
170
  os.environ['PATH'] = os.path.dirname(
130
171
  self.probackup_path) + ':' + os.environ['PATH']
131
172
 
132
- elif os.name == 'nt':
173
+ elif os_name == 'nt':
133
174
  self.EXTERNAL_DIRECTORY_DELIMITER = ';'
134
175
  os.environ['PATH'] = os.path.dirname(
135
176
  self.probackup_path) + ';' + os.environ['PATH']
@@ -169,7 +210,7 @@ class Init(object):
169
210
  self.old_probackup_version = match.group(0) if match else None
170
211
 
171
212
  self.remote = test_env.get('PGPROBACKUP_SSH_REMOTE', None) == 'ON'
172
- self.ptrack = test_env.get('PG_PROBACKUP_PTRACK', None) == 'ON' and self.pg_config_version >= 110000
213
+ self.ptrack = test_env.get('PG_PROBACKUP_PTRACK', None) == 'ON' and num_version >= 110000
173
214
  self.wal_tree_enabled = test_env.get('PG_PROBACKUP_WAL_TREE_ENABLED', None) == 'ON'
174
215
 
175
216
  self.bckp_source = test_env.get('PG_PROBACKUP_SOURCE', 'pro').lower()
@@ -225,6 +266,7 @@ class Init(object):
225
266
  try:
226
267
  init_params = Init()
227
268
  except Exception as e:
269
+ traceback.print_exc(file=sys.stderr)
228
270
  logging.error(str(e))
229
271
  logging.warning("testgres.plugins.probackup2.init_params is set to None.")
230
272
  init_params = None
@@ -4,7 +4,7 @@ except ImportError:
4
4
  from distutils.core import setup
5
5
 
6
6
  setup(
7
- version='0.8.2',
7
+ version='0.9.0',
8
8
  name='testgres_pg_probackup2',
9
9
  packages=['pg_probackup2', 'pg_probackup2.storage'],
10
10
  description='Plugin for testgres that manages pg_probackup2',
@@ -14,5 +14,10 @@ setup(
14
14
  author='Postgres Professional',
15
15
  author_email='testgres@postgrespro.ru',
16
16
  keywords=['pg_probackup', 'testing', 'testgres'],
17
- install_requires=['testgres>=1.14.4', 'zstd', 'lz4']
17
+ install_requires=[
18
+ 'lz4',
19
+ 'pefile',
20
+ 'testgres>=1.14.4',
21
+ 'zstd'
22
+ ]
18
23
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testgres_pg_probackup2
3
- Version: 0.8.2
3
+ Version: 0.9.0
4
4
  Summary: Plugin for testgres that manages pg_probackup2
5
5
  Home-page: https://github.com/postgrespro/testgres
6
6
  Author: Postgres Professional
@@ -8,9 +8,10 @@ Author-email: testgres@postgrespro.ru
8
8
  License: PostgreSQL
9
9
  Keywords: pg_probackup,testing,testgres
10
10
  Description-Content-Type: text/markdown
11
+ Requires-Dist: lz4
12
+ Requires-Dist: pefile
11
13
  Requires-Dist: testgres>=1.14.4
12
14
  Requires-Dist: zstd
13
- Requires-Dist: lz4
14
15
  Dynamic: author
15
16
  Dynamic: author-email
16
17
  Dynamic: description-content-type