Clean up various integration tests. (#60613)

* Fix var_blending test temp dir usage.

* Fix filters integration test:

- Fix use of `output_dir`.
- Use `localhost` instead of `testhost` since we're only testing filters.
- Fix `fileglob` test to actually test a directory that exists.

* Fix lookups integration test:

- Fix use of `output_dir`.
- Use `localhost` instead of `testhost` since we're only testing lookups.

* Fix ansible-runner test temp dir usage.

* Fix template and template_jinja2_latest test.

Use the `OUTPUT_DIR` env var to get the output directory for the tests.

* Fix Python version compat in filters test.

* Skip filters test on Python 2.6.
pull/60617/head
Matt Clay 5 years ago committed by GitHub
parent f52657fb7d
commit 0c74ee4352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,4 +2,4 @@
set -eux set -eux
ANSIBLE_ROLES_PATH=../ ansible-playbook test.yml -e '@../../integration_config.yml' -i inventory "$@" ANSIBLE_ROLES_PATH=../ ansible-playbook test.yml -i inventory "$@"

@ -1,5 +1,5 @@
- name: execute the script - name: execute the script
command: "'{{ ansible_python_interpreter }}' '{{ role_path }}/files/adhoc_example1.py' '{{ output_dir }}'" command: "'{{ ansible_python_interpreter }}' '{{ role_path }}/files/adhoc_example1.py' '{{ lookup('env', 'OUTPUT_DIR') }}'"
environment: environment:
AWX_LIB_DIRECTORY: "{{ callback_path }}" AWX_LIB_DIRECTORY: "{{ callback_path }}"
register: script register: script

@ -1,5 +1,5 @@
- name: execute the script - name: execute the script
command: "'{{ ansible_python_interpreter }}' '{{ role_path }}/files/playbook_example1.py' '{{ output_dir }}'" command: "'{{ ansible_python_interpreter }}' '{{ role_path }}/files/playbook_example1.py' '{{ lookup('env', 'OUTPUT_DIR') }}'"
environment: environment:
AWX_LIB_DIRECTORY: "{{ callback_path }}" AWX_LIB_DIRECTORY: "{{ callback_path }}"
register: script register: script

@ -1 +1,2 @@
shippable/posix/group2 shippable/posix/group2
skip/python2.6 # filters are controller only, and we no longer support Python 2.6 on the controller

@ -44,7 +44,7 @@ quoted = quoted
The fileglob module returns the list of things matching a pattern. The fileglob module returns the list of things matching a pattern.
fileglob = [] fileglob = one.txt, two.txt
There are also various string operations that work on paths. These do not require There are also various string operations that work on paths. These do not require
files to exist and are passthrus to the python os.path functions files to exist and are passthrus to the python os.path functions

@ -1,4 +1,4 @@
- hosts: testhost - hosts: localhost
gather_facts: yes gather_facts: yes
roles: roles:
- { role: filters } - { role: filters }

@ -9,4 +9,4 @@ source virtualenv.sh
pip install jmespath netaddr pip install jmespath netaddr
ANSIBLE_ROLES_PATH=../ ansible-playbook filters.yml -i ../../inventory -e @../../integration_config.yml "$@" ANSIBLE_ROLES_PATH=../ ansible-playbook filters.yml "$@"

@ -3,6 +3,9 @@
# Copyright: (c) 2019, Ansible Project # Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- set_fact:
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
- name: a dummy task to test the changed and success filters - name: a dummy task to test the changed and success filters
shell: echo hi shell: echo hi
register: some_registered_var register: some_registered_var

@ -38,7 +38,7 @@ quoted = {{ 'quoted' | quote }}
The fileglob module returns the list of things matching a pattern. The fileglob module returns the list of things matching a pattern.
fileglob = {{ (output_dir + '/*') | fileglob }} fileglob = {{ (playbook_dir + '/files/fileglob/*') | fileglob | map('basename') | sort | join(', ') }}
There are also various string operations that work on paths. These do not require There are also various string operations that work on paths. These do not require
files to exist and are passthrus to the python os.path functions files to exist and are passthrus to the python os.path functions

@ -1,4 +1,4 @@
- hosts: testhost - hosts: localhost
gather_facts: yes gather_facts: yes
roles: roles:
- { role: lookups } - { role: lookups }

@ -8,6 +8,6 @@ source virtualenv.sh
# because plugins and requirements are loaded before the task runs # because plugins and requirements are loaded before the task runs
pip install passlib pip install passlib
ANSIBLE_ROLES_PATH=../ ansible-playbook lookups.yml -i ../../inventory -e @../../integration_config.yml "$@" ANSIBLE_ROLES_PATH=../ ansible-playbook lookups.yml "$@"
ansible-playbook template_lookup_vaulted.yml -i ../../inventory -e @../../integration_config.yml --vault-password-file test_vault_pass "$@" ansible-playbook template_lookup_vaulted.yml --vault-password-file test_vault_pass "$@"

@ -4,6 +4,9 @@
# FILE LOOKUP # FILE LOOKUP
- set_fact:
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
- name: make a new file to read - name: make a new file to read
copy: dest={{output_dir}}/foo.txt mode=0644 content="bar" copy: dest={{output_dir}}/foo.txt mode=0644 content="bar"

@ -2,6 +2,8 @@
- hosts: testhost - hosts: testhost
gather_facts: False gather_facts: False
tasks: tasks:
- set_fact:
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
- file: - file:
path: '{{ output_dir }}/café.txt' path: '{{ output_dir }}/café.txt'
state: 'absent' state: 'absent'

@ -1,4 +1,7 @@
--- ---
- set_fact:
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
- template: - template:
src: test src: test
dest: "{{ output_dir }}/templated_test" dest: "{{ output_dir }}/templated_test"

@ -2,16 +2,16 @@
set -eux set -eux
ANSIBLE_ROLES_PATH=../ ansible-playbook template.yml -i ../../inventory -e @../../integration_config.yml -v "$@" ANSIBLE_ROLES_PATH=../ ansible-playbook template.yml -i ../../inventory -v "$@"
# Test for #35571 # Test for #35571
ansible testhost -i testhost, -m debug -a 'msg={{ hostvars["localhost"] }}' -e "vars1={{ undef }}" -e "vars2={{ vars1 }}" ansible testhost -i testhost, -m debug -a 'msg={{ hostvars["localhost"] }}' -e "vars1={{ undef }}" -e "vars2={{ vars1 }}"
# Test for https://github.com/ansible/ansible/issues/27262 # Test for https://github.com/ansible/ansible/issues/27262
ansible-playbook ansible_managed.yml -c ansible_managed.cfg -i ../../inventory -e @../../integration_config.yml -v "$@" ansible-playbook ansible_managed.yml -c ansible_managed.cfg -i ../../inventory -v "$@"
# Test for #42585 # Test for #42585
ANSIBLE_ROLES_PATH=../ ansible-playbook custom_template.yml -i ../../inventory -e @../../integration_config.yml -v "$@" ANSIBLE_ROLES_PATH=../ ansible-playbook custom_template.yml -i ../../inventory -v "$@"
# Test for several corner cases #57188 # Test for several corner cases #57188

@ -16,6 +16,9 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- set_fact:
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
- name: show python interpreter - name: show python interpreter
debug: debug:
msg: "{{ ansible_python['executable'] }}" msg: "{{ ansible_python['executable'] }}"
@ -395,7 +398,7 @@
assert: assert:
that: that:
- "template_result is not changed" - "template_result is not changed"
- "'templated_var_loaded' in lookup('file', '{{output_dir | expanduser}}/short.templated')" - "'templated_var_loaded' in lookup('file', output_dir + '/short.templated')"
- name: change var for the template - name: change var for the template
set_fact: set_fact:
@ -409,7 +412,7 @@
- name: verify that the file was marked as changed in check mode but the content was not changed - name: verify that the file was marked as changed in check mode but the content was not changed
assert: assert:
that: that:
- "'templated_var_loaded' in lookup('file', '{{output_dir | expanduser }}/short.templated')" - "'templated_var_loaded' in lookup('file', output_dir + '/short.templated')"
- "template_result is changed" - "template_result is changed"
# Create a template using a child template, to ensure that variables # Create a template using a child template, to ensure that variables

@ -9,4 +9,4 @@ pip install -U jinja2
ANSIBLE_ROLES_PATH=../ ANSIBLE_ROLES_PATH=../
export ANSIBLE_ROLES_PATH export ANSIBLE_ROLES_PATH
ansible-playbook -i ../../inventory main.yml -e @../../integration_config.yml -v "$@" ansible-playbook -i ../../inventory main.yml -v "$@"

@ -18,6 +18,9 @@
- include_vars: more_vars.yml - include_vars: more_vars.yml
- set_fact:
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
- name: deploy a template that will use variables at various levels - name: deploy a template that will use variables at various levels
template: src=foo.j2 dest={{output_dir}}/foo.templated template: src=foo.j2 dest={{output_dir}}/foo.templated
register: template_result register: template_result

@ -2,4 +2,4 @@
set -eux set -eux
ansible-playbook test_var_blending.yml -i inventory -e @integration_config.yml -v "$@" ansible-playbook test_var_blending.yml -i inventory -e @test_vars.yml -v "$@"

Loading…
Cancel
Save