Skip to content

test(observers): cover the observer handlers (5/6) - #262

Draft
marceloneppel wants to merge 1 commit into
observers-4-script-testsfrom
observers-5-observer-tests
Draft

test(observers): cover the observer handlers (5/6)#262
marceloneppel wants to merge 1 commit into
observers-4-script-testsfrom
observers-5-observer-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 #261.

Solution

Ports the cluster topology observer's start/stop and raft-observer unit-rendering suites from the VM charm onto the library harness: patch targets move from the charms' _peers/_peer_members_ips properties to the library state (peer_relation/peer_members_ips), the harness peer relation backs the positive cases, and the raft-observer test reads its expected systemd unit content from the package templates instead of the charm's templates/ directory.

Adds the authorisation rules observer's start/stop coverage (the K8s charm had none): guards on status, peers, container connectivity and cluster initialisation, the already-running and dead-pid restart paths, SIGTERM stop with databag cleanup, and the substrate gating of both handlers' construction on the abstract charm.

Every test runs under both substrates via the session fixture and skips itself on the substrate that does not ship the handler.

Provenance: tests ported from tests/unit/test_cluster_topology_observer.py @ 03494fb7b77f96b3108d5968b5eb4d4b61fb6f7f (postgresql-operator 16/edge); the authorisation rules handler tests are new, matching the ported behavior.

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.

Ports the cluster topology observer's start/stop and raft-observer
unit-rendering suites from the VM charm onto the library harness: patch
targets move from the charms' _peers/_peer_members_ips properties to
the library state (peer_relation/peer_members_ips), the harness peer
relation backs the positive cases, and the raft-observer test reads its
expected systemd unit content from the package templates instead of the
charm's templates/ directory.

Adds the authorisation rules observer's start/stop coverage (the K8s
charm had none): guards on status, peers, container connectivity and
cluster initialisation, the already-running and dead-pid restart paths,
SIGTERM stop with databag cleanup, and the substrate gating of both
handlers' construction on the abstract charm.

Every test runs under both substrates via the session fixture and skips
itself on the substrate that does not ship the handler.

Provenance: tests ported from tests/unit/test_cluster_topology_observer.py
@ 03494fb7b77f96b3108d5968b5eb4d4b61fb6f7f (postgresql-operator 16/edge);
the authorisation rules handler tests are new, matching the ported
behavior.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@marceloneppel
marceloneppel force-pushed the observers-4-script-tests branch from 9b238f9 to 83e7b51 Compare September 4, 2026 21:27
@marceloneppel
marceloneppel force-pushed the observers-5-observer-tests branch from f82b44f to cef5ced 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