@@ -43,7 +43,7 @@ def __str__(self):
43
43
class ProbackupApp :
44
44
45
45
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 ):
47
47
self .test_class = test_class
48
48
self .pg_node = pg_node
49
49
self .pb_log_path = pb_log_path
@@ -56,9 +56,10 @@ def __init__(self, test_class: unittest.TestCase,
56
56
self .verbose = init_params .verbose
57
57
self .archive_compress = init_params .archive_compress
58
58
self .test_class .output = None
59
+ self .execution_time = execution_time
59
60
60
61
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 ):
62
63
"""
63
64
Run pg_probackup
64
65
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,
113
114
cmdline = ['gdbserver' ] + ['localhost:' + str (gdb_port )] + cmdline
114
115
print ("pg_probackup gdb suspended, waiting gdb connection on localhost:{0}" .format (gdb_port ))
115
116
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
+
121
133
if command [0 ] == 'backup' and return_id :
122
134
# return backup ID
123
135
for line in self .test_class .output .splitlines ():
@@ -213,7 +225,8 @@ def backup_node(
213
225
old_binary = False , return_id = True , no_remote = False ,
214
226
env = None ,
215
227
expect_error = False ,
216
- sync = False
228
+ sync = False ,
229
+ execution_time = False
217
230
):
218
231
if options is None :
219
232
options = []
@@ -253,7 +266,7 @@ def backup_node(
253
266
cmd_list += ['--no-sync' ]
254
267
255
268
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 )
257
270
258
271
def backup_replica_node (self , instance , node , data_dir = False , * ,
259
272
master , backup_type = 'full' , datname = False ,
0 commit comments