Skip to content

Commit 77c36ee

Browse files
committed
tests: lookup pg_probackup binary presense in BINDIR, PGPROBACKUPBIN and parent directory. Add pg_probackup directory to PATH
1 parent cb27b21 commit 77c36ee

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

tests/helpers/ptrack_helpers.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,37 @@ def __init__(self, *args, **kwargs):
221221
self.probackup_path = self.test_env["PGPROBACKUPBIN"]
222222
else:
223223
if self.verbose:
224-
print('PGPROBINDIR is not an executable file')
224+
print('PGPROBACKUPBIN is not an executable file')
225+
226+
if not self.probackup_path:
227+
probackup_path_tmp = os.path.join(
228+
testgres.get_pg_config()["BINDIR"], 'pg_probackup')
229+
230+
if os.path.isfile(probackup_path_tmp):
231+
if not os.access(probackup_path_tmp, os.X_OK):
232+
print('{0} is not an executable file'.format(
233+
probackup_path_tmp))
234+
else:
235+
self.probackup_path = probackup_path_tmp
236+
225237
if not self.probackup_path:
226-
self.probackup_path = os.path.abspath(os.path.join(
238+
probackup_path_tmp = os.path.abspath(os.path.join(
227239
self.dir_path, "../pg_probackup"))
228240

241+
if os.path.isfile(probackup_path_tmp):
242+
if not os.access(probackup_path_tmp, os.X_OK):
243+
print('{0} is not an executable file'.format(
244+
probackup_path_tmp))
245+
else:
246+
self.probackup_path = probackup_path_tmp
247+
248+
if not self.probackup_path:
249+
print('pg_probackup binary is not found')
250+
exit(1)
251+
252+
os.environ['PATH'] = os.path.dirname(
253+
self.probackup_path) + ":" + os.environ['PATH']
254+
229255
def make_simple_node(
230256
self,
231257
base_dir=None,

0 commit comments

Comments
 (0)