Skip to content

Commit 1d79230

Browse files
siddavamshi4gionn
andauthored
OPSEXP-3267 migrate activemq testinfra tests to ansible (#1205)
Co-authored-by: Giovanni Toraldo <[email protected]>
1 parent c4c19aa commit 1d79230

File tree

6 files changed

+66
-71
lines changed

6 files changed

+66
-71
lines changed

roles/activemq/molecule/default/converge.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
---
2-
- name: Handle secrets
3-
vars:
4-
autogen_unsecure_secrets: True
5-
ansible.builtin.import_playbook: ../../../../playbooks/secrets.yml
62
- name: Converge
73
hosts: all
84
tasks:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
ansible_user: ansible
2+
activemq_username: activemq # pragma: allowlist secret
3+
activemq_password: activemq # pragma: allowlist secret

roles/activemq/molecule/default/molecule.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,3 @@ provisioner:
3434
inventory:
3535
links:
3636
host_vars: host_vars
37-
verifier:
38-
name: testinfra
39-
env:
40-
TEST_HOST: "localhost"
41-
options:
42-
verbose: true

roles/activemq/molecule/default/tests/test_activemq.py

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
- name: ActiveMQ Tests
3+
hosts: all
4+
become: yes
5+
vars:
6+
activemq_version: "5.18.7"
7+
activemq_binary_path: "/opt/apache-activemq-{{ activemq_version }}/bin/activemq"
8+
config_folder: "/etc/opt/alfresco"
9+
tasks:
10+
- name: Populate service facts
11+
ansible.builtin.service_facts:
12+
13+
- name: Check if ActiveMQ binary exists
14+
ansible.builtin.stat:
15+
path: "{{ activemq_binary_path }}"
16+
register: activemq_binary
17+
18+
- name: Fail if ActiveMQ binary is missing
19+
ansible.builtin.fail:
20+
msg: "ActiveMQ binary not found at {{ activemq_binary_path }}"
21+
when: not activemq_binary.stat.exists
22+
23+
- name: Run ActiveMQ version command and validate output
24+
ansible.builtin.shell: ". {{ config_folder }}/setenv.sh && $ACTIVEMQ_HOME/bin/activemq --version"
25+
become: yes
26+
register: activemq_version_output
27+
failed_when: "'ActiveMQ ' ~ activemq_version not in activemq_version_output.stdout"
28+
changed_when: false
29+
30+
- name: Run and validate ActiveMQ home
31+
ansible.builtin.shell: ". {{ config_folder }}/setenv.sh && echo $ACTIVEMQ_HOME"
32+
become: yes
33+
register: activemq_home_path
34+
failed_when: "'/opt/apache-activemq-' ~ activemq_version not in activemq_home_path.stdout"
35+
changed_when: false
36+
37+
- name: Check that activemq service is up and running
38+
ansible.builtin.assert:
39+
that:
40+
- ansible_facts.services['activemq.service'] is defined
41+
- ansible_facts.services['activemq.service'].state == 'running'
42+
quiet: true
43+
44+
- name: Validate ActiveMQ web console response
45+
ansible.builtin.uri:
46+
url: "http://localhost:8161"
47+
user: "{{ activemq_username }}"
48+
password: "{{ activemq_password }}"
49+
force_basic_auth: yes
50+
return_content: yes
51+
status_code: 200
52+
register: activemq_web_response
53+
failed_when:
54+
- "'Welcome to the Apache ActiveMQ!' not in activemq_web_response.content"
55+
56+
- name: Validate JVM memory settings
57+
ansible.builtin.command: "pgrep -fa java"
58+
register: jvm_opts
59+
changed_when: false
60+
failed_when:
61+
- "'-Xmx900m' not in jvm_opts.stdout"
62+
- "'-Xms300m' not in jvm_opts.stdout"

roles/activemq/tasks/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108
- file: jetty-realm
109109
line: "{{ activemq_username }}: MD5:{{ activemq_password | md5 }}, admin"
110110
no_log: true
111+
loop_control:
112+
label: "{{ item.file }}"
111113

112114
- name: Change location of ActiveMQ logs
113115
vars:

0 commit comments

Comments
 (0)