test(observers): cover the observer scripts (4/6) - #261
Draft
marceloneppel wants to merge 1 commit into
Draft
Conversation
2 tasks
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
force-pushed
the
observers-3-vm-observer
branch
from
September 4, 2026 21:26
9563abf to
b22b18e
Compare
marceloneppel
force-pushed
the
observers-4-script-tests
branch
from
September 4, 2026 21:27
9b238f9 to
83e7b51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-asynciojoins the unit dependency group andasyncio_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) andtests/unit/test_authorisation_rules_observer.py@dec4b9602d8642310d0516e5cb3551e183e1418e(postgresql-k8s-operator), both on 16/edge.Checklist
Wiring up at canonical/postgresql-operator#1940 and canonical/postgresql-k8s-operator#1725.