mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Split integration tests out from Makefile. (#17976)
This commit is contained in:
64
test/integration/targets/lookup_paths/play.yml
Normal file
64
test/integration/targets/lookup_paths/play.yml
Normal file
@@ -0,0 +1,64 @@
|
||||
- name: setup state
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/files state=directory
|
||||
- file: path={{playbook_dir}}/roles/showfile/files state=directory
|
||||
- copy: dest={{playbook_dir}}/roles/showfile/files/testfile content='in role files'
|
||||
- copy: dest={{playbook_dir}}/roles/showfile/tasks/testfile content='in role tasks'
|
||||
- copy: dest={{playbook_dir}}/roles/showfile/testfile content='in role'
|
||||
- copy: dest={{playbook_dir}}/files/testfile content='in files'
|
||||
- copy: dest={{playbook_dir}}/testfile content='in local'
|
||||
- set_fact: role_out="in role files" play_out="in files" stage='setup'
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: remove from role/files
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/roles/showfile/files/testfile state=absent
|
||||
- set_fact: role_out="in role tasks" play_out="in files" stage='remove 1'
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: remove from role/tasks
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/roles/showfile/tasks/testfile state=absent
|
||||
- set_fact: role_out="in files" play_out="in files" stage='remote 2'
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: remove from role dir
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/roles/showfile/testfile state=absent
|
||||
- set_fact: role_out="in files" play_out="in files" stage='remove 3'
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: remove from play/files
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/files/testfile state=absent
|
||||
- set_fact: role_out="in local" play_out="in local" stage='remove 4'
|
||||
|
||||
- include: testplay.yml
|
||||
|
||||
- name: cleanup
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- file: path={{playbook_dir}}/testfile state=absent
|
||||
- file: path={{playbook_dir}}/files state=absent
|
||||
- file: path={{playbook_dir}}/roles/showfile/files state=absent
|
||||
@@ -0,0 +1,2 @@
|
||||
- name: relative to role
|
||||
set_fact: role_result="{{lookup('file', 'testfile')}}"
|
||||
5
test/integration/targets/lookup_paths/runme.sh
Executable file
5
test/integration/targets/lookup_paths/runme.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
ansible-playbook play.yml -i ../../inventory -v "$@"
|
||||
19
test/integration/targets/lookup_paths/testplay.yml
Normal file
19
test/integration/targets/lookup_paths/testplay.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
- name: test initial state
|
||||
hosts: testhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
roles:
|
||||
- showfile
|
||||
tasks:
|
||||
- name: from play
|
||||
set_fact: play_result="{{lookup('file', 'testfile')}}"
|
||||
|
||||
- name: output output {{stage}}
|
||||
debug: msg="play> {{play_out}}, role> {{role_out}}"
|
||||
|
||||
- name: verify that result match expected
|
||||
assert:
|
||||
that:
|
||||
- 'play_result == play_out'
|
||||
- 'role_result == role_out'
|
||||
|
||||
Reference in New Issue
Block a user