Skip to content

Commit

Permalink
Merge pull request #149 from canonical/IAM-700-update-hydra-version
Browse files Browse the repository at this point in the history
Bump hydra to 2.2.0
  • Loading branch information
natalian98 authored Mar 7, 2024
2 parents 7622bb2 + 6de431b commit 9712332
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ resources:
oci-image:
type: oci-image
description: OCI image for hydra container
upstream-source: ghcr.io/canonical/hydra:2.1.1
upstream-source: ghcr.io/canonical/hydra:2.2.0
requires:
pg-database:
interface: postgresql_client
Expand Down
3 changes: 3 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,9 @@ def _on_run_migration(self, event: ActionEvent) -> None:
self._set_peer_data(self._migration_peer_data_key, self._hydra_cli.get_version())
event.log("Updated migration version in peer data.")

if self.unit.status == WaitingStatus("Waiting for migration to run"):
self._handle_status_update_config(event)

def _on_database_relation_departed(self, event: RelationDepartedEvent) -> None:
"""Event Handler for database relation departed event."""
self.unit.status = BlockedStatus("Missing required relation with postgresql")
Expand Down
33 changes: 33 additions & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,3 +1179,36 @@ def test_timeout_on_run_migration_action(

mocked_run_migration.assert_called_once()
event.fail.assert_called()


def test_unit_status_before_run_migration_action(
harness: Harness,
mocked_migration_is_needed: MagicMock,
mocked_run_migration: MagicMock,
mocked_get_secrets: MagicMock,
) -> None:
harness.set_can_connect(CONTAINER_NAME, True)
mocked_migration_is_needed.return_value = True
setup_peer_relation(harness)
setup_ingress_relation(harness, "public")
setup_postgres_relation(harness)
assert harness.charm.unit.status == WaitingStatus("Waiting for migration to run")


def test_unit_status_after_run_migration_action(
harness: Harness,
mocked_migration_is_needed: MagicMock,
mocked_run_migration: MagicMock,
mocked_get_secrets: MagicMock,
) -> None:
harness.set_can_connect(CONTAINER_NAME, True)
mocked_migration_is_needed.return_value = True
setup_peer_relation(harness)
setup_ingress_relation(harness, "public")
setup_postgres_relation(harness)

mocked_migration_is_needed.return_value = False
event = MagicMock()
harness.charm._on_run_migration(event)

assert isinstance(harness.model.unit.status, ActiveStatus)

0 comments on commit 9712332

Please sign in to comment.