From 51e8557bc1bbbff9ae938a750d47d23672b82d7e Mon Sep 17 00:00:00 2001 From: Mia Altieri Date: Fri, 1 Sep 2023 09:50:36 +0000 Subject: [PATCH] process pbm response --- src/charm.py | 3 ++- tests/integration/backup_tests/test_backups.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/charm.py b/src/charm.py index ae5ef0cd8..3b87b06be 100755 --- a/src/charm.py +++ b/src/charm.py @@ -1003,7 +1003,8 @@ def run_pbm_command(self, cmd: List[str]) -> str: Raises: subprocess.CalledProcessError """ - return subprocess.check_output(f"charmed-mongodb.pbm {' '.join(cmd)}", shell=True) + pbm_response = subprocess.check_output(f"charmed-mongodb.pbm {' '.join(cmd)}", shell=True) + return pbm_response.decode("utf-8") def start_backup_service(self) -> None: """Starts the pbm agent. diff --git a/tests/integration/backup_tests/test_backups.py b/tests/integration/backup_tests/test_backups.py index 1436b047e..b7cb64d48 100644 --- a/tests/integration/backup_tests/test_backups.py +++ b/tests/integration/backup_tests/test_backups.py @@ -135,7 +135,7 @@ async def test_create_and_list_backups(ops_test: OpsTest) -> None: # verify backup is started action = await db_unit.run_action(action_name="create-backup") backup_result = await action.wait() - assert backup_result.results["backup-status"] == "backup started", "backup didn't start" + assert "backup started" in backup_result.results["backup-status"], "backup didn't start" # verify backup is present in the list of backups # the action `create-backup` only confirms that the command was sent to the `pbm`. Creating a @@ -401,4 +401,4 @@ async def test_update_backup_password(ops_test: OpsTest) -> None: # verify we still have connection to pbm via creating a backup action = await db_unit.run_action(action_name="create-backup") backup_result = await action.wait() - assert backup_result.results["backup-status"] == "backup started", "backup didn't start" + assert "backup started" in backup_result.results["backup-status"], "backup didn't start"