mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Pacman: Improve url integrity test (#4968)
* Fix typo * Host url package * Delete cached files * Add cases for cached url package * Rename file_pkg for clarification * Change port to 8080, as 80 is already used in pipeline * Added fragment * Change port to 8000, as 8080 is already used in pipeline * Fixed changelog fragment * Change port to 53280, as 8000 is already used in pipeline * Change port to 27617 (copied from get_url), as 53280 is already used in pipeline * Also download the signature of url package Co-authored-by: Jean Raby <jean@raby.sh> * Fix duplication errors Co-authored-by: Jean Raby <jean@raby.sh> * Copied waiting from get_url; applyed output redirection from jraby * Fix signature filename * Use correct cache dir * Add missing assertions for uninstall_1c * Fix typo * Delete changelog fragment * Make python server true async with 90 sec timeout Copied from ainsible.builtin.get_url Co-authored-by: Jean Raby <jean@raby.sh>
This commit is contained in:
parent
be0e47bfdc
commit
76b235c6b3
1 changed files with 100 additions and 10 deletions
|
@ -1,9 +1,13 @@
|
||||||
---
|
---
|
||||||
- vars:
|
- vars:
|
||||||
|
http_port: 27617
|
||||||
reg_pkg: ed
|
reg_pkg: ed
|
||||||
url_pkg: lemon
|
url_pkg: lemon
|
||||||
|
url_pkg_filename: url.pkg.zst
|
||||||
|
url_pkg_path: '/tmp/'
|
||||||
|
url_pkg_url: 'http://localhost:{{http_port}}/{{url_pkg_filename}}'
|
||||||
file_pkg: hdparm
|
file_pkg: hdparm
|
||||||
file_pkg_path: /tmp/pkg.zst
|
file_pkg_path: /tmp/file.pkg.zst
|
||||||
extra_pkg: core/sdparm
|
extra_pkg: core/sdparm
|
||||||
extra_pkg_outfmt: sdparm
|
extra_pkg_outfmt: sdparm
|
||||||
block:
|
block:
|
||||||
|
@ -15,11 +19,33 @@
|
||||||
- '{{file_pkg}}'
|
- '{{file_pkg}}'
|
||||||
- '{{extra_pkg}}'
|
- '{{extra_pkg}}'
|
||||||
state: absent
|
state: absent
|
||||||
|
- name: Make sure that url package is not cached
|
||||||
|
file:
|
||||||
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Get URL for {{url_pkg}}
|
- name: Get URL for {{url_pkg}}
|
||||||
command:
|
command:
|
||||||
cmd: pacman --sync --print-format "%l" {{url_pkg}}
|
cmd: pacman --sync --print-format "%l" {{url_pkg}}
|
||||||
register: url_pkg_url
|
register: url_pkg_stdout
|
||||||
|
- name: Download {{url_pkg}} pkg
|
||||||
|
get_url:
|
||||||
|
url: '{{url_pkg_stdout.stdout}}'
|
||||||
|
dest: '{{url_pkg_path}}/{{url_pkg_filename}}'
|
||||||
|
- name: Download {{url_pkg}} pkg sig
|
||||||
|
get_url:
|
||||||
|
url: '{{url_pkg_stdout.stdout}}.sig'
|
||||||
|
dest: '{{url_pkg_path}}/{{url_pkg_filename}}.sig'
|
||||||
|
- name: Host {{url_pkg}}
|
||||||
|
shell:
|
||||||
|
cmd: 'python -m http.server --directory {{url_pkg_path}} {{http_port}} >/dev/null 2>&1'
|
||||||
|
async: 90
|
||||||
|
poll: 0
|
||||||
|
- name: Wait for http.server to come up online
|
||||||
|
wait_for:
|
||||||
|
host: 'localhost'
|
||||||
|
port: '{{http_port}}'
|
||||||
|
state: started
|
||||||
|
|
||||||
- name: Get URL for {{file_pkg}}
|
- name: Get URL for {{file_pkg}}
|
||||||
command:
|
command:
|
||||||
|
@ -34,26 +60,50 @@
|
||||||
pacman:
|
pacman:
|
||||||
name:
|
name:
|
||||||
- '{{reg_pkg}}'
|
- '{{reg_pkg}}'
|
||||||
- '{{url_pkg_url.stdout}}'
|
- '{{url_pkg_url}}'
|
||||||
- '{{file_pkg_path}}'
|
- '{{file_pkg_path}}'
|
||||||
check_mode: True
|
check_mode: True
|
||||||
register: install_1
|
register: install_1
|
||||||
|
|
||||||
|
- name: Install packages from url (check mode, cached)
|
||||||
|
pacman:
|
||||||
|
name:
|
||||||
|
- '{{url_pkg_url}}'
|
||||||
|
check_mode: True
|
||||||
|
register: install_1c
|
||||||
|
- name: Delete cached {{url_pkg}}
|
||||||
|
file:
|
||||||
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Install packages from mixed sources
|
- name: Install packages from mixed sources
|
||||||
pacman:
|
pacman:
|
||||||
name:
|
name:
|
||||||
- '{{reg_pkg}}'
|
- '{{reg_pkg}}'
|
||||||
- '{{url_pkg_url.stdout}}'
|
- '{{url_pkg_url}}'
|
||||||
- '{{file_pkg_path}}'
|
- '{{file_pkg_path}}'
|
||||||
register: install_2
|
register: install_2
|
||||||
|
- name: Delete cached {{url_pkg}}
|
||||||
|
file:
|
||||||
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Install packages from mixed sources - (idempotency)
|
- name: Install packages from mixed sources - (idempotency)
|
||||||
pacman:
|
pacman:
|
||||||
name:
|
name:
|
||||||
- '{{reg_pkg}}'
|
- '{{reg_pkg}}'
|
||||||
- '{{url_pkg_url.stdout}}'
|
- '{{url_pkg_url}}'
|
||||||
- '{{file_pkg_path}}'
|
- '{{file_pkg_path}}'
|
||||||
register: install_3
|
register: install_3
|
||||||
|
- name: Install packages from url - (idempotency, cached)
|
||||||
|
pacman:
|
||||||
|
name:
|
||||||
|
- '{{url_pkg_url}}'
|
||||||
|
register: install_3c
|
||||||
|
- name: Delete cached {{url_pkg}}
|
||||||
|
file:
|
||||||
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Install packages with their regular names (idempotency)
|
- name: Install packages with their regular names (idempotency)
|
||||||
pacman:
|
pacman:
|
||||||
|
@ -62,54 +112,89 @@
|
||||||
- '{{url_pkg}}'
|
- '{{url_pkg}}'
|
||||||
- '{{file_pkg}}'
|
- '{{file_pkg}}'
|
||||||
register: install_4
|
register: install_4
|
||||||
|
- name: Delete cached {{url_pkg}}
|
||||||
|
file:
|
||||||
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Install new package with already installed packages from mixed sources
|
- name: Install new package with already installed packages from mixed sources
|
||||||
pacman:
|
pacman:
|
||||||
name:
|
name:
|
||||||
- '{{reg_pkg}}'
|
- '{{reg_pkg}}'
|
||||||
- '{{url_pkg_url.stdout}}'
|
- '{{url_pkg_url}}'
|
||||||
- '{{file_pkg_path}}'
|
- '{{file_pkg_path}}'
|
||||||
- '{{extra_pkg}}'
|
- '{{extra_pkg}}'
|
||||||
register: install_5
|
register: install_5
|
||||||
|
- name: Delete cached {{url_pkg}}
|
||||||
|
file:
|
||||||
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Uninstall packages - mixed sources (check mode)
|
- name: Uninstall packages - mixed sources (check mode)
|
||||||
pacman:
|
pacman:
|
||||||
state: absent
|
state: absent
|
||||||
name:
|
name:
|
||||||
- '{{reg_pkg}}'
|
- '{{reg_pkg}}'
|
||||||
- '{{url_pkg_url.stdout}}'
|
- '{{url_pkg_url}}'
|
||||||
- '{{file_pkg_path}}'
|
- '{{file_pkg_path}}'
|
||||||
check_mode: True
|
check_mode: True
|
||||||
register: uninstall_1
|
register: uninstall_1
|
||||||
|
- name: Uninstall packages - url (check mode, cached)
|
||||||
|
pacman:
|
||||||
|
state: absent
|
||||||
|
name:
|
||||||
|
- '{{url_pkg_url}}'
|
||||||
|
check_mode: True
|
||||||
|
register: uninstall_1c
|
||||||
|
- name: Delete cached {{url_pkg}}
|
||||||
|
file:
|
||||||
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Uninstall packages - mixed sources
|
- name: Uninstall packages - mixed sources
|
||||||
pacman:
|
pacman:
|
||||||
state: absent
|
state: absent
|
||||||
name:
|
name:
|
||||||
- '{{reg_pkg}}'
|
- '{{reg_pkg}}'
|
||||||
- '{{url_pkg_url.stdout}}'
|
- '{{url_pkg_url}}'
|
||||||
- '{{file_pkg_path}}'
|
- '{{file_pkg_path}}'
|
||||||
register: uninstall_2
|
register: uninstall_2
|
||||||
|
- name: Delete cached {{url_pkg}}
|
||||||
|
file:
|
||||||
|
path: '/var/cache/pacman/pkg/{{url_pkg_filename}}'
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Uninstall packages - mixed sources (idempotency)
|
- name: Uninstall packages - mixed sources (idempotency)
|
||||||
pacman:
|
pacman:
|
||||||
state: absent
|
state: absent
|
||||||
name:
|
name:
|
||||||
- '{{reg_pkg}}'
|
- '{{reg_pkg}}'
|
||||||
- '{{url_pkg_url.stdout}}'
|
- '{{url_pkg_url}}'
|
||||||
- '{{file_pkg_path}}'
|
- '{{file_pkg_path}}'
|
||||||
register: uninstall_3
|
register: uninstall_3
|
||||||
|
|
||||||
|
- name: Uninstall package - url (idempotency, cached)
|
||||||
|
pacman:
|
||||||
|
state: absent
|
||||||
|
name:
|
||||||
|
- '{{url_pkg_url}}'
|
||||||
|
register: uninstall_3c
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- install_1 is changed
|
- install_1 is changed
|
||||||
- install_1.msg == 'Would have installed 3 packages'
|
- install_1.msg == 'Would have installed 3 packages'
|
||||||
- install_1.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
|
- install_1.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
|
||||||
|
- install_1c is changed
|
||||||
|
- install_1c.msg == 'Would have installed 1 packages'
|
||||||
|
- install_1c.packages|sort() == [url_pkg]
|
||||||
- install_2 is changed
|
- install_2 is changed
|
||||||
- install_2.msg == 'Installed 3 package(s)'
|
- install_2.msg == 'Installed 3 package(s)'
|
||||||
- install_1.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
|
- install_2.packages|sort() == [reg_pkg, url_pkg, file_pkg]|sort()
|
||||||
- install_3 is not changed
|
- install_3 is not changed
|
||||||
- install_3.msg == 'package(s) already installed'
|
- install_3.msg == 'package(s) already installed'
|
||||||
|
- install_3c is not changed
|
||||||
|
- install_3c.msg == 'package(s) already installed'
|
||||||
- install_4 is not changed
|
- install_4 is not changed
|
||||||
- install_4.msg == 'package(s) already installed'
|
- install_4.msg == 'package(s) already installed'
|
||||||
- install_5 is changed
|
- install_5 is changed
|
||||||
|
@ -118,8 +203,13 @@
|
||||||
- uninstall_1 is changed
|
- uninstall_1 is changed
|
||||||
- uninstall_1.msg == 'Would have removed 3 packages'
|
- uninstall_1.msg == 'Would have removed 3 packages'
|
||||||
- uninstall_1.packages | length() == 3 # pkgs have versions here
|
- uninstall_1.packages | length() == 3 # pkgs have versions here
|
||||||
|
- uninstall_1c is changed
|
||||||
|
- uninstall_1c.msg == 'Would have removed 1 packages'
|
||||||
|
- uninstall_1c.packages | length() == 1 # pkgs have versions here
|
||||||
- uninstall_2 is changed
|
- uninstall_2 is changed
|
||||||
- uninstall_2.msg == 'Removed 3 package(s)'
|
- uninstall_2.msg == 'Removed 3 package(s)'
|
||||||
- uninstall_2.packages | length() == 3
|
- uninstall_2.packages | length() == 3
|
||||||
- uninstall_3 is not changed
|
- uninstall_3 is not changed
|
||||||
- uninstall_3.msg == 'package(s) already absent'
|
- uninstall_3.msg == 'package(s) already absent'
|
||||||
|
- uninstall_3c is not changed
|
||||||
|
- uninstall_3c.msg == 'package(s) already absent'
|
||||||
|
|
Loading…
Reference in a new issue