Skip to content

Commit

Permalink
Add a tox environment & dependencies for running molecule tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Goddard committed Feb 20, 2018
1 parent 0f5832e commit 318f73c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ ansible/kolla-venv/

# Vagrant
.vagrant

# Molecule
.molecule/

# Pytest
.cache/
.pytest_cache/
pytestdebug.log
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 25 additions & 0 deletions tools/test-molecule.sh
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 318f73c

Please sign in to comment.