Skip to content

test(observers): cover the observer scripts (4/6) - #261

Draft
marceloneppel wants to merge 1 commit into
observers-3-vm-observerfrom
observers-4-script-tests
Draft

test(observers): cover the observer scripts (4/6)#261
marceloneppel wants to merge 1 commit into
observers-3-vm-observerfrom
observers-4-script-tests

Conversation

@marceloneppel

@marceloneppel marceloneppel commented Sep 4, 2026

Copy link
Copy Markdown
Member

Issue

Part of the observers module migration from the PostgreSQL VM and K8s charms' 16/edge branches into this library. Stacks on #260.

Solution

Ports the scripts' unit suites from both charms: the cluster topology observer script (dispatch, main watch loop, databases snapshot diffing) and the raft observer script (raft connectivity decision table), plus the authorisation rules observer script's suite from the K8s charm (databases snapshot diffing and main watch loop). Patch targets move to the single_kernel_postgresql.scripts.* module paths.

The authorisation rules script defines its own UnreachableUnitsError, so its main-loop test asserts against that class rather than the cluster topology observer's.

pytest-asyncio joins the unit dependency group and asyncio_mode = "auto" mirrors the charms' pytest config, as the ported main-loop tests are async without explicit markers.

Provenance: tests ported from tests/unit/test_cluster_topology_observer.py @ 03494fb7b77f96b3108d5968b5eb4d4b61fb6f7f (postgresql-operator) and tests/unit/test_authorisation_rules_observer.py @ dec4b9602d8642310d0516e5cb3551e183e1418e (postgresql-k8s-operator), both on 16/edge.

Checklist

  • I have added or updated any relevant documentation.
  • I have cleaned any remaining cloud resources from my accounts.

Wiring up at canonical/postgresql-operator#1940 and canonical/postgresql-k8s-operator#1725.

@marceloneppel marceloneppel added the enhancement New feature or request label Sep 4, 2026
Ports the scripts' unit suites from both charms: the cluster topology
observer script (dispatch, main watch loop, databases snapshot diffing)
and the raft observer script (raft connectivity decision table), plus
the authorisation rules observer script's suite from the K8s charm
(databases snapshot diffing and main watch loop). Patch targets move to
the single_kernel_postgresql.scripts.* module paths.

The authorisation rules script defines its own UnreachableUnitsError,
so its main-loop test asserts against that class rather than the
cluster topology observer's.

pytest-asyncio joins the unit dependency group and asyncio_mode=auto
mirrors the charms' pytest config, as the ported main-loop tests are
async without explicit markers.

Provenance: tests ported from tests/unit/test_cluster_topology_observer.py
@ 03494fb7b77f96b3108d5968b5eb4d4b61fb6f7f (postgresql-operator) and
tests/unit/test_authorisation_rules_observer.py @
dec4b9602d8642310d0516e5cb3551e183e1418e (postgresql-k8s-operator),
both on 16/edge.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@marceloneppel
marceloneppel force-pushed the observers-3-vm-observer branch from 9563abf to b22b18e Compare September 4, 2026 21:26
@marceloneppel
marceloneppel force-pushed the observers-4-script-tests branch from 9b238f9 to 83e7b51 Compare September 4, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant