diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index c81249b..5c51131 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -110,3 +110,15 @@ jobs: - name: Run integration test - ah_collection_upload run: ansible-test integration ah_collection_upload working-directory: /home/runner/collections/ansible_collections/ansible/hub + + - name: Run integration test - collection_remote + run: ansible-test integration collection_remote + working-directory: /home/runner/collections/ansible_collections/ansible/hub + + - name: Run integration test - collection_repository + run: ansible-test integration collection_repository + working-directory: /home/runner/collections/ansible_collections/ansible/hub + + - name: Run integration test - collection_repository_sync + run: ansible-test integration collection_repository_sync + working-directory: /home/runner/collections/ansible_collections/ansible/hub \ No newline at end of file diff --git a/tests/integration/targets/ah_collection_upload/tasks/main.yml b/tests/integration/targets/ah_collection_upload/tasks/main.yml index cefd517..c99bc23 100644 --- a/tests/integration/targets/ah_collection_upload/tasks/main.yml +++ b/tests/integration/targets/ah_collection_upload/tasks/main.yml @@ -64,35 +64,7 @@ that: - r.changed - - name: Delete a collection to the given collection - ansible.hub.ah_collection: - namespace: "{{ namespace }}" - name: "{{ collection_name }}" - version: 1.0.0 - state: absent - register: r - - - name: Check if the collection is deleted successfully - assert: - that: - - r.changed - - r.deleted - always: - - name: Delete a collection to the given collection - ansible.hub.ah_collection: - namespace: "{{ namespace }}" - name: "{{ collection_name }}" - version: 1.0.0 - state: absent - ignore_errors: true - - - name: Delete namespace - ansible.hub.ah_namespace: - name: "{{ namespace }}" - state: absent - ignore_errors: true - - name: Remove built collection ansible.builtin.file: path: "{{ build_path }}/sample-sample-1.0.0.tar.gz" diff --git a/tests/integration/targets/collection_remote/tasks/main.yml b/tests/integration/targets/collection_remote/tasks/main.yml new file mode 100644 index 0000000..5485bfd --- /dev/null +++ b/tests/integration/targets/collection_remote/tasks/main.yml @@ -0,0 +1,57 @@ +--- +- name: collection_remote integration tests + module_defaults: + group/ansible.hub.hub: + ah_host: "{{ ah_host }}" + ah_username: "{{ ah_username }}" + ah_password: "{{ ah_password }}" + validate_certs: "{{ ah_verify_ssl }}" + block: + - name: Generate a test_id for the test + set_fact: + test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') | lower }}" + when: test_id is not defined + + - name: Define variables + set_fact: + collection_repo_name: "sample_{{ test_id }}" + distribution: "sample_{{ test_id }}" + + - name: Create a collection repository + ansible.hub.collection_repository: + name: "{{ collection_repo_name }}" + description: "description of the repository" + pulp_labels: + pipeline: "approved" + distribution: + name: "{{ distribution }}" + state: present + remote: community + wait: true + register: r + + - name: Check if the collection repository is created + assert: + that: + - r.changed + + - name: Configure collection + collection_remote: + name: "{{ collection_repo_name }}" + url: https://galaxy.ansible.com/api/ + requirements: + - galaxy.galaxy + - infra.controller_configuration + register: r + + - name: Check if the collection_remote works + assert: + that: + - r.changed + + always: + - name: Cleanup - Delete collection repository + ansible.hub.collection_repository: + name: "{{ collection_repo_name }}" + state: absent + ignore_errors: true diff --git a/tests/integration/targets/collection_repository/tasks/main.yml b/tests/integration/targets/collection_repository/tasks/main.yml new file mode 100644 index 0000000..6bcc9f4 --- /dev/null +++ b/tests/integration/targets/collection_repository/tasks/main.yml @@ -0,0 +1,114 @@ +--- +- name: collection_repository integration tests + module_defaults: + group/ansible.hub.hub: + ah_host: "{{ ah_host }}" + ah_username: "{{ ah_username }}" + ah_password: "{{ ah_password }}" + validate_certs: "{{ ah_verify_ssl }}" + block: + - name: Generate a test_id for the test + set_fact: + test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') | lower }}" + when: test_id is not defined + + - name: Define variables + set_fact: + collection_repo_name: "sample_{{ test_id }}" + distribution: "sample_{{ test_id }}" + + - name: Create a collection repository in check mode + ansible.hub.collection_repository: + name: "{{ collection_repo_name }}" + description: "description of the repository" + pulp_labels: + pipeline: "approved" + distribution: + name: "{{ distribution }}" + state: present + remote: community + wait: true + register: r + check_mode: yes + + - name: Check if the collection repository is created in check mode + assert: + that: + - r.changed + + - name: Create a collection repository + ansible.hub.collection_repository: + name: "{{ collection_repo_name }}" + description: "description of the repository" + pulp_labels: + pipeline: "approved" + distribution: + name: "{{ distribution }}" + state: present + remote: community + wait: true + register: r + + - name: Check if the collection repository is created + assert: + that: + - r.changed + + - name: Create a collection repository again + ansible.hub.collection_repository: + name: "{{ collection_repo_name }}" + description: "description of the repository" + pulp_labels: + pipeline: "approved" + distribution: + name: "{{ distribution }}" + state: present + remote: community + wait: true + register: r + + - name: Check if the collection repository is not created again + assert: + that: + - not r.changed + + - name: Delete collection repository in check mode + ansible.hub.collection_repository: + name: "{{ collection_repo_name }}" + state: absent + check_mode: yes + register: r + + - name: Check if the collection is deleted in check mode + assert: + that: + - r.changed + + - name: Delete collection repository + ansible.hub.collection_repository: + name: "{{ collection_repo_name }}" + state: absent + register: r + + - name: Check if the collection is deleted + assert: + that: + - r.changed + + - name: Delete collection repository again + ansible.hub.collection_repository: + name: "{{ collection_repo_name }}" + state: absent + register: r + + - name: Check if the collection is not deleted again + assert: + that: + - not r.changed + + always: + - name: Cleanup - Delete collection repository + ansible.hub.collection_repository: + name: "{{ collection_repo_name }}" + state: absent + ignore_errors: true diff --git a/tests/integration/targets/collection_repository_sync/tasks/main.yml b/tests/integration/targets/collection_repository_sync/tasks/main.yml new file mode 100644 index 0000000..ddd67da --- /dev/null +++ b/tests/integration/targets/collection_repository_sync/tasks/main.yml @@ -0,0 +1,31 @@ +--- +- name: collection_repository_sync integration tests + module_defaults: + group/ansible.hub.hub: + ah_host: "{{ ah_host }}" + ah_username: "{{ ah_username }}" + ah_password: "{{ ah_password }}" + validate_certs: "{{ ah_verify_ssl }}" + block: + - name: Sync rh-certified in check mode + ansible.hub.collection_repository_sync: + name: rh-certified + wait: false + check_mode: yes + register: r + + - name: Check if sync is successful + assert: + that: + - r.changed + + - name: Sync rh-certified + ansible.hub.collection_repository_sync: + name: rh-certified + wait: false + register: r + + - name: Check if sync is successful + assert: + that: + - r.changed