Move ansible linter tests outside run_tests.sh
- move all ansible linter tests in tests/ansible-linters.sh - ensure pbid variable contains smoke.yml ID Change-Id: Iea4d8f4d48e0950a976135ba7082d2422212a4c1
This commit is contained in:
parent
8f095d9d70
commit
ea8d54e5be
29
run_tests.sh
29
run_tests.sh
@ -31,18 +31,6 @@ optional arguments:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Some tests only work on certain versions of Ansible.
|
|
||||||
# Use Ansible's pseudo semver to determine if we can run something.
|
|
||||||
function semver_compare {
|
|
||||||
cat << EOF | python
|
|
||||||
from __future__ import print_function
|
|
||||||
import sys
|
|
||||||
from distutils.version import LooseVersion
|
|
||||||
|
|
||||||
print(LooseVersion('${1}') ${2} LooseVersion('${3}'))
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
# Cleanup from any previous runs if necessary
|
# Cleanup from any previous runs if necessary
|
||||||
function cleanup {
|
function cleanup {
|
||||||
[[ -e "${LOGDIR}" ]] && rm -rf "${LOGDIR}"
|
[[ -e "${LOGDIR}" ]] && rm -rf "${LOGDIR}"
|
||||||
@ -126,13 +114,8 @@ export ANSIBLE_ACTION_PLUGINS="ara/plugins/actions"
|
|||||||
export ANSIBLE_LIBRARY="ara/plugins/modules"
|
export ANSIBLE_LIBRARY="ara/plugins/modules"
|
||||||
export ARA_DATABASE="${DATABASE}"
|
export ARA_DATABASE="${DATABASE}"
|
||||||
|
|
||||||
# Lint
|
# Run linters
|
||||||
for file in $(find ara/tests/integration ! -path '*import*.yml' -regex '.*.y[a]?ml'); do
|
bash tests/ansible-linters.sh
|
||||||
ansible-lint ${file}
|
|
||||||
done
|
|
||||||
for file in $(find ara/tests/integration -maxdepth 1 ! -path '*import*.yml' -regex '.*.y[a]?ml'); do
|
|
||||||
ansible-playbook --syntax-check ${file}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Run test playbooks
|
# Run test playbooks
|
||||||
# smoke.yml run output will be re-used later
|
# smoke.yml run output will be re-used later
|
||||||
@ -149,14 +132,8 @@ kill $!
|
|||||||
# Test include role which is a bit special
|
# Test include role which is a bit special
|
||||||
ansible-playbook -vv ara/tests/integration/include_role.yml
|
ansible-playbook -vv ara/tests/integration/include_role.yml
|
||||||
|
|
||||||
if [[ $(semver_compare "${ansible_version}" ">=" "2.4.0.0") == "True" ]]; then
|
|
||||||
ansible-playbook --syntax-check ara/tests/integration/import.yml
|
|
||||||
ansible-lint ara/tests/integration/import.yml
|
|
||||||
ansible-playbook -vv ara/tests/integration/import.yml
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run test commands
|
# Run test commands
|
||||||
pbid=$(ara playbook list -c ID -f value |head -n1)
|
pbid=$(ara playbook list | awk '/smoke.yml/ {print $2}')
|
||||||
|
|
||||||
ara playbook show $pbid -f json
|
ara playbook show $pbid -f json
|
||||||
ara host list -b $pbid -f yaml
|
ara host list -b $pbid -f yaml
|
||||||
|
48
tests/ansible-linters.sh
Executable file
48
tests/ansible-linters.sh
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Copyright (c) 2017 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# This file is part of ARA: Ansible Run Analysis.
|
||||||
|
#
|
||||||
|
# ARA is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# ARA is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with ARA. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
export ANSIBLE_ACTION_PLUGINS="ara/plugins/actions"
|
||||||
|
export ANSIBLE_LIBRARY="ara/plugins/modules"
|
||||||
|
|
||||||
|
# Some tests only work on certain versions of Ansible.
|
||||||
|
# Use Ansible's pseudo semver to determine if we can run something.
|
||||||
|
function semver_compare {
|
||||||
|
cat << EOF | python
|
||||||
|
from __future__ import print_function
|
||||||
|
import sys
|
||||||
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
|
print(LooseVersion('${1}') ${2} LooseVersion('${3}'))
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
find ara/tests/integration ! -path '*import*.yml' -regex '.*.y[a]?ml' \
|
||||||
|
| xargs -I file ansible-lint file
|
||||||
|
|
||||||
|
find ara/tests/integration -maxdepth 1 ! -path '*import*.yml' -regex '.*.y[a]?ml' \
|
||||||
|
| xargs -I file ansible-playbook -i 'localhost,' --syntax-check file
|
||||||
|
|
||||||
|
ansible_version=$(ansible --version | awk '/^ansible/ {print $2}')
|
||||||
|
|
||||||
|
if [[ $(semver_compare "${ansible_version}" ">=" "2.4.0.0") == "True" ]]; then
|
||||||
|
ansible-playbook --syntax-check ara/tests/integration/import.yml
|
||||||
|
ansible-lint ara/tests/integration/import.yml
|
||||||
|
ansible-playbook -vv ara/tests/integration/import.yml
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user