Skip to content

Commit

Permalink
Merge pull request #179 from guidograzioli/mirroring_scenario
Browse files Browse the repository at this point in the history
Fix invalid `broker-connections` when boolean options are used
  • Loading branch information
guidograzioli authored Sep 24, 2024
2 parents dc2569d + 86c6089 commit e9dbad9
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
with:
fqcn: 'middleware_automation/amq'
molecule_tests: >-
[ "default", "static_cluster", "replication", "live_only", "federation", "amq_upgrade", "mask_passwords", "custom_xml", "uninstall" ]
[ "default", "static_cluster", "replication", "live_only", "mirroring", "federation", "amq_upgrade", "mask_passwords", "custom_xml", "uninstall" ]
47 changes: 47 additions & 0 deletions molecule/mirroring/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
- name: Converge
hosts: all
gather_facts: yes
vars:
activemq_cluster_enabled: false
activemq_ha_enabled: false
activemq_shared_storage: false
activemq_replication: false
activemq_scale_down_enabled: false
activemq_configure_firewalld: false
activemq_systemd_wait_for_log: false
activemq_systemd_wait_for_port: true
activemq_cluster_discovery: "provided"
activemq_nio_enabled: true
activemq_cors_strict_checking: false
activemq_prometheus_enabled: false
activemq_acceptors:
- name: "{{ inventory_hostname }}"
bind_address: 0.0.0.0
bind_port: "{{ activemq_port }}"
parameters:
tcpSendBufferSize: 1048576
tcpReceiveBufferSize: 1048576
protocols: AMQP
useEpoll: true
sslEnabled: false
activemq_addresses:
- name: queue.in
anycast:
- name: queue.in
- name: queue.out
anycast:
- name: queue.out
- name: DLQ
anycast:
- name: DLQ
parameters:
durable: True
- name: ExpiryQueue
anycast:
- name: ExpiryQueue
- name: a.test
anycast:
- name: a.test
roles:
- middleware_automation.amq.activemq
77 changes: 77 additions & 0 deletions molecule/mirroring/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
driver:
name: docker
platforms:
- name: instance1
image: registry.access.redhat.com/ubi9/ubi-init:latest
pre_build_image: true
privileged: true
command: "/usr/sbin/init"
networks:
- name: amq
tmpfs:
- /run
- /tmp
- name: instance2
image: registry.access.redhat.com/ubi9/ubi-init:latest
pre_build_image: true
privileged: true
command: "/usr/sbin/init"
networks:
- name: amq
tmpfs:
- /run
- /tmp
provisioner:
name: ansible
config_options:
defaults:
interpreter_python: auto_silent
ssh_connection:
pipelining: false
playbooks:
prepare: prepare.yml
converge: converge.yml
verify: verify.yml
inventory:
host_vars:
localhost:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
instance1:
activemq_broker_connections:
- uri: "tcp://instance2:{{ activemq_port }}"
name: DC2
sync: true
user: amq-broker
password: amq-broker
operations:
- type: mirror
parameters:
queue_removal: false
instance2:
activemq_broker_connections:
- uri: "tcp://instance1:{{ activemq_port }}"
name: DC1
sync: true
user: amq-broker
password: amq-broker
operations:
- type: mirror
parameters:
queue_removal: false
env:
ANSIBLE_FORCE_COLOR: "true"
verifier:
name: ansible
scenario:
test_sequence:
- cleanup
- destroy
- create
- prepare
- converge
- idempotence
- side_effect
- verify
- cleanup
- destroy
6 changes: 6 additions & 0 deletions molecule/mirroring/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Prepare
hosts: all
tasks:
- name: "Run preparation common to all scenario"
ansible.builtin.include_tasks: ../prepare.yml
1 change: 1 addition & 0 deletions molecule/mirroring/roles
71 changes: 71 additions & 0 deletions molecule/mirroring/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
- name: Verify
hosts: all
tasks:
- name: Populate service facts
ansible.builtin.service_facts:

- name: Populate activemq facts
middleware_automation.amq.activemq_facts:
base_url: http://localhost:8161
auth_username: amq-broker
auth_password: amq-broker
validate_certs: false

- name: Check if amq-broker service is started
ansible.builtin.assert:
that:
- ansible_facts.services["amq-broker.service"]["state"] == "running"
- ansible_facts.services["amq-broker.service"]["status"] == "enabled"

- name: Read content of instance1 logs
ansible.builtin.slurp:
src: /var/log/activemq/amq-broker/artemis.log
register: slurped_log_instance1
delegate_to: instance1
run_once: true
no_log: true

- name: Read content of instance2 logs
ansible.builtin.slurp:
src: /var/log/activemq/amq-broker/artemis.log
register: slurped_log_instance2
delegate_to: instance2
run_once: true
no_log: true

- name: Check cluster status
run_once: true
block:
- name: Check live-only on instance1
ansible.builtin.assert:
that:
- "'live Message Broker is starting' in slurped_log_instance1.content|b64decode or 'Primary message broker is starting' in slurped_log_instance1.content|b64decode"
- "'Connected on Server AMQP Connection DC2 on instance2:61616' in slurped_log_instance1.content|b64decode"
quiet: true
- name: Check live-only on instance2
ansible.builtin.assert:
that:
- "'live message broker is starting' in slurped_log_instance2.content|b64decode or 'Primary message broker is starting' in slurped_log_instance2.content|b64decode"
- "'Connected on Server AMQP Connection DC1 on instance1:61616' in slurped_log_instance2.content|b64decode"
quiet: true

- name: Check cluster status via jolokia facts (master)
ansible.builtin.assert:
that:
- ansible_facts.activemq.Active == true
- ansible_facts.activemq.Backup == false
- ansible_facts.activemq.Clustered == false
- ansible_facts.activemq.SharedStore == false
- ansible_facts.activemq.HAPolicy == "Primary Only"
when: inventory_hostname == 'instance1'

- name: Check cluster status via jolokia facts
ansible.builtin.assert:
that:
- ansible_facts.activemq.Active == true
- ansible_facts.activemq.Backup == false
- ansible_facts.activemq.Clustered == false
- ansible_facts.activemq.SharedStore == false
- ansible_facts.activemq.HAPolicy == "Primary Only"
when: inventory_hostname == 'instance2'
2 changes: 1 addition & 1 deletion roles/activemq/templates/broker_connections.broker.xml.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<amqp-connection uri="{{ broker_connection.uri }}" name="{{ broker_connection.name }}" {% if broker_connection['user'] is defined %} user="{{ broker_connection.user }}" password="{{ broker_connection.password | default(activemq_instance_password) }}"{% endif %}>
{% for operation in broker_connection.operations | default([]) %}
<{{ operation.type }} {% for param in lookup('ansible.builtin.dict', operation.parameters, wantlist=true) | default([]) %}{{ param.key | replace('_','-') }}="{{ param.value }}" {% endfor %}/>
<{{ operation.type }} {% for param in lookup('ansible.builtin.dict', operation.parameters, wantlist=true) | default([]) %}{{ param.key | replace('_','-') }}="{{ param.value | string | lower }}" {% endfor %}/>
{% endfor %}
</amqp-connection>

0 comments on commit e9dbad9

Please sign in to comment.