Adds molecule testing for stonith-exists

Change-Id: I432d68fbed4f5a5f0dd96e0fc465650068c984a2
(cherry picked from commit 352dadd850)
This commit is contained in:
Cédric Jeanneret 2019-07-26 11:01:39 +02:00 committed by Gael Chamoulaud
parent 56a3990a31
commit a716e48a69
5 changed files with 178 additions and 0 deletions

View File

@ -0,0 +1,37 @@
# Molecule managed
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
{% for pkg in item.easy_install | default([]) %}
# install pip for centos where there is no python-pip rpm in default repos
RUN easy_install {{ pkg }}
{% endfor %}
CMD ["sh", "-c", "while true; do sleep 10000; done"]

View File

@ -0,0 +1,46 @@
---
driver:
name: docker
log: true
platforms:
- name: centos7
hostname: centos7
image: centos:7
pkg_extras: python-setuptools
easy_install:
- pip
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
- name: fedora28
hostname: fedora28
image: fedora:28
pkg_extras: python*-setuptools
environment:
<<: *env
provisioner:
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- verify
- destroy
lint:
enabled: false
verifier:
name: testinfra
lint:
name: flake8

View File

@ -0,0 +1,56 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Converge
hosts: all
tasks:
- name: Safe run
include_role:
name: stonith-exists
- name: Fail the validation
block:
- name: Faulty pcs script
copy:
dest: /usr/bin/pcs
mode: 0755
content: |
#!/bin/sh
echo "NO stonith devices configured"
exit 0
- name: Run validation
include_role:
name: stonith-exists
rescue:
- name: Clear host errors
meta: clear_host_errors
- name: Test output
debug:
msg: The validation works! End play
- name: End play
meta: end_play
- name: Fail playbook if reached
fail:
msg: |
The stonith-exists validation didn't properly detect failed
stonith config

View File

@ -0,0 +1,30 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Prepare
hosts: all
gather_facts: no
tasks:
- name: Populate successful stonith
copy:
dest: /usr/bin/pcs
mode: 0755
content: |
#!/bin/sh
echo "Stonith service configured"
exit 0

View File

@ -21,6 +21,7 @@
- tripleo-validations-centos-7-molecule-undercloud-heat-purge-deleted
- tripleo-validations-centos-7-molecule-undercloud-tokenflush
- tripleo-validations-centos-7-molecule-rabbitmq-limits
- tripleo-validations-centos-7-molecule-stonith-exists
gate:
queue: integrated
jobs:
@ -42,6 +43,7 @@
- tripleo-validations-centos-7-molecule-undercloud-heat-purge-deleted
- tripleo-validations-centos-7-molecule-undercloud-tokenflush
- tripleo-validations-centos-7-molecule-rabbitmq-limits
- tripleo-validations-centos-7-molecule-stonith-exists
name: tripleo-validations-molecule-jobs
- job:
files:
@ -170,3 +172,10 @@
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: rabbitmq-limits
- job:
files:
- ^roles/stonith-exists/.*
name: tripleo-validations-centos-7-molecule-stonith-exists
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: stonith-exists