Adds job that runs molecule tests
Enable testing roles with molecule via tox-molecule job. Its first version only tried to run tripleo-bootstrap role on two supported platforms. Test locally by running `tox -e molecule` or `pytest path/to/molecule.yml` if you have pytest-molecule installed. Depends-On: https://review.opendev.org/#/c/663599/ Change-Id: I27157c439aea5ca6bda2e2d9070644ef7bb23a9d
This commit is contained in:
parent
a1495d5f0f
commit
7e8c221fe2
|
@ -0,0 +1,21 @@
|
|||
# Molecule managed
|
||||
|
||||
{% 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"]
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
driver:
|
||||
name: docker
|
||||
|
||||
platforms:
|
||||
- name: centos7
|
||||
hostname: centos7
|
||||
image: centos:7
|
||||
dockerfile: ../Dockerfile.j2
|
||||
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
|
||||
dockerfile: ../Dockerfile.j2
|
||||
pkg_extras: python*-setuptools
|
||||
environment:
|
||||
<<: *env
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
log: true
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
- destroy
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
- destroy
|
||||
|
||||
lint:
|
||||
enabled: false
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
|
||||
- name: Converge
|
||||
hosts: all
|
||||
tasks:
|
||||
|
||||
- name: include tripleo-bootstrap role
|
||||
include_role:
|
||||
name: tripleo-bootstrap
|
|
@ -0,0 +1,15 @@
|
|||
- name: Prepare
|
||||
hosts: all
|
||||
tasks:
|
||||
|
||||
# TODO: replace these steps with meta dependency on another role to avoid code duplication
|
||||
- name: install deplorean repo
|
||||
get_url:
|
||||
url: "https://trunk.rdoproject.org/{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-master/current-tripleo/delorean.repo"
|
||||
dest: /etc/yum.repos.d/delorean.repo
|
||||
|
||||
# stuff like jq is provided here for centos-7
|
||||
- name: install deplorean-deps repo
|
||||
get_url:
|
||||
url: "https://trunk.rdoproject.org/{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-master/delorean-deps.repo"
|
||||
dest: /etc/yum.repos.d/delorean-deps.repo
|
|
@ -166,3 +166,7 @@ mistral.actions =
|
|||
tripleo.templates.upload_default = tripleo_common.actions.templates:UploadTemplatesAction
|
||||
# deprecated for rocky release, will be removed in the "S" cycle
|
||||
tripleo.role.list = tripleo_common.actions.plan:ListRolesAction
|
||||
|
||||
[tool:pytest]
|
||||
norecursedirs = .git .tox dist
|
||||
log_cli = true
|
||||
|
|
36
tox.ini
36
tox.ini
|
@ -1,10 +1,29 @@
|
|||
[tox]
|
||||
minversion = 2.0
|
||||
envlist = pep8,py37,py36,py27
|
||||
envlist = pep8,py37,py36,py27,molecule
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
setenv =
|
||||
ANSIBLE_FORCE_COLOR=1
|
||||
ANSIBLE_INVENTORY={toxinidir}/tests/hosts.ini
|
||||
ANSIBLE_NOCOWS=1
|
||||
ANSIBLE_RETRY_FILES_ENABLED=0
|
||||
ANSIBLE_STDOUT_CALLBACK=debug
|
||||
PY_COLORS=1
|
||||
VIRTUAL_ENV={envdir}
|
||||
# pip: Avoid 2020-01-01 warnings: https://github.com/pypa/pip/issues/6207
|
||||
# paramiko CryptographyDeprecationWarning: https://github.com/ansible/ansible/issues/52598
|
||||
PYTHONWARNINGS=ignore:DEPRECATION::pip._internal.cli.base_command,ignore::UserWarning
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
passenv =
|
||||
ANSIBLE_*
|
||||
DOCKER_*
|
||||
MOLECULE_*
|
||||
PYTEST*
|
||||
SSH_AUTH_SOCK
|
||||
TERM
|
||||
install_command = pip install {opts} {packages}
|
||||
deps =
|
||||
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt}
|
||||
|
@ -62,6 +81,21 @@ commands =
|
|||
--exclude-dir .git \
|
||||
| xargs bashate --error . --verbose --ignore=E006,E040,E042"
|
||||
|
||||
[testenv:molecule]
|
||||
deps =
|
||||
ansi2html
|
||||
docker>=3.7
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-html
|
||||
pytest-molecule
|
||||
pytest-xdist
|
||||
mock
|
||||
molecule>=2.22rc1
|
||||
selinux
|
||||
commands =
|
||||
python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {posargs:roles}
|
||||
|
||||
[flake8]
|
||||
# E123, E125 skipped as they are invalid PEP-8.
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
- openstack-python-jobs
|
||||
- openstack-python36-jobs
|
||||
- openstack-python37-jobs
|
||||
- openstack-tox-molecule
|
||||
- publish-openstack-docs-pti
|
||||
- release-notes-jobs-python3
|
||||
- tripleo-multinode-container-minimal
|
||||
|
|
Loading…
Reference in New Issue