Skip to content

Commit

Permalink
[ignore] Made all the test cases cleaner for aci_tenant_action_rule_p…
Browse files Browse the repository at this point in the history
…rofile.
  • Loading branch information
gmicol committed Nov 9, 2023
1 parent 70d6153 commit ab49828
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# GNU General Public License v3.0+ (see LICENSE 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:
ansible.builtin.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: Set vars
set_fact:
ansible.builtin.set_fact:
aci_info: &aci_info
host: "{{ aci_hostname }}"
username: "{{ aci_username }}"
Expand All @@ -27,7 +27,7 @@
state: absent

- name: Verify Cloud and Non-Cloud Sites in use.
include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml

- name: Execute tasks only for non-cloud sites
when: query_cloud.current == [] # This condition will execute only non-cloud sites
Expand Down Expand Up @@ -78,7 +78,7 @@
register: nm_add_action_rule_add_comm_2

- name: Asserts for additional communities action rules creation tasks
assert:
ansible.builtin.assert:
that:
- cm_add_action_rule_add_comm is changed
- cm_add_action_rule_add_comm.previous == []
Expand All @@ -105,7 +105,7 @@
register: query_action_rule_add_comm

- name: Asserts query tasks
assert:
ansible.builtin.assert:
that:
- query_all_action_rule_add_comm is not changed
- query_all_action_rule_add_comm.current|length >= 2
Expand All @@ -131,7 +131,7 @@
register: nm_remove_action_rule_add_comm_idempotency

