Use centralised test scripts

This patch consumes the test scripts implemented by
https://review.openstack.org/375061 to ensure that
the tests and test preparation is consistent and
more maintainable.

Change-Id: I5acf2bc37b7d9a38e6c3f964bac719421de42ec0
This commit is contained in:
Jesse Pretorius 2016-09-28 08:37:40 +01:00 committed by Jesse Pretorius (odyssey4me)
parent 19b8c679e4
commit 22bfbea3f0
5 changed files with 26 additions and 76 deletions

View File

@ -30,4 +30,4 @@ export ANSIBLE_SSH_ARGS="-o ControlMaster=no \
-o ForwardAgent=yes" -o ForwardAgent=yes"
echo "Run manual functional tests by executing the following:" echo "Run manual functional tests by executing the following:"
echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml -e \"rolename=$(pwd)\"" echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml"

View File

@ -58,7 +58,7 @@
retries: 5 retries: 5
delay: 10 delay: 10
vars_files: vars_files:
- playbooks/test-vars.yml - common/test-vars.yml
- test-vars.yml - test-vars.yml
- name: Playbook for tempest testing of horizon - name: Playbook for tempest testing of horizon
@ -71,5 +71,5 @@
. {{ tempest_bin }}/activate . {{ tempest_bin }}/activate
{{ tempest_bin | dirname }}/run_tempest.sh --no-virtual-env --serial tempest_horizon.tests.scenario.test_dashboard_basic_ops.TestDashboardBasicOps {{ tempest_bin | dirname }}/run_tempest.sh --no-virtual-env --serial tempest_horizon.tests.scenario.test_dashboard_basic_ops.TestDashboardBasicOps
vars_files: vars_files:
- playbooks/test-vars.yml - common/test-vars.yml
- test-vars.yml - test-vars.yml

View File

@ -45,5 +45,5 @@
roles: roles:
- role: "os_horizon" - role: "os_horizon"
vars_files: vars_files:
- playbooks/test-vars.yml - common/test-vars.yml
- test-vars.yml - test-vars.yml

View File

@ -14,19 +14,19 @@
# limitations under the License. # limitations under the License.
# Setup the host # Setup the host
- include: playbooks/test-setup-host.yml - include: common/test-setup-host.yml
# Install RabbitMQ/MariaDB # Install RabbitMQ/MariaDB
- include: playbooks/test-install-infra.yml - include: common/test-install-infra.yml
# Install Keystone # Install Keystone
- include: playbooks/test-install-keystone.yml - include: common/test-install-keystone.yml
# Install Horizon # Install Horizon
- include: test-install-horizon.yml - include: test-install-horizon.yml
# Install Tempest # Install Tempest
- include: playbooks/test-install-tempest.yml - include: common/test-install-tempest.yml
# Test Horizon # Test Horizon
- include: test-horizon-functional.yml - include: test-horizon-functional.yml

86
tox.ini
View File

