From 9500aac5b969284119d8495b8f601d4da8ad9194 Mon Sep 17 00:00:00 2001 From: David Newswanger Date: Thu, 29 Jun 2017 10:53:42 -0400 Subject: [PATCH] added integration tests for dpkg_selections (#26043) --- .../targets/dpkg_selections/aliases | 2 + .../dpkg_selections/defaults/main.yaml | 1 + .../tasks/dpkg_selections.yaml | 86 +++++++++++++++++++ .../targets/dpkg_selections/tasks/main.yaml | 3 + 4 files changed, 92 insertions(+) create mode 100644 test/integration/targets/dpkg_selections/aliases create mode 100644 test/integration/targets/dpkg_selections/defaults/main.yaml create mode 100644 test/integration/targets/dpkg_selections/tasks/dpkg_selections.yaml create mode 100644 test/integration/targets/dpkg_selections/tasks/main.yaml diff --git a/test/integration/targets/dpkg_selections/aliases b/test/integration/targets/dpkg_selections/aliases new file mode 100644 index 0000000000..7978f4a6ce --- /dev/null +++ b/test/integration/targets/dpkg_selections/aliases @@ -0,0 +1,2 @@ +posix/ci/group1 +destructive diff --git a/test/integration/targets/dpkg_selections/defaults/main.yaml b/test/integration/targets/dpkg_selections/defaults/main.yaml new file mode 100644 index 0000000000..94bd9bcc3d --- /dev/null +++ b/test/integration/targets/dpkg_selections/defaults/main.yaml @@ -0,0 +1 @@ +hello_old_version: 2.6-1 diff --git a/test/integration/targets/dpkg_selections/tasks/dpkg_selections.yaml b/test/integration/targets/dpkg_selections/tasks/dpkg_selections.yaml new file mode 100644 index 0000000000..c263743f0d --- /dev/null +++ b/test/integration/targets/dpkg_selections/tasks/dpkg_selections.yaml @@ -0,0 +1,86 @@ +- name: download and install old version of hello + apt: "deb=https://launchpad.net/ubuntu/+archive/primary/+files/hello_{{ hello_old_version }}_amd64.deb" + +- name: freeze version for hello + dpkg_selections: + name: hello + selection: hold + +- name: get dpkg selections + shell: "dpkg --get-selections | grep hold" + register: result + +- debug: var=result + +- name: check that hello is marked as hold + assert: + that: + - "'hello' in result.stdout" + +- name: attempt to upgrade hello + apt: + upgrade: dist + +- name: check hello version + shell: dpkg -s hello | grep Version | awk '{print $2}' + register: hello_version + +- name: ensure hello was not upgraded + assert: + that: + - "{{ hello_version.stdout }} == {{ hello_old_version }}" + +- name: remove version freeze + dpkg_selections: + name: hello + selection: install + +- name: upgrade hello + apt: + upgrade: dist + +- 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 }}" + +- name: set hello to deinstall + dpkg_selections: + name: hello + selection: deinstall + +- name: get dpkg selections + shell: "dpkg --get-selections | grep deinstall" + register: result + +- debug: var=result + +- name: check that hello is marked as deinstall + assert: + that: + - "'hello' in result.stdout" + +- name: set hello to purge + dpkg_selections: + name: hello + selection: purge + +- name: get dpkg selections + shell: "dpkg --get-selections | grep purge" + register: result + +- debug: var=result + +- name: check that hello is marked as purge + assert: + that: + - "'hello' in result.stdout" + +- name: remove hello + apt: + name: hello + state: absent diff --git a/test/integration/targets/dpkg_selections/tasks/main.yaml b/test/integration/targets/dpkg_selections/tasks/main.yaml new file mode 100644 index 0000000000..6abd1dec10 --- /dev/null +++ b/test/integration/targets/dpkg_selections/tasks/main.yaml @@ -0,0 +1,3 @@ +--- + - include: 'dpkg_selections.yaml' + when: ansible_distribution in ('Ubuntu', 'Debian')