Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 6 additions & 103 deletions tests/playbooks/integration_pytest_python3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,110 +30,16 @@
tasks:
- name: Run Pytest tests
block:
- name: Create tempdir for code to test
tempfile:
state: directory
prefix: lsrtest_
register: _rundir

- name: Get tempfile for tar
tempfile:
prefix: lsrtest_
suffix: ".tar"
register: temptar
delegate_to: localhost

- name: Include the task '../tasks/get_modules_and_utils_paths.yml'
include_tasks: ../tasks/get_modules_and_utils_paths.yml

- name: Get tests directory
set_fact:
tests_directory: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- tests
- network
paths:
- "../.."

# TODO: using tar and copying the file is a workaround for the
# synchronize module that does not work in test-harness. Related issue:
# https://github.com/linux-system-roles/test-harness/issues/102
#
- name: Create Tar file
command: >
tar -cvf {{ temptar.path }} --exclude "*.pyc"
--exclude "__pycache__"
-C {{ tests_directory | realpath | dirname }}
{{ tests_directory | basename }}
-C {{ modules_parent_and_dir.stdout_lines[0] }}
{{ modules_parent_and_dir.stdout_lines[1] }}
-C {{ module_utils_parent_and_dir.stdout_lines[0] }}
{{ module_utils_parent_and_dir.stdout_lines[1] }}
# noqa command-instead-of-module
delegate_to: localhost
changed_when: false

- name: Copy testrepo.tar to the remote system
copy:
src: "{{ temptar.path }}"
dest: "{{ _rundir.path }}"
mode: preserve

- name: Untar testrepo.tar
unarchive:
src: "{{ _rundir.path }}/{{ temptar.path | basename }}"
dest: "{{ _rundir.path }}"
remote_src: true

- name: "Create subdirectory './ansible' under '{{ _rundir.path }}'"
file:
state: directory
path: "{{ _rundir.path }}/ansible"
mode: "0755"

- name: Move module_utils to ansible directory
shell: |
if [ -d {{ _rundir.path }}/module_utils ]; then
mv {{ _rundir.path }}/module_utils {{ _rundir.path }}/ansible
fi
changed_when: false

- name: Fake out python module directories, primarily for python2
shell: |
for dir in $(find {{ _rundir.path }} -type d -print); do
if [ ! -f "$dir/__init__.py" ]; then
touch "$dir/__init__.py"
fi
done
changed_when: false

- name: Set _lsr_python_path
set_fact:
_lsr_python_path: "{{
_rundir.path ~ '/' ~
modules_parent_and_dir.stdout_lines[1] ~ ':' ~ _rundir.path
}}"

- name: Show _lsr_python_path
debug:
msg: path {{ _lsr_python_path }}

- name: "List the files in {{ _rundir.path }}"
command: ls -alrtFR {{ _rundir.path }}
changed_when: false
- name: Copy python files to the remote system
include_tasks: ../tasks/setup_remote_pytest.yml

- name: Run pytest with nm provider
block:
- name: Run pytest with nm
command: >
pytest-3
{{ _rundir.path }}/{{ tests_directory | basename }}/integration/
--provider=nm
register: playbook_run
command: pytest-3 {{ _rundir.path }}/integration/ --provider=nm
environment:
PYTHONPATH: "{{ _lsr_python_path }}"
register: playbook_run
changed_when: false
always:
- name: Debug stdout_lines of the running playbook with nm
Expand All @@ -149,13 +55,10 @@
use: "{{ (__network_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
- name: Run pytest with initscripts
command: >
pytest-3
{{ _rundir.path }}/{{ tests_directory | basename }}/integration/
--provider=initscripts
register: playbook_run
command: pytest-3 {{ _rundir.path }}/integration/ --provider=initscripts
environment:
PYTHONPATH: "{{ _lsr_python_path }}"
register: playbook_run
changed_when: false
always:
- name: Debug stdout_lines of the running playbook with initscripts
Expand Down
98 changes: 0 additions & 98 deletions tests/tasks/get_modules_and_utils_paths.yml

This file was deleted.

Loading
Loading