Skip to content

Commit

Permalink
Update test_update_synchronous_node_count
Browse files Browse the repository at this point in the history
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
  • Loading branch information
marceloneppel committed Jul 8, 2024
1 parent 35713aa commit 6c1f2c4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/unit/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from charms.operator_libs_linux.v2 import snap
from jinja2 import Template
from ops.testing import Harness
from tenacity import stop_after_delay
from tenacity import RetryError, stop_after_delay, wait_fixed

from charm import PostgresqlOperatorCharm
from cluster import Patroni
Expand Down Expand Up @@ -429,7 +429,9 @@ def test_switchover(peers_ips, patroni):


def test_update_synchronous_node_count(peers_ips, patroni):
with patch("requests.patch") as _patch:
with patch("cluster.stop_after_delay", return_value=stop_after_delay(0)) as _wait_fixed, patch(
"cluster.wait_fixed", return_value=wait_fixed(0)
) as _wait_fixed, patch("requests.patch") as _patch:
response = _patch.return_value
response.status_code = 200

Expand All @@ -439,6 +441,11 @@ def test_update_synchronous_node_count(peers_ips, patroni):
"http://1.1.1.1:8008/config", json={"synchronous_node_count": 0}, verify=True
)

# Test when the request fails.
response.status_code = 500
with tc.assertRaises(RetryError):
patroni.update_synchronous_node_count()


def test_configure_patroni_on_unit(peers_ips, patroni):
with (
Expand Down

0 comments on commit 6c1f2c4

Please sign in to comment.