Expand integration test coverage for `deb822_repository` module

PR #85586
pull/84937/merge
Patrick Kingston 3 months ago committed by GitHub
parent 975f60ebf9
commit 36f00cdf1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -32,6 +32,104 @@
assert:
that: no_python3_debian.msg is contains 'python3-debian is not installed'
- name: check failure when in check mode
deb822_repository:
name: myrepo
types: deb
uris: "http://example.com/debian/"
suites: stable
components: main
register: no_python3_debian_check
check_mode: true
ignore_errors: true
- name: assert check mode failure without python3-debian
assert:
that: no_python3_debian_check is failed
- name: find apt path
command:
cmd: which apt
register: aptpath
- name: hide apt from ansible
command:
cmd: mv {{ aptpath.stdout_lines[0] }} /usr/bin/apthidden
become: true
- name: run deb822 with installation to check failure on nonexistent apt
deb822_repository:
name: myrepo
types: deb
uris: "http://example.com/debian/"
suites: stable
components: main
install_python_debian: true
register: failed_no_apt
ignore_errors: true
- name: assert failure
assert:
that: failed_no_apt is failed
- name: move apt back
command:
cmd: mv /usr/bin/apthidden {{ aptpath.stdout_lines[0] }}
become: true
- name: break apt update
copy:
content: "deb [invalid syntax] http://invalid.example.com/debian stable main"
dest: /etc/apt/sources.list.d/broken.list
- name: run deb822 with installation to check failure on apt update
deb822_repository:
name: myrepo
types: deb
uris: "http://example.com/debian/"
suites: stable
components: main
install_python_debian: true
register: failed_apt_update
ignore_errors: true
- name: assert failure
assert:
that: failed_apt_update.msg is contains 'Failed update'
- name: restore apt update
file:
path: /etc/apt/sources.list.d/broken.list
state: absent
- name: create apt preference file to break python3-debian installation
copy:
content: |
Package: python3-debian
Pin: release *
Pin-Priority: -1 # Never install
dest: /etc/apt/preferences.d/99-break-python3-debian.pref
- name: run deb822 with installation to check failure on apt install
deb822_repository:
name: myrepo
types: deb
uris: "http://example.com/debian/"
suites: stable
components: main
install_python_debian: true
register: failed_apt_install
ignore_errors: true
- name: assert failure on broken install
assert:
that: failed_apt_install is failed
- name: remove preference file
file:
path: /etc/apt/preferences.d/99-break-python3-debian.pref
state: absent
- name: run deb822 to check for python3-debian installation
deb822_repository:
name: myrepo
@ -57,6 +155,33 @@
that:
- not py3_deb_install.changed
- name: use venv to test interpreter respawn into installed environment
vars:
venv_dir: "{{ output_dir }}/nodeb_venv"
venv_python: "{{ venv_dir }}/bin/python"
block:
- name: ensure venv exists
pip:
name: coverage
virtualenv: "{{ venv_dir }}"
virtualenv_command: "{{ ansible_python_interpreter }} -m venv"
- name: run deb822 WITHOUT python3-debian installed to test respawning
deb822_repository:
name: myrepo
types: deb
uris: "http://example.com/debian/"
suites: stable
components: main
register: no_python3_debian
vars:
ansible_python_interpreter: "{{ venv_python }}"
ignore_errors: true
- name: Clean up the previously added basic Debian repository
deb822_repository:
name: myrepo
state: absent
- import_tasks: test.yml
- import_tasks: install.yml

Loading…
Cancel
Save