Skip to content

Add parsing backup_id in run app.py #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -119,10 +119,7 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
env=env
).decode('utf-8', errors='replace')
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 @@ -139,6 +136,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