diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:16:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:16:49 +0000 |
commit | 48e387c5c12026a567eb7b293a3a590241c0cecb (patch) | |
tree | 80f2573be2d7d534b8ac4d2a852fe43f7ac35324 /test/integration/targets/ansible-galaxy-collection | |
parent | Releasing progress-linux version 2.16.6-1~progress7.99u1. (diff) | |
download | ansible-core-48e387c5c12026a567eb7b293a3a590241c0cecb.tar.xz ansible-core-48e387c5c12026a567eb7b293a3a590241c0cecb.zip |
Merging upstream version 2.17.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/ansible-galaxy-collection')
10 files changed, 119 insertions, 10 deletions
diff --git a/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py b/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py index 6182e86..25fb5dd 100644 --- a/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py +++ b/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py @@ -3,8 +3,7 @@ # Copyright: (c) 2020, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations import hashlib import io @@ -12,6 +11,7 @@ import json import os import sys import tarfile +from ansible.module_utils.common.file import S_IRWXU_RXG_RXO manifest = { 'collection_info': { @@ -47,7 +47,7 @@ files = { def add_file(tar_file, filename, b_content, update_files=True): tar_info = tarfile.TarInfo(filename) tar_info.size = len(b_content) - tar_info.mode = 0o0755 + tar_info.mode = S_IRWXU_RXG_RXO tar_file.addfile(tarinfo=tar_info, fileobj=io.BytesIO(b_content)) if update_files: diff --git a/test/integration/targets/ansible-galaxy-collection/files/test_module.py b/test/integration/targets/ansible-galaxy-collection/files/test_module.py index d7e4814..d4bb3c3 100644 --- a/test/integration/targets/ansible-galaxy-collection/files/test_module.py +++ b/test/integration/targets/ansible-galaxy-collection/files/test_module.py @@ -4,8 +4,7 @@ # (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import absolute_import, division, print_function -__metaclass__ = type +from __future__ import annotations DOCUMENTATION = ''' diff --git a/test/integration/targets/ansible-galaxy-collection/handlers/main.yml b/test/integration/targets/ansible-galaxy-collection/handlers/main.yml new file mode 100644 index 0000000..d58a516 --- /dev/null +++ b/test/integration/targets/ansible-galaxy-collection/handlers/main.yml @@ -0,0 +1,7 @@ +- name: uninstall gpg + command: brew uninstall gpg + become: yes + become_user: >- + {{ brew_stat.stat.pw_name }} + environment: + HOMEBREW_NO_AUTO_UPDATE: True diff --git a/test/integration/targets/ansible-galaxy-collection/library/reset_pulp.py b/test/integration/targets/ansible-galaxy-collection/library/reset_pulp.py index c1f5e1d..90397a5 100644 --- a/test/integration/targets/ansible-galaxy-collection/library/reset_pulp.py +++ b/test/integration/targets/ansible-galaxy-collection/library/reset_pulp.py @@ -3,8 +3,7 @@ # Copyright: (c) 2020, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations DOCUMENTATION = ''' --- diff --git a/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py b/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py index 423edd9..b7d262a 100644 --- a/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py +++ b/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py @@ -3,8 +3,7 @@ # Copyright: (c) 2020, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type +from __future__ import annotations ANSIBLE_METADATA = { 'metadata_version': '1.1', diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/download.yml b/test/integration/targets/ansible-galaxy-collection/tasks/download.yml index a554c27..8a2fa56 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/download.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/download.yml @@ -170,6 +170,33 @@ - '"Downloading collection ''ansible_test.my_collection:1.0.0'' to" in download_collection.stdout' - download_collection_actual.stat.exists +- block: + - name: create skeleton collection for trailing slash test + command: ansible-galaxy collection init trailing_dir.name --init-path "{{ galaxy_dir }}" + + - name: install collection with directory source and trailing slash - {{ test_id }} + command: ansible-galaxy collection download '{{ galaxy_dir }}/trailing_dir/name/' {{ galaxy_verbosity }} + args: + chdir: '{{ galaxy_dir }}/download' + register: download_dir_slash + + - name: get result of install collections with with trailing slash - {{ test_id }} + stat: + path: '{{ galaxy_dir }}/download/collections/trailing_dir-name-1.0.0.tar.gz' + register: download_dir_slash_actual + + - name: assert install collections with with trailing slash - {{ test_id }} + assert: + that: + - '"Downloading collection ''trailing_dir.name:1.0.0'' to" in download_dir_slash.stdout' + - download_dir_slash_actual.stat.exists + + always: + - name: remove trailing dir skeleton + file: + path: '{{ galaxy_dir }}/trailing_dir' + state: absent + - name: remove test download dir file: path: '{{ galaxy_dir }}/download' diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/init.yml b/test/integration/targets/ansible-galaxy-collection/tasks/init.yml index 46198fe..6a00553 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/init.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/init.yml @@ -128,11 +128,18 @@ - link: custom_skeleton/galaxy.yml source: galaxy.yml + - name: create j2 file + copy: + dest: "{{ galaxy_dir }}/scratch/skeleton/custom_skeleton/README.j2" + content: !unsafe | + Requires ansible-core >={{ min_ansible_version }} + - name: initialize a collection using the skeleton - command: ansible-galaxy collection init ansible_test.my_collection {{ init_path }} {{ skeleton }} + command: ansible-galaxy collection init ansible_test.my_collection {{ init_path }} {{ skeleton }} {{ extra }} vars: init_path: '--init-path {{ galaxy_dir }}/scratch/skeleton' skeleton: '--collection-skeleton {{ galaxy_dir }}/scratch/skeleton/custom_skeleton' + extra: '-e min_ansible_version="2.17"' - name: stat expected collection contents stat: @@ -143,6 +150,7 @@ - plugins/inventory - galaxy.yml - plugins/inventory/foo.py + - README - assert: that: @@ -150,7 +158,18 @@ - stat_result.results[1].stat.islnk - stat_result.results[2].stat.islnk - stat_result.results[3].stat.isreg + - stat_result.results[4].stat.isreg + + - name: Verify the README was templated successfully + copy: + dest: "{{ galaxy_dir }}/scratch/skeleton/ansible_test/my_collection/README" + content: | + Requires ansible-core >=2.17 + register: validate_readme_content + - assert: + that: + - not validate_readme_content.changed always: - name: cleanup file: diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/install.yml b/test/integration/targets/ansible-galaxy-collection/tasks/install.yml index 9237826..5959110 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/install.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/install.yml @@ -1141,6 +1141,33 @@ - (install_concrete_pre_actual.results[0].content | b64decode | from_json).collection_info.version == '1.1.0-beta.1' - (install_concrete_pre_actual.results[1].content | b64decode | from_json).collection_info.version == '1.0.0' +- block: + - name: create skeleton collection for trailing slash test + command: ansible-galaxy collection init trailing_dir.name --init-path "{{ galaxy_dir }}/scratch" + + - name: install collection with directory source and trailing slash - {{ test_id }} + command: ansible-galaxy collection install '{{ galaxy_dir }}/scratch/trailing_dir/name/' {{ galaxy_verbosity }} + environment: + ANSIBLE_COLLECTIONS_PATHS: '{{ galaxy_dir }}/ansible_collections' + register: install_dir_slash + + - name: get result of install collections with with trailing slash - {{ test_id }} + slurp: + path: '{{ galaxy_dir }}/ansible_collections/trailing_dir/name/MANIFEST.json' + register: install_dir_slash_actual + + - name: assert install collections with with trailing slash - {{ test_id }} + assert: + that: + - '"Installing ''trailing_dir.name:1.0.0'' to" in install_dir_slash.stdout' + - (install_dir_slash_actual.content | b64decode | from_json).collection_info.version == '1.0.0' + + always: + - name: remove trailing dir skeleton + file: + path: '{{ galaxy_dir }}/scratch/trailing_dir' + state: absent + - name: remove collection dir after round of testing - {{ test_id }} file: path: '{{ galaxy_dir }}/ansible_collections' diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/setup_gpg.yml b/test/integration/targets/ansible-galaxy-collection/tasks/setup_gpg.yml index ddc4d8a..66fe220 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/setup_gpg.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/setup_gpg.yml @@ -7,6 +7,27 @@ - absent - directory +- when: ansible_facts.distribution == 'MacOSX' + block: + - name: MACOS | Find brew binary + command: which brew + register: brew_which + + - name: MACOS | Get owner of brew binary + stat: + path: >- + {{ brew_which.stdout }} + register: brew_stat + + - command: brew install gpg + become: yes + become_user: >- + {{ brew_stat.stat.pw_name }} + environment: + HOMEBREW_NO_AUTO_UPDATE: True + notify: + - uninstall gpg + - name: get username for generating key command: whoami register: user diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml b/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml index 0fe2f82..2ad9c83 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml @@ -270,6 +270,16 @@ path: '{{ galaxy_dir }}/ansible_collections/ansible_test/verify/plugins/modules/test_new_dir' state: directory +- name: create a new ignore directory + file: + path: '{{ galaxy_dir }}/ansible_collections/ansible_test/verify/plugins/modules/__pycache__' + state: directory + +- name: create a new ignore file + file: + path: '{{ galaxy_dir }}/ansible_collections/ansible_test/verify/plugins/modules/__pycache__/test.cpython-311.pyc' + state: touch + - name: verify modified collection locally-only (should fail) command: ansible-galaxy collection verify --offline ansible_test.verify register: verify @@ -282,6 +292,7 @@ - "'plugins/modules/test_module.py' in verify.stdout" - "'plugins/modules/test_new_file.py' in verify.stdout" - "'plugins/modules/test_new_dir' in verify.stdout" + - "'plugins/modules/__pycache__/test.cpython-311.pyc' not in verify.stdout" # TODO: add a test for offline Galaxy signature metadata |