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
pull/34568/merge
Martin Krizek 7 years ago committed by GitHub
parent 0efbb702b9
commit 73d3ed85ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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,8 +15,8 @@
# 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/>.
- block:
- include: 'apt.yml' - include: 'apt.yml'
when: ansible_distribution in ('Ubuntu', 'Debian')
- block: - block:
- include: 'repo.yml' - include: 'repo.yml'
@ -27,23 +27,18 @@
- 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 - name: Remove aptitude, if installed, to test fall-back to apt-get
apt: apt:
@ -53,8 +48,6 @@
- aptitude_status.stdout.find('ii') != -1 - aptitude_status.stdout.find('ii') != -1
- include: "upgrade.yml aptitude_present={{ False | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}" - include: "upgrade.yml aptitude_present={{ False | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"
when:
- ansible_distribution in ('Ubuntu', 'Debian')
with_items: with_items:
- { upgrade_type: safe, force_apt_get: False } - { upgrade_type: safe, force_apt_get: False }
- { upgrade_type: full, force_apt_get: False } - { upgrade_type: full, force_apt_get: False }
@ -66,9 +59,7 @@
pkg: aptitude pkg: aptitude
state: present state: present
- include: upgrade.yml upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }} - include: "upgrade.yml aptitude_present={{ True | bool }} upgrade_type={{ item.upgrade_type }} force_apt_get={{ item.force_apt_get }}"
when:
- ansible_distribution in ('Ubuntu', 'Debian')
with_items: with_items:
- { upgrade_type: safe, force_apt_get: False } - { upgrade_type: safe, force_apt_get: False }
- { upgrade_type: full, force_apt_get: False } - { upgrade_type: full, force_apt_get: False }
@ -81,3 +72,6 @@
state: absent state: absent
when: when:
- aptitude_status.stdout.find('ii') == -1 - aptitude_status.stdout.find('ii') == -1
when:
- ansible_distribution in ('Ubuntu', 'Debian')

@ -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…
Cancel
Save