- name: Asserts deletion tasks
assert:
ansible.builtin.assert:
that:
- cm_remove_action_rule_add_comm is changed
- cm_remove_action_rule_add_comm.proposed == {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# GNU General Public License v3.0+ (see LICENSE 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:
ansible.builtin.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: Set vars
set_fact:
ansible.builtin.set_fact:
aci_info: &aci_info
host: "{{ aci_hostname }}"
username: "{{ aci_username }}"
Expand All @@ -27,7 +27,7 @@
state: absent

- name: Verify Cloud and Non-Cloud Sites in use.
include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml

- name: Execute tasks only for non-cloud sites
when: query_cloud.current == [] # This condition will execute only non-cloud sites
Expand Down Expand Up @@ -79,7 +79,7 @@
register: nm_add_action_rule_set_as_path_2

- name: Asserts for set AS path action rule creation tasks
assert:
ansible.builtin.assert:
that:
- cm_add_action_rule_set_as_path is changed
- cm_add_action_rule_set_as_path.previous == []
Expand All @@ -106,7 +106,7 @@
register: query_action_rule_set_as_path

- name: Asserts query tasks
assert:
ansible.builtin.assert:
that:
- query_all_action_rule_set_as_path is not changed
- query_all_action_rule_set_as_path.current|length >= 2
Expand All @@ -132,7 +132,7 @@
register: nm_remove_action_rule_set_as_path_idempotency

- name: Asserts deletion tasks
assert:
ansible.builtin.assert:
that:
- cm_remove_action_rule_set_as_path is changed
- cm_remove_action_rule_set_as_path.proposed == {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# GNU General Public License v3.0+ (see LICENSE 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:
ansible.builtin.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: Set vars
set_fact:
ansible.builtin.set_fact:
aci_info: &aci_info
host: "{{ aci_hostname }}"
username: "{{ aci_username }}"
Expand All @@ -27,7 +27,7 @@
state: absent

- name: Verify Cloud and Non-Cloud Sites in use.
include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml

- name: Execute tasks only for non-cloud sites
when: query_cloud.current == [] # This condition will execute only non-cloud sites
Expand Down Expand Up @@ -87,7 +87,7 @@
register: nm_add_action_rule_set_as_path_asn_2

- name: Asserts for Set AS Path ASN action rule creation tasks
assert:
ansible.builtin.assert:
that:
- cm_add_action_rule_set_as_path_asn is changed
- cm_add_action_rule_set_as_path_asn.previous == []
Expand All @@ -114,7 +114,7 @@
register: query_action_rule_set_as_path_asn

- name: Asserts query tasks
assert:
ansible.builtin.assert:
that:
- query_all_action_rule_set_as_path_asn is not changed
- query_all_action_rule_set_as_path_asn.current|length >= 2
Expand All @@ -140,7 +140,7 @@
register: nm_remove_action_rule_set_as_path_asn_idempotency

- name: Asserts deletion tasks
assert:
ansible.builtin.assert:
that:
- cm_remove_action_rule_set_as_path_asn is changed
- cm_remove_action_rule_set_as_path_asn.proposed == {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
# GNU General Public License v3.0+ (see LICENSE 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:
ansible.builtin.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: Set vars
set_fact:
ansible.builtin.set_fact:
aci_info: &aci_info
host: "{{ aci_hostname }}"
username: "{{ aci_username }}"
Expand All @@ -21,13 +21,19 @@
use_proxy: '{{ aci_use_proxy | default(true) }}'
output_level: debug

# CLEAN ENVIRONMENT
- name: Remove the ansible_tenant
cisco.aci.aci_tenant: &aci_tenant_absent
<<: *aci_info
tenant: ansible_tenant
state: absent

- name: Verify Cloud and Non-Cloud Sites in use.
include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml

- name: Execute tasks only for non-cloud sites
when: query_cloud.current == [] # This condition will execute only non-cloud sites
block: # block specifies execution of tasks within, based on conditions
# Clean Environment
- name: create tenant
cisco.aci.aci_tenant: &aci_tenant_present
<<: *aci_info
Expand Down Expand Up @@ -105,7 +111,7 @@
register: nm_add_tenant_action_rule_profile_2

- name: Asserts for creation tasks for action rule profile 1
assert:
ansible.builtin.assert:
that:
- cm_add_tenant_action_rule_profile_1 is changed
- cm_add_tenant_action_rule_profile_1.previous == []
Expand All @@ -128,7 +134,7 @@

- name: Asserts for creation tasks for action rule profile 2 - APIC version >= 5.0
when: version.current.0.topSystem.attributes.version is version('5', '>=')
assert:
ansible.builtin.assert:
that:
- nm_add_tenant_action_rule_profile_2_5 is changed
- nm_add_tenant_action_rule_profile_2_5.current.0.rtctrlAttrP.attributes.name == "anstest_2"
Expand All @@ -138,7 +144,7 @@

- name: Asserts for creation tasks for action rule profile 2 - APIC version < 5.0
when: version.current.0.topSystem.attributes.version is version('5', '<')
assert:
ansible.builtin.assert:
that:
- nm_add_tenant_action_rule_profile_2 is changed
- nm_add_tenant_action_rule_profile_2.current.0.rtctrlAttrP.attributes.name == "anstest_2"
Expand All @@ -157,7 +163,7 @@
register: query_first_tenant_action_rule_profile

- name: Asserts for query tasks
assert:
ansible.builtin.assert:
that:
- query_all_tenant_action_rule_profile is not changed
- query_all_tenant_action_rule_profile.current | length >= 2
Expand Down Expand Up @@ -218,7 +224,7 @@
register: nm_delete_children_tenant_action_rule_profile_2

- name: Asserts for deletion tasks for action rule profile 1
assert:
ansible.builtin.assert:
that:
- cm_delete_children_tenant_action_rule_profile_1 is changed
- cm_delete_children_tenant_action_rule_profile_1.current == cm_delete_children_tenant_action_rule_profile_1.previous
Expand All @@ -228,14 +234,14 @@

- name: Asserts for deletion tasks for action rule profile 2 - APIC version >= 5.0
when: version.current.0.topSystem.attributes.version is version('5', '>=')
assert:
ansible.builtin.assert:
that:
- nm_delete_children_tenant_action_rule_profile_2_5 is changed
- nm_delete_children_tenant_action_rule_profile_2_5.current.0.rtctrlAttrP | length == 1

- name: Asserts for deletion tasks for action rule profile 2 - APIC version < 5.0
when: version.current.0.topSystem.attributes.version is version('5', '<')
assert:
ansible.builtin.assert:
that:
- nm_delete_children_tenant_action_rule_profile_2 is changed
- nm_delete_children_tenant_action_rule_profile_2.current.0.rtctrlAttrP | length == 1
Expand Down Expand Up @@ -274,7 +280,7 @@
register: nm_delete_tenant_action_rule_profile_2

- name: Asserts for deletion tasks for action rule profile 1
assert:
ansible.builtin.assert:
that:
- cm_delete_tenant_action_rule_profile_1 is changed
- cm_delete_tenant_action_rule_profile_1.proposed == {}
Expand All @@ -286,21 +292,21 @@

- name: Asserts for deletion tasks for action rule profile 2 - APIC version >= 5.0
when: version.current.0.topSystem.attributes.version is version('5', '>=')
assert:
ansible.builtin.assert:
that:
- nm_delete_tenant_action_rule_profile_2_5 is changed
- nm_delete_tenant_action_rule_profile_2_5.previous != []
- nm_delete_tenant_action_rule_profile_2_5.current == []

- name: Asserts for deletion tasks for action rule profile 2 - APIC version < 5.0
when: version.current.0.topSystem.attributes.version is version('5', '<')
assert:
ansible.builtin.assert:
that:
- nm_delete_tenant_action_rule_profile_2 is changed
- nm_delete_tenant_action_rule_profile_2.previous != []
- nm_delete_tenant_action_rule_profile_2.current == []

- name: Delete tenant - clean up the environment
- name: Delete tenant - cleanup before ending tests
cisco.aci.aci_tenant:
<<: *aci_tenant_present
state: absent

0 comments on commit ab49828

Please sign in to comment.