Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apt: allow for integration tests using fake repo #37639

Merged
merged 4 commits into from
Mar 22, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions test/integration/targets/apt/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dependencies:
- prepare_tests
- setup_deb_repo
11 changes: 11 additions & 0 deletions test/integration/targets/apt/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
- include: 'apt.yml'
when: ansible_distribution in ('Ubuntu', 'Debian')

- block:
- include: 'repo.yml'
always:
- apt_repository:
repo: "deb file:{{ repodir }} ./"
state: absent
- file:
name: "{{ repodir }}"
state: absent
when: ansible_distribution in ('Ubuntu', 'Debian')

- include: 'apt-multiarch.yml'
when: ansible_distribution in ('Ubuntu', 'Debian') and ansible_userspace_architecture != apt_foreign_arch

Expand Down
42 changes: 42 additions & 0 deletions test/integration/targets/apt/tasks/repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
- block:
- name: Install foo package version 1.0.0
apt:
name: foo=1.0.0
allow_unauthenticated: yes
register: apt_result

- name: Check install with dpkg
shell: dpkg-query -l foo
register: dpkg_result

- name: Check if install was successful
assert:
that:
- "apt_result is success"
- "dpkg_result is success"
- "'1.0.0' in dpkg_result.stdout"

- name: Update to foo version 1.0.1
apt:
name: foo
state: latest
allow_unauthenticated: yes
register: apt_result

- name: Check install with dpkg
shell: dpkg-query -l foo
register: dpkg_result

- name: Check if install was successful
assert:
that:
- "apt_result is success"
- "dpkg_result is success"
- "'1.0.1' in dpkg_result.stdout"

always:
- name: Clean up
apt:
name: foo
state: absent
allow_unauthenticated: yes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Section: misc
Priority: optional
Standards-Version: 2.3.3

Package: foo
Version: 1.0.0
Section: system
Maintainer: John Doe <john@doe.com>
Architecture: all
Description: Dummy package
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Section: misc
Priority: optional
Standards-Version: 2.3.3

Package: foo
Version: 1.0.1
Section: system
Maintainer: John Doe <john@doe.com>
Architecture: all
Description: Dummy package
36 changes: 36 additions & 0 deletions test/integration/targets/setup_deb_repo/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
- block:
- name: Install needed packages
apt:
name: "{{ item }}"
with_items:
- dpkg-dev
- equivs
- libfile-fcntllock-perl # to silence warning by equivs-build

- set_fact:
repodir: /tmp/repo/

- name: Create repo dir
file:
path: "{{ repodir }}"
state: directory
mode: 0755

- name: Create deb files
shell: "equivs-build {{ item }}"
args:
chdir: "{{ repodir }}"
with_fileglob:
- "files/package_specs/*"

- name: Create repo
shell: dpkg-scanpackages --multiversion . /dev/null | gzip -9c > Packages.gz
args:
chdir: "{{ repodir }}"

- name: Install the repo
apt_repository:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repo should be removed when the test ends (success or failure) along with the installed package(s).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, should be fixed. Also did that in the yum tests - #37770.

repo: "deb file:{{ repodir }} ./"
validate_certs: no

when: ansible_distribution in ['Ubuntu', 'Debian']