diff --git a/test/integration/targets/apt/defaults/main.yml b/test/integration/targets/apt/defaults/main.yml index 05a5780fd34..7ad2497d470 100644 --- a/test/integration/targets/apt/defaults/main.yml +++ b/test/integration/targets/apt/defaults/main.yml @@ -1 +1,2 @@ apt_foreign_arch: i386 +hello_old_version: 2.6-1 diff --git a/test/integration/targets/apt/tasks/apt.yml b/test/integration/targets/apt/tasks/apt.yml index 9cdd7837e8e..53404d131fe 100644 --- a/test/integration/targets/apt/tasks/apt.yml +++ b/test/integration/targets/apt/tasks/apt.yml @@ -116,6 +116,7 @@ - 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 diff --git a/test/integration/targets/apt/tasks/main.yml b/test/integration/targets/apt/tasks/main.yml index 29682d3ad98..ea5679b7e44 100644 --- a/test/integration/targets/apt/tasks/main.yml +++ b/test/integration/targets/apt/tasks/main.yml @@ -15,11 +15,29 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -- include: 'apt.yml' - when: ansible_distribution in ('Ubuntu', 'Debian') + - include: 'apt.yml' + when: ansible_distribution in ('Ubuntu', 'Debian') -- include: 'apt-multiarch.yml' - when: ansible_distribution in ('Ubuntu', 'Debian') and ansible_userspace_architecture != apt_foreign_arch + - include: 'apt-multiarch.yml' + when: ansible_distribution in ('Ubuntu', 'Debian') and ansible_userspace_architecture != apt_foreign_arch -- include: 'apt-builddep.yml' - when: ansible_distribution in ('Ubuntu', 'Debian') + - include: 'apt-builddep.yml' + when: ansible_distribution in ('Ubuntu', 'Debian') + + - name: Check if aptitude is installed + command: dpkg-query -l aptitude + register: deb_check + when: ansible_distribution in ('Ubuntu', 'Debian') + + - include: upgrade.yml upgrade_type=dist + when: ansible_distribution in ('Ubuntu', 'Debian') + + - include: upgrade.yml upgrade_type=safe + when: + - ansible_distribution in ('Ubuntu', 'Debian') + - deb_check.stdout.find('no packages found') != -1 + + - include: upgrade.yml upgrade_type=full + when: + - ansible_distribution in ('Ubuntu', 'Debian') + - deb_check.stdout.find('no packages found') != -1 diff --git a/test/integration/targets/apt/tasks/upgrade.yml b/test/integration/targets/apt/tasks/upgrade.yml new file mode 100644 index 00000000000..8a630bb5568 --- /dev/null +++ b/test/integration/targets/apt/tasks/upgrade.yml @@ -0,0 +1,45 @@ +--- +#### Tests for upgrade/download functions in modules/packaging/os/apt.py #### +- name: download and install old version of hello + apt: "deb=https://launchpad.net/ubuntu/+archive/primary/+files/hello_{{ hello_old_version }}_amd64.deb" + +- name: check hello version + shell: dpkg -s hello | grep Version | awk '{print $2}' + register: hello_version + +- debug: var=hello_version + +- name: ensure the correct version of hello has been installed + assert: + that: + - "{{ hello_version.stdout }}=={{ hello_old_version }}" + +- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version" + apt: + upgrade: "{{ upgrade_type }}" + +- name: check hello version + shell: dpkg -s hello | grep Version | awk '{print $2}' + register: hello_version + +- name: check that old version upgraded correctly + assert: + that: + - "{{ hello_version.stdout }}!={{ hello_old_version }}" + - "{{ hello_version.changed }}" + +- name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version (Idempotant)" + apt: + upgrade: "{{ upgrade_type }}" + register: result + +- name: check that nothing has changed (Idempotant) + assert: + that: + - "result.changed == false" + +- name: remove hello + apt: + pkg: hello + state: absent + autoclean: yes