From c5a7beecc4ceda8c6dbdc78a55192583d2879c0e Mon Sep 17 00:00:00 2001 From: Bruno Date: Fri, 19 Jan 2018 23:13:31 -0800 Subject: fix integration tests (#35117) --- ...ccess_port_to_interface_policy_leaf_profile.yml | 125 --------------------- .../tasks/main.yml | 125 +++++++++++++++++++++ .../aci_switch_leaf_policy_profile/tasks/main.yml | 5 - .../aci_switch_leaf_selector/tasks/main.yml | 8 +- 4 files changed, 126 insertions(+), 137 deletions(-) delete mode 100644 test/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/aci_access_port_to_interface_policy_leaf_profile.yml create mode 100644 test/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml diff --git a/test/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/aci_access_port_to_interface_policy_leaf_profile.yml b/test/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/aci_access_port_to_interface_policy_leaf_profile.yml deleted file mode 100644 index 43a4428c89..0000000000 --- a/test/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/aci_access_port_to_interface_policy_leaf_profile.yml +++ /dev/null @@ -1,125 +0,0 @@ -# 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: 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 - -# TODO: Ensure that leaf Policy Group Exists (module missing) (infra:AccPortGrp) - -- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - check mode works - aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_present - <<: *aci_interface_policy_leaf_profile_present - access_port_selector: anstest_accessportselector - leaf_port_blk: anstest_leafportblkname - fromPort: 13 - toPort: 16 - check_mode: yes - register: accessport_to_intf_check_mode_present - -- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - creation works - aci_access_port_to_interface_policy_leaf_profile: - <<: *aci_access_port_to_interface_policy_leaf_profile_present - register: accessport_to_intf_present - -- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - idempotency works - aci_access_port_to_interface_policy_leaf_profile: - <<: *aci_access_port_to_interface_policy_leaf_profile_present - register: accessport_to_intf_idempotent - -- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - update works - aci_access_port_to_interface_policy_leaf_profile: - <<: *aci_access_port_to_interface_policy_leaf_profile_present - policy_group: anstest_policygroupname - register: accessport_to_intf_update - -# TODO: also test for errors -- name: present assertions - assert: - that: - - accessport_to_intf_check_mode_present.changed == true - - accessport_to_intf_present.changed == true - - accessport_to_intf_present.existing == [] - - 'accessport_to_intf_present.config == {"infraHPortS": {"attributes": {"name": "anstest_accessportselector"}, "children": [{"infraPortBlk": {"attributes": {"fromPort": "13", "name": "anstest_leafportblkname", "toPort": "16"}}}, {"infraRsAccBaseGrp": {"attributes": {"tDn": "uni/infra/funcprof/accportgrp-None"}}}]}}' - - accessport_to_intf_idempotent.changed == false - - accessport_to_intf_idempotent.config == {} - - accessport_to_intf_update.changed == true - - 'accessport_to_intf_update.config == {"infraHPortS": {"attributes": {},"children": [{"infraRsAccBaseGrp": {"attributes": {"tDn": "uni/infra/funcprof/accportgrp-anstest_policygroupname"}}}]}}' - -- name: Query Specific access_port_selector and leaf_interface_profile binding - aci_access_port_to_interface_policy_leaf_profile: - <<: *aci_interface_policy_leaf_profile_present - access_port_selector: anstest_accessportselector # "{{ fake_var | default(omit) }}" ? - state: query - register: binding_query - -- name: present assertions - assert: - that: - - binding_query.changed == false - - binding_query.existing | length >= 1 - - '"api/mo/uni/infra/accportprof-leafintprftest/hports-anstest_accessportselector-typ-range.json" in binding_query.url' - -- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode - aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_absent - <<: *aci_interface_policy_leaf_profile_present - access_port_selector: anstest_accessportselector - state: absent - check_mode: yes - register: accessport_to_intf_check_mode_absent - -- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - delete works - aci_access_port_to_interface_policy_leaf_profile: - <<: *aci_access_port_to_interface_policy_leaf_profile_absent - register: accessport_to_intf_absent - -- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - idempotency works - aci_access_port_to_interface_policy_leaf_profile: - <<: *aci_access_port_to_interface_policy_leaf_profile_absent - register: accessport_to_intf_absent_idempotent - -- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode - aci_access_port_to_interface_policy_leaf_profile: - <<: *aci_interface_policy_leaf_profile_present - #access_port_selector: anstest_accessportselector - state: absent - ignore_errors: yes - register: accessport_to_intf_absent_missing_param - -- name: absent assertions - assert: - that: - - accessport_to_intf_check_mode_absent.changed == true - - accessport_to_intf_check_mode_absent.existing != [] - - accessport_to_intf_absent.changed == true - - accessport_to_intf_absent.existing == accessport_to_intf_check_mode_absent.existing - - accessport_to_intf_absent_idempotent.changed == false - - accessport_to_intf_absent_idempotent.existing == [] - - accessport_to_intf_absent_missing_param.failed == true - - 'accessport_to_intf_absent_missing_param.msg == "state is absent but all of the following are missing: access_port_selector"' - - -- name: Remove an interface access port selector associated with an Interface Policy Leaf Profile - Clean up - aci_access_port_to_interface_policy_leaf_profile: - <<: *aci_access_port_to_interface_policy_leaf_profile_absent - state: absent - -- name: Remove Interface policy leaf profile - Cleanup - aci_interface_policy_leaf_profile: - <<: *aci_interface_policy_leaf_profile_present - state: absent diff --git a/test/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml b/test/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml new file mode 100644 index 0000000000..43a4428c89 --- /dev/null +++ b/test/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml @@ -0,0 +1,125 @@ +# 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: 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 + +# TODO: Ensure that leaf Policy Group Exists (module missing) (infra:AccPortGrp) + +- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - check mode works + aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_present + <<: *aci_interface_policy_leaf_profile_present + access_port_selector: anstest_accessportselector + leaf_port_blk: anstest_leafportblkname + fromPort: 13 + toPort: 16 + check_mode: yes + register: accessport_to_intf_check_mode_present + +- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - creation works + aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_access_port_to_interface_policy_leaf_profile_present + register: accessport_to_intf_present + +- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - idempotency works + aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_access_port_to_interface_policy_leaf_profile_present + register: accessport_to_intf_idempotent + +- name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - update works + aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_access_port_to_interface_policy_leaf_profile_present + policy_group: anstest_policygroupname + register: accessport_to_intf_update + +# TODO: also test for errors +- name: present assertions + assert: + that: + - accessport_to_intf_check_mode_present.changed == true + - accessport_to_intf_present.changed == true + - accessport_to_intf_present.existing == [] + - 'accessport_to_intf_present.config == {"infraHPortS": {"attributes": {"name": "anstest_accessportselector"}, "children": [{"infraPortBlk": {"attributes": {"fromPort": "13", "name": "anstest_leafportblkname", "toPort": "16"}}}, {"infraRsAccBaseGrp": {"attributes": {"tDn": "uni/infra/funcprof/accportgrp-None"}}}]}}' + - accessport_to_intf_idempotent.changed == false + - accessport_to_intf_idempotent.config == {} + - accessport_to_intf_update.changed == true + - 'accessport_to_intf_update.config == {"infraHPortS": {"attributes": {},"children": [{"infraRsAccBaseGrp": {"attributes": {"tDn": "uni/infra/funcprof/accportgrp-anstest_policygroupname"}}}]}}' + +- name: Query Specific access_port_selector and leaf_interface_profile binding + aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_interface_policy_leaf_profile_present + access_port_selector: anstest_accessportselector # "{{ fake_var | default(omit) }}" ? + state: query + register: binding_query + +- name: present assertions + assert: + that: + - binding_query.changed == false + - binding_query.existing | length >= 1 + - '"api/mo/uni/infra/accportprof-leafintprftest/hports-anstest_accessportselector-typ-range.json" in binding_query.url' + +- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode + aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_absent + <<: *aci_interface_policy_leaf_profile_present + access_port_selector: anstest_accessportselector + state: absent + check_mode: yes + register: accessport_to_intf_check_mode_absent + +- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - delete works + aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_access_port_to_interface_policy_leaf_profile_absent + register: accessport_to_intf_absent + +- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - idempotency works + aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_access_port_to_interface_policy_leaf_profile_absent + register: accessport_to_intf_absent_idempotent + +- name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode + aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_interface_policy_leaf_profile_present + #access_port_selector: anstest_accessportselector + state: absent + ignore_errors: yes + register: accessport_to_intf_absent_missing_param + +- name: absent assertions + assert: + that: + - accessport_to_intf_check_mode_absent.changed == true + - accessport_to_intf_check_mode_absent.existing != [] + - accessport_to_intf_absent.changed == true + - accessport_to_intf_absent.existing == accessport_to_intf_check_mode_absent.existing + - accessport_to_intf_absent_idempotent.changed == false + - accessport_to_intf_absent_idempotent.existing == [] + - accessport_to_intf_absent_missing_param.failed == true + - 'accessport_to_intf_absent_missing_param.msg == "state is absent but all of the following are missing: access_port_selector"' + + +- name: Remove an interface access port selector associated with an Interface Policy Leaf Profile - Clean up + aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_access_port_to_interface_policy_leaf_profile_absent + state: absent + +- name: Remove Interface policy leaf profile - Cleanup + aci_interface_policy_leaf_profile: + <<: *aci_interface_policy_leaf_profile_present + state: absent diff --git a/test/integration/targets/aci_switch_leaf_policy_profile/tasks/main.yml b/test/integration/targets/aci_switch_leaf_policy_profile/tasks/main.yml index 1b053d7f6a..b6dd71d541 100644 --- a/test/integration/targets/aci_switch_leaf_policy_profile/tasks/main.yml +++ b/test/integration/targets/aci_switch_leaf_policy_profile/tasks/main.yml @@ -2,11 +2,6 @@ # Copyright 2017, Bruno Calogero # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -- name: setting facts - set_fact: - aci_hostname: svlngen4-fab4-apic1.cisco.com - aci_username: admin - aci_password: F@b44p1c - name: Test that we have an ACI APIC host, ACI username and ACI password fail: diff --git a/test/integration/targets/aci_switch_leaf_selector/tasks/main.yml b/test/integration/targets/aci_switch_leaf_selector/tasks/main.yml index 4d4f38fbba..26761f06b2 100644 --- a/test/integration/targets/aci_switch_leaf_selector/tasks/main.yml +++ b/test/integration/targets/aci_switch_leaf_selector/tasks/main.yml @@ -1,14 +1,8 @@ # Test code for the ACI modules -# Copyright 2017, Bruno Calogero +# Copyright 2017, Bruno Calogero # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -- name: hello there - set_fact: - aci_hostname: svlngen4-fab4-apic1.cisco.com - aci_username: admin - aci_password: F@b44p1c - - 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.' -- cgit v1.2.1