From 6933fc428a0d045afd52a0d58c45ced42224e9c0 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Wed, 18 Sep 2024 14:03:51 -0700 Subject: [PATCH] * ah_user * ah_ee_repository * ah_ee_repository_sync Signed-off-by: Abhijeet Kasurde --- .github/workflows/integration.yml | 16 +++++ .../targets/ah_ee_repository/tasks/main.yml | 68 +++++++++++++++++++ .../ah_ee_repository_sync/tasks/main.yml | 68 +++++++++++++++++++ .../targets/ah_token/tasks/main.yml | 19 ++++++ .../targets/ah_user/tasks/main.yml | 36 ++++++++++ 5 files changed, 207 insertions(+) create mode 100644 tests/integration/targets/ah_ee_repository/tasks/main.yml create mode 100644 tests/integration/targets/ah_ee_repository_sync/tasks/main.yml create mode 100644 tests/integration/targets/ah_token/tasks/main.yml create mode 100644 tests/integration/targets/ah_user/tasks/main.yml diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 5e85fe2..4e39430 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -126,3 +126,19 @@ jobs: - name: Run integration test - ah_ee_registry run: ansible-test integration ah_ee_registry working-directory: /home/runner/collections/ansible_collections/ansible/hub + + - name: Run integration test - ah_ee_repository + run: ansible-test integration ah_ee_repository + working-directory: /home/runner/collections/ansible_collections/ansible/hub + + - name: Run integration test - ah_ee_repository_sync + run: ansible-test integration ah_ee_repository_sync + working-directory: /home/runner/collections/ansible_collections/ansible/hub + + - name: Run integration test - ah_token + run: ansible-test integration ah_token + working-directory: /home/runner/collections/ansible_collections/ansible/hub + + - name: Run integration test - ah_user + run: ansible-test integration ah_user + working-directory: /home/runner/collections/ansible_collections/ansible/hub diff --git a/tests/integration/targets/ah_ee_repository/tasks/main.yml b/tests/integration/targets/ah_ee_repository/tasks/main.yml new file mode 100644 index 0000000..f38b473 --- /dev/null +++ b/tests/integration/targets/ah_ee_repository/tasks/main.yml @@ -0,0 +1,68 @@ +--- +- name: ah_ee_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: + registry_name: "ee_{{ test_id }}" + ee_repo_name: "ee_repo_{{ test_id }}" + + - name: Create EE remote registry + ansible.hub.ah_ee_registry: + name: "{{ registry_name }}" + url: https://quay.io/my/registry + state: present + register: r + + - name: Check if the remote registry EE is created + assert: + that: + - r.changed + + - name: Add a remote repository from registry + ansible.hub.ah_ee_repository: + name: "{{ ee_repo_name }}" + upstream_name: "upstream_{{ ee_repo_name }}" + registry: "{{ registry_name }}" + include_tags: + - latest + state: present + register: r + + - name: Check if the remote registry EE is created + assert: + that: + - r.changed + + - name: Remove a remote repository + ansible.hub.ah_ee_repository: + name: "{{ ee_repo_name }}" + state: absent + register: r + + - name: Check if the remote registry EE is deleted + assert: + that: + - r.changed + always: + - name: Remove a remote repository + ansible.hub.ah_ee_repository: + name: "{{ ee_repo_name }}" + state: absent + ignore_errors: true + + - name: Remove EE remote registry + ansible.hub.ah_ee_registry: + name: "{{ registry_name }}" + state: absent + ignore_errors: true diff --git a/tests/integration/targets/ah_ee_repository_sync/tasks/main.yml b/tests/integration/targets/ah_ee_repository_sync/tasks/main.yml new file mode 100644 index 0000000..fdd9b15 --- /dev/null +++ b/tests/integration/targets/ah_ee_repository_sync/tasks/main.yml @@ -0,0 +1,68 @@ +--- +- name: ah_ee_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: 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: + registry_name: "ee_{{ test_id }}" + ee_repo_name: "ee_repo_{{ test_id }}" + + - name: Create EE remote registry + ansible.hub.ah_ee_registry: + name: "{{ registry_name }}" + url: https://quay.io/my/registry + state: present + register: r + + - name: Check if the remote registry EE is created + assert: + that: + - r.changed + + - name: Add a remote repository from registry + ansible.hub.ah_ee_repository: + name: "{{ ee_repo_name }}" + upstream_name: "upstream_{{ ee_repo_name }}" + registry: "{{ registry_name }}" + include_tags: + - latest + state: present + register: r + + - name: Check if the remote registry EE is created + assert: + that: + - r.changed + + - name: Sync a remote repository + ansible.hub.ah_ee_repository_sync: + name: "{{ ee_repo_name }}" + wait: false + register: r + + - name: Check if the remote registry EE is sync + assert: + that: + - r.changed + always: + - name: Remove a remote repository + ansible.hub.ah_ee_repository: + name: "{{ ee_repo_name }}" + state: absent + ignore_errors: true + + - name: Remove EE remote registry + ansible.hub.ah_ee_registry: + name: "{{ registry_name }}" + state: absent + ignore_errors: true diff --git a/tests/integration/targets/ah_token/tasks/main.yml b/tests/integration/targets/ah_token/tasks/main.yml new file mode 100644 index 0000000..543aaca --- /dev/null +++ b/tests/integration/targets/ah_token/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: ah_token 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: Create a token + ansible.hub.ah_token: + state: present + register: r + no_log: true + + - name: Check if the token is created + assert: + that: + - r.changed diff --git a/tests/integration/targets/ah_user/tasks/main.yml b/tests/integration/targets/ah_user/tasks/main.yml new file mode 100644 index 0000000..05ff84b --- /dev/null +++ b/tests/integration/targets/ah_user/tasks/main.yml @@ -0,0 +1,36 @@ +--- +- name: ah_user 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: Ensure the user exists + ansible.hub.ah_user: + username: "user_{{ test_id }}" + first_name: "first_{{ test_id }}" + last_name: "last_{{ test_id }}" + email: "user_{{ test_id }}@example.com" + password: vs9mrD55NP + state: present + register: r + + - name: Check if the user is created + assert: + that: + - r.changed + + always: + - name: Remove user + ansible.hub.ah_user: + username: "user_{{ test_id }}" + state: absent + register: r + ignore_errors: true