Migrate Linux CI roles to test targets. (#17997)

This commit is contained in:
Matt Clay 2016-10-13 09:09:25 -07:00 committed by GitHub
commit 75e4645ee7
263 changed files with 53 additions and 53 deletions

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_tests

View file

@ -0,0 +1,55 @@
# test installing build-deps using netcat and quilt as test victims.
#
# Deps can be discovered like so (taken from ubuntu 12.04)
# ====
# root@localhost:~ # apt-rdepends --build-depends --follow=DEPENDS netcat
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# netcat
# Build-Depends: debhelper (>= 8.0.0)
# Build-Depends: quilt
# root@localhost:~ #
# ====
# Since many things depend on debhelper, let's just uninstall quilt, then
# install build-dep for netcat to get it back. build-dep doesn't have an
# uninstall, so we don't need to test for reverse actions (eg, uninstall
# build-dep and ensure things are clean)
# uninstall quilt
- name: check quilt with dpkg
shell: dpkg -s quilt
register: dpkg_result
ignore_errors: true
tags: ['test_apt_builddep']
- name: uninstall quilt with apt
apt: pkg=quilt state=absent purge=yes
register: apt_result
when: dpkg_result|success
tags: ['test_apt_builddep']
# install build-dep for netcat
- name: install netcat build-dep with apt
apt: pkg=netcat state=build-dep
register: apt_result
tags: ['test_apt_builddep']
- name: verify build_dep of netcat
assert:
that:
- "'changed' in apt_result"
tags: ['test_apt_builddep']
# ensure debhelper and qilt are installed
- name: check build_deps with dpkg
shell: dpkg --get-selections | egrep '(debhelper|quilt)'
failed_when: False
register: dpkg_result
tags: ['test_apt_builddep']
- name: verify build_deps are really there
assert:
that:
- "dpkg_result.rc == 0"
tags: ['test_apt_builddep']

View file

@ -0,0 +1,150 @@
- name: show python version
debug: var=ansible_python_version
- name: use python-apt
set_fact:
python_apt: python-apt
when: ansible_python_version | version_compare('3', '<')
- name: use python3-apt
set_fact:
python_apt: python3-apt
when: ansible_python_version | version_compare('3', '>=')
# UNINSTALL 'python-apt'
# The `apt` module has the smarts to auto-install `python-apt`. To test, we
# will first uninstall `python-apt`.
- name: check {{ python_apt }} with dpkg
shell: dpkg -s {{ python_apt }}
register: dpkg_result
ignore_errors: true
- name: uninstall {{ python_apt }} with apt
apt: pkg={{ python_apt }} state=absent purge=yes
register: apt_result
when: dpkg_result|success
# UNINSTALL 'hello'
# With 'python-apt' uninstalled, the first call to 'apt' should install
# python-apt.
- name: uninstall hello with apt
apt: pkg=hello state=absent purge=yes
register: apt_result
- name: check hello with dpkg
shell: dpkg-query -l hello
failed_when: False
register: dpkg_result
- name: verify uninstallation of hello
assert:
that:
- "'changed' in apt_result"
- "dpkg_result.rc == 1"
# UNINSTALL AGAIN
- name: uninstall hello with apt
apt: pkg=hello state=absent purge=yes
register: apt_result
- name: verify no change on re-uninstall
assert:
that:
- "not apt_result.changed"
# INSTALL
- name: install hello with apt
apt: name=hello state=present
register: apt_result
- name: check hello with dpkg
shell: dpkg-query -l hello
failed_when: False
register: dpkg_result
- debug: var=apt_result
- debug: var=dpkg_result
- name: verify installation of hello
assert:
that:
- "apt_result.changed"
- "dpkg_result.rc == 0"
- name: verify apt module outputs
assert:
that:
- "'changed' in apt_result"
- "'stderr' in apt_result"
- "'stdout' in apt_result"
- "'stdout_lines' in apt_result"
# INSTALL AGAIN
- name: install hello with apt
apt: name=hello state=present
register: apt_result
- name: verify no change on re-install
assert:
that:
- "not apt_result.changed"
# UNINSTALL AGAIN
- name: uninstall hello with apt
apt: pkg=hello state=absent purge=yes
register: apt_result
# INSTALL WITH VERSION WILDCARD
- name: install hello with apt
apt: name=hello=2.* state=present
register: apt_result
- name: check hello with wildcard with dpkg
shell: dpkg-query -l hello
failed_when: False
register: dpkg_result
- debug: var=apt_result
- debug: var=dpkg_result
- name: verify installation of hello
assert:
that:
- "apt_result.changed"
- "dpkg_result.rc == 0"
- name: check hello version
shell: dpkg -s hello | grep Version | awk '{print $2}'
register: hello_version
- name: check hello architecture
shell: dpkg -s hello | grep Architecture | awk '{print $2}'
register: hello_architecture
- name: uninstall hello with apt
apt: pkg=hello state=absent purge=yes
- name: install deb file
apt: deb="/var/cache/apt/archives/hello_{{ hello_version.stdout }}_{{ hello_architecture.stdout }}.deb"
register: apt_initial
- name: install deb file again
apt: deb="/var/cache/apt/archives/hello_{{ hello_version.stdout }}_{{ hello_architecture.stdout }}.deb"
register: apt_secondary
- name: verify installation of hello
assert:
that:
- "apt_initial.changed"
- "not apt_secondary.changed"
- name: uninstall hello with apt
apt: pkg=hello state=absent purge=yes
- name: force install of deb
apt: deb="/var/cache/apt/archives/hello_{{ hello_version.stdout }}_{{ hello_architecture.stdout }}.deb" force=true
register: dpkg_force
- name: verify installation of hello
assert:
that:
- "dpkg_force.changed"

View file

@ -0,0 +1,22 @@
# (c) 2014, James Tanner <tanner.jc@gmail.com>
# 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: 'apt.yml'
when: ansible_distribution in ('Ubuntu', 'Debian')
- include: 'apt-builddep.yml'
when: ansible_distribution in ('Ubuntu', 'Debian')