Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests - II #25

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
68 changes: 68 additions & 0 deletions tests/integration/targets/ah_ee_repository/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
68 changes: 68 additions & 0 deletions tests/integration/targets/ah_ee_repository_sync/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions tests/integration/targets/ah_token/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions tests/integration/targets/ah_user/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
Loading