Skip to content

Commit

Permalink
Merge "Add molecule infrastructure"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Feb 14, 2020
2 parents 22be797 + 7313847 commit ed9e7e7
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ log/*
# Containers
browbeat-containers/collectd-openstack/config/*
ansible-errors.json

# Molecule
.molecule/

# Pytest
.cache/
.pytest_cache/
.pytestdebug.log
4 changes: 3 additions & 1 deletion .zuul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions ansible/README.testing.rst
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions ci-scripts/molecule/test-molecule.sh
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 4 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed9e7e7

Please sign in to comment.