Re-structure integration tests
- Split zuul.yaml for readability - Default everything to debug verbosity - Remove ara-tests, replaced by basic.yaml - Move tox -e ansible-integration to use basic.yaml Change-Id: I37209271613b99fc8ad52e9e7286f8979e74c168
This commit is contained in:
parent
99324c552e
commit
6bcb1680ba
@ -12,121 +12,6 @@
|
||||
vars:
|
||||
tox_envlist: linters
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-tests-base
|
||||
parent: base
|
||||
vars:
|
||||
ara_tests_cleanup: false
|
||||
integration_ansible_name: "{{ ansible_user_dir }}/src/github.com/ansible/ansible"
|
||||
integration_ansible_version: null
|
||||
pre-run: tests/role-integration-pre.yaml
|
||||
run: playbooks/ara_tests.yaml
|
||||
post-run: tests/ara_tests_post.yaml
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-tests-fedora-devel
|
||||
parent: ansible-role-ara-tests-base
|
||||
nodeset: fedora-latest
|
||||
required-projects:
|
||||
- name: github.com/ansible/ansible
|
||||
override-checkout: devel
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-tests-fedora-2.7
|
||||
parent: ansible-role-ara-tests-base
|
||||
nodeset: fedora-latest
|
||||
required-projects:
|
||||
- name: github.com/ansible/ansible
|
||||
override-checkout: stable-2.7
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-tests-ubuntu-2.6
|
||||
parent: ansible-role-ara-tests-base
|
||||
nodeset: ubuntu-bionic
|
||||
required-projects:
|
||||
- name: github.com/ansible/ansible
|
||||
override-checkout: stable-2.6
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-base
|
||||
parent: base
|
||||
files:
|
||||
- ara/*
|
||||
- playbooks/*
|
||||
- roles/*
|
||||
- tests/*
|
||||
- .zuul.d/*
|
||||
- setup.py
|
||||
- setup.cfg
|
||||
- requirements.txt
|
||||
- test-requirements.txt
|
||||
pre-run: tests/role-integration-pre.yaml
|
||||
run: playbooks/ara_api.yaml
|
||||
vars:
|
||||
ara_tests_cleanup: false
|
||||
ara_api_source: "{{ ansible_user_dir }}/src/opendev.org/recordsansible/ara"
|
||||
ara_api_version: HEAD
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-ubuntu
|
||||
parent: ansible-role-ara-api-base
|
||||
nodeset: ubuntu-bionic
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-fedora
|
||||
parent: ansible-role-ara-api-base
|
||||
nodeset: fedora-latest
|
||||
|
||||
# TODO: the install-docker role assumes running on Ubuntu
|
||||
- job:
|
||||
name: ansible-role-ara-api-ubuntu-postgresql
|
||||
parent: ansible-role-ara-api-base
|
||||
nodeset: ubuntu-bionic
|
||||
roles:
|
||||
- zuul: zuul/zuul-jobs
|
||||
pre-run: tests/install_docker.yaml
|
||||
run: tests/with_postgresql.yaml
|
||||
post-run: tests/ara_tests_post.yaml
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-web-base
|
||||
parent: base
|
||||
files:
|
||||
# ara
|
||||
- ara/*
|
||||
- playbooks/*
|
||||
- roles/*
|
||||
- tests/*
|
||||
- .zuul.d/*
|
||||
- setup.py
|
||||
- setup.cfg
|
||||
- requirements.txt
|
||||
- test-requirements.txt
|
||||
# ara-web
|
||||
- src/.*
|
||||
- public/.*
|
||||
- package.json
|
||||
- package-lock.json
|
||||
required-projects:
|
||||
- recordsansible/ara-web
|
||||
run: playbooks/ara_web.yaml
|
||||
post-run: tests/role-ara-web-post.yaml
|
||||
vars:
|
||||
ara_web_source: "{{ ansible_user_dir }}/src/opendev.org/recordsansible/ara-web"
|
||||
ara_web_api_server: "https://api.demo.recordsansible.org"
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-web-ubuntu
|
||||
parent: ansible-role-ara-web-base
|
||||
nodeset: ubuntu-bionic
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-web-fedora
|
||||
parent: ansible-role-ara-web-base
|
||||
nodeset: fedora-latest
|
||||
|
||||
- secret:
|
||||
name: ara_git_mirror_credentials
|
||||
data:
|
||||
@ -186,38 +71,3 @@
|
||||
- name: git_mirror_credentials
|
||||
secret: ara_git_mirror_credentials
|
||||
pass-to-parent: true
|
||||
|
||||
- project:
|
||||
vars:
|
||||
rtd_webhook_id: '49230'
|
||||
templates:
|
||||
- docs-on-readthedocs
|
||||
check:
|
||||
jobs:
|
||||
- ansible-role-ara-tests-fedora-2.7
|
||||
- ansible-role-ara-tests-fedora-devel:
|
||||
voting: false
|
||||
- ansible-role-ara-tests-ubuntu-2.6
|
||||
- ansible-role-ara-api-ubuntu
|
||||
- ansible-role-ara-api-fedora
|
||||
- ansible-role-ara-api-ubuntu-postgresql
|
||||
- ansible-role-ara-web-ubuntu
|
||||
- ansible-role-ara-web-fedora
|
||||
- ara-tox-linters
|
||||
- ara-tox-py3
|
||||
gate:
|
||||
jobs:
|
||||
- ansible-role-ara-tests-fedora-2.7
|
||||
- ansible-role-ara-tests-ubuntu-2.6
|
||||
- ansible-role-ara-api-ubuntu
|
||||
- ansible-role-ara-api-fedora
|
||||
- ansible-role-ara-api-ubuntu-postgresql
|
||||
- ansible-role-ara-web-ubuntu
|
||||
- ansible-role-ara-web-fedora
|
||||
- ara-tox-linters
|
||||
- ara-tox-py3
|
||||
post:
|
||||
jobs:
|
||||
- ara-upload-git-mirror
|
||||
|
||||
# This line left intentionally blank for reloading Zuul jobs after branch change
|
30
.zuul.d/project.yaml
Normal file
30
.zuul.d/project.yaml
Normal file
@ -0,0 +1,30 @@
|
||||
- project:
|
||||
vars:
|
||||
rtd_webhook_id: '49230'
|
||||
templates:
|
||||
- docs-on-readthedocs
|
||||
check:
|
||||
jobs:
|
||||
- ansible-role-ara-api-fedora-devel
|
||||
- ansible-role-ara-api-fedora-2.8
|
||||
- ansible-role-ara-api-ubuntu-2.7
|
||||
- ansible-role-ara-api-ubuntu-2.6
|
||||
- ansible-role-ara-api-ubuntu-postgresql
|
||||
- ansible-role-ara-web-ubuntu
|
||||
- ansible-role-ara-web-fedora
|
||||
- ara-tox-linters
|
||||
- ara-tox-py3
|
||||
gate:
|
||||
jobs:
|
||||
- ansible-role-ara-api-fedora-devel
|
||||
- ansible-role-ara-api-fedora-2.8
|
||||
- ansible-role-ara-api-ubuntu-2.7
|
||||
- ansible-role-ara-api-ubuntu-2.6
|
||||
- ansible-role-ara-api-ubuntu-postgresql
|
||||
- ansible-role-ara-web-ubuntu
|
||||
- ansible-role-ara-web-fedora
|
||||
- ara-tox-linters
|
||||
- ara-tox-py3
|
||||
post:
|
||||
jobs:
|
||||
- ara-upload-git-mirror
|
113
.zuul.d/role-jobs.yaml
Normal file
113
.zuul.d/role-jobs.yaml
Normal file
@ -0,0 +1,113 @@
|
||||
- job:
|
||||
name: ansible-role-ara-api-base
|
||||
parent: base
|
||||
files:
|
||||
- ara/*
|
||||
- playbooks/*
|
||||
- roles/*
|
||||
- tests/*
|
||||
- .zuul.d/*
|
||||
- setup.py
|
||||
- setup.cfg
|
||||
- requirements.txt
|
||||
- test-requirements.txt
|
||||
pre-run: tests/role-integration-pre.yaml
|
||||
run: playbooks/ara_api.yaml
|
||||
post-run: tests/role-integration-post.yaml
|
||||
vars:
|
||||
ara_tests_cleanup: false
|
||||
ara_api_source: "{{ ansible_user_dir }}/src/opendev.org/recordsansible/ara"
|
||||
ara_api_version: HEAD
|
||||
ara_api_log_level: DEBUG
|
||||
ara_api_debug: true
|
||||
ara_api_root_dir: /tmp/ara-integration-tests/.ara
|
||||
ara_tests_ansible_name: "{{ ansible_user_dir }}/src/github.com/ansible/ansible"
|
||||
ara_tests_ansible_version: null
|
||||
required-projects:
|
||||
- name: github.com/ansible/ansible
|
||||
override-checkout: stable-2.8
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-ubuntu
|
||||
parent: ansible-role-ara-api-base
|
||||
nodeset: ubuntu-bionic
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-fedora
|
||||
parent: ansible-role-ara-api-base
|
||||
nodeset: fedora-latest
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-fedora-devel
|
||||
parent: ansible-role-ara-api-fedora
|
||||
required-projects:
|
||||
- name: github.com/ansible/ansible
|
||||
override-checkout: devel
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-fedora-2.8
|
||||
parent: ansible-role-ara-api-fedora
|
||||
required-projects:
|
||||
- name: github.com/ansible/ansible
|
||||
override-checkout: stable-2.8
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-ubuntu-2.7
|
||||
parent: ansible-role-ara-api-ubuntu
|
||||
required-projects:
|
||||
- name: github.com/ansible/ansible
|
||||
override-checkout: stable-2.7
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-api-ubuntu-2.6
|
||||
parent: ansible-role-ara-api-ubuntu
|
||||
required-projects:
|
||||
- name: github.com/ansible/ansible
|
||||
override-checkout: stable-2.6
|
||||
|
||||
# Database server jobs
|
||||
- job:
|
||||
name: ansible-role-ara-api-ubuntu-postgresql
|
||||
parent: ansible-role-ara-api-ubuntu
|
||||
roles:
|
||||
- zuul: zuul/zuul-jobs
|
||||
pre-run: tests/install_docker.yaml
|
||||
run: tests/with_postgresql.yaml
|
||||
|
||||
# ara-web jobs
|
||||
- job:
|
||||
name: ansible-role-ara-web-base
|
||||
parent: base
|
||||
files:
|
||||
# ara
|
||||
- ara/*
|
||||
- playbooks/*
|
||||
- roles/*
|
||||
- tests/*
|
||||
- .zuul.d/*
|
||||
- setup.py
|
||||
- setup.cfg
|
||||
- requirements.txt
|
||||
- test-requirements.txt
|
||||
# ara-web
|
||||
- src/.*
|
||||
- public/.*
|
||||
- package.json
|
||||
- package-lock.json
|
||||
required-projects:
|
||||
- recordsansible/ara-web
|
||||
run: playbooks/ara_web.yaml
|
||||
post-run: tests/role-ara-web-post.yaml
|
||||
vars:
|
||||
ara_web_source: "{{ ansible_user_dir }}/src/opendev.org/recordsansible/ara-web"
|
||||
ara_web_api_server: "https://api.demo.recordsansible.org"
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-web-ubuntu
|
||||
parent: ansible-role-ara-web-base
|
||||
nodeset: ubuntu-bionic
|
||||
|
||||
- job:
|
||||
name: ansible-role-ara-web-fedora
|
||||
parent: ansible-role-ara-web-base
|
||||
nodeset: fedora-latest
|
@ -1,4 +0,0 @@
|
||||
.. _ansible-role-ara-tests:
|
||||
|
||||
.. include:: ../../roles/ara_tests/README.rst
|
||||
:end-before: include_delimiter_end
|
@ -25,4 +25,3 @@ Table of Contents
|
||||
|
||||
ansible-role-ara-api <ansible-role-ara-api>
|
||||
ansible-role-ara-web <ansible-role-ara-web>
|
||||
ansible-role-ara-tests <ansible-role-ara-tests>
|
||||
|
@ -1,5 +0,0 @@
|
||||
- name: Run ARA smoke tests
|
||||
hosts: all
|
||||
gather_facts: yes
|
||||
roles:
|
||||
- ara_tests
|
@ -1,53 +0,0 @@
|
||||
ansible-role-ara-tests
|
||||
======================
|
||||
|
||||
An Ansible role that installs ARA and Ansible to run quick and inexpensive
|
||||
tests that do not require superuser privileges.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
See `defaults/main.yaml <https://github.com/ansible-community/ara/blob/master/roles/ara_tests/defaults/main.yaml>`_.
|
||||
|
||||
.. literalinclude:: ../../roles/ara_tests/defaults/main.yaml
|
||||
:language: yaml+jinja
|
||||
:start-after: www.gnu.org
|
||||
|
||||
TL;DR
|
||||
-----
|
||||
|
||||
.. code-block:: yaml+jinja
|
||||
|
||||
- name: Test ARA with the latest version of Ansible
|
||||
hosts: all
|
||||
gather_facts: yes
|
||||
roles:
|
||||
- ara_tests
|
||||
|
||||
What the role ends up doing by default:
|
||||
|
||||
- Creates a directory to contain the files for the duration of the tests
|
||||
- Installs ARA from source and the latest version of Ansible in a virtualenv
|
||||
- Runs test playbooks designed to exercise different features of ARA
|
||||
|
||||
.. _include_delimiter_end:
|
||||
|
||||
Copyright
|
||||
---------
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Copyright (c) 2019 Red Hat, Inc.
|
||||
|
||||
ARA Records Ansible 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 Records Ansible 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 Records Ansible. If not, see <http://www.gnu.org/licenses/>.
|
@ -1,34 +0,0 @@
|
||||
---
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of ARA Records Ansible.
|
||||
#
|
||||
# ARA Records Ansible 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 Records Ansible 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 Records Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Root directory where integration tests will prepare and store data
|
||||
ara_tests_root: "/tmp/ara-integration-tests"
|
||||
|
||||
# Directory where the virtualenv will be created
|
||||
ara_tests_virtualenv: "{{ ara_tests_root }}/ara-tests-virtualenv"
|
||||
|
||||
# Directory where ARA_BASE_DIR will be set
|
||||
ara_tests_data: "{{ ara_tests_root }}/.ara/server"
|
||||
|
||||
# Name of the Ansible package
|
||||
# This can be "ansible" which will use pip or it could be something like
|
||||
# /home/user/git/ansible as well as git+https://github.com/ansible/ansible
|
||||
ara_tests_ansible_name: ansible
|
||||
|
||||
# Version of Ansible from pypi to install
|
||||
ara_tests_ansible_version: latest
|
@ -1,35 +0,0 @@
|
||||
---
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of ARA Records Ansible.
|
||||
#
|
||||
# ARA Records Ansible 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 Records Ansible 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 Records Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
galaxy_info:
|
||||
author: David Moreau-Simard
|
||||
description: Self-contained role to test ARA with Ansible
|
||||
license: GPLv3
|
||||
min_ansible_version: 2.7
|
||||
platforms:
|
||||
- name: Fedora
|
||||
versions:
|
||||
- 29
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- bionic
|
||||
galaxy_tags:
|
||||
- ansible
|
||||
- ara
|
||||
|
||||
dependencies: []
|
@ -1,112 +0,0 @@
|
||||
---
|
||||
# Copyright (c) 2018 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of ARA Records Ansible.
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
- name: Ensure integration test root exists
|
||||
file:
|
||||
path: "{{ ara_tests_root }}"
|
||||
state: directory
|
||||
|
||||
- name: Set location of the git repository with Zuul
|
||||
set_fact:
|
||||
_ara_tests_repository: "{{ ansible_user_dir }}/src/opendev.org/recordsansible/ara"
|
||||
when: zuul is defined
|
||||
|
||||
- name: Set location of the git repository without Zuul
|
||||
set_fact:
|
||||
_ara_tests_repository: "{{ lookup('pipe', 'git rev-parse --show-toplevel') }}"
|
||||
when: zuul is not defined
|
||||
|
||||
- name: Ensure python3-venv is installed for Ubuntu
|
||||
become: yes
|
||||
package:
|
||||
name: python3-venv
|
||||
state: present
|
||||
when: ansible_distribution == "Ubuntu"
|
||||
|
||||
# If a version is not explicitly set we want to make sure to
|
||||
# completely omit the version argument to pip, as it will be coming
|
||||
# from the long-form integration_ansible_name variable. Additionally, if
|
||||
# the version is the special value "latest", then we also want to omit
|
||||
# any version number, but also set the package state to "latest".
|
||||
- name: Set Ansible version for installation
|
||||
set_fact:
|
||||
_install_ansible_version: "{{ ara_tests_ansible_version }}"
|
||||
when: ara_tests_ansible_version not in ("", "latest")
|
||||
|
||||
- name: Set Ansible package state for installation
|
||||
set_fact:
|
||||
_install_ansible_state: latest
|
||||
when: ara_tests_ansible_version == "latest"
|
||||
|
||||
- name: Initialize virtual environment with Ansible
|
||||
pip:
|
||||
name: "{{ ara_tests_ansible_name }}"
|
||||
version: "{{ _install_ansible_version | default(omit, True) }}"
|
||||
state: "{{ _install_ansible_state | default(omit, True) }}"
|
||||
virtualenv: "{{ ara_tests_virtualenv }}"
|
||||
virtualenv_command: /usr/bin/python3 -m venv
|
||||
|
||||
- name: Install ARA from source in virtual environment
|
||||
pip:
|
||||
name: "{{ _ara_tests_repository }}[server]"
|
||||
state: present
|
||||
virtualenv: "{{ ara_tests_virtualenv }}"
|
||||
virtualenv_command: /usr/bin/python3 -m venv
|
||||
|
||||
- name: Get ARA plugins directory
|
||||
command: "{{ ara_tests_virtualenv }}/bin/python -m ara.setup.plugins"
|
||||
register: ara_setup_plugins
|
||||
|
||||
# These aren't in the same task (i.e, with loop) so we can tell individual test
|
||||
# runs apart easily rather than keeping all the output bundled in a single task.
|
||||
# TODO: Add validation for the tests
|
||||
- environment:
|
||||
ANSIBLE_CALLBACK_PLUGINS: "{{ ara_setup_plugins.stdout }}/callback"
|
||||
ANSIBLE_ACTION_PLUGINS: "{{ ara_setup_plugins.stdout }}/action"
|
||||
ARA_DEBUG: true
|
||||
ARA_LOG_LEVEL: DEBUG
|
||||
ARA_BASE_DIR: "{{ ara_tests_data }}"
|
||||
ARA_SECRET_KEY: testing
|
||||
vars:
|
||||
_ansible_playbook: "{{ ara_tests_virtualenv }}/bin/ansible-playbook -vvv"
|
||||
_test_root: "{{ _ara_tests_repository }}/tests/integration"
|
||||
block:
|
||||
# smoke.yaml tests setting ara_playbook_name in one of three plays
|
||||
- name: Run smoke.yaml integration test
|
||||
command: "{{ _ansible_playbook }} {{ _test_root }}/smoke.yaml"
|
||||
|
||||
- name: Run hosts.yaml integration test
|
||||
command: "{{ _ansible_playbook }} {{ _test_root }}/hosts.yaml"
|
||||
|
||||
- name: Run import.yaml integration test
|
||||
command: "{{ _ansible_playbook }} {{ _test_root }}/import.yaml"
|
||||
|
||||
# Tests setting ara_playbook_name as an extra var
|
||||
- name: Run failed.yaml integration test
|
||||
command: >
|
||||
{{ _ansible_playbook }} {{ _test_root }}/failed.yaml -e ara_playbook_name="Failed playbook"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Run incomplete.yaml integration test
|
||||
shell: |
|
||||
{{ _ansible_playbook }} {{ _test_root }}/incomplete.yaml &
|
||||
sleep 5
|
||||
kill $!
|
||||
args:
|
||||
executable: /bin/bash
|
||||
ignore_errors: yes
|
118
tests/basic.yaml
Normal file
118
tests/basic.yaml
Normal file
@ -0,0 +1,118 @@
|
||||
---
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of ARA Records Ansible.
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
- name: Basic ARA tests without Ansible roles
|
||||
hosts: all
|
||||
vars:
|
||||
_ansible_name: ansible
|
||||
_ansible_version: latest
|
||||
ara_api_root_dir: /tmp/ara-integration-tests/.ara
|
||||
ara_api_venv_path: /tmp/ara-integration-tests/venv
|
||||
ara_api_secret_key: testing
|
||||
ara_api_debug: true
|
||||
ara_api_log_level: DEBUG
|
||||
tasks:
|
||||
- name: Ensure root directory exists
|
||||
file:
|
||||
path: "{{ ara_api_root_dir }}"
|
||||
state: directory
|
||||
|
||||
- name: Set location of the git repository without Zuul
|
||||
set_fact:
|
||||
_ara_tests_repository: "{{ lookup('pipe', 'git rev-parse --show-toplevel') }}"
|
||||
when: zuul is not defined
|
||||
|
||||
- name: Ensure python3-venv is installed for Ubuntu
|
||||
become: yes
|
||||
package:
|
||||
name: python3-venv
|
||||
state: present
|
||||
when: ansible_distribution == "Ubuntu"
|
||||
|
||||
# If a version is not explicitly set we want to make sure to
|
||||
# completely omit the version argument to pip, as it will be coming
|
||||
# from the long-form integration_ansible_name variable. Additionally, if
|
||||
# the version is the special value "latest", then we also want to omit
|
||||
# any version number, but also set the package state to "latest".
|
||||
- name: Set Ansible version for installation
|
||||
set_fact:
|
||||
_install_ansible_version: "{{ _ansible_version }}"
|
||||
when: _ansible_version not in ("", "latest")
|
||||
|
||||
- name: Set Ansible package state for installation
|
||||
set_fact:
|
||||
_install_ansible_state: latest
|
||||
when: _ansible_version == "latest"
|
||||
|
||||
- name: Initialize virtual environment with Ansible
|
||||
pip:
|
||||
name: "{{ _ansible_name }}"
|
||||
version: "{{ _install_ansible_version | default(omit, True) }}"
|
||||
state: "{{ _install_ansible_state | default(omit, True) }}"
|
||||
virtualenv: "{{ ara_api_venv_path }}"
|
||||
virtualenv_command: /usr/bin/python3 -m venv
|
||||
|
||||
- name: Install ARA from source in virtual environment
|
||||
pip:
|
||||
name: "{{ _ara_tests_repository }}[server]"
|
||||
state: present
|
||||
virtualenv: "{{ ara_api_venv_path }}"
|
||||
virtualenv_command: /usr/bin/python3 -m venv
|
||||
|
||||
- name: Get ARA plugins directory
|
||||
command: "{{ ara_api_venv_path }}/bin/python -m ara.setup.plugins"
|
||||
register: ara_setup_plugins
|
||||
|
||||
# These aren't in the same task (i.e, with loop) so we can tell individual test
|
||||
# runs apart easily rather than keeping all the output bundled in a single task.
|
||||
# TODO: Add validation for the tests
|
||||
- environment:
|
||||
ANSIBLE_CALLBACK_PLUGINS: "{{ ara_setup_plugins.stdout }}/callback"
|
||||
ANSIBLE_ACTION_PLUGINS: "{{ ara_setup_plugins.stdout }}/action"
|
||||
ARA_DEBUG: "{{ ara_api_debug }}"
|
||||
ARA_LOG_LEVEL: "{{ ara_api_log_level }}"
|
||||
ARA_BASE_DIR: "{{ ara_api_root_dir }}"
|
||||
ARA_SECRET_KEY: "{{ ara_api_secret_key }}"
|
||||
vars:
|
||||
_ansible_playbook: "{{ ara_api_venv_path }}/bin/ansible-playbook -vvv"
|
||||
_test_root: "{{ _ara_tests_repository }}/tests/integration"
|
||||
block:
|
||||
# smoke.yaml tests setting ara_playbook_name in one of three plays
|
||||
- name: Run smoke.yaml integration test
|
||||
command: "{{ _ansible_playbook }} {{ _test_root }}/smoke.yaml"
|
||||
|
||||
- name: Run hosts.yaml integration test
|
||||
command: "{{ _ansible_playbook }} {{ _test_root }}/hosts.yaml"
|
||||
|
||||
- name: Run import.yaml integration test
|
||||
command: "{{ _ansible_playbook }} {{ _test_root }}/import.yaml"
|
||||
|
||||
# Tests setting ara_playbook_name as an extra var
|
||||
- name: Run failed.yaml integration test
|
||||
command: >
|
||||
{{ _ansible_playbook }} {{ _test_root }}/failed.yaml -e ara_playbook_name="Failed playbook"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Run incomplete.yaml integration test
|
||||
shell: |
|
||||
{{ _ansible_playbook }} {{ _test_root }}/incomplete.yaml &
|
||||
sleep 5
|
||||
kill $!
|
||||
args:
|
||||
executable: /bin/bash
|
||||
ignore_errors: yes
|
@ -27,7 +27,7 @@
|
||||
recurse: yes
|
||||
|
||||
- name: Recover integration test data
|
||||
command: cp -rp /tmp/ara-integration-tests/.ara/server {{ ansible_user_dir }}/workspace/logs/server
|
||||
command: cp -rp {{ ara_api_root_dir }}/server {{ ansible_user_dir }}/workspace/logs/server
|
||||
|
||||
- name: Upload log artifacts
|
||||
synchronize:
|
3
tox.ini
3
tox.ini
@ -41,7 +41,8 @@ setenv =
|
||||
deps = ansible
|
||||
commands =
|
||||
ansible-playbook -i localhost, --connection=local \
|
||||
{toxinidir}/playbooks/ara_tests.yaml -e ara_tests_root={envtmpdir} {posargs}
|
||||
{toxinidir}/tests/basic.yaml \
|
||||
-e ara_api_root_dir={envtmpdir}/.ara {posargs}
|
||||
|
||||
[testenv:cover]
|
||||
commands =
|
||||
|
Loading…
x
Reference in New Issue
Block a user