network/tests/playbooks/integration_pytest_python3.yml
Gris Ge b0f5d6352a test: Fix EL6 repo
* As EPEL6 has been moved to archive, created `tests/tasks/enable_epel.yml`.
 * As CentOS6 has been moved to vault, created `tests/tests_00_setup.yml`.

Signed-off-by: Gris Ge <fge@redhat.com>
2020-12-22 08:14:39 +08:00

92 lines
2.4 KiB
YAML

# SPDX-License-Identifier: BSD-3-Clause
---
- name: Install dependencies for integration tests
hosts: all
vars:
- rpmdependencies:
- git
- python3-pip
- rsync
tasks:
- name: Install rpm dependencies
package:
state: present
name: "{{ rpmdependencies }}"
- name: Install Pytest
command: "pip3 install pytest"
# Import needed in order to install initscripts dependencies on the remote
# system.
- import_playbook: "../tests_default_initscripts.yml"
# Import needed in order to install Network Manager dependencies on the remote
# system.
- import_playbook: "../tests_default_nm.yml"
- name: Run Pytest tests
hosts: all
vars:
- rundir: /run/system-roles-test
tasks:
- file:
state: directory
path: "{{ rundir }}"
recurse: true
- command: git rev-parse --show-toplevel
register: git_top_directory
delegate_to: localhost
- debug:
var: git_top_directory
- synchronize:
src: "{{ git_top_directory.stdout }}/"
dest: "{{ rundir }}/"
recursive: yes
delete: yes
rsync_opts:
- "--exclude=.pyc"
- "--exclude=__pycache__"
when: False
# 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
shell: 'tar -cvf {{ git_top_directory.stdout }}/testrepo.tar
--exclude "*.pyc" --exclude "__pycache__" --exclude testrepo.tar
-C {{ git_top_directory.stdout }} .'
delegate_to: localhost
- name: Copy testrepo.tar to the remote system
copy:
src: "{{ git_top_directory.stdout }}/testrepo.tar"
dest: "{{ rundir }}"
- name: Untar testrepo.tar
command: tar xf testrepo.tar
args:
chdir: "{{ rundir }}"
- block:
- name: Run pytest with nm
command: "pytest {{ rundir }}/tests/integration/ --provider=nm"
register: playbook_run
always:
- debug:
var: playbook_run.stdout_lines
- block:
- name: Run pytest with initscripts
command: >
pytest '{{ rundir }}/tests/integration/' --provider=initscripts
register: playbook_run
always:
- debug:
var: playbook_run.stdout_lines