Skip to content

Commit c1cfc26

Browse files
authored
Add parsing backup_id in run app.py (#126)
1 parent 63db275 commit c1cfc26

File tree

1 file changed

+14
-4
lines changed
  • testgres/plugins/pg_probackup2/pg_probackup2

1 file changed

+14
-4
lines changed

Diff for: testgres/plugins/pg_probackup2/pg_probackup2/app.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
124124
self.execution_time = end_time - start_time
125125

126126
if command[0] == 'backup' and return_id:
127-
# return backup ID
128-
for line in self.test_class.output.splitlines():
129-
if 'INFO: Backup' and 'completed' in line:
130-
result = line.split()[2]
127+
result = self.get_backup_id()
131128
else:
132129
result = self.test_class.output
133130
if expect_error is True:
@@ -144,6 +141,19 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
144141
else:
145142
raise ProbackupException(self.test_class.output, self.test_class.cmd)
146143

144+
def get_backup_id(self):
145+
if init_params.major_version > 2:
146+
pattern = re.compile(r"Backup (.*) completed successfully.")
147+
for line in self.test_class.output.splitlines():
148+
match = pattern.search(line)
149+
if match:
150+
return match.group(1)
151+
else:
152+
for line in self.test_class.output.splitlines():
153+
if 'INFO: Backup' and 'completed' in line:
154+
return line.split()[2]
155+
return None
156+
147157
def init(self, options=None, old_binary=False, skip_log_directory=False, expect_error=False, use_backup_dir=True):
148158
if options is None:
149159
options = []

0 commit comments

Comments
 (0)