Files
openstack-ansible-rabbitmq_…/tests/test-rabbitmq-functional.yml
Dmitriy Rabotyagov 45f6078fe5 Add molecule testing to the role
Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/939824
Change-Id: Iba67d3e321c6ebc256bb63de27ce61c26db10ab0
2025-01-23 13:48:52 +01:00

85 lines
3.3 KiB
YAML

---
# Copyright 2016, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Run functional tests
hosts: rabbitmq_all
any_errors_fatal: true
user: root
gather_facts: true
tasks:
- name: Check rabbitmq is running
command: "pgrep -f rabbit"
- name: Open rabbitmq.config
slurp:
src: "/etc/rabbitmq/rabbitmq.conf"
register: rabbitmq_config
- name: Read rabbitmq_ssl_cert
community.crypto.x509_certificate_info:
path: "/etc/rabbitmq/rabbitmq.pem"
register: rabbitmq_ssl_cert_stat
- name: Read rabbit files
set_fact:
rabbitmq_config_contents: "{{ rabbitmq_config.content | b64decode }}"
- name: Check files contents
assert:
that:
- "'ssl_options.certfile = /etc/rabbitmq/rabbitmq.pem' in rabbitmq_config_contents"
- "'ssl_options.keyfile = /etc/rabbitmq/rabbitmq.key' in rabbitmq_config_contents"
- not rabbitmq_ssl_cert_stat['expired']
- rabbitmq_ssl_cert_stat['issuer']['commonName'] == 'RabbitMQ Intermediate CA'
- rabbitmq_ssl_cert_stat['subject']['commonName'] == inventory_hostname
- "'IP:' ~ rabbitmq_node_address in rabbitmq_ssl_cert_stat['subject_alt_name']"
- name: Get status of rabbitmq
command: rabbitmqctl status --formatter json
register: rabbitmqctl_status
changed_when: false
- name: Get cluster status of rabbitmq
command: rabbitmqctl cluster_status --formatter json
register: rabbitmqctl_cluster_status
changed_when: false
- name: Ensure proper resulting state of deployment
vars:
cluster_status: "{{ rabbitmqctl_cluster_status.stdout | from_json }}"
node_status: "{{ rabbitmqctl_status.stdout | from_json }}"
cluster_rabbit_versions: "{{ cluster_status['versions'].values() | map(attribute='rabbitmq_version') | unique }}"
cluster_erlang_versions: "{{ cluster_status['versions'].values() | map(attribute='erlang_version') | unique }}"
assert:
that:
- not node_status['is_under_maintenance']
- node_status['alarms'] | length == 0
- "'rabbitmq_management' in node_status['active_plugins']"
- cluster_rabbit_versions | length == 1
- cluster_erlang_versions | length == 1
- cluster_status['running_nodes'] | length == 3
- cluster_status['disk_nodes'] | length == 3
- name: Get the policy list
command: rabbitmqctl -q list_policies --formatter json
register: rabbitmq_policies_output
changed_when: false
# Expected policy: "/ CQv2 .* all {"queue-version":2} 0"
- name: Validate that the expected policies are present
assert:
that: rabbitmq_policies_output.stdout | from_json | selectattr('name', 'eq', 'CQv2') | length > 0