diff options
author | Alexander Bethke <oolongbrothers@zeibar.net> | 2019-03-20 01:16:26 +0100 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2019-03-19 17:16:26 -0700 |
commit | 8f354ea307078b58b8cdf3734c79c58c59dee9a6 (patch) | |
tree | fb00e9c5716286bc6da8e05593b1aa9dec43e8f0 | |
parent | a4cdf0d6980adef1d87c18fe758812628d8eb636 (diff) | |
download | ansible-8f354ea307078b58b8cdf3734c79c58c59dee9a6.tar.gz |
Use local dummy repo for flatpak_remote integration tests (#52668)
* Use local dummy repo for flatpak_remote integration tests
* Excludes versions of Ubuntu older than 16.04 from tests
Since there are no flatpak packages available for these Ubuntu versions
* Adds handler that removes temporary symlink
11 files changed, 182 insertions, 14 deletions
diff --git a/test/integration/targets/flatpak_remote/aliases b/test/integration/targets/flatpak_remote/aliases index 094c5aa7ac..743bcb6e72 100644 --- a/test/integration/targets/flatpak_remote/aliases +++ b/test/integration/targets/flatpak_remote/aliases @@ -1,7 +1,6 @@ -unsupported +shippable/posix/group3 destructive skip/freebsd skip/osx skip/rhel needs/root -needs/privileged diff --git a/test/integration/targets/flatpak_remote/meta/main.yml b/test/integration/targets/flatpak_remote/meta/main.yml index 07faa21776..314f77eba9 100644 --- a/test/integration/targets/flatpak_remote/meta/main.yml +++ b/test/integration/targets/flatpak_remote/meta/main.yml @@ -1,2 +1,3 @@ dependencies: - prepare_tests + - setup_flatpak_remote diff --git a/test/integration/targets/flatpak_remote/tasks/check_mode.yml b/test/integration/targets/flatpak_remote/tasks/check_mode.yml index 4185432586..7ce89a8c15 100644 --- a/test/integration/targets/flatpak_remote/tasks/check_mode.yml +++ b/test/integration/targets/flatpak_remote/tasks/check_mode.yml @@ -5,7 +5,7 @@ - name: Test addition of absent flatpak remote (check mode) flatpak_remote: name: flatpak-test - flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo + flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo state: present register: addition_result check_mode: true @@ -19,7 +19,7 @@ - name: Test non-existent idempotency of addition of absent flatpak remote (check mode) flatpak_remote: name: flatpak-test - flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo + flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo state: present register: double_addition_result check_mode: true @@ -57,7 +57,7 @@ - name: Test addition of present flatpak remote (check mode) flatpak_remote: name: check-mode-test-remote - flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo + flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo state: present register: addition_result check_mode: true diff --git a/test/integration/targets/flatpak_remote/tasks/main.yml b/test/integration/targets/flatpak_remote/tasks/main.yml index daa7d8cd17..9c3ec6d798 100644 --- a/test/integration/targets/flatpak_remote/tasks/main.yml +++ b/test/integration/targets/flatpak_remote/tasks/main.yml @@ -24,9 +24,9 @@ # executable override - name: Test executable override - flatpak: - name: org.gnome.Characters - remote: flathub + flatpak_remote: + name: irrelevant + remote: irrelevant state: present executable: nothing-that-exists ignore_errors: true @@ -53,4 +53,5 @@ method: system when: | - ansible_distribution in ('Fedora', 'Ubuntu') + ansible_distribution == 'Fedora' or + ansible_distribution == 'Ubuntu' and not ansible_distribution_major_version | int < 16 diff --git a/test/integration/targets/flatpak_remote/tasks/setup.yml b/test/integration/targets/flatpak_remote/tasks/setup.yml index b9c34c50b1..b2fd276604 100644 --- a/test/integration/targets/flatpak_remote/tasks/setup.yml +++ b/test/integration/targets/flatpak_remote/tasks/setup.yml @@ -6,11 +6,12 @@ when: ansible_distribution == 'Fedora' - block: - - name: Activate flatpak ppa on Ubuntu + - name: Activate flatpak ppa on Ubuntu versions older than 18.04/bionic apt_repository: repo: "ppa:alexlarsson/flatpak" state: present mode: 0644 + when: ansible_lsb.major_release | int < 18 - name: Install flatpak package on Ubuntu apt: @@ -19,8 +20,8 @@ when: ansible_distribution == 'Ubuntu' -- name: Install flatpak_remote for testing check mode +- name: Install flatpak remote for testing check mode flatpak_remote: name: check-mode-test-remote - flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo + flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo state: present diff --git a/test/integration/targets/flatpak_remote/tasks/test.yml b/test/integration/targets/flatpak_remote/tasks/test.yml index bf386c18fe..97a13f0cbd 100644 --- a/test/integration/targets/flatpak_remote/tasks/test.yml +++ b/test/integration/targets/flatpak_remote/tasks/test.yml @@ -3,7 +3,7 @@ - name: Test addition - {{ method }} flatpak_remote: name: flatpak-test - flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo + flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo state: present method: "{{ method }}" register: addition_result @@ -17,7 +17,7 @@ - name: Test idempotency of addition - {{ method }} flatpak_remote: name: flatpak-test - flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo + flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo state: present method: "{{ method }}" register: double_addition_result diff --git a/test/integration/targets/setup_flatpak_remote/README.md b/test/integration/targets/setup_flatpak_remote/README.md new file mode 100644 index 0000000000..d7916c14b3 --- /dev/null +++ b/test/integration/targets/setup_flatpak_remote/README.md @@ -0,0 +1,138 @@ +# Create a dummy flatpak repository remote + +This document describes how to create a local flatpak dummy repo. Just like the one contained in the `files/repo.tar.gxz` archive. + + +## Create a hello world app + +Prerequisites: + + - flathub + +Prepare the environment: + +``` +flatpak install --system flathub org.freedesktop.Platform//1.6 org.freedesktop.Sdk//1.6 +``` + +Create a hello world executable: + +``` +echo $'#!/bin/sh\necho hello world' > hello.sh +``` + +To create dummy flatpaks, run this (defining a unique NUM for every flatpak to add): + +``` +export NUM=1 +flatpak build-init appdir$NUM com.dummy.App$NUM org.freedesktop.Sdk org.freedesktop.Platform 1.6; +flatpak build appdir$NUM mkdir /app/bin; +flatpak build appdir$NUM install --mode=750 hello.sh /app/bin; +flatpak build-finish --command=hello.sh appdir$NUM +``` + +## Create a repo and/or add the app to it + +Create a repo and add the file to it in one command: + +``` +flatpak build-export repo appdir$NUM stable +``` + +## Create flatpak*-files + +Put a flatpakref file under the repo folder (`repo/com.dummy.App1.flatpakref`): + +``` +[Flatpak Ref] +Title=Dummy App$NUM +Name=com.dummy.App$NUM +Branch=stable +Url=file:///tmp/flatpak/repo +GPGKey={{ base64-encoded public KEY }} +IsRuntime=false +RuntimeRepo=https://flathub.org/repo/flathub.flatpakrepo +``` + +Add a `.flatpakrepo` file to the `repo` folder (`repo/dummy-repo.flatpakrepo`): + +``` +[Flatpak Repo] +Title=Dummy Repo +Url=file:///tmp/flatpak/repo +Comment=Dummy repo for ansible module integration testing +Description=Dummy repo for ansible module integration testing +GPGKey={{ base64-encoded public KEY }} +``` + +## Sign the repo + +Create a new key in a new gpg home folder (On RedHat systems, the executable needs to addressed as gpg2): + +``` +mkdir gpg +gpg --homedir gpg --quick-gen-key test@dummy.com +``` + +Sign the repo and summary file, you need to redo this when you update the repository: + +``` +flatpak build-sign repo --gpg-sign=KEY_ID --gpg-homedir=gpg +flatpak build-update-repo repo --gpg-sign=KEY_ID --gpg-homedir=gpg +``` + +Export the public key as a file: + +``` +gpg --homedir=gpg --export KEY_ID > dummy-repo.gpg +``` + +Create base64-encoded string from gpg-file for `GPGKey=` property in flatpak*-files: + +``` +base64 dummy-repo.gpg | tr -d '\n' +``` + +## How to use the repo + +Now you can add the `repo` folder as a local repo: + +``` +flatpak --system remote-add --gpg-import=/tmp/flatpak/repo/dummy-repo.gpg dummy-repo /tmp/flatpak/repo +``` + +Or, via `.flatpakrepo` file: + +``` +flatpak --system remote-add dummy-repo /tmp/flatpak/repo/dummy-repo.flatpakrepo +``` + +And install the hello world flatpaks like this: + +``` +flatpak --system install dummy-repo com.dummy.App$NUM +``` + +Or from flatpakref: + +``` +flatpak --system install --from /tmp/flatpak/repo/com.dummy.App$NUM.flatpakref +``` + +Run the app: + +``` +flatpak run com.dummy.App$NUM +``` + +To install an app without any runtime dependencies (the app will be broken, but it is enough to test flatpak installation): + +``` +flatpak --system install --no-deps dummy-repo com.dummy.App$NUM +``` + +## Sources: + +* https://blogs.gnome.org/alexl/2017/02/10/maintaining-a-flatpak-repository/ + +* http://docs.flatpak.org/en/latest/first-build.html diff --git a/test/integration/targets/setup_flatpak_remote/files/repo.tar.xz b/test/integration/targets/setup_flatpak_remote/files/repo.tar.xz Binary files differnew file mode 100644 index 0000000000..41a89c46ef --- /dev/null +++ b/test/integration/targets/setup_flatpak_remote/files/repo.tar.xz diff --git a/test/integration/targets/setup_flatpak_remote/handlers/main.yaml b/test/integration/targets/setup_flatpak_remote/handlers/main.yaml new file mode 100644 index 0000000000..9380dee96b --- /dev/null +++ b/test/integration/targets/setup_flatpak_remote/handlers/main.yaml @@ -0,0 +1,4 @@ +- name: remove temporary flatpak link + file: + state: absent + path: /tmp/flatpak diff --git a/test/integration/targets/setup_flatpak_remote/meta/main.yaml b/test/integration/targets/setup_flatpak_remote/meta/main.yaml new file mode 100644 index 0000000000..75ee4583ac --- /dev/null +++ b/test/integration/targets/setup_flatpak_remote/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - setup_remote_tmp_dir diff --git a/test/integration/targets/setup_flatpak_remote/tasks/main.yaml b/test/integration/targets/setup_flatpak_remote/tasks/main.yaml new file mode 100644 index 0000000000..c199d216fa --- /dev/null +++ b/test/integration/targets/setup_flatpak_remote/tasks/main.yaml @@ -0,0 +1,22 @@ +- name: Set up dummy flatpak repository remote + block: + + - name: Copy repo into place + unarchive: + src: repo.tar.xz + dest: "{{ remote_tmp_dir }}" + owner: root + group: root + mode: 0644 + + - name: Create deterministic link to temp directory + file: + state: link + src: "{{ remote_tmp_dir }}/" + path: "/tmp/flatpak" + owner: root + group: root + mode: 0644 + notify: remove temporary flatpak link + + become: true |