ansible/test/integration/targets/aci_encap_pool/tasks/vxlan.yml
Dag Wieers d8ba8c03f3
ACI: Make querying links and nodes possible (#43441)
This functionality was not considered when the module was written, but
there's no reason why it shouldn't be supported.

We had to rework the query string construction and object filtering.
This new functionality allows to filter on arbitrary keys and supports
None values.

This PR fixes various issues with the existing framework, including
querying specific objects using construct_url_4 (i.e.
aci_epg_to_contract and aci_static_binding_to_epg)
2018-08-07 23:54:54 +02:00

177 lines
4.8 KiB
YAML

---
- name: ensure vxlan pool anstest does not exist for tests to kick off
aci_encap_pool: &aci_vxlan_absent
host: "{{ aci_hostname }}"
username: "{{ aci_username }}"
password: "{{ aci_password }}"
validate_certs: '{{ aci_validate_certs | default(false) }}'
use_ssl: '{{ aci_use_ssl | default(true) }}'
use_proxy: '{{ aci_use_proxy | default(true) }}'
output_level: debug
state: absent
pool: anstest
pool_type: vxlan
- name: ensure vxlan pool anstest_2 does not exist for tests to kick off
aci_encap_pool:
<<: *aci_vxlan_absent
pool: anstest_2
- name: ensure vxlan pool anstest_3 does not exist for tests to kick off
aci_encap_pool:
<<: *aci_vxlan_absent
pool: anstest_3
- name: create vxlan pool - check mode works
aci_encap_pool: &aci_vxlan_present
<<: *aci_vxlan_absent
state: present
descr: Ansible Test
check_mode: yes
register: create_vxlan_check_mode
- name: assertion test - present
assert:
that:
- create_vxlan_check_mode is changed
- 'create_vxlan_check_mode.sent == {"fvnsVxlanInstP": {"attributes": {"descr": "Ansible Test", "name": "anstest"}}}'
- name: create vxlan pool - creation works
aci_encap_pool:
<<: *aci_vxlan_present
register: create_vxlan
- name: assertion test - present
assert:
that:
- create_vxlan is changed
- create_vxlan.previous == []
- create_vxlan.sent == create_vxlan_check_mode.sent
- name: create vxlan pool again - idempotency works
aci_encap_pool:
<<: *aci_vxlan_present
register: idempotent_vxlan
- name: assertion test - present
assert:
that:
- idempotent_vxlan is not changed
- 'idempotent_vxlan.previous.0.fvnsVxlanInstP.attributes.name == "anstest"'
- idempotent_vxlan.sent == {}
- name: update vxlan pool - update works
aci_encap_pool:
<<: *aci_vxlan_present
descr: Ansible Test Change
register: update_vxlan
- name: assertion test - present
assert:
that:
- update_vxlan is changed
- 'update_vxlan.sent == {"fvnsVxlanInstP": {"attributes": {"descr": "Ansible Test Change"}}}'
- name: create vxlan pool - used for query
aci_encap_pool:
<<: *aci_vxlan_present
name: anstest_2
register: create_vxlan_2
- name: assertion test - present
assert:
that:
- create_vxlan_2 is changed
- name: create vxlan pool with pool allocation mode - failure message works
aci_encap_pool:
<<: *aci_vxlan_present
name: anstest_3
pool_allocation_mode: dynamic
ignore_errors: yes
register: create_vxlan_alloc_mode
- name: assertion test - present
assert:
that:
- create_vxlan_alloc_mode is failed
- "create_vxlan_alloc_mode.msg == 'vxlan pools do not support setting the \\'pool_allocation_mode\\'; please remove this parameter from the task'"
- name: get vxlan pool - get object works
aci_encap_pool: &aci_vxlan_query
<<: *aci_vxlan_present
state: query
register: query_vxlan
- name: assertion test - query
assert:
that:
- query_vxlan is not changed
- query_vxlan.current | length == 1
- '"infra/vxlanns-anstest.json" in query_vxlan.url'
- name: get created static vlan pool - get class works
aci_encap_pool:
<<: *aci_vxlan_query
pool: "{{ fake_var | default(omit) }}"
register: query_vxlan_all
- name: assertion test - query
assert:
that:
- query_vxlan_all is not changed
- query_vxlan_all.current | length > 1
- '"class/fvnsVxlanInstP.json" in query_vxlan_all.url'
- name: delete vxlan pool - check mode works
aci_encap_pool:
<<: *aci_vxlan_absent
check_mode: yes
register: delete_vxlan_check_mode
- name: assertion test - absent
assert:
that:
- delete_vxlan_check_mode is changed
- delete_vxlan_check_mode.previous != []
- name: delete vxlan pool - deletion works
aci_encap_pool:
<<: *aci_vxlan_absent
register: delete_vxlan
- name: assertion test - absent
assert:
that:
- delete_vxlan is changed
- delete_vxlan.previous == delete_vxlan_check_mode.previous
- delete_vxlan.previous.0.fvnsVxlanInstP.attributes.name == "anstest"
- name: delete vxlan pool again - idempotency works
aci_encap_pool:
<<: *aci_vxlan_absent
register: delete_vxlan_idempotent
- name: missing param - failure message works
aci_encap_pool:
<<: *aci_vxlan_absent
pool: "{{ fake_var | default(omit) }}"
ignore_errors: yes
register: delete_vxlan_pool_fail
- name: assertion test - absent
assert:
that:
- delete_vxlan_idempotent is not changed
- delete_vxlan_idempotent.previous == []
- name: delete vxlan pool - cleanup
aci_encap_pool:
<<: *aci_vxlan_absent
pool: anstest_2
- name: assertion test - absent
assert:
that:
- delete_vxlan_pool_fail is failed
- 'delete_vxlan_pool_fail.msg == "state is absent but all of the following are missing: pool"'