diff --git a/src/charm.py b/src/charm.py index ab887a52ee..99592539af 100755 --- a/src/charm.py +++ b/src/charm.py @@ -1468,7 +1468,7 @@ def _restart(self, event: RunWithLock) -> None: return try: - for attempt in Retrying(wait=wait_fixed(3), stop_after_delay=stop_after_delay(300)): + for attempt in Retrying(wait=wait_fixed(3), stop=stop_after_delay(300)): with attempt: if not self._can_connect_to_postgresql: assert False diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 415048e6ad..48907eb4d0 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -1135,6 +1135,7 @@ def test_restart(harness): with ( patch("charm.Patroni.restart_postgresql") as _restart_postgresql, patch("charm.Patroni.are_all_members_ready") as _are_all_members_ready, + patch("charm.PostgresqlOperatorCharm._can_connect_to_postgresql", return_value=True), ): _are_all_members_ready.side_effect = [False, True, True]