Skip to content

Commit

Permalink
Test async replication tests fix
Browse files Browse the repository at this point in the history
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
  • Loading branch information
marceloneppel committed Jun 20, 2024
1 parent 7e9266f commit d5f69d5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/relations/async_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def __init__(self, charm):
super().__init__(charm, "postgresql")
self.charm = charm
self.framework.observe(
self.charm.on[REPLICATION_OFFER_RELATION].relation_joined,
self._on_async_relation_joined,
self.charm.on[REPLICATION_OFFER_RELATION].relation_created,
self._on_async_relation_created,
)
self.framework.observe(
self.charm.on[REPLICATION_CONSUMER_RELATION].relation_joined,
self._on_async_relation_joined,
self.charm.on[REPLICATION_CONSUMER_RELATION].relation_created,
self._on_async_relation_created,
)
self.framework.observe(
self.charm.on[REPLICATION_OFFER_RELATION].relation_changed,
Expand Down Expand Up @@ -546,13 +546,7 @@ def _on_async_relation_changed(self, event: RelationChangedEvent) -> None:

self._handle_database_start(event)

def _on_async_relation_departed(self, event: RelationDepartedEvent) -> None:
"""Set a flag to avoid setting a wrong status message on relation broken event handler."""
# This is needed because of https://bugs.launchpad.net/juju/+bug/1979811.
if event.departing_unit == self.charm.unit and self.charm._peers is not None:
self.charm._peers.data[self.charm.unit].update({"departing": "True"})

def _on_async_relation_joined(self, _) -> None:
def _on_async_relation_created(self, _) -> None:
"""Publish this unit address in the relation data."""
self._relation.data[self.charm.unit].update({"unit-address": self.charm._unit_ip})

Expand All @@ -563,6 +557,12 @@ def _on_async_relation_joined(self, _) -> None:
"unit-promoted-cluster-counter": highest_promoted_cluster_counter
})

def _on_async_relation_departed(self, event: RelationDepartedEvent) -> None:
"""Set a flag to avoid setting a wrong status message on relation broken event handler."""
# This is needed because of https://bugs.launchpad.net/juju/+bug/1979811.
if event.departing_unit == self.charm.unit and self.charm._peers is not None:
self.charm._peers.data[self.charm.unit].update({"departing": "True"})

def _on_create_replication(self, event: ActionEvent) -> None:
"""Set up asynchronous replication between two clusters."""
if self._get_primary_cluster() is not None:
Expand Down

0 comments on commit d5f69d5

Please sign in to comment.