@ -22,12 +22,11 @@ passenv =
NO_PROXY NO_PROXY
whitelist_externals = whitelist_externals =
bash bash
git
rm
wget
setenv = setenv =
VIRTUAL_ENV={envdir}
PYTHONUNBUFFERED=1 PYTHONUNBUFFERED=1
ROLE_NAME=os_horizon
VIRTUAL_ENV={envdir}
WORKING_DIR={toxinidir}
[testenv:docs] [testenv:docs]
@ -53,17 +52,17 @@ commands =
{posargs} {posargs}
[testenv:tests_clone]
commands =
bash -c "if [ ! -d "{toxinidir}/tests/common" ]; then \
git clone https://git.openstack.org/openstack/openstack-ansible-tests {toxinidir}/tests/common; \
fi"
[testenv:pep8] [testenv:pep8]
commands = commands =
# Run hacking/flake8 check for all python files {[testenv:tests_clone]commands}
bash -c "grep --recursive --binary-files=without-match \ bash -c "{toxinidir}/tests/common/test-pep8.sh"
--files-with-match '^.!.*python$' \
--exclude-dir .eggs \
--exclude-dir .git \
--exclude-dir .tox \
--exclude-dir *.egg-info \
--exclude-dir doc \
{toxinidir} | xargs flake8 --verbose"
[flake8] [flake8]
@ -79,64 +78,22 @@ max-line-length = 120
[testenv:bashate] [testenv:bashate]
commands = commands =
# Run bashate check for all bash scripts {[testenv:tests_clone]commands}
# Ignores the following rules: bash -c "{toxinidir}/tests/common/test-bashate.sh"
# 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] [testenv:ansible]
deps = deps =
{[testenv]deps} {[testenv]deps}
ansible==2.1.1 -rhttp://git.openstack.org/cgit/openstack/openstack-ansible-tests/plain/test-ansible-deps.txt
ansible-lint>=2.7.0,<3.0.0
setenv =
{[testenv]setenv}
ANSIBLE_HOST_KEY_CHECKING = False
ANSIBLE_SSH_CONTROL_PATH = /tmp/%%h-%%r
# TODO (odyssey4me) These are only here as they are non-standard folder
# names for Ansible 1.9.x. We are using the standard folder names for
# Ansible v2.x. We can remove this when we move to Ansible 2.x.
ANSIBLE_ACTION_PLUGINS = {homedir}/.ansible/plugins/action
ANSIBLE_CALLBACK_PLUGINS = {homedir}/.ansible/plugins/callback
ANSIBLE_FILTER_PLUGINS = {homedir}/.ansible/plugins/filter
ANSIBLE_LOOKUP_PLUGINS = {homedir}/.ansible/plugins/lookup
# This is required as the default is the current path or a path specified
# in ansible.cfg
ANSIBLE_LIBRARY = {homedir}/.ansible/plugins/library
# This is required as the default is '/etc/ansible/roles' or a path
# specified in ansible.cfg
ANSIBLE_ROLES_PATH = {homedir}/.ansible/roles:{toxinidir}/..
ANSIBLE_TRANSPORT = "ssh"
commands = commands =
rm -rf {homedir}/.ansible/plugins {[testenv:tests_clone]commands}
git clone https://git.openstack.org/openstack/openstack-ansible-plugins \ bash -c "{toxinidir}/tests/common/test-ansible-env-prep.sh"
{homedir}/.ansible/plugins
rm -rf {homedir}/.ansible/roles
ansible-galaxy install \
--role-file={toxinidir}/tests/ansible-role-requirements.yml \
--force
rm -rf {homedir}/.ansible/roles/os_horizon
bash -c "ln -s {toxinidir} {homedir}/.ansible/roles/os_horizon"
rm -rf {toxinidir}/tests/playbooks
git clone https://git.openstack.org/openstack/openstack-ansible-tests \
{toxinidir}/tests/playbooks
[testenv:ansible-syntax] [testenv:ansible-syntax]
deps = deps =
{[testenv:ansible]deps} {[testenv:ansible]deps}
setenv =
{[testenv:ansible]setenv}
commands = commands =
{[testenv:ansible]commands} {[testenv:ansible]commands}
ansible-playbook -i {toxinidir}/tests/inventory \ ansible-playbook -i {toxinidir}/tests/inventory \
@ -163,10 +120,7 @@ install_command =
[testenv:func_logs] [testenv:func_logs]
commands = commands =
bash -c 'mkdir -p {toxinidir}/logs' bash -c "{toxinidir}/tests/common/test-log-collect.sh"
bash -c 'rsync --archive --verbose --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true'
bash -c 'find "{toxinidir}/logs/" -type f | sed "p;s|$|.txt|" | xargs -n2 mv'
bash -c 'command gzip --best --recursive "{toxinidir}/logs/"'
[testenv:functional] [testenv:functional]
@ -182,8 +136,6 @@ install_command =
{[testenv:func_base]install_command} {[testenv:func_base]install_command}
deps = deps =
{[testenv:ansible]deps} {[testenv:ansible]deps}
setenv =
{[testenv:ansible]setenv}
commands = commands =
{[testenv:ansible]commands} {[testenv:ansible]commands}
ansible-playbook -i {toxinidir}/tests/inventory \ ansible-playbook -i {toxinidir}/tests/inventory \
@ -196,8 +148,6 @@ commands =
[testenv:linters] [testenv:linters]
deps = deps =
{[testenv:ansible]deps} {[testenv:ansible]deps}
setenv =
{[testenv:ansible]setenv}
commands = commands =
{[testenv:pep8]commands} {[testenv:pep8]commands}
{[testenv:bashate]commands} {[testenv:bashate]commands}