Add molecule infrastructure

- Add molecule support to test ansible roles.
- Also fix flake8 failures.
- Also drop python36 from the templates

Change-Id: Ib647d93144a02a6be7340991c31f65842fdf3f29
Signed-off-by: Charles Short <chucks@redhat.com>
This commit is contained in:
Charles Short 2019-11-21 06:28:03 -05:00
parent a3a3c51152
commit 73138475dc
6 changed files with 63 additions and 3 deletions

8
.gitignore vendored
View File

@ -46,3 +46,11 @@ log/*
# Containers
browbeat-containers/collectd-openstack/config/*
ansible-errors.json
# Molecule
.molecule/
# Pytest
.cache/
.pytest_cache/
.pytestdebug.log

View File

@ -3,17 +3,19 @@
templates:
- docs-on-readthedocs
- openstack-python37-jobs
- openstack-python36-jobs
- openstack-tox-molecule
vars:
rtd_webhook_id: '51626'
check:
jobs:
- openstack-tox-linters
- openstack-tox-py27
- openstack-tox-molecule
gate:
jobs:
- openstack-tox-linters
- openstack-tox-py27
- openstack-tox-molecule
post:
jobs:
- browbeat-upload-git-mirror

View File

@ -0,0 +1,17 @@
Running browebat ansible unit tests
===================================
Running ansible molecule unit tests
-----------------------------------
- Ensure that you have docker installed:
https://docs.docker.com/install/
- Run tox -e molecule
Adding ansible molecue unit test
--------------------------------
- cd ansible/install/roles/<example role>
molecule init scenario --role-name <example role> --driver-name docker

View File

@ -0,0 +1,27 @@
#!/bin/bash
# Run molecule tests. Any arguments passed to this script will be passed onto
# molecule.
set -e
molecules="$(find ansible/install/roles/ -name molecule -type d)"
failed=0
ran=0
for molecule in $molecules; do
pushd $(dirname $molecule)
if ! molecule test --all $*; then
failed=$((failed + 1))
fi
ran=$((ran + 1))
popd
done
if [[ $failed -ne 0 ]]; then
echo "Failed $failed / $ran molecule tests"
exit 1
fi
echo "Ran $ran molecule tests successfully"

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking<0.11,>=0.10.0
hacking>=1.1.0,<1.2.0 # Apache-2.0
pykwalify
coverage>=3.6
@ -21,3 +21,6 @@ testscenarios>=0.4
testtools>=1.4.0
twine
wheel
docker<3 # Apache-2.0
molecule<3 # MIT
selinux>=0.1.5rc1

View File

@ -1,6 +1,6 @@
[tox]
minversion = 3.1.1
envlist = py27,py37,linters,dist,insights
envlist = py27,py37,linters,dist,insights,molecule
skipsdist = True
[testenv]
@ -78,6 +78,9 @@ commands =
python setup.py sdist bdist_wheel
twine upload dist/*
[testenv:molecule]
commands = {toxinidir}/ci-scripts/molecule/test-molecule.sh
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = True