1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
# 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: Test the ARA API with the distributed sqlite backend
hosts: all
gather_facts: yes
vars_files:
- vars/distributed_sqlite_tests.yaml
tasks:
# Generate ourselves a fresh database to run tests with
- name: Set up the API with the default sqlite backend
include_role:
name: ara_api
public: yes
# These are tasks rather than a standalone playbook to give us an easy
# access to all the variables within the same play.
- include_tasks: test_tasks.yaml
- name: Enable the distributed sqlite backend
vars:
ara_api_distributed_sqlite: true
include_role:
name: ara_api
public: yes
- name: Ensure there are no pending handlers
meta: flush_handlers
- name: Create test directories
file:
path: "{{ ara_api_distributed_sqlite_root }}/{{ item }}"
state: directory
recurse: yes
loop: "{{ _test_directories }}"
- name: Copy the database to the test directories
copy:
src: "{{ ara_api_database_name }}"
dest: "{{ ara_api_distributed_sqlite_root }}/{{ item }}/ansible.sqlite"
remote_src: true
loop: "{{ _test_directories }}"
- name: Test that the API works
uri:
url: "http://127.0.0.1:8000/{{ item }}/api/v1/"
return_content: yes
register: api_test
loop: "{{ _test_directories }}"
- name: Print API responses for debug purposes
debug:
msg: "{{ item['json'] | to_nice_json }}"
loop: "{{ api_test.results }}"
|