Add Molecule tests for the role undercloud-ram.
Change-Id: I0551ab56324ede7f1d33e0e9a680c26ea164023c Signed-off-by: Luke Short <ekultails@gmail.com> Co-Authored-By: Sorin Sbarnea <ssbarnea@redhat.com>
This commit is contained in:
parent
73aad529e8
commit
5bd41653b6
37
roles/undercloud-ram/molecule/default/Dockerfile.j2
Normal file
37
roles/undercloud-ram/molecule/default/Dockerfile.j2
Normal 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"]
|
46
roles/undercloud-ram/molecule/default/molecule.yml
Normal file
46
roles/undercloud-ram/molecule/default/molecule.yml
Normal 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
|
42
roles/undercloud-ram/molecule/default/playbook.yml
Normal file
42
roles/undercloud-ram/molecule/default/playbook.yml
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
# 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
|
||||
|
||||
vars:
|
||||
min_undercloud_ram_gb: 1000000
|
||||
|
||||
tasks:
|
||||
- block:
|
||||
- include_role:
|
||||
name: undercloud-ram
|
||||
rescue:
|
||||
- name: Clear host errors
|
||||
meta: clear_host_errors
|
||||
|
||||
- debug:
|
||||
msg: The validation works! End the playbook run
|
||||
|
||||
- name: End play
|
||||
meta: end_play
|
||||
|
||||
- name: Fail the test
|
||||
fail:
|
||||
msg: |
|
||||
The undercloud-ram role should have detected that there is not
|
||||
enough RAM
|
15
roles/undercloud-ram/molecule/default/verify.yml
Normal file
15
roles/undercloud-ram/molecule/default/verify.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
# 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.
|
@ -1,8 +1,9 @@
|
||||
---
|
||||
- name: Verify the RAM requirements
|
||||
fail:
|
||||
debug:
|
||||
msg: >-
|
||||
The RAM on the undercloud node is {{ ansible_memtotal_mb }} MB,
|
||||
the minimal recommended value is {{ min_undercloud_ram_gb|int * 1024 }} MB.
|
||||
the minimal recommended value is
|
||||
{{ min_undercloud_ram_gb|int * 1024 }} MB.
|
||||
# NOTE(shadower): converting GB to MB
|
||||
failed_when: "(ansible_memtotal_mb) < min_undercloud_ram_gb|int * 1024"
|
||||
|
19
tox.ini
19
tox.ini
@ -1,6 +1,6 @@
|
||||
[tox]
|
||||
minversion = 2.0
|
||||
envlist = py35,py36,py27,pep8
|
||||
minversion = 3.8
|
||||
envlist = pep8,py35,py36,py27,molecule
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
@ -58,3 +58,18 @@ deps =
|
||||
-c{toxinidir}/lower-constraints.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
-r{toxinidir}/requirements.txt
|
||||
|
||||
[testenv:molecule]
|
||||
deps =
|
||||
ansi2html
|
||||
docker>=3.7
|
||||
mock
|
||||
molecule>=2.22rc3
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-html
|
||||
pytest-molecule>=1.0rc1
|
||||
pytest-xdist
|
||||
selinux
|
||||
commands =
|
||||
python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {posargs:roles}
|
||||
|
@ -4,6 +4,7 @@
|
||||
- openstack-python-jobs
|
||||
- openstack-python35-jobs
|
||||
- openstack-python36-jobs
|
||||
- openstack-tox-molecule
|
||||
- check-requirements
|
||||
- publish-openstack-docs-pti
|
||||
- release-notes-jobs-python3
|
||||
|
Loading…
x
Reference in New Issue
Block a user