Files
matrix-docker-ansible-deploy/roles/custom/matrix-bridge-heisenbridge/molecule/default/verify.yml
T
Slavi PantaleevandClaude Opus 5 c447e1528b Reword the Molecule scenario comments
They were hard-wrapped at 80 characters, broke mid-parenthesis, and spent lines
restating what the code below them does.

Rewrapped at natural boundaries instead, with the narration dropped and only the
reasons, gotchas and surprises kept. Section dividers stay - they delineate long
plays rather than narrate them.

Comments only; no scenario behaviour changes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEH3vxYSQ5SV4N5z61eyGT
2026-08-27 18:02:53 +03:00

127 lines
5.6 KiB
YAML

# SPDX-FileCopyrightText: 2026 Slavi Pantaleev
#
# SPDX-License-Identifier: AGPL-3.0-or-later
---
# Proves heisenbridge starts, reads the registration the role rendered, and is the version
# the role pins. It does NOT connect to IRC. See docs/molecule-testing.md.
- name: Verify heisenbridge
hosts: all
become: true
vars_files:
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/vars.yml"
- "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../molecule-shared/playbook-context.yml"
gather_facts: false
tasks:
- name: Load the role's defaults under a separate name
ansible.builtin.include_vars:
file: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/main.yml"
name: heisenbridge_role_defaults
- name: Wait for the heisenbridge service to become active
ansible.builtin.systemd_service:
name: matrix-heisenbridge.service
register: heisenbridge_service
until: heisenbridge_service.status.ActiveState == 'active'
retries: 30
delay: 5
failed_when: false
# `Restart=always` means a bridge crash-looping on unreadable config still reports
# `active`, so the restart counter is checked too.
- name: Assert the service is active and has not been restarting
ansible.builtin.assert:
that:
- heisenbridge_service.status.ActiveState == 'active'
- heisenbridge_service.status.NRestarts is defined
- heisenbridge_service.status.NRestarts | int == 0
fail_msg: >-
matrix-heisenbridge.service is
{{ heisenbridge_service.status.ActiveState | default('unknown') }}
after {{ heisenbridge_service.status.NRestarts | default('?') }}
automatic restart(s)
success_msg: "matrix-heisenbridge.service is active and has not restarted"
# Heisenbridge keeps everything directly under its base path, unlike the mautrix bridges.
- name: Read the appservice registration the role rendered
ansible.builtin.slurp:
src: "{{ matrix_bridge_heisenbridge_base_path }}/registration.yaml"
register: heisenbridge_registration_file
# Token and URL both differ from anything heisenbridge would pick on its own, so their
# presence means the role rendered this file rather than the bridge generating one.
- name: Assert the registration carries the scenario's token and namespace
ansible.builtin.assert:
that:
- matrix_bridge_heisenbridge_appservice_token in heisenbridge_registration_rendered
- "'heisenbridge' in heisenbridge_registration_rendered"
fail_msg: "The appservice registration does not carry the scenario's token"
success_msg: "The appservice registration carries the scenario's token"
vars:
heisenbridge_registration_rendered: "{{ heisenbridge_registration_file.content | b64decode }}"
# The role passes the owner on the command line rather than through a config file,
# so the unit is where it can be checked.
- name: Read the systemd unit the role rendered
ansible.builtin.slurp:
src: /etc/systemd/system/matrix-heisenbridge.service
register: heisenbridge_unit_file
- name: Assert the unit carries the owner and homeserver URL the scenario set
ansible.builtin.assert:
that:
- matrix_bridge_heisenbridge_owner in heisenbridge_unit_rendered
- matrix_bridge_heisenbridge_homeserver_url in heisenbridge_unit_rendered
fail_msg: "The unit does not carry the scenario's owner and homeserver URL"
success_msg: "The unit carries the scenario's owner and homeserver URL"
vars:
heisenbridge_unit_rendered: "{{ heisenbridge_unit_file.content | b64decode }}"
# identd binds host port 113 when enabled. Asserting its absence keeps the default from
# silently becoming "on".
- name: Assert identd is not published while it is disabled
ansible.builtin.assert:
that:
- "'-p 113:' not in (heisenbridge_unit_file.content | b64decode)"
fail_msg: >-
The unit publishes identd on port 113 even though
matrix_bridge_heisenbridge_identd_enabled is false
success_msg: "identd is not published while it is disabled"
- name: Read the image of the running container
ansible.builtin.command:
argv:
- docker
- container
- inspect
- matrix-heisenbridge
- --format
- "{{ '{{' }} .Config.Image {{ '}}' }}"
register: heisenbridge_image
changed_when: false
- name: Assert the running container is the version defaults/main.yml pins
ansible.builtin.assert:
that:
- heisenbridge_role_defaults.matrix_bridge_heisenbridge_version | string in heisenbridge_image.stdout
fail_msg: >-
The running container is {{ heisenbridge_image.stdout }}, which does not
carry the pinned version
{{ heisenbridge_role_defaults.matrix_bridge_heisenbridge_version }}
success_msg: "The running container is the version defaults/main.yml pins"
- name: Read the labels the role rendered
ansible.builtin.slurp:
src: "{{ matrix_bridge_heisenbridge_base_path }}/labels"
register: heisenbridge_labels
- name: Assert no Traefik labels are emitted while Traefik support is disabled
ansible.builtin.assert:
that:
- "'traefik.' not in (heisenbridge_labels.content | b64decode)"
fail_msg: >-
Traefik labels were emitted even though
matrix_bridge_heisenbridge_container_labels_traefik_enabled is false
success_msg: "No Traefik labels are emitted while Traefik support is disabled"