mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
Fix apt tests (#37922)
* Fix apt tests * Enable the test in CI * Additional fixes not discovered locally * Don't break mysql tests and fix for 14.04 upgrade * Remove not needed when cond * Add shebang to fix-udev script * Remove workaround in favor of rebuilding containers * Remove leftover script
This commit is contained in:
parent
0efbb702b9
commit
73d3ed85ef
4 changed files with 59 additions and 79 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
posix/ci/group1
|
||||||
destructive
|
destructive
|
||||||
skip/freebsd
|
skip/freebsd
|
||||||
skip/osx
|
skip/osx
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
- name: show python version
|
|
||||||
debug: var=ansible_python_version
|
|
||||||
|
|
||||||
- name: use python-apt
|
- name: use python-apt
|
||||||
set_fact:
|
set_fact:
|
||||||
python_apt: python-apt
|
python_apt: python-apt
|
||||||
|
@ -62,9 +59,6 @@
|
||||||
failed_when: False
|
failed_when: False
|
||||||
register: dpkg_result
|
register: dpkg_result
|
||||||
|
|
||||||
- debug: var=apt_result
|
|
||||||
- debug: var=dpkg_result
|
|
||||||
|
|
||||||
- name: verify installation of hello
|
- name: verify installation of hello
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
@ -104,9 +98,6 @@
|
||||||
failed_when: False
|
failed_when: False
|
||||||
register: dpkg_result
|
register: dpkg_result
|
||||||
|
|
||||||
- debug: var=apt_result
|
|
||||||
- debug: var=dpkg_result
|
|
||||||
|
|
||||||
- name: verify installation of hello
|
- name: verify installation of hello
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
@ -177,7 +168,7 @@
|
||||||
- name: verify sane error message
|
- name: verify sane error message
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'E:Failed to fetch' in apt_result['msg']"
|
- "'Failed to fetch' in apt_result['msg']"
|
||||||
- "'403' in apt_result['msg']"
|
- "'403' in apt_result['msg']"
|
||||||
|
|
||||||
- name: Clean up
|
- name: Clean up
|
||||||
|
|
|
@ -15,69 +15,63 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- include: 'apt.yml'
|
- block:
|
||||||
when: ansible_distribution in ('Ubuntu', 'Debian')
|
- include: 'apt.yml'
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- include: 'repo.yml'
|
- include: 'repo.yml'
|
||||||
always:
|
always:
|
||||||
- apt_repository:
|
- apt_repository:
|
||||||
repo: "deb file:{{ repodir }} ./"
|
repo: "deb file:{{ repodir }} ./"
|
||||||
state: absent
|
state: absent
|
||||||
- file:
|
- file:
|
||||||
name: "{{ repodir }}"
|
name: "{{ repodir }}"
|
||||||
state: absent
|
state: absent
|
||||||
when: ansible_distribution in ('Ubuntu', 'Debian')
|
|
||||||
|
|
||||||
- include: 'apt-multiarch.yml'
|
- include: 'apt-multiarch.yml'
|
||||||
when: ansible_distribution in ('Ubuntu', 'Debian') and ansible_userspace_architecture != apt_foreign_arch
|
when:
|
||||||
|
- ansible_userspace_architecture != apt_foreign_arch
|
||||||
|
|
||||||
- include: 'apt-builddep.yml'
|
- include: 'apt-builddep.yml'
|
||||||
when: ansible_distribution in ('Ubuntu', 'Debian')
|
|
||||||
|
|
||||||
- include: upgrade.yml upgrade_type=dist
|
- include: "upgrade.yml aptitude_present={{ True | bool }} upgrade_type=dist force_apt_get={{ False | bool }}"
|
||||||
when: ansible_distribution in ('Ubuntu', 'Debian')
|
|
||||||
|
|
||||||
- name: Check if aptitude is installed
|
- name: Check if aptitude is installed
|
||||||
command: dpkg-query --show --showformat='${db:Status-Abbrev}' aptitude
|
command: dpkg-query --show --showformat='${db:Status-Abbrev}' aptitude
|
||||||
register: aptitude_status
|
register: aptitude_status
|
||||||
when: ansible_distribution in ('Ubuntu', 'Debian')
|
|
||||||
|
|
||||||
- debug: var=aptitude_status.stdout
|
- name: Remove aptitude, if installed, to test fall-back to apt-get
|
||||||
|
apt:
|
||||||
|
pkg: aptitude
|
||||||
|
state: absent
|
||||||
|
when:
|
||||||
|
- aptitude_status.stdout.find('ii') != -1
|
||||||
|
|
||||||
- name: Remove aptitude, if installed, to test fall-back to apt-get
|
- include: "upgrade.yml aptitude_present={{ False | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"
|
||||||
apt:
|
with_items:
|
||||||
pkg: aptitude
|
- { upgrade_type: safe, force_apt_get: False }
|
||||||
state: absent
|
- { upgrade_type: full, force_apt_get: False }
|
||||||
when:
|
- { upgrade_type: safe, force_apt_get: True }
|
||||||
- aptitude_status.stdout.find('ii') != -1
|
- { upgrade_type: full, force_apt_get: True }
|
||||||
|
|
||||||
- include: "upgrade.yml aptitude_present={{ False | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"
|
- name: (Re-)Install aptitude, run same tests again
|
||||||
when:
|
apt:
|
||||||
- ansible_distribution in ('Ubuntu', 'Debian')
|
pkg: aptitude
|
||||||
with_items:
|
state: present
|
||||||
- { upgrade_type: safe, force_apt_get: False }
|
|
||||||
- { upgrade_type: full, force_apt_get: False }
|
|
||||||
- { upgrade_type: safe, force_apt_get: True }
|
|
||||||
- { upgrade_type: full, force_apt_get: True }
|
|
||||||
|
|
||||||
- name: (Re-)Install aptitude, run same tests again
|
- include: "upgrade.yml aptitude_present={{ True | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"
|
||||||
apt:
|
with_items:
|
||||||
pkg: aptitude
|
- { upgrade_type: safe, force_apt_get: False }
|
||||||
state: present
|
- { upgrade_type: full, force_apt_get: False }
|
||||||
|
- { upgrade_type: safe, force_apt_get: True }
|
||||||
|
- { upgrade_type: full, force_apt_get: True }
|
||||||
|
|
||||||
- include: upgrade.yml upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}
|
- name: Remove aptitude if not originally present
|
||||||
when:
|
apt:
|
||||||
- ansible_distribution in ('Ubuntu', 'Debian')
|
pkg: aptitude
|
||||||
with_items:
|
state: absent
|
||||||
- { upgrade_type: safe, force_apt_get: False }
|
when:
|
||||||
- { upgrade_type: full, force_apt_get: False }
|
- aptitude_status.stdout.find('ii') == -1
|
||||||
- { upgrade_type: safe, force_apt_get: True }
|
|
||||||
- { upgrade_type: full, force_apt_get: True }
|
|
||||||
|
|
||||||
- name: Remove aptitude if not originally present
|
when:
|
||||||
apt:
|
- ansible_distribution in ('Ubuntu', 'Debian')
|
||||||
pkg: aptitude
|
|
||||||
state: absent
|
|
||||||
when:
|
|
||||||
- aptitude_status.stdout.find('ii') == -1
|
|
||||||
|
|
|
@ -7,41 +7,35 @@
|
||||||
shell: dpkg -s hello | grep Version | awk '{print $2}'
|
shell: dpkg -s hello | grep Version | awk '{print $2}'
|
||||||
register: hello_version
|
register: hello_version
|
||||||
|
|
||||||
- debug: var=hello_version
|
|
||||||
|
|
||||||
- name: ensure the correct version of hello has been installed
|
- name: ensure the correct version of hello has been installed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "{{ hello_version.stdout }}=={{ hello_old_version }}"
|
- "{{ hello_version.stdout }}=={{ hello_old_version }}"
|
||||||
|
|
||||||
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version, force_apt_get: {{force_apt_get|default(False)}}"
|
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version, force_apt_get: {{force_apt_get}}"
|
||||||
apt:
|
apt:
|
||||||
upgrade: "{{ upgrade_type }}"
|
upgrade: "{{ upgrade_type }}"
|
||||||
force_apt_get: "{{ force_apt_get | default(False) }}"
|
force_apt_get: "{{ force_apt_get }}"
|
||||||
register: upgrade_result
|
register: upgrade_result
|
||||||
|
|
||||||
- name: check hello version
|
- name: check hello version
|
||||||
shell: dpkg -s hello | grep Version | awk '{print $2}'
|
shell: dpkg -s hello | grep Version | awk '{print $2}'
|
||||||
register: hello_version
|
register: hello_version
|
||||||
|
|
||||||
- debug: var=upgrade_result.warnings|default([])
|
|
||||||
- debug: var=aptitude_present
|
|
||||||
- debug: var=force_apt_get
|
|
||||||
|
|
||||||
- name: check that warning is not given when force_apt_get set
|
- name: check that warning is not given when force_apt_get set
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'Could not find aptitude. Using apt-get instead' not in upgrade_result.warnings | default([])"
|
- "'warnings' not in upgrade_result"
|
||||||
when:
|
when:
|
||||||
- force_apt_get | default(False)
|
- force_apt_get
|
||||||
|
|
||||||
- name: check that warning is given when aptitude not found and force_apt_get not set
|
- name: check that warning is given when aptitude not found and force_apt_get not set
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'Could not find aptitude. Using apt-get instead' in upgrade_result.warnings"
|
- "'Could not find aptitude. Using apt-get instead' in upgrade_result.warnings[0]"
|
||||||
when:
|
when:
|
||||||
- not aptitude_present|default(True)
|
- not aptitude_present
|
||||||
- not force_apt_get|default(False)
|
- not force_apt_get
|
||||||
|
|
||||||
- name: check that old version upgraded correctly
|
- name: check that old version upgraded correctly
|
||||||
assert:
|
assert:
|
||||||
|
@ -52,7 +46,7 @@
|
||||||
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version (Idempotant)"
|
- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version (Idempotant)"
|
||||||
apt:
|
apt:
|
||||||
upgrade: "{{ upgrade_type }}"
|
upgrade: "{{ upgrade_type }}"
|
||||||
force_apt_get: "{{ force_apt_get | default(False) }}"
|
force_apt_get: "{{ force_apt_get }}"
|
||||||
register: second_upgrade_result
|
register: second_upgrade_result
|
||||||
|
|
||||||
- name: check that nothing has changed (Idempotant)
|
- name: check that nothing has changed (Idempotant)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue