From bf69f987f9abdcea267fdf20181d08fbd81aceee Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 16 Jan 2018 14:05:34 -0800 Subject: [PATCH] added aci_interface_selector_to_switch_policy_leaf_profile integration test (#34903) --- .../aliases | 0 .../tasks/main.yml | 148 ++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 test/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/aliases create mode 100644 test/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/tasks/main.yml diff --git a/test/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/aliases b/test/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/aliases new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/tasks/main.yml b/test/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/tasks/main.yml new file mode 100644 index 0000000000..7f6df8ce35 --- /dev/null +++ b/test/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/tasks/main.yml @@ -0,0 +1,148 @@ +# Test code for the ACI modules +# Copyright 2017, Bruno Calogero + +# 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: delete Switch Policy Leaf profile for kick off + aci_switch_policy_leaf_profile: + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + leaf_profile: swleafprftest + validate_certs: no + use_ssl: no + state: absent + +- name: delete Interface Policy Leaf profile for kick off + aci_interface_policy_leaf_profile: + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + leaf_interface_profile: leafintprftest + validate_certs: no + use_ssl: no + use_proxy: no + state: absent + +- name: Ensuring Switch Policy Leaf profile exists for kick off + aci_switch_policy_leaf_profile: &aci_switch_policy_leaf_profile_present + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + leaf_profile: swleafprftest + validate_certs: no + use_ssl: no + state: present + register: leaf_profile_present + +- name: Ensuring Interface Policy Leaf profile exists for kick off + aci_interface_policy_leaf_profile: &aci_interface_policy_leaf_profile_present + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + leaf_interface_profile: leafintprftest + validate_certs: no + use_ssl: no + use_proxy: no + state: present + register: leaf_profile_present + +- name: Bind an Interface Selector to a Switch Policy Leaf Profile - check mode works + aci_interface_selector_to_switch_policy_leaf_profile: &aci_interface_selector_to_switch_policy_leaf_profile_present + <<: *aci_switch_policy_leaf_profile_present + interface_selector: leafintprftest + check_mode: yes + register: intftoleaf_check_mode_present + +- name: Bind an Interface Selector to a Switch Policy Leaf Profile - creation works + aci_interface_selector_to_switch_policy_leaf_profile: + <<: *aci_interface_selector_to_switch_policy_leaf_profile_present + register: intftoleaf_present + +- name: Bind an Interface Selector to a Switch Policy Leaf Profile - idempotency works + aci_interface_selector_to_switch_policy_leaf_profile: + <<: *aci_interface_selector_to_switch_policy_leaf_profile_present + register: intftoleaf_idempotent + +# TODO: also test for errors +- name: present assertions + assert: + that: + - intftoleaf_check_mode_present.changed == true + - intftoleaf_present.changed == true + - intftoleaf_present.existing == [] + - 'intftoleaf_present.config == {"infraRsAccPortP": {"attributes": {"tDn": "uni/infra/accportprof-leafintprftest"}}}' + - intftoleaf_idempotent.changed == false + - intftoleaf_idempotent.config == {} + +- name: Query an interface selector profile associated with a switch policy leaf profile + aci_interface_selector_to_switch_policy_leaf_profile: + <<: *aci_switch_policy_leaf_profile_present + interface_selector: leafintprftest + state: query + register: binding_query + +- name: query assertions + assert: + that: + - binding_query.changed == false + - binding_query.existing | length >= 1 + - '"api/mo/uni/infra/nprof-swleafprftest/rsaccPortP-[uni/infra/accportprof-leafintprftest].json" in binding_query.url' + +- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode + aci_interface_selector_to_switch_policy_leaf_profile: &aci_interface_selector_to_switch_policy_leaf_profile_absent + <<: *aci_switch_policy_leaf_profile_present + interface_selector: leafintprftest + state: absent + check_mode: yes + register: intftoleaf_check_mode_absent + +- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - delete works + aci_interface_selector_to_switch_policy_leaf_profile: + <<: *aci_interface_selector_to_switch_policy_leaf_profile_absent + register: intftoleaf_absent + +- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - idempotency works + aci_interface_selector_to_switch_policy_leaf_profile: + <<: *aci_interface_selector_to_switch_policy_leaf_profile_absent + register: intftoleaf_absent_idempotent + +- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode + aci_interface_selector_to_switch_policy_leaf_profile: + <<: *aci_switch_policy_leaf_profile_present + state: absent + ignore_errors: yes + register: intftoleaf_absent_missing_param + +- name: absent assertions + assert: + that: + - intftoleaf_check_mode_absent.changed == true + - intftoleaf_check_mode_absent.existing != [] + - intftoleaf_absent.changed == true + - intftoleaf_absent.existing == intftoleaf_check_mode_absent.existing + - intftoleaf_absent_idempotent.changed == false + - intftoleaf_absent_idempotent.existing == [] + - intftoleaf_absent_missing_param.failed == true + - 'intftoleaf_absent_missing_param.msg == "state is absent but all of the following are missing: interface_selector"' + +- name: Remove an interface selector associated with a Switch Policy Leaf Profile - Clean up + aci_interface_selector_to_switch_policy_leaf_profile: + <<: *aci_interface_selector_to_switch_policy_leaf_profile_absent + state: absent + +- name: delete Switch Policy Leaf profile - Clean up + aci_switch_policy_leaf_profile: + <<: *aci_switch_policy_leaf_profile_present + state: absent + +- name: delete Interface Policy Leaf profile - Clean up + aci_interface_policy_leaf_profile: + <<: *aci_interface_policy_leaf_profile_present + leaf_interface_profile: leafintprftest + state: absent