8399965ed0
When parsing the openstack_user_config.yml file, the code would not account for user mistakes when multiple IP addresses were specified for the same hostname. When multiple IP addresses were specified, the last one parsed would be written to the inventory. This change instead throws a runtime error when this situation arises, so that the invalid config cannot be written. The tox.ini configuration is modified to make sure that the insert order on the configuration dictionary is the same on every run of the tests. Were this not set, the insertion order may well change dependon on the hash seed, which would cause test failures because the assertions would not match. An OrderedDict is also used to ensure platform differences don't affect testing order. The behavior of this class shouldn't differ from normal dictionaries in a way that invalidates the test cases. Change-Id: I7c724b1dd668a8372bf2dafaf3461e0a3cb1a557
109 lines
3.4 KiB
INI
109 lines
3.4 KiB
INI
[tox]
|
|
minversion = 1.6
|
|
skipsdist = True
|
|
envlist = docs,linters,releasenotes
|
|
|
|
[testenv]
|
|
usedevelop = True
|
|
install_command = pip install -U {opts} {packages}
|
|
setenv = VIRTUAL_ENV={envdir}
|
|
deps = -r{toxinidir}/test-requirements.txt
|
|
whitelist_externals = bash
|
|
basepython = python2.7
|
|
|
|
[testenv:releasenotes]
|
|
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
|
|
|
[testenv:docs]
|
|
commands=
|
|
python setup.py build_sphinx
|
|
|
|
# environment used by the -infra templated docs job
|
|
[testenv:venv]
|
|
deps = -r{toxinidir}/test-requirements.txt
|
|
commands = {posargs}
|
|
|
|
# Run hacking/flake8 check for all python files
|
|
[testenv:pep8]
|
|
commands =
|
|
bash -c "grep -Irl \
|
|
-e '!/usr/bin/env python' \
|
|
-e '!/bin/python' \
|
|
-e '!/usr/bin/python' \
|
|
--exclude-dir '.*' \
|
|
--exclude-dir 'doc' \
|
|
--exclude-dir '*.egg' \
|
|
--exclude-dir '*.egg-info' \
|
|
--exclude-dir '*templates' \
|
|
--exclude 'tox.ini' \
|
|
--exclude '*.sh' \
|
|
{toxinidir} | xargs flake8 --verbose"
|
|
|
|
|
|
[flake8]
|
|
# Ignores the following rules due to how ansible modules work in general
|
|
# F403 'from ansible.module_utils.basic import *' used;
|
|
# unable to detect undefined names
|
|
# H303 No wildcard (*) import.
|
|
ignore=F403,H303
|
|
|
|
[testenv:bashate]
|
|
commands =
|
|
# Run bashate check for all bash scripts
|
|
# Ignores the following rules:
|
|
# E003: Indent not multiple of 4 (we prefer to use multiples of 2)
|
|
# E006: Line longer than 79 columns (as many scripts use jinja
|
|
# templating, this is very difficult)
|
|
# E040: Syntax error determined using `bash -n` (as many scripts
|
|
# use jinja templating, this will often fail and the syntax
|
|
# error will be discovered in execution anyway)
|
|
bash -c "grep --recursive --binary-files=without-match \
|
|
--files-with-match '^.!.*\(ba\)\?sh$' \
|
|
--exclude-dir .tox \
|
|
--exclude-dir .git \
|
|
{toxinidir} | xargs bashate --error . --verbose --ignore=E003,E006,E040"
|
|
|
|
[testenv:ansible-lint]
|
|
commands =
|
|
# Perform an Ansible lint check
|
|
bash -c "ansible-lint {toxinidir}/playbooks/*.yml"
|
|
|
|
[testenv:ansible-syntax]
|
|
commands =
|
|
# Perform an Ansible syntax check
|
|
bash -c "mkdir -p {envtmpdir}/ansible; \
|
|
export ANSIBLE_CONFIG={envtmpdir}/ansible/ansible.cfg; \
|
|
export ANSIBLE_ROLES_PATH={envtmpdir}/ansible/roles; \
|
|
sed 's|/etc/ansible|{envtmpdir}/ansible|' \
|
|
{toxinidir}/tests/ansible.cfg | \
|
|
tee {envtmpdir}/ansible/ansible.cfg; \
|
|
sed 's|path: /etc/ansible|path: {envtmpdir}/ansible|' \
|
|
{toxinidir}/ansible-role-requirements.yml | \
|
|
tee {envtmpdir}/ansible/ansible-role-requirements.yml; \
|
|
ansible-galaxy install \
|
|
--role-file={envtmpdir}/ansible/ansible-role-requirements.yml \
|
|
--roles-path={envtmpdir}/ansible/roles \
|
|
--force; \
|
|
ansible-playbook -i 'localhost ansible-connection=local,' \
|
|
--syntax-check \
|
|
--list-tasks \
|
|
{toxinidir}/playbooks/*.yml"
|
|
|
|
[testenv:inventory]
|
|
# Use a fixed seed since some inventory tests rely on specific ordering
|
|
setenv =
|
|
{[testenv]setenv}
|
|
PYTHONHASHSEED = 100
|
|
commands =
|
|
coverage erase
|
|
coverage run {toxinidir}/tests/test_inventory.py
|
|
coverage report --show-missing --include={toxinidir}/playbooks/inventory/*
|
|
|
|
[testenv:linters]
|
|
commands =
|
|
{[testenv:pep8]commands}
|
|
{[testenv:bashate]commands}
|
|
{[testenv:ansible-lint]commands}
|
|
{[testenv:ansible-syntax]commands}
|
|
{[testenv:inventory]commands}
|