From 59eff2e3e0a6b4ca04defbad0a86ae6fcc1984e1 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 5 Jan 2022 17:49:05 +0100 Subject: [PATCH] Re-enable snap tests (#3967) (#3981) * Re-enable snap tests. * Skip tests on RHEL 8.2 and 8.3. * Refactor snap setup. * Try to simplify setup. (cherry picked from commit bb78d98f8fec9bc253634a9fd97bf072741c1df0) Co-authored-by: Felix Fontein --- .../{snap => setup_snap}/defaults/main.yml | 0 .../{snap => setup_snap}/handlers/main.yml | 0 .../targets/setup_snap/meta/main.yml | 3 +++ .../tasks/D-Fedora.yml} | 0 .../targets/setup_snap/tasks/D-RedHat-8.2.yml | 1 + .../targets/setup_snap/tasks/D-RedHat-8.3.yml | 1 + .../tasks/Debian.yml | 0 .../{snap => setup_snap}/tasks/RedHat.yml | 0 .../{snap => setup_snap}/tasks/default.yml | 0 .../targets/setup_snap/tasks/main.yml | 23 +++++++++++++++++++ .../{snap => setup_snap}/tasks/nothing.yml | 0 tests/integration/targets/snap/aliases | 1 - tests/integration/targets/snap/meta/main.yml | 3 +-- .../integration/targets/snap/tasks/Fedora.yml | 1 - tests/integration/targets/snap/tasks/main.yml | 13 ----------- tests/integration/targets/snap_alias/aliases | 1 - .../targets/snap_alias/defaults/main.yml | 4 ---- .../targets/snap_alias/handlers/main.yml | 5 ---- .../targets/snap_alias/meta/main.yml | 3 +-- .../targets/snap_alias/tasks/Fedora.yml | 1 - .../targets/snap_alias/tasks/RedHat.yml | 1 - .../targets/snap_alias/tasks/default.yml | 21 ----------------- .../targets/snap_alias/tasks/main.yml | 13 ----------- .../targets/snap_alias/tasks/nothing.yml | 2 -- 24 files changed, 30 insertions(+), 67 deletions(-) rename tests/integration/targets/{snap => setup_snap}/defaults/main.yml (100%) rename tests/integration/targets/{snap => setup_snap}/handlers/main.yml (100%) create mode 100644 tests/integration/targets/setup_snap/meta/main.yml rename tests/integration/targets/{snap/tasks/Debian.yml => setup_snap/tasks/D-Fedora.yml} (100%) create mode 120000 tests/integration/targets/setup_snap/tasks/D-RedHat-8.2.yml create mode 120000 tests/integration/targets/setup_snap/tasks/D-RedHat-8.3.yml rename tests/integration/targets/{snap_alias => setup_snap}/tasks/Debian.yml (100%) rename tests/integration/targets/{snap => setup_snap}/tasks/RedHat.yml (100%) rename tests/integration/targets/{snap => setup_snap}/tasks/default.yml (100%) create mode 100644 tests/integration/targets/setup_snap/tasks/main.yml rename tests/integration/targets/{snap => setup_snap}/tasks/nothing.yml (100%) delete mode 120000 tests/integration/targets/snap/tasks/Fedora.yml delete mode 100644 tests/integration/targets/snap_alias/defaults/main.yml delete mode 100644 tests/integration/targets/snap_alias/handlers/main.yml delete mode 120000 tests/integration/targets/snap_alias/tasks/Fedora.yml delete mode 120000 tests/integration/targets/snap_alias/tasks/RedHat.yml delete mode 100644 tests/integration/targets/snap_alias/tasks/default.yml delete mode 100644 tests/integration/targets/snap_alias/tasks/nothing.yml diff --git a/tests/integration/targets/snap/defaults/main.yml b/tests/integration/targets/setup_snap/defaults/main.yml similarity index 100% rename from tests/integration/targets/snap/defaults/main.yml rename to tests/integration/targets/setup_snap/defaults/main.yml diff --git a/tests/integration/targets/snap/handlers/main.yml b/tests/integration/targets/setup_snap/handlers/main.yml similarity index 100% rename from tests/integration/targets/snap/handlers/main.yml rename to tests/integration/targets/setup_snap/handlers/main.yml diff --git a/tests/integration/targets/setup_snap/meta/main.yml b/tests/integration/targets/setup_snap/meta/main.yml new file mode 100644 index 0000000000..0e51c36ebd --- /dev/null +++ b/tests/integration/targets/setup_snap/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - setup_pkg_mgr + - setup_epel diff --git a/tests/integration/targets/snap/tasks/Debian.yml b/tests/integration/targets/setup_snap/tasks/D-Fedora.yml similarity index 100% rename from tests/integration/targets/snap/tasks/Debian.yml rename to tests/integration/targets/setup_snap/tasks/D-Fedora.yml diff --git a/tests/integration/targets/setup_snap/tasks/D-RedHat-8.2.yml b/tests/integration/targets/setup_snap/tasks/D-RedHat-8.2.yml new file mode 120000 index 0000000000..0b06951496 --- /dev/null +++ b/tests/integration/targets/setup_snap/tasks/D-RedHat-8.2.yml @@ -0,0 +1 @@ +nothing.yml \ No newline at end of file diff --git a/tests/integration/targets/setup_snap/tasks/D-RedHat-8.3.yml b/tests/integration/targets/setup_snap/tasks/D-RedHat-8.3.yml new file mode 120000 index 0000000000..0b06951496 --- /dev/null +++ b/tests/integration/targets/setup_snap/tasks/D-RedHat-8.3.yml @@ -0,0 +1 @@ +nothing.yml \ No newline at end of file diff --git a/tests/integration/targets/snap_alias/tasks/Debian.yml b/tests/integration/targets/setup_snap/tasks/Debian.yml similarity index 100% rename from tests/integration/targets/snap_alias/tasks/Debian.yml rename to tests/integration/targets/setup_snap/tasks/Debian.yml diff --git a/tests/integration/targets/snap/tasks/RedHat.yml b/tests/integration/targets/setup_snap/tasks/RedHat.yml similarity index 100% rename from tests/integration/targets/snap/tasks/RedHat.yml rename to tests/integration/targets/setup_snap/tasks/RedHat.yml diff --git a/tests/integration/targets/snap/tasks/default.yml b/tests/integration/targets/setup_snap/tasks/default.yml similarity index 100% rename from tests/integration/targets/snap/tasks/default.yml rename to tests/integration/targets/setup_snap/tasks/default.yml diff --git a/tests/integration/targets/setup_snap/tasks/main.yml b/tests/integration/targets/setup_snap/tasks/main.yml new file mode 100644 index 0000000000..26e02ddc56 --- /dev/null +++ b/tests/integration/targets/setup_snap/tasks/main.yml @@ -0,0 +1,23 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +- name: Print information on which we distinguish + debug: + msg: "Distribution '{{ ansible_facts.distribution }}', version '{{ ansible_facts.distribution_version }}', OS family '{{ ansible_facts.os_family }}'" + +- name: Include distribution specific tasks + include_tasks: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "D-{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_version }}.yml" + - "D-{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml" + - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml" + - "D-{{ ansible_facts.distribution }}.yml" + - "{{ ansible_facts.os_family }}.yml" + - "nothing.yml" + paths: + - "{{ role_path }}/tasks" diff --git a/tests/integration/targets/snap/tasks/nothing.yml b/tests/integration/targets/setup_snap/tasks/nothing.yml similarity index 100% rename from tests/integration/targets/snap/tasks/nothing.yml rename to tests/integration/targets/setup_snap/tasks/nothing.yml diff --git a/tests/integration/targets/snap/aliases b/tests/integration/targets/snap/aliases index 69547e21e7..ee303bf346 100644 --- a/tests/integration/targets/snap/aliases +++ b/tests/integration/targets/snap/aliases @@ -4,4 +4,3 @@ skip/freebsd skip/osx skip/macos skip/docker -disabled # FIXME diff --git a/tests/integration/targets/snap/meta/main.yml b/tests/integration/targets/snap/meta/main.yml index 0e51c36ebd..6ee9a022c1 100644 --- a/tests/integration/targets/snap/meta/main.yml +++ b/tests/integration/targets/snap/meta/main.yml @@ -1,3 +1,2 @@ dependencies: - - setup_pkg_mgr - - setup_epel + - setup_snap diff --git a/tests/integration/targets/snap/tasks/Fedora.yml b/tests/integration/targets/snap/tasks/Fedora.yml deleted file mode 120000 index 0abaec1677..0000000000 --- a/tests/integration/targets/snap/tasks/Fedora.yml +++ /dev/null @@ -1 +0,0 @@ -default.yml \ No newline at end of file diff --git a/tests/integration/targets/snap/tasks/main.yml b/tests/integration/targets/snap/tasks/main.yml index 0f8c9b4c26..9ca431bafe 100644 --- a/tests/integration/targets/snap/tasks/main.yml +++ b/tests/integration/targets/snap/tasks/main.yml @@ -4,19 +4,6 @@ # and should not be used as examples of how to write Ansible roles # #################################################################### -- name: Include distribution specific tasks - include_tasks: "{{ lookup('first_found', params) }}" - vars: - params: - files: - - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml" - - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml" - - "{{ ansible_facts.distribution }}.yml" - - "{{ ansible_facts.os_family }}.yml" - - "nothing.yml" - paths: - - "{{ role_path }}/tasks" - - block: - name: Make sure package is not installed community.general.snap: diff --git a/tests/integration/targets/snap_alias/aliases b/tests/integration/targets/snap_alias/aliases index 69547e21e7..ee303bf346 100644 --- a/tests/integration/targets/snap_alias/aliases +++ b/tests/integration/targets/snap_alias/aliases @@ -4,4 +4,3 @@ skip/freebsd skip/osx skip/macos skip/docker -disabled # FIXME diff --git a/tests/integration/targets/snap_alias/defaults/main.yml b/tests/integration/targets/snap_alias/defaults/main.yml deleted file mode 100644 index 2290001f7e..0000000000 --- a/tests/integration/targets/snap_alias/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -has_snap: false - -snap_packages: - - snapd diff --git a/tests/integration/targets/snap_alias/handlers/main.yml b/tests/integration/targets/snap_alias/handlers/main.yml deleted file mode 100644 index a80cc98e49..0000000000 --- a/tests/integration/targets/snap_alias/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: Remove snapd - package: - name: "{{ snap_packages }}" - state: absent diff --git a/tests/integration/targets/snap_alias/meta/main.yml b/tests/integration/targets/snap_alias/meta/main.yml index 0e51c36ebd..6ee9a022c1 100644 --- a/tests/integration/targets/snap_alias/meta/main.yml +++ b/tests/integration/targets/snap_alias/meta/main.yml @@ -1,3 +1,2 @@ dependencies: - - setup_pkg_mgr - - setup_epel + - setup_snap diff --git a/tests/integration/targets/snap_alias/tasks/Fedora.yml b/tests/integration/targets/snap_alias/tasks/Fedora.yml deleted file mode 120000 index 0abaec1677..0000000000 --- a/tests/integration/targets/snap_alias/tasks/Fedora.yml +++ /dev/null @@ -1 +0,0 @@ -default.yml \ No newline at end of file diff --git a/tests/integration/targets/snap_alias/tasks/RedHat.yml b/tests/integration/targets/snap_alias/tasks/RedHat.yml deleted file mode 120000 index 0abaec1677..0000000000 --- a/tests/integration/targets/snap_alias/tasks/RedHat.yml +++ /dev/null @@ -1 +0,0 @@ -default.yml \ No newline at end of file diff --git a/tests/integration/targets/snap_alias/tasks/default.yml b/tests/integration/targets/snap_alias/tasks/default.yml deleted file mode 100644 index 938addc33a..0000000000 --- a/tests/integration/targets/snap_alias/tasks/default.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- name: Install snapd - package: - name: "{{ snap_packages }}" - state: present - notify: Remove snapd - -- name: Make sure that snapd is running - service: - name: snapd - state: started - -- name: Create link /snap - file: - src: /var/lib/snapd/snap - dest: /snap - state: link - -- name: Inform that snap is installed - set_fact: - has_snap: true diff --git a/tests/integration/targets/snap_alias/tasks/main.yml b/tests/integration/targets/snap_alias/tasks/main.yml index 2ed419bf57..81b7c3618a 100644 --- a/tests/integration/targets/snap_alias/tasks/main.yml +++ b/tests/integration/targets/snap_alias/tasks/main.yml @@ -4,19 +4,6 @@ # and should not be used as examples of how to write Ansible roles # #################################################################### -- name: Include distribution specific tasks - include_tasks: "{{ lookup('first_found', params) }}" - vars: - params: - files: - - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml" - - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml" - - "{{ ansible_facts.distribution }}.yml" - - "{{ ansible_facts.os_family }}.yml" - - "nothing.yml" - paths: - - "{{ role_path }}/tasks" - - name: Test include_tasks: test.yml when: has_snap diff --git a/tests/integration/targets/snap_alias/tasks/nothing.yml b/tests/integration/targets/snap_alias/tasks/nothing.yml deleted file mode 100644 index 11642d1fcd..0000000000 --- a/tests/integration/targets/snap_alias/tasks/nothing.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# Do nothing