added integration tests for yum repository (#25671)

* added integration tests for yum repository

* fixed escaped single quote

* extended yum_repository tests to include fedora

* removed unused variable file

* added check for return values

* replaced escaped double quotes with single quotes, switched to lookup for reading repofile
pull/19554/head
David Newswanger 8 years ago committed by John R Barker
parent 7348a613bb
commit 1bc5761bea

@ -0,0 +1,2 @@
posix/ci/group1
destructive

@ -0,0 +1,24 @@
# (c) 2017, Red Hat <davidn@redhat.coms>
# This file is part of Ansible
#
# Ansible 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.
#
# Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>.
- include: 'yum_repository_centos.yml'
when: ansible_distribution in ['CentOS']
# separate file for fedora because repos, package managers and packages are
# different
- include: 'yum_repository_fedora.yml'
when: ansible_distribution in ['Fedora']

@ -0,0 +1,148 @@
---
- name: ensure sl is uninstalled to begin with
yum:
name: sl
state: absent
- name: disable epel
yum_repository:
name: epel
state: absent
- name: disable epel (Idempotant)
yum_repository:
name: epel
state: absent
register: epel_remove
- name: check return values
assert:
that:
- "epel_remove.repo == 'epel'"
- "epel_remove.state == 'absent'"
- name: check Idempotant
assert:
that: not epel_remove.changed
- name: install sl, which should fail
yum:
name: sl
state: present
ignore_errors: yes
register: sl_result
- debug: var=sl_result
- name: check that install failed
assert:
that:
- sl_result.failed
- "sl_result.msg==\"No package matching 'sl' found available, installed or updated\""
- name: re-add epel
yum_repository:
name: epel
description: EPEL yum repo
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
state: present
register: epel_add
- name: check return values
assert:
that:
- "epel_add.repo == 'epel'"
- "epel_add.state == 'present'"
- name: get repolist
shell: yum repolist
register: repolist
- name: ensure epel was added
assert:
that:
- "'epel' in repolist.stdout"
- epel_add.changed
- name: install sl
yum:
name: sl
state: present
register: sl_result
- name: check that sl was successfully installed
assert:
that:
- sl_result.changed
- name: remove sl
yum:
name: sl
state: absent
- name: change configuration of epel repo
yum_repository:
name: epel
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
description: New description
async: no
enablegroups: no
file: epel2
exclude:
- sl
ip_resolve: 4
keepalive: no
register: epel_add
- set_fact:
repofile: "{{ lookup('file', '/etc/yum.repos.d/epel2.repo') }}"
- debug: var=repofile
- name: check that options are correctly getting written to the repo file
assert:
that:
- "'async = 0' in repofile"
- "'name = New description' in repofile"
- "'enablegroups = 0' in repofile"
- "\"exclude = ['sl']\" in repofile"
- "'ip_resolve = 4' in repofile"
- "'keepalive = 0' in repofile"
- name: check new config doesn't change (Idempotant)
yum_repository:
name: epel
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
description: New description
async: no
enablegroups: no
file: epel2
exclude:
- sl
ip_resolve: 4
keepalive: no
register: epel_add
- name: check Idempotant
assert:
that: not epel_add.changed
- name: re-enable the epel repo
yum_repository:
name: epel
description: EPEL yum repo
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
state: present
- name: re-enable the epel repo (Idempotant)
yum_repository:
name: epel
description: EPEL yum repo
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
state: present
register: epel_add
- name: check Idempotant
assert:
that: not epel_add.changed

@ -0,0 +1,143 @@
---
- name: ensure libbdplus is uninstalled to begin with
dnf:
name: libbdplus
state: absent
- name: disable rpmfusion
yum_repository:
name: rpmfusion-free
state: absent
- name: disable rpmfusion (Idempotant)
yum_repository:
name: rpmfusion-free
state: absent
register: fusion_remove
- name: check return values
assert:
that:
- "fusion_remove.repo == 'rpmfusion-free'"
- "fusion_remove.state == 'absent'"
- name: check Idempotant
assert:
that: not fusion_remove.changed
- name: install libbdplus, which should fail
dnf:
name: libbdplus
state: present
ignore_errors: yes
register: lib_result
- name: check that install failed
assert:
that:
- lib_result.failed
- "lib_result.msg=='No package libbdplus available.'"
- name: re-add rpmfusion
yum_repository:
name: rpmfusion-free
description: RPM Fusion for Fedora 25 - Free
baseurl: http://download1.rpmfusion.org/free/fedora/releases/{{ ansible_distribution_major_version }}/Everything/{{ ansible_architecture }}/os/
state: present
register: fusion_add
- name: check return values
assert:
that:
- "fusion_add.repo == 'rpmfusion-free'"
- "fusion_add.state == 'present'"
- name: get repolist
shell: dnf repolist
register: repolist
- name: ensure rpm fusion was added
assert:
that:
- "'rpmfusion-free' in repolist.stdout"
- fusion_add.changed
- name: install libbdplus
dnf:
name: libbdplus
state: present
register: lib_result
- name: check that libbdplus was successfully installed
assert:
that:
- lib_result.changed
- name: remove libbdplus
dnf:
name: libbdplus
state: absent
- name: change configuration of rpmfusion repo
yum_repository:
name: rpmfusion-free
description: New description
baseurl: http://download1.rpmfusion.org/free/fedora/releases/{{ ansible_distribution_major_version }}/Everything/{{ ansible_architecture }}/os/
async: no
enablegroups: no
file: fusion2
exclude:
- libbdplus
ip_resolve: 4
keepalive: no
register: fusion_add
- set_fact:
repofile: "{{ lookup('file', '/etc/yum.repos.d/fusion2.repo') }}"
- name: check that options are correctly getting written to the repo file
assert:
that:
- "'async = 0' in repofile"
- "'name = New description' in repofile"
- "'enablegroups = 0' in repofile"
- "\"exclude = ['libbdplus']\" in repofile"
- "'ip_resolve = 4' in repofile"
- "'keepalive = 0' in repofile"
- name: check new config doesn't change (Idempotant)
yum_repository:
name: rpmfusion-free
description: New description
baseurl: http://download1.rpmfusion.org/free/fedora/releases/{{ ansible_distribution_major_version }}/Everything/{{ ansible_architecture }}/os/
async: no
enablegroups: no
file: fusion2
exclude:
- libbdplus
ip_resolve: 4
keepalive: no
register: fusion_add
- name: check Idempotant
assert:
that: not fusion_add.changed
- name: re-add rpmfusion
yum_repository:
name: rpmfusion-free
description: RPM Fusion for Fedora 25 - Free
baseurl: http://download1.rpmfusion.org/free/fedora/releases/{{ ansible_distribution_major_version }}/Everything/{{ ansible_architecture }}/os/
state: present
- name: re-add rpmfusion
yum_repository:
name: rpmfusion-free
description: RPM Fusion for Fedora 25 - Free
baseurl: http://download1.rpmfusion.org/free/fedora/releases/{{ ansible_distribution_major_version }}/Everything/{{ ansible_architecture }}/os/
state: present
register: fusion_add
- name: check Idempotant
assert:
that: not fusion_add.changed
Loading…
Cancel
Save