@@ -43,7 +43,7 @@ def __str__(self):
4343class ProbackupApp :
4444
4545 def __init__ (self , test_class : unittest .TestCase ,
46- pg_node , pb_log_path , test_env , auto_compress_alg , backup_dir ):
46+ pg_node , pb_log_path , test_env , auto_compress_alg , backup_dir , execution_time ):
4747 self .test_class = test_class
4848 self .pg_node = pg_node
4949 self .pb_log_path = pb_log_path
@@ -56,9 +56,10 @@ def __init__(self, test_class: unittest.TestCase,
5656 self .verbose = init_params .verbose
5757 self .archive_compress = init_params .archive_compress
5858 self .test_class .output = None
59+ self .execution_time = execution_time
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 , execution_time = False ):
6263 """
6364 Run pg_probackup
6465 backup_dir: target directory for making backup
@@ -113,11 +114,22 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
113114 cmdline = ['gdbserver' ] + ['localhost:' + str (gdb_port )] + cmdline
114115 print ("pg_probackup gdb suspended, waiting gdb connection on localhost:{0}" .format (gdb_port ))
115116
116- self .test_class .output = subprocess .check_output (
117- cmdline ,
118- stderr = subprocess .STDOUT ,
119- env = env
120- ).decode ('utf-8' , errors = 'replace' )
117+ if execution_time :
118+ start_time = time .time ()
119+ self .test_class .output = subprocess .check_output (
120+ cmdline ,
121+ stderr = subprocess .STDOUT ,
122+ env = env
123+ ).decode ('utf-8' , errors = 'replace' )
124+ end_time = time .time ()
125+ self .execution_time = end_time - start_time
126+ else :
127+ self .test_class .output = subprocess .check_output (
128+ cmdline ,
129+ stderr = subprocess .STDOUT ,
130+ env = env
131+ ).decode ('utf-8' , errors = 'replace' )
132+
121133 if command [0 ] == 'backup' and return_id :
122134 # return backup ID
123135 for line in self .test_class .output .splitlines ():
@@ -213,7 +225,8 @@ def backup_node(
213225 old_binary = False , return_id = True , no_remote = False ,
214226 env = None ,
215227 expect_error = False ,
216- sync = False
228+ sync = False ,
229+ execution_time = False
217230 ):
218231 if options is None :
219232 options = []
@@ -253,7 +266,7 @@ def backup_node(
253266 cmd_list += ['--no-sync' ]
254267
255268 return self .run (cmd_list + options , gdb , old_binary , return_id , env = env ,
256- expect_error = expect_error )
269+ expect_error = expect_error , execution_time = execution_time )
257270
258271 def backup_replica_node (self , instance , node , data_dir = False , * ,
259272 master , backup_type = 'full' , datname = False ,
0 commit comments