Skip to content

Commit

Permalink
add federation molecule scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
guidograzioli committed Sep 24, 2024
1 parent 7a2d7db commit 5910f6a
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 4 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", "amq_upgrade", "mask_passwords", "custom_xml", "uninstall" ]
[ "default", "static_cluster", "replication", "live_only", "federation", "amq_upgrade", "mask_passwords", "custom_xml", "uninstall" ]
58 changes: 58 additions & 0 deletions molecule/federation/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
- 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: CORE,AMQP
useEpoll: true
sslEnabled: false
activemq_connectors:
- name: instance1
address: instance1
- name: instance2
address: instance2
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
- name: b.test
anycast:
- name: b.test
parameters:
max_consumers: 1
delay_before_dispatch: 3
roles:
- middleware_automation.amq.activemq
83 changes: 83 additions & 0 deletions molecule/federation/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
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:
amq_broker_federations:
- name: amq1-federation
upstreams:
- name: instance2
user: amq-broker
password: amq-broker
static_connectors:
- instance2
queue_policies:
- name: TEST
includes:
- queue_match: TEST
address_match: TEST
instance2:
amq_broker_federations:
- name: amq2-federation
upstreams:
- name: instance1
user: amq-broker
password: amq-broker
static_connectors:
- instance1
queue_policies:
- name: TEST
includes:
- queue_match: TEST
address_match: TEST
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/federation/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/federation/roles
69 changes: 69 additions & 0 deletions molecule/federation/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
- 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"
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"
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'
3 changes: 2 additions & 1 deletion roles/activemq/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ activemq_replication: false
activemq_replicated: false
## cluster discovery: >
# 'jgroups' for shared file ping, 'multicast' for UDP multicast
# 'static' for static declaration + ansible_play_hosts, 'provided' for using activemq_cluster_connections only
# 'static' for static declaration + ansible_play_hosts
# 'provided' for using activemq_cluster_connections only (for federation keep the list empty)
activemq_cluster_discovery: static
activemq_cluster_connections: []
activemq_scale_down_enabled: false
Expand Down
9 changes: 7 additions & 2 deletions roles/activemq/tasks/connectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
notify:
- restart amq_broker

- name: Configure cluster connections
- name: Configure discovery/broadcast groups
become: true
when:
- activemq_cluster_discovery == 'static' or activemq_cluster_discovery == 'provided'
- activemq_ha_enabled or activemq_cluster_enabled
block:
- name: Remove discovery groups
middleware_automation.common.xml:
Expand All @@ -52,6 +51,12 @@
conf: urn:activemq
core: urn:activemq:core

- name: Configure cluster connections
become: true
when:
- activemq_cluster_discovery == 'static' or activemq_cluster_discovery == 'provided'
- activemq_ha_enabled or activemq_cluster_enabled
block:
- name: Create cluster connections configuration string
ansible.builtin.set_fact:
cluster_connections: "{{ lookup('template', 'cluster_connections.broker.xml.j2') }}"
Expand Down

0 comments on commit 5910f6a

Please sign in to comment.