Import integration tests and jobs from ara-infra

Now that ara-{client,server,plugins} are no longer separate projects,
we can bring back the tests and jobs to ara so they are easier to
manage and maintain in-tree.

Jobs are renamed in the process to avoid a chicken-and-egg issue
from the jobs existing in the ara-infra repository while they are
in use and moved here.

It was necessary to squash a brief fix to get pbr to look at the
version of "ara" instead of "ara-clients".

Change-Id: I9d79e6bd4c714842420df30b183ce1d016692885
This commit is contained in:
David Moreau Simard 2019-03-04 11:38:50 -05:00
parent b0d62ba7c4
commit c1218db1ef
No known key found for this signature in database
GPG Key ID: CBEB466764A9E621
27 changed files with 991 additions and 41 deletions

View File

@ -1,21 +0,0 @@
- job:
name: ara-tox-py3
parent: tox
nodeset: ubuntu-bionic
vars:
tox_envlist: py3
- job:
name: ara-tox-linters
parent: tox
nodeset: ubuntu-bionic
vars:
tox_envlist: linters
# TODO: Delete this, all linters have been merged into tox-linters
- job:
name: tox-format
parent: tox
nodeset: ubuntu-bionic
vars:
tox_envlist: format

View File

@ -1,19 +0,0 @@
- project:
vars:
rtd_webhook_id: '49230'
templates:
- docs-on-readthedocs
check:
jobs:
- ara-integration-fedora-2.7
- ara-integration-fedora-devel:
voting: false
- ara-integration-ubuntu-2.6
- ara-tox-linters
- ara-tox-py3
gate:
jobs:
- ara-integration-fedora-2.7
- ara-integration-ubuntu-2.6
- ara-tox-linters
- ara-tox-py3

66
.zuul.yaml Normal file
View File

@ -0,0 +1,66 @@
- job:
name: ara-tox-py3
parent: tox
nodeset: ubuntu-bionic
vars:
tox_envlist: py3
- job:
name: ara-tox-linters
parent: tox
nodeset: ubuntu-bionic
vars:
tox_envlist: linters
- job:
name: ara-1.0-integration-base
parent: base
vars:
integration_ansible_name: "{{ ansible_user_dir }}/src/github.com/ansible/ansible"
integration_ansible_version: null
run: playbooks/integration-tests.yaml
post-run: tests/integration-post.yaml
- job:
name: ara-1.0-integration-fedora-devel
parent: ara-integration-base
nodeset: fedora-latest
required-projects:
- name: github.com/ansible/ansible
override-checkout: devel
- job:
name: ara-1.0-integration-fedora-2.7
parent: ara-1.0-integration-base
nodeset: fedora-latest
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.7
- job:
name: ara-1.0-integration-ubuntu-2.6
parent: ara-1.0-integration-base
nodeset: ubuntu-bionic
required-projects:
- name: github.com/ansible/ansible
override-checkout: stable-2.6
- project:
vars:
rtd_webhook_id: '49230'
templates:
- docs-on-readthedocs
check:
jobs:
- ara-1.0-integration-fedora-2.7
- ara-1.0-integration-fedora-devel:
voting: false
- ara-1.0-integration-ubuntu-2.6
- ara-tox-linters
- ara-tox-py3
gate:
jobs:
- ara-1.0-integration-fedora-2.7
- ara-1.0-integration-ubuntu-2.6
- ara-tox-linters
- ara-tox-py3

View File

@ -24,7 +24,7 @@ import logging
import pbr.version
import requests
CLIENT_VERSION = pbr.version.VersionInfo("ara-clients").release_string()
CLIENT_VERSION = pbr.version.VersionInfo("ara").release_string()
class HttpClient(object):

View File

@ -0,0 +1,7 @@
- name: Run ARA integration tests
hosts: all
gather_facts: yes
tasks:
- name: Include the integration-tests role
include_role:
name: integration-tests

1
playbooks/roles Symbolic link
View File

@ -0,0 +1 @@
../roles

View File

