11import contextlib
22import importlib
33import json
4+ import logging
45import os
56import re
67import subprocess
@@ -43,22 +44,22 @@ def __str__(self):
4344class ProbackupApp :
4445
4546def __init__ (self ,test_class :unittest .TestCase ,
46- pg_node ,pb_log_path ,test_env ,auto_compress_alg ,backup_dir ):
47+ pg_node ,pb_log_path ,test_env ,auto_compress_alg ,backup_dir , probackup_path = None ):
4748self .test_class = test_class
4849self .pg_node = pg_node
4950self .pb_log_path = pb_log_path
5051self .test_env = test_env
5152self .auto_compress_alg = auto_compress_alg
5253self .backup_dir = backup_dir
53- self .probackup_path = init_params .probackup_path
54+ self .probackup_path = probackup_path or init_params .probackup_path
5455self .probackup_old_path = init_params .probackup_old_path
5556self .remote = init_params .remote
5657self .verbose = init_params .verbose
5758self .archive_compress = init_params .archive_compress
5859self .test_class .output = None
5960
6061def run (self ,command ,gdb = False ,old_binary = False ,return_id = True ,env = None ,
61- skip_log_directory = False ,expect_error = False ,use_backup_dir = True ):
62+ skip_log_directory = False ,expect_error = False ,use_backup_dir = True , silent = False ):
6263"""
6364 Run pg_probackup
6465 backup_dir: target directory for making backup
@@ -97,8 +98,9 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
9798strcommand += ' -j 1'
9899
99100self .test_class .cmd = binary_path + ' ' + strcommand
100- if self .verbose :
101- print (self .test_class .cmd )
101+ if not silent :
102+ logging .info (self .test_class .cmd .replace (self .probackup_path ,self .probackup_path .split ('/' )[- 1 ])
103+ .replace ('/' .join (self .backup_dir .path .split ('/' )[0 :- 2 ]),'..' ))
102104
103105cmdline = [binary_path ,* command ]
104106if gdb is True :
@@ -207,7 +209,8 @@ def backup_node(
207209old_binary = False ,return_id = True ,no_remote = False ,
208210env = None ,
209211expect_error = False ,
210- sync = False
212+ sync = False ,
213+ silent = False
211214 ):
212215if options is None :
213216options = []
@@ -247,7 +250,7 @@ def backup_node(
247250cmd_list += ['--no-sync' ]
248251
249252return self .run (cmd_list + options ,gdb ,old_binary ,return_id ,env = env ,
250- expect_error = expect_error )
253+ expect_error = expect_error , silent = silent )
251254
252255def backup_replica_node (self ,instance ,node ,data_dir = False ,* ,
253256master ,backup_type = 'full' ,datname = False ,
@@ -394,7 +397,8 @@ def show(
394397options = None ,as_text = False ,as_json = True ,old_binary = False ,
395398env = None ,
396399expect_error = False ,
397- gdb = False
400+ gdb = False ,
401+ silent = False
398402 ):
399403
400404if options is None :
@@ -417,12 +421,12 @@ def show(
417421if as_text :
418422# You should print it when calling as_text=true
419423return self .run (cmd_list + options ,old_binary = old_binary ,env = env ,
420- expect_error = expect_error ,gdb = gdb )
424+ expect_error = expect_error ,gdb = gdb , silent = silent )
421425
422426# get show result as list of lines
423427if as_json :
424428text_json = str (self .run (cmd_list + options ,old_binary = old_binary ,env = env ,
425- expect_error = expect_error ,gdb = gdb ))
429+ expect_error = expect_error ,gdb = gdb , silent = silent ))
426430try :
427431if expect_error :
428432return text_json