Add a tox environment & dependencies for running molecule tests

This commit is contained in:
Mark Goddard 2018-02-08 11:56:11 +00:00
parent 0f5832e865
commit 318f73cc52
5 changed files with 49 additions and 4 deletions

8
.gitignore vendored
View File

@ -57,3 +57,11 @@ ansible/kolla-venv/
# Vagrant
.vagrant
# Molecule
.molecule/
# Pytest
.cache/
.pytest_cache/
pytestdebug.log

View File

@ -27,6 +27,8 @@ env:
- TOX_ENV=ansible-syntax
# Run ansible tests.
- TOX_ENV=ansible
# Run molecule tests.
- TOX_ENV=molecule
install:
# Install tox in a virtualenv to ensure we have an up to date version.

View File

@ -2,11 +2,12 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking>=0.12.0,<0.13 # Apache-2.0
ansible-lint>=3.0.0 # MIT
bashate>=0.2 # Apache-2.0
coverage>=4.0 # Apache-2.0
doc8 # Apache-2.0
sphinx>=1.5.1 # BSD
docker<3 # Apache-2.0
hacking>=0.12.0,<0.13 # Apache-2.0
molecule<3 # MIT
oslotest>=1.10.0 # Apache-2.0
ansible-lint>=3.0.0 # MIT
sphinx>=1.5.1 # BSD

25
tools/test-molecule.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# Run molecule tests. Any arguments passed to this script will be passed onto
# molecule.
set -e
molecules="$(find ansible/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

@ -52,6 +52,15 @@ commands =
{toxinidir}/ansible/roles/*/tests/main.yml \
{posargs}"
[testenv:molecule]
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike} {opts} {packages}
commands =
# Install ansible role dependencies from Galaxy.
ansible-galaxy install \
-r {toxinidir}/requirements.yml \
-p {toxinidir}/ansible/roles
{toxinidir}/tools/test-molecule.sh {posargs}
[testenv:alint]
commands = ansible-lint ansible/*.yaml