@ -0,0 +1,47 @@
integration-tests
=================
Installs a specified version of ARA and Ansible into a virtual environment
and runs integration tests that do not require superuser privileges.
Requirements
============
Since the role is designed to run without superuser privileges, the following
things should be installed in order to let the role use them:
- git
- python3
- pip
- virtualenv
Variables
=========
From ``defaults/main.yaml``:
Root directory where integration tests will prepare and store data::
integration_root: "/tmp/ara-integration-tests"
Directory where the virtualenv will be created::
integration_virtualenv: "{{ integration_root }}/venv"
Directory where ARA_BASE_DIR will be set::
integration_data: "{{ integration_root }}/data"
Whether the root directory should be cleaned up between runs::
integration_cleanup: true
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``::
integration_ansible_name: ansible
Version of Ansible from pypi to install::
integration_ansible_version: latest

View File

@ -0,0 +1,37 @@
---
# 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/>.
# Root directory where integration tests will prepare and store data
integration_root: "/tmp/ara-integration-tests"
# Directory where the virtualenv will be created
integration_virtualenv: "{{ integration_root }}/venv"
# Directory where ARA_BASE_DIR will be set
integration_data: "{{ integration_root }}/data"
# Whether the root directory should be cleaned up between runs
integration_cleanup: true
# 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
integration_ansible_name: ansible
# Version of Ansible from pypi to install
integration_ansible_version: latest

View File

@ -0,0 +1,122 @@
---
# 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: Clean up integration test root
file:
path: "{{ integration_root }}"
state: absent
when: integration_cleanup | bool
- name: Create integration test root
file:
path: "{{ integration_root }}"
state: directory
# Zuul already prepares the src repository on the remote node
- name: Symlink Zuul repositories to integration test root
file:
src: "{{ ansible_user_dir }}/src/git.openstack.org/openstack/ara"
dest: "{{ integration_root }}/ara"
state: link
when: zuul is defined
- when: zuul is not defined
block:
# The expectation is that the integration tests are run from a checked out
# git repository. Use this repository for the tests so we are able to test
# local modifications. Synchronize is used in place of symlink so we are
# able to run integration tests on a remote machine if necessary.
# git rev-parse --show-toplevel returns the root git directory
- name: Synchronize ara-infra to integration root
synchronize:
src: "{{ lookup('pipe', 'git rev-parse --show-toplevel') }}"
dest: "{{ integration_root }}/"
delete: yes
# 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: "{{ integration_ansible_version }}"
when: integration_ansible_version not in ("", "latest")
- name: Set Ansible package state for installation
set_fact:
_install_ansible_state: latest
when: integration_ansible_version == "latest"
- name: Initialize virtual environment with Ansible
pip:
name: "{{ integration_ansible_name }}"
version: "{{ _install_ansible_version | default(omit, True) }}"
state: "{{ _install_ansible_state | default(omit, True) }}"
virtualenv: "{{ integration_virtualenv }}"
virtualenv_python: python3
- name: Install ARA from source in virtual environment
pip:
name: "{{ integration_root }}/ara"
state: present
virtualenv: "{{ integration_virtualenv }}"
virtualenv_python: python3
- name: Get ARA plugins directory
command: "{{ integration_root }}/venv/bin/python -m ara.plugins"
register: ara_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_plugins.stdout }}/callback"
ANSIBLE_ACTION_PLUGINS: "{{ ara_plugins.stdout }}/action"
ARA_DEBUG: true
ARA_LOG_LEVEL: DEBUG
ARA_BASE_DIR: "{{ integration_data }}"
ARA_SECRET_KEY: testing
vars:
ansible_playbook: "{{ integration_virtualenv }}/bin/ansible-playbook -vvv"
test_root: "{{ integration_root }}/ara/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

View File

@ -0,0 +1,37 @@
---
# 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: Integration tests post-run
hosts: all
gather_facts: yes
tasks:
- name: Create server log directory
file:
path: "{{ ansible_user_dir }}/workspace/logs"
state: directory
recurse: yes
- name: Recover integration test data
command: cp -rp /tmp/ara-integration-tests/data {{ ansible_user_dir }}/workspace/logs/data
- name: Upload log artifacts
synchronize:
src: "{{ ansible_user_dir }}/workspace/logs"
dest: "{{ zuul.executor.log_root }}"
mode: pull
verify_host: true

