Skip to content

Commit

Permalink
Add parsing backup_id in run app.py (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
demonolock authored May 30, 2024
1 parent 63db275 commit c1cfc26
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions testgres/plugins/pg_probackup2/pg_probackup2/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
self.execution_time = end_time - start_time

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

def get_backup_id(self):
if init_params.major_version > 2:
pattern = re.compile(r"Backup (.*) completed successfully.")
for line in self.test_class.output.splitlines():
match = pattern.search(line)
if match:
return match.group(1)
else:
for line in self.test_class.output.splitlines():
if 'INFO: Backup' and 'completed' in line:
return line.split()[2]
return None

def init(self, options=None, old_binary=False, skip_log_directory=False, expect_error=False, use_backup_dir=True):
if options is None:
options = []
Expand Down

0 comments on commit c1cfc26

Please sign in to comment.