mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-09 14:50:02 -07:00
Network ACI: Add integration tests for several module (#33016)
This commit is contained in:
parent
a40ce1ba5e
commit
5747bf34d1
26 changed files with 2482 additions and 0 deletions
1
test/integration/targets/aci_ap/aliases
Normal file
1
test/integration/targets/aci_ap/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
# No AcI Simulator yet, so not enabled
|
164
test/integration/targets/aci_ap/tasks/main.yml
Normal file
164
test/integration/targets/aci_ap/tasks/main.yml
Normal file
|
@ -0,0 +1,164 @@
|
|||
# Test code for the ACI modules
|
||||
# Copyright 2017, Jacob McGill <jmcgill298
|
||||
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Test that we have an ACI APIC host, ACI username and ACI password
|
||||
fail:
|
||||
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
|
||||
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
|
||||
|
||||
- name: ensure tenant exists for tests to kick off
|
||||
aci_tenant: &aci_tenant_present
|
||||
host: "{{ aci_hostname }}"
|
||||
username: "{{ aci_username }}"
|
||||
password: "{{ aci_password }}"
|
||||
validate_certs: no
|
||||
state: present
|
||||
tenant: anstest
|
||||
register: tenant_present
|
||||
|
||||
- name: create ap - check mode works
|
||||
aci_ap: &aci_ap_present
|
||||
<<: *aci_tenant_present
|
||||
ap: anstest
|
||||
description: Ansible Test
|
||||
check_mode: yes
|
||||
register: ap_present_check_mode
|
||||
|
||||
- name: create ap - creation works
|
||||
aci_ap:
|
||||
<<: *aci_ap_present
|
||||
register: ap_present
|
||||
|
||||
- name: create ap - extra for query
|
||||
aci_ap:
|
||||
<<: *aci_tenant_present
|
||||
ap: anstest2
|
||||
|
||||
- name: create ap - idempotency works
|
||||
aci_ap:
|
||||
<<: *aci_ap_present
|
||||
register: ap_present_idempotent
|
||||
|
||||
- name: update ap - update works
|
||||
aci_ap:
|
||||
<<: *aci_ap_present
|
||||
description: Ansible Test Update
|
||||
register: ap_present_update
|
||||
|
||||
- name: create ap - creation works
|
||||
aci_ap:
|
||||
<<: *aci_tenant_present
|
||||
ignore_errors: yes
|
||||
register: ap_present_missing_param
|
||||
|
||||
- name: present asserts
|
||||
assert:
|
||||
that:
|
||||
- ap_present_check_mode.changed == true
|
||||
- ap_present.changed == true
|
||||
- ap_present.existing == []
|
||||
- ap_present.config == ap_present_check_mode.config
|
||||
- 'ap_present.config == {"fvAp": {"attributes": {"descr": "Ansible Test", "name": "anstest"}}}'
|
||||
- ap_present_idempotent.changed == false
|
||||
- ap_present_idempotent.existing != []
|
||||
- ap_present_idempotent.config == {}
|
||||
- ap_present_update.changed == true
|
||||
- 'ap_present_update.config.fvAp.attributes == {"descr": "Ansible Test Update"}'
|
||||
- ap_present_missing_param.failed == true
|
||||
- 'ap_present_missing_param.msg == "state is present but the following are missing: ap"'
|
||||
|
||||
- name: get ap - query specific ap
|
||||
aci_ap: &aci_ap_query
|
||||
<<: *aci_ap_present
|
||||
state: query
|
||||
register: query_ap
|
||||
|
||||
- name: get all ap for tenant - query tenant aps
|
||||
aci_ap:
|
||||
<<: *aci_ap_query
|
||||
ap: "{{ fakevar | default(omit) }}"
|
||||
register: query_ap_tenant
|
||||
|
||||
- name: get all ap by name - query ap name
|
||||
aci_ap:
|
||||
<<: *aci_ap_query
|
||||
tenant: "{{ fakevar | default(omit) }}"
|
||||
register: query_ap_ap
|
||||
|
||||
- name: get all aps - query general
|
||||
aci_ap:
|
||||
<<: *aci_ap_query
|
||||
tenant: "{{ fakevar | default(omit) }}"
|
||||
ap: "{{ fakevar | default(omit) }}"
|
||||
register: query_all
|
||||
|
||||
- name: query assertions
|
||||
assert:
|
||||
that:
|
||||
- query_ap.changed == false
|
||||
- query_ap.existing | length == 1
|
||||
- 'query_ap.existing.0.fvAp.attributes.name == "anstest"'
|
||||
- '"tn-anstest/ap-anstest.json" in query_ap.url'
|
||||
- query_ap_tenant.changed == false
|
||||
- query_ap_tenant.existing | length == 1
|
||||
- query_ap_tenant.existing.0.fvTenant.children | length == 2
|
||||
- '"rsp-subtree-class=fvAp" in query_ap_tenant.filter_string'
|
||||
- '"tn-anstest.json" in query_ap_tenant.url'
|
||||
- query_ap_ap.changed == false
|
||||
- query_ap_ap.existing != []
|
||||
- query_ap_ap.existing.0.fvAp is defined
|
||||
- '"query-target-filter=eq(fvAp.name, \"anstest\")" in query_ap_ap.filter_string'
|
||||
- '"class/fvAp.json" in query_ap_ap.url'
|
||||
- query_all.changed == false
|
||||
- query_all.existing | length > 1
|
||||
- '"class/fvAp.json" in query_all.url'
|
||||
|
||||
- name: delete ap - check_mode works
|
||||
aci_ap: &aci_ap_absent
|
||||
<<: *aci_ap_present
|
||||
state: absent
|
||||
check_mode: yes
|
||||
register: ap_delete_check_mode
|
||||
|
||||
- name: delete ap - delete works
|
||||
aci_ap:
|
||||
<<: *aci_ap_absent
|
||||
register: ap_delete
|
||||
|
||||
- name: delete ap - delete idempotency works
|
||||
aci_ap:
|
||||
<<: *aci_ap_absent
|
||||
register: ap_delete_idempotent
|
||||
|
||||
- name: delete ap - missing param error
|
||||
aci_ap:
|
||||
<<: *aci_ap_absent
|
||||
tenant: "{{ fakevar | default(omit) }}"
|
||||
ignore_errors: yes
|
||||
register: ap_delete_missing_param
|
||||
|
||||
- name: delete ap remove ap used for query
|
||||
aci_ap:
|
||||
<<: *aci_ap_absent
|
||||
ap: anstest2
|
||||
|
||||
- name: absent assertions
|
||||
assert:
|
||||
that:
|
||||
- ap_delete_check_mode.changed == true
|
||||
- ap_delete_check_mode.existing != []
|
||||
- '"tn-anstest/ap-anstest.json" in ap_delete_check_mode.url'
|
||||
- ap_delete.changed == true
|
||||
- ap_delete.existing == ap_delete_check_mode.existing
|
||||
- ap_delete_idempotent.changed == false
|
||||
- ap_delete_idempotent.existing == []
|
||||
- ap_delete_missing_param.failed == true
|
||||
- 'ap_delete_missing_param.msg == "state is absent but the following are missing: tenant"'
|
||||
|
||||
- name: delete tenant - cleanup before ending tests
|
||||
aci_tenant:
|
||||
<<: *aci_tenant_present
|
||||
state: absent
|
||||
when: tenant_present.changed == true
|
Loading…
Add table
Add a link
Reference in a new issue