View File

@ -0,0 +1,25 @@
---
# 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: Failed playbook
hosts: localhost
tasks:
- fail:
msg: "This is a failed playbook"
tags:
- skip_ansible_lint

View File

@ -0,0 +1,48 @@
---
# 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: Create fake hosts for host tests
hosts: localhost
gather_facts: yes
tasks:
- name: Add fake hosts in inventory
add_host:
name: "{{ item }}"
ansible_host: "127.0.0.1"
ansible_connection: "local"
with_items:
- host1
- host2
- host3
- name: ARA Hosts test play
hosts: all
gather_facts: yes
tasks:
- name: Ping
ping:
- name: Do something only on host1
set_fact:
something: 'done'
when: inventory_hostname == 'host1'
- name: Fail something only on host2
command: /bin/false
when: inventory_hostname == 'host2'
ignore_errors: true

View File

@ -0,0 +1,20 @@
---
# 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/>.
- import_playbook: imported.yaml

View File

@ -0,0 +1,34 @@
---
# 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/>.
# Tests for the new import tasks from Ansible 2.4
- name: Import a role
hosts: localhost
gather_facts: no
tasks:
- name: Import role
import_role:
name: imported-role
- name: Include a role
hosts: localhost
gather_facts: no
tasks:
- name: Include role
include_role:
name: imported-role

View File

@ -0,0 +1,34 @@
---
# 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/>.
# Tests for https://github.com/ansible/ansible/issues/30385
- name: Test include role without static
hosts: localhost
gather_facts: no
tasks:
- name: Include role without static
include_role:
name: included-role
- name: Test include role with static
hosts: localhost
gather_facts: no
tasks:
- name: Include role with static
include_role:
name: included-role

View File

@ -0,0 +1,27 @@
---
# 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: Incomplete playbook
hosts: localhost
gather_facts: no
tasks:
- debug:
msg: "This playbook is meant to be interrupted"
- name: Sleep for thirty seconds
command: sleep 30
changed_when: false

View File

@ -0,0 +1,20 @@
---
# 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/>.
role_message: "This message is from an imported role"
task_message: "This message is from an imported task in an imported role"

View File

@ -0,0 +1,20 @@
---
# 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/>.
- debug:
msg: "{{ task_message }}"

View File

@ -0,0 +1,23 @@
---
# 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: Import task
import_tasks: imported-task.yaml
- name: Include task
include_tasks: imported-task.yaml

View File

@ -0,0 +1,20 @@
---
# 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/>.
role_message: "This message is from an included role"
task_message: "This message is from an included task in an included role"

View File

@ -0,0 +1,20 @@
---
# 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/>.
- debug:
msg: "{{ task_message }}"

View File

@ -0,0 +1,20 @@
---
# 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/>.
- debug:
msg: "{{ role_message }}"

View File

@ -0,0 +1,29 @@
---
# 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/>.
list_items:
- one
- two
dict_items:
one:
name: "key-one"
value: "value-one"
two:
name: "key-two"
value: "value-two"

View File

@ -0,0 +1,199 @@
---
# 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/>.
# Ensure no_log is respected
- name: Print normal data
debug:
msg: "normal data"
- name: Print confidential data
debug:
msg: "confidential data"
no_log: "yes"
# ARA record and read modules specific tests
- name: Record data with no type
ara_record:
key: "notype"
value: "text"
register: notype
- name: Validate notype key
assert:
that:
- notype.key == "notype"
- notype.value == "text"
- notype.type == "text"
- name: Update notype key with specified playbook
ara_record:
playbook_id: "{{ notype.playbook_id }}"
key: "notype"
value: "updated text"
type: "text"
register: notype_update
- name: Validate notype key
assert:
that:
- notype_update.key == "notype"
- notype_update.value == "updated text"
- notype_update.type == "text"
- name: Record data with text type
ara_record:
key: "foo"
value: "bar"
type: "text"
- name: Update existing key's value and type
ara_record:
key: "foo"
value: "http://barfoo"
type: "url"
register: foo
- name: Validate foo key
assert:
that:
- foo.key == "foo"
- foo.value == "http://barfoo"
- foo.type == "url"
- name: Add another k/v pair with ara_record
ara_record:
key: "bar"
value: '{ "foo": "bar" }'
type: "json"
register: bar
- name: Validate bar key
assert:
that:
- bar.key == "bar"
- "bar.value == '{ \"foo\": \"bar\" }'"
- bar.type == "json"
- name: Record a list value
vars:
someitems:
- one
- two
- three
- go
ara_record:
key: "somelist"
value: "{{ someitems }}"
type: "list"
register: somelist
- name: Validate somelist key
vars:
someitems:
- one
- two
- three
- go
assert:
that:
- somelist.key == "somelist"
- somelist.value == someitems
- somelist.type == "list"
- name: Record a dict value
vars:
dictdata:
foo: "bar"
bar: "foo"
ara_record:
key: "somedict"
value: "{{ dictdata }}"
type: "dict"
register: somedict
- name: Validate somedict key
vars:
dictdata:
foo: "bar"
bar: "foo"
assert:
that:
- somedict.key == "somedict"
- somedict.value == dictdata
- somedict.type == "dict"
- name: Record a list as a text type
vars:
list:
- foo
- bar
ara_record:
key: "list_as_text"
value: "{{ list }}"
type: "text"
register: list_as_text
# The key is still recorded as an actual list, however, it will be rendered
# as text in the UI.
- name: Validate list_as_text key
vars:
list:
- foo
- bar
assert:
that:
- list_as_text.key == "list_as_text"
- list_as_text.value == list
- list_as_text.value != "[u'foo', u'bar']"
- list_as_text.type == "text"
# Things that should fail
- name: Record with no key
ara_record:
value: "value"
ignore_errors: "yes"
register: nokey
- name: Validate nokey failure
assert:
that:
- nokey.failed
- name: Record with no value
ara_record:
key: "key"
ignore_errors: "yes"
register: novalue
- name: Validate novalue failure
assert:
that:
- novalue.failed
- name: Record with invalid type
ara_record:
key: "key"
value: "value"
type: "hadoop"
ignore_errors: "yes"
register: invalid
- name: Validate invalid failure
assert:
that:
- invalid.failed

View File

@ -0,0 +1,23 @@
---
# 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: Deferred setup
setup:
- include_tasks: ara-ops.yaml
- include_tasks: test-ops.yaml

View File

@ -0,0 +1,56 @@
---
# 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/>.
# Tests some things around blocks, failures and rescues
- block:
- name: Debug message
debug:
msg: "Successful debug task"
- name: Return false
command: /bin/false
- name: Command that should not run
debug:
msg: "This should never run"
rescue:
- name: Rescue task
debug:
msg: "Rescue was called successfully"
always:
- name: Task that should always run
debug:
msg: "This should always be printed"
- name: Test a skipped task
debug:
msg: "This is skipped"
when: false
- name: Test with_items
debug:
msg: "{{ item }}"
with_items: "{{ list_items }}"
- name: Test with_dict
debug:
msg: "{{ item.value.name }}: {{ item.value.value }}"
with_dict: "{{ dict_items }}"
- name: Test for XSS
command: echo "<script>alert(document.cookie)</script>"
changed_when: False

View File

@ -0,0 +1,55 @@
---
# 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: ARA Tasks test play
hosts: localhost
gather_facts: no
vars:
ara_playbook_name: Smoke tests
tasks:
- name: ARA Integration test
debug:
msg: "ARA Integration test"
tags:
- tagged
roles:
- { role: "smoke-tests" }
- name: Add a host with non-ascii characters
hosts: localhost
gather_facts: no
tasks:
- name: Add a host with non-ascii character
add_host:
name: "höstñämë"
ansible_host: "127.0.0.1"
ansible_connection: "local"
tags:
- untag
- verytag
- name: Play with non-ascii characters - ä, ö, ü
hosts: höstñämë
gather_facts: yes
tasks:
- name: Task with non-ascii characters - ä, ö, ü
debug:
msg: "This is a task result with non-ascii characters: ä, ö, ü"
tags:
- untag
- verytag