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
4546 def __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 ):
4748 self .test_class = test_class
4849 self .pg_node = pg_node
4950 self .pb_log_path = pb_log_path
5051 self .test_env = test_env
5152 self .auto_compress_alg = auto_compress_alg
5253 self .backup_dir = backup_dir
53- self .probackup_path = init_params .probackup_path
54+ self .probackup_path = probackup_path or init_params .probackup_path
5455 self .probackup_old_path = init_params .probackup_old_path
5556 self .remote = init_params .remote
5657 self .verbose = init_params .verbose
5758 self .archive_compress = init_params .archive_compress
5859 self .test_class .output = None
5960
6061 def 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,
9798 strcommand += ' -j 1'
9899
99100 self .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
103105 cmdline = [binary_path , * command ]
104106 if gdb is True :
@@ -207,7 +209,8 @@ def backup_node(
207209 old_binary = False , return_id = True , no_remote = False ,
208210 env = None ,
209211 expect_error = False ,
210- sync = False
212+ sync = False ,
213+ silent = False
211214 ):
212215 if options is None :
213216 options = []
@@ -247,7 +250,7 @@ def backup_node(
247250 cmd_list += ['--no-sync' ]
248251
249252 return 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
252255 def backup_replica_node (self , instance , node , data_dir = False , * ,
253256 master , backup_type = 'full' , datname = False ,
@@ -394,7 +397,8 @@ def show(
394397 options = None , as_text = False , as_json = True , old_binary = False ,
395398 env = None ,
396399 expect_error = False ,
397- gdb = False
400+ gdb = False ,
401+ silent = False
398402 ):
399403
400404 if options is None :
@@ -417,12 +421,12 @@ def show(
417421 if as_text :
418422 # You should print it when calling as_text=true
419423 return 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
423427 if as_json :
424428 text_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 ))
426430 try :
427431 if expect_error :
428432 return text_json
0 commit comments