summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2022-09-28 10:12:30 -0400
committerGitHub <noreply@github.com>2022-09-28 09:12:30 -0500
commit551ddebeab451c1f158e4ef8b656d60ff57689be (patch)
tree40057217688f195761edf3e62110be4adbdb0c21 /test
parent00d60a45fa7cd61b25d622735ceb4c8f6a125a76 (diff)
downloadansible-551ddebeab451c1f158e4ef8b656d60ff57689be.tar.gz
[2.13] Limit Galaxy API calls during ansible-galaxy dependency resolution (#78722)
* Limit Galaxy API calls during ansible-galaxy collection dependency resolution when possible Installing a tarfile with a dependency from a Galaxy server (e.g. dependencies: {'ns.coll': '>=1.0.0'}) does not get the available versions of the dependency from the galaxy server if a sufficient version is already installed. Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua> (cherry picked from commit 41b62f7db459b7c3a1d97302da3b9f2cbf302670)
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/ansible-galaxy-collection/tasks/install_offline.yml51
-rw-r--r--test/integration/targets/ansible-galaxy-collection/tasks/main.yml7
2 files changed, 58 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/install_offline.yml b/test/integration/targets/ansible-galaxy-collection/tasks/install_offline.yml
new file mode 100644
index 0000000000..8edb773e56
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection/tasks/install_offline.yml
@@ -0,0 +1,51 @@
+- set_fact:
+ init_dir: "{{ galaxy_dir }}/offline/setup"
+ build_dir: "{{ galaxy_dir }}/offline/build"
+ install_dir: "{{ galaxy_dir }}/offline/collections"
+
+- name: create test directories
+ file:
+ path: "{{ item }}"
+ state: directory
+ loop:
+ - "{{ init_dir }}"
+ - "{{ build_dir }}"
+ - "{{ install_dir }}"
+
+- name: test installing a tarfile with an installed dependency offline
+ block:
+ - name: init two collections
+ command: ansible-galaxy collection init ns.{{ item }} --init-path {{ init_dir }}
+ loop:
+ - coll1
+ - coll2
+
+ - name: add one collection as the dependency of the other
+ lineinfile:
+ path: "{{ galaxy_dir }}/offline/setup/ns/coll1/galaxy.yml"
+ regexp: "^dependencies:*"
+ line: "dependencies: {'ns.coll2': '1.0.0'}"
+
+ - name: build both collections
+ command: ansible-galaxy collection build {{ init_dir }}/ns/{{ item }}
+ args:
+ chdir: "{{ build_dir }}"
+ loop:
+ - coll1
+ - coll2
+
+ - name: install the dependency from the tarfile
+ command: ansible-galaxy collection install {{ build_dir }}/ns-coll2-1.0.0.tar.gz -p {{ install_dir }} -s offline
+
+ - name: install the tarfile with the installed dependency
+ command: ansible-galaxy collection install {{ build_dir }}/ns-coll1-1.0.0.tar.gz -p {{ install_dir }} -s offline
+
+ always:
+ - name: clean up test directories
+ file:
+ path: "{{ item }}"
+ state: absent
+ loop:
+ - "{{ init_dir }}"
+ - "{{ build_dir }}"
+ - "{{ install_dir }}"
diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/main.yml b/test/integration/targets/ansible-galaxy-collection/tasks/main.yml
index 063b7f0896..724c861e69 100644
--- a/test/integration/targets/ansible-galaxy-collection/tasks/main.yml
+++ b/test/integration/targets/ansible-galaxy-collection/tasks/main.yml
@@ -56,6 +56,13 @@
loop_control:
loop_var: resolvelib_version
+- name: run ansible-galaxy collection offline installation tests
+ include_tasks: install_offline.yml
+ args:
+ apply:
+ environment:
+ ANSIBLE_CONFIG: '{{ galaxy_dir }}/ansible.cfg'
+
- name: run ansible-galaxy collection publish tests for {{ test_name }}
include_tasks: publish.yml
args: