flatpak: add tests in CI, add no_dependencies parameter (#2751)

* Similar version restrictions than flatpak_remote tests.

* ...

* Try to work around missing dependencies.

* Revert "Try to work around missing dependencies."

This reverts commit 66a4e38566.

* Add changelog.

* App8 -> App2; make sure that there are two apps App1 and App2.

* Fix forgotten variabe.

* Remove test notices.

* Seems like flatpak no longer supports file:// URLs.

The tests would need to be rewritten to offer the URL via http:// instead.

* Try local HTTP server for URL tests.

* ...

* Lint, add status check.

* Add boilerplate.

* Add 'ps aux'.

* Surrender to -f.

* Work around apparent flatpak bug.

* Fix YAML.

* Improve condition.

* Make sure test reruns behave better.
This commit is contained in:
Felix Fontein 2021-06-08 08:46:20 +02:00 committed by GitHub
parent 94a53adff1
commit bb37b67166
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 255 additions and 140 deletions

View file

@ -4,8 +4,8 @@
- name: Test addition of absent flatpak (check mode)
flatpak:
name: org.gnome.Characters
remote: flathub
name: com.dummy.App1
remote: dummy-remote
state: present
register: addition_result
check_mode: true
@ -18,8 +18,8 @@
- name: Test non-existent idempotency of addition of absent flatpak (check mode)
flatpak:
name: org.gnome.Characters
remote: flathub
name: com.dummy.App1
remote: dummy-remote
state: present
register: double_addition_result
check_mode: true
@ -36,7 +36,7 @@
- name: Test removal of absent flatpak check mode
flatpak:
name: org.gnome.Characters
name: com.dummy.App1
state: absent
register: removal_result
check_mode: true
@ -51,8 +51,8 @@
- name: Test addition of absent flatpak with url (check mode)
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Characters.flatpakref
remote: flathub
name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
remote: dummy-remote
state: present
register: url_addition_result
check_mode: true
@ -65,8 +65,8 @@
- name: Test non-existent idempotency of addition of absent flatpak with url (check mode)
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Characters.flatpakref
remote: flathub
name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
remote: dummy-remote
state: present
register: double_url_addition_result
check_mode: true
@ -85,7 +85,7 @@
- name: Test removal of absent flatpak with url not doing anything (check mode)
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Characters.flatpakref
name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
state: absent
register: url_removal_result
check_mode: true
@ -96,15 +96,14 @@
- url_removal_result is not changed
msg: "Removing an absent flatpak shall mark module execution as not changed"
# - Tests with present flatpak -------------------------------------------------
# state=present on present flatpak
- name: Test addition of present flatpak (check mode)
flatpak:
name: org.gnome.Calculator
remote: flathub
name: com.dummy.App2
remote: dummy-remote
state: present
register: addition_present_result
check_mode: true
@ -119,7 +118,7 @@
- name: Test removal of present flatpak (check mode)
flatpak:
name: org.gnome.Calculator
name: com.dummy.App2
state: absent
register: removal_present_result
check_mode: true
@ -132,7 +131,7 @@
- name: Test non-existent idempotency of removal (check mode)
flatpak:
name: org.gnome.Calculator
name: com.dummy.App2
state: absent
register: double_removal_present_result
check_mode: true
@ -149,8 +148,8 @@
- name: Test addition with url of present flatpak (check mode)
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Calculator.flatpakref
remote: flathub
name: http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
remote: dummy-remote
state: present
register: url_addition_present_result
check_mode: true
@ -165,7 +164,7 @@
- name: Test removal with url of present flatpak (check mode)
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Calculator.flatpakref
name: http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
state: absent
register: url_removal_present_result
check_mode: true
@ -178,8 +177,8 @@
- name: Test non-existent idempotency of removal with url of present flatpak (check mode)
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Calculator.flatpakref
remote: flathub
name: http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
remote: dummy-remote
state: absent
register: double_url_removal_present_result
check_mode: true

View file

@ -30,8 +30,8 @@
- name: Test executable override
flatpak:
name: org.gnome.Characters
remote: flathub
name: com.dummy.App1
remote: dummy-remote
state: present
executable: nothing-that-exists
ignore_errors: true
@ -57,5 +57,20 @@
vars:
method: system
always:
- name: Check HTTP server status
async_status:
jid: "{{ webserver_status.ansible_job_id }}"
ignore_errors: true
- name: List processes
command: ps aux
- name: Stop HTTP server
command: >-
pkill -f -- '{{ remote_tmp_dir }}/serve.py'
when: |
ansible_distribution in ('Fedora', 'Ubuntu')
ansible_distribution == 'Fedora' or
ansible_distribution == 'Ubuntu' and not ansible_distribution_major_version | int < 16

View file

@ -4,32 +4,58 @@
state: present
become: true
when: ansible_distribution == 'Fedora'
- block:
- name: Activate flatpak ppa on Ubuntu
apt_repository:
repo: ppa:alexlarsson/flatpak
state: present
mode: '0644'
when: ansible_lsb.major_release | int < 18
- name: Install flatpak package on Ubuntu
apt:
name: flatpak
state: present
become: true
when: ansible_distribution == 'Ubuntu'
- name: Enable flathub for user
- name: Install dummy remote for user
flatpak_remote:
name: flathub
name: dummy-remote
state: present
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo
method: user
- name: Enable flathub for system
- name: Install dummy remote for system
flatpak_remote:
name: flathub
name: dummy-remote
state: present
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
flatpakrepo_url: /tmp/flatpak/repo/dummy-repo.flatpakrepo
method: system
- name: Remove (if necessary) flatpak for testing check mode on absent flatpak
flatpak:
name: com.dummy.App1
remote: dummy-remote
state: absent
no_dependencies: true
- name: Add flatpak for testing check mode on present flatpak
flatpak:
name: org.gnome.Calculator
remote: flathub
name: com.dummy.App2
remote: dummy-remote
state: present
no_dependencies: true
- name: Copy HTTP server
copy:
src: serve.py
dest: '{{ remote_tmp_dir }}/serve.py'
mode: '0755'
- name: Start HTTP server
command: '{{ remote_tmp_dir }}/serve.py 127.0.0.1 8000 /tmp/flatpak/'
async: 120
poll: 0
register: webserver_status

View file

@ -2,10 +2,11 @@
- name: Test addition - {{ method }}
flatpak:
name: org.gnome.Characters
remote: flathub
name: com.dummy.App1
remote: dummy-remote
state: present
method: "{{ method }}"
no_dependencies: true
register: addition_result
- name: Verify addition test result - {{ method }}
@ -16,10 +17,11 @@
- name: Test idempotency of addition - {{ method }}
flatpak:
name: org.gnome.Characters
remote: flathub
name: com.dummy.App1
remote: dummy-remote
state: present
method: "{{ method }}"
no_dependencies: true
register: double_addition_result
- name: Verify idempotency of addition test result - {{ method }}
@ -32,9 +34,10 @@
- name: Test removal - {{ method }}
flatpak:
name: org.gnome.Characters
name: com.dummy.App1
state: absent
method: "{{ method }}"
no_dependencies: true
register: removal_result
- name: Verify removal test result - {{ method }}
@ -45,9 +48,10 @@
- name: Test idempotency of removal - {{ method }}
flatpak:
name: org.gnome.Characters
name: com.dummy.App1
state: absent
method: "{{ method }}"
no_dependencies: true
register: double_removal_result
- name: Verify idempotency of removal test result - {{ method }}
@ -60,10 +64,11 @@
- name: Test addition with url - {{ method }}
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Characters.flatpakref
remote: flathub
name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
remote: dummy-remote
state: present
method: "{{ method }}"
no_dependencies: true
register: url_addition_result
- name: Verify addition test result - {{ method }}
@ -74,10 +79,11 @@
- name: Test idempotency of addition with url - {{ method }}
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Characters.flatpakref
remote: flathub
name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
remote: dummy-remote
state: present
method: "{{ method }}"
no_dependencies: true
register: double_url_addition_result
- name: Verify idempotency of addition with url test result - {{ method }}
@ -90,26 +96,46 @@
- name: Test removal with url - {{ method }}
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Characters.flatpakref
name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
state: absent
method: "{{ method }}"
no_dependencies: true
register: url_removal_result
ignore_errors: true
- name: Verify removal test result - {{ method }}
- name: Verify removal test result failed - {{ method }}
# It looks like flatpak has a bug when the hostname contains a port. If this is the case, it emits
# the following message, which we check for. If another error happens, we fail.
# Upstream issue: https://github.com/flatpak/flatpak/issues/4307
# (The second message happens with Ubuntu 18.04.)
assert:
that:
- url_removal_result is changed
msg: "state=absent with url as name shall remove flatpak when present"
- >-
url_removal_result.msg in [
"error: Invalid branch 127.0.0.1:8000: Branch can't contain :",
"error: Invalid id http:: Name can't contain :",
]
when: url_removal_result is failed
- name: Test idempotency of removal with url - {{ method }}
flatpak:
name: https://flathub.org/repo/appstream/org.gnome.Characters.flatpakref
state: absent
method: "{{ method }}"
register: double_url_removal_result
- when: url_removal_result is not failed
block:
- name: Verify idempotency of removal with url test result - {{ method }}
assert:
that:
- double_url_removal_result is not changed
msg: "state=absent with url as name shall not do anything when flatpak is not present"
- name: Verify removal test result - {{ method }}
assert:
that:
- url_removal_result is changed
msg: "state=absent with url as name shall remove flatpak when present"
- name: Test idempotency of removal with url - {{ method }}
flatpak:
name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
state: absent
method: "{{ method }}"
no_dependencies: true
register: double_url_removal_result
- name: Verify idempotency of removal with url test result - {{ method }}
assert:
that:
- double_url_removal_result is not changed
msg: "state=absent with url as name shall not do anything when flatpak is not present"