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:
parent
a3a3c51152
commit
73138475dc
8
.gitignore
vendored
8
.gitignore
vendored
@ -46,3 +46,11 @@ log/*
|
||||
# Containers
|
||||
browbeat-containers/collectd-openstack/config/*
|
||||
ansible-errors.json
|
||||
|
||||
# Molecule
|
||||
.molecule/
|
||||
|
||||
# Pytest
|
||||
.cache/
|
||||
.pytest_cache/
|
||||
.pytestdebug.log
|
||||
|
@ -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
|
||||
|
17
ansible/README.testing.rst
Normal file
17
ansible/README.testing.rst
Normal 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
|
27
ci-scripts/molecule/test-molecule.sh
Executable file
27
ci-scripts/molecule/test-molecule.sh
Executable 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"
|
@ -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
|
||||
|
5
tox.ini
5
tox.ini
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user