From 5747bf34d1f363cb5ed441e36bd782cc39c439db Mon Sep 17 00:00:00 2001 From: Jacob McGill Date: Fri, 17 Nov 2017 10:19:13 -0500 Subject: [PATCH] Network ACI: Add integration tests for several module (#33016) --- test/integration/targets/aci_ap/aliases | 1 + .../integration/targets/aci_ap/tasks/main.yml | 164 ++++++++++ test/integration/targets/aci_bd/aliases | 1 + .../integration/targets/aci_bd/tasks/main.yml | 190 ++++++++++++ .../integration/targets/aci_bd_subnet/aliases | 1 + .../targets/aci_bd_subnet/tasks/main.yml | 233 +++++++++++++++ .../targets/aci_config_rollback/aliases | 1 + .../aci_config_rollback/tasks/main.yml | 91 ++++++ .../targets/aci_config_snapshot/aliases | 1 + .../aci_config_snapshot/tasks/main.yml | 139 +++++++++ test/integration/targets/aci_contract/aliases | 1 + .../targets/aci_contract/tasks/main.yml | 160 ++++++++++ .../targets/aci_contract_subject/aliases | 1 + .../aci_contract_subject/tasks/main.yml | 238 +++++++++++++++ .../aci_contract_subject_to_filter/aliases | 1 + .../tasks/main.yml | 190 ++++++++++++ test/integration/targets/aci_epg/aliases | 1 + .../targets/aci_epg/tasks/main.yml | 168 +++++++++++ .../targets/aci_epg_to_contract/aliases | 1 + .../aci_epg_to_contract/tasks/main.yml | 235 +++++++++++++++ .../targets/aci_epg_to_domain/aliases | 1 + .../targets/aci_epg_to_domain/tasks/main.yml | 211 +++++++++++++ .../targets/aci_filter_entry/aliases | 1 + .../targets/aci_filter_entry/tasks/main.yml | 279 ++++++++++++++++++ test/integration/targets/aci_vrf/aliases | 1 + .../targets/aci_vrf/tasks/main.yml | 171 +++++++++++ 26 files changed, 2482 insertions(+) create mode 100644 test/integration/targets/aci_ap/aliases create mode 100644 test/integration/targets/aci_ap/tasks/main.yml create mode 100644 test/integration/targets/aci_bd/aliases create mode 100644 test/integration/targets/aci_bd/tasks/main.yml create mode 100644 test/integration/targets/aci_bd_subnet/aliases create mode 100644 test/integration/targets/aci_bd_subnet/tasks/main.yml create mode 100644 test/integration/targets/aci_config_rollback/aliases create mode 100644 test/integration/targets/aci_config_rollback/tasks/main.yml create mode 100644 test/integration/targets/aci_config_snapshot/aliases create mode 100644 test/integration/targets/aci_config_snapshot/tasks/main.yml create mode 100644 test/integration/targets/aci_contract/aliases create mode 100644 test/integration/targets/aci_contract/tasks/main.yml create mode 100644 test/integration/targets/aci_contract_subject/aliases create mode 100644 test/integration/targets/aci_contract_subject/tasks/main.yml create mode 100644 test/integration/targets/aci_contract_subject_to_filter/aliases create mode 100644 test/integration/targets/aci_contract_subject_to_filter/tasks/main.yml create mode 100644 test/integration/targets/aci_epg/aliases create mode 100644 test/integration/targets/aci_epg/tasks/main.yml create mode 100644 test/integration/targets/aci_epg_to_contract/aliases create mode 100644 test/integration/targets/aci_epg_to_contract/tasks/main.yml create mode 100644 test/integration/targets/aci_epg_to_domain/aliases create mode 100644 test/integration/targets/aci_epg_to_domain/tasks/main.yml create mode 100644 test/integration/targets/aci_filter_entry/aliases create mode 100644 test/integration/targets/aci_filter_entry/tasks/main.yml create mode 100644 test/integration/targets/aci_vrf/aliases create mode 100644 test/integration/targets/aci_vrf/tasks/main.yml diff --git a/test/integration/targets/aci_ap/aliases b/test/integration/targets/aci_ap/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_ap/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_ap/tasks/main.yml b/test/integration/targets/aci_ap/tasks/main.yml new file mode 100644 index 0000000000..eadced8d90 --- /dev/null +++ b/test/integration/targets/aci_ap/tasks/main.yml @@ -0,0 +1,164 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill 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 diff --git a/test/integration/targets/aci_bd/aliases b/test/integration/targets/aci_bd/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_bd/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_bd/tasks/main.yml b/test/integration/targets/aci_bd/tasks/main.yml new file mode 100644 index 0000000000..dd1ad2f142 --- /dev/null +++ b/test/integration/targets/aci_bd/tasks/main.yml @@ -0,0 +1,190 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill 1 + - query_all.existing.0.fvBD is defined + - '"rsp-subtree-class=fvRsCtx,fvRsIgmpsn,fvRsBDToNdP,fvRsBdToEpRet" in query_all.filter_string' + - '"class/fvBD.json" in query_all.url' + - query_tenant.changed == false + - query_tenant.existing | length == 1 + - query_tenant.existing.0.fvTenant.children | length == 2 + - '"rsp-subtree-class=fvRsCtx,fvRsIgmpsn,fvRsBDToNdP,fvRsBdToEpRet,fvBD" in query_tenant.filter_string' + - '"tn-anstest.json" in query_tenant.url' + - query_bd_bd.changed == false + - query_bd_bd.existing != [] + - '"query-target-filter=eq(fvBD.name, \"anstest\")" in query_bd_bd.filter_string' + - '"rsp-subtree=full&rsp-subtree-class=fvRsCtx,fvRsIgmpsn,fvRsBDToNdP,fvRsBdToEpRet" in query_bd_bd.filter_string' + - '"class/fvBD.json" in query_bd_bd.url' + - query_bd.changed == false + - query_bd.existing | length == 1 + - 'query_bd.existing.0.fvBD.attributes.name == "anstest"' + - '"rsp-subtree-class=fvRsCtx,fvRsIgmpsn,fvRsBDToNdP,fvRsBdToEpRet" in query_bd.filter_string' + - '"tn-anstest/BD-anstest.json" in query_bd.url' + +- name: delete bd - check mode works + aci_bd: &aci_bd_absent + <<: *aci_bd_present + state: absent + check_mode: yes + register: bd_absent_check_mode + +- name: delete bd - delete works + aci_bd: + <<: *aci_bd_absent + register: bd_absent + +- name: delete bd again - idempotency works + aci_bd: + <<: *aci_bd_absent + register: bd_absent_idempotent + +- name: delete bd - cleanup + aci_bd: + <<: *aci_bd_absent + name: anstest2 + +- name: delete bd missing param - fails properly + aci_bd: + <<: *aci_bd_absent + bd: "{{ fakevar | default(omit) }}" + ignore_errors: yes + register: bd_absent_missing_param + +- name: asserts for deletion task + assert: + that: + - bd_absent_check_mode.changed == true + - bd_absent_check_mode.proposed == {} + - bd_absent.changed == true + - bd_absent.existing != [] + - bd_absent_idempotent.changed == false + - bd_absent_idempotent.existing == [] + - bd_absent_missing_param.failed == true + - 'bd_absent_missing_param.msg == "state is absent but the following are missing: bd"' + +- name: delete vrf - cleanup before ending tests + aci_vrf: + <<: *aci_vrf_present + state: absent + when: vrf_present.changed == true + +- name: delete tenant - cleanup before ending tests + aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present.changed == true diff --git a/test/integration/targets/aci_bd_subnet/aliases b/test/integration/targets/aci_bd_subnet/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_bd_subnet/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_bd_subnet/tasks/main.yml b/test/integration/targets/aci_bd_subnet/tasks/main.yml new file mode 100644 index 0000000000..8d176fcb94 --- /dev/null +++ b/test/integration/targets/aci_bd_subnet/tasks/main.yml @@ -0,0 +1,233 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill 1 + - get_all_tenant.changed == false + - '"tn-anstest.json" in get_all_tenant.url' + - get_all_bd.changed == false + - '"query-target-filter=eq(fvBD.name, \"anstest\")" in get_all_bd.filter_string' + - '"class/fvBD.json" in get_all_bd.url' + - get_all_tenant_bd.changed == false + - '"tn-anstest/BD-anstest.json" in get_all_tenant_bd.url' + - get_all_tenant_bd.existing.0.fvBD.children | length > 1 + - get_subnet_tenant.changed == false + - '"rsp-subtree-filter=eq(fvSubnet.ip, \"10.100.100.1/24\")" in get_subnet_tenant.filter_string' + - '"tn-anstest.json" in get_subnet_tenant.url' + - get_subnet_bd.changed == false + - '"query-target-filter=eq(fvBD.name, \"anstest\")" and "rsp-subtree-filter=eq(fvSubnet.ip, \"10.100.100.1/24\")" in get_subnet_bd.filter_string' + - '"class/fvBD.json" in get_subnet_bd.url' + - get_subnet.changed == false + - get_subnet.existing | length == 1 + - '"tn-anstest/BD-anstest/subnet-[10.100.100.1/24].json" in get_subnet.url' + - get_subnets_gateway.changed == false + - '"query-target-filter=eq(fvSubnet.ip, \"10.100.100.1/24\")" in get_subnets_gateway.filter_string' + - '"class/fvSubnet.json" in get_subnets_gateway.url' + +- name: delete subnet - check mode works + aci_bd_subnet: + <<: *aci_subnet_absent + check_mode: yes + register: delete_check_mode + +- name: delete subnet - delete works + aci_bd_subnet: + <<: *aci_subnet_absent + register: delete_subnet + +- name: delete subnet - cleanup + aci_bd_subnet: + <<: *aci_subnet2_absent + +- name: delete subnet again - idempotency works + aci_bd_subnet: + <<: *aci_subnet2_absent + register: delete_idempotency + +- name: asserts for deletion task + assert: + that: + - delete_check_mode.changed == true + - delete_check_mode.proposed == {} + - delete_subnet.changed == true + - delete_subnet.existing != [] + - 'delete_subnet.method == "DELETE"' + - delete_idempotency.changed == false + - delete_idempotency.existing == [] + +- name: delete bd - cleanup before ending tests + aci_bd: + <<: *aci_bd_present + state: absent + when: bd_present.changed == true + +- name: delete tenant - cleanup before ending tests + aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present.changed == true diff --git a/test/integration/targets/aci_config_rollback/aliases b/test/integration/targets/aci_config_rollback/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_config_rollback/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_config_rollback/tasks/main.yml b/test/integration/targets/aci_config_rollback/tasks/main.yml new file mode 100644 index 0000000000..1bbc09c448 --- /dev/null +++ b/test/integration/targets/aci_config_rollback/tasks/main.yml @@ -0,0 +1,91 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill " in rollback_preview.diff' + - '"snapshots.diff.xml" in rollback_preview.url' + - rollback_missing_param.failed == true + - 'rollback_missing_param.msg == "state is rollback but the following are missing: import_policy"' + - rollback_rollback.changed == true + - '"ce2_" in rollback_rollback.config.configImportP.attributes.fileName' + - '".tar.gz" in rollback_rollback.config.configImportP.attributes.fileName' + - '"fabric/configimp-anstest.json" in rollback_rollback.url' + - tenant_removed.changed == false + - tenant_removed.existing == [] diff --git a/test/integration/targets/aci_config_snapshot/aliases b/test/integration/targets/aci_config_snapshot/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_config_snapshot/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_config_snapshot/tasks/main.yml b/test/integration/targets/aci_config_snapshot/tasks/main.yml new file mode 100644 index 0000000000..d6465783c0 --- /dev/null +++ b/test/integration/targets/aci_config_snapshot/tasks/main.yml @@ -0,0 +1,139 @@ +# Test code for the ACI modules +# Copyright 2017, Dag Wieers + +# 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: create a snapshot - creation works + aci_config_snapshot: &create_snapshot + hostname: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: no + export_policy: anstest + max_count: 10 + include_secure: no + format: json + description: ansible test + register: create + +- name: update snapshot to include secure and use xml - update works + aci_config_snapshot: + <<: *create_snapshot + include_secure: "yes" + format: xml + register: create_update + +- name: create a snapshot invalid max_count - error message + aci_config_snapshot: + <<: *create_snapshot + max_count: 11 + ignore_errors: yes + register: invalid_max_count + +- name: create a snapshot invalid max_count - error message + aci_config_snapshot: + <<: *create_snapshot + export_policy: "{{ fake_var | default(omit) }}" + ignore_errors: yes + register: missing_param + +- name: present assertion tests + assert: + that: + - create.failed == false + - create.changed == true + - 'create.config.configExportP.attributes.adminSt == "triggered"' + - create_update.failed == false + - create_update.changed == true + - 'create_update.config == {"configExportP": {"attributes": {"adminSt": "triggered", "format": "xml", "includeSecureFields": "yes"}}}' + - invalid_max_count.failed == true + - 'invalid_max_count.msg == "The \"max_count\" must be a number between 1 and 10"' + - missing_param.failed == true + - 'missing_param.msg == "state is present but the following are missing: export_policy"' + +- name: query with export_policy + aci_config_snapshot: &query_snapshot + <<: *create_snapshot + state: query + register: query_export + +- name: generate snapshot name + set_fact: + test_snapshot: "{{ query_export.existing.0.configSnapshotCont.children.0.configSnapshot.attributes.rn.strip('snapshot-') }}" + +- name: query with export_policy and snapshot + aci_config_snapshot: &query_both + <<: *query_snapshot + snapshot: "{{ test_snapshot }}" + register: query_export_snapshot + +- name: query with snapshot - module add run- to snapshot + aci_config_snapshot: + <<: *query_snapshot + export_policy: "{{ fake_var | default(omit) }}" + snapshot: "{{ test_snapshot.strip('run-') }}" + register: query_snapshot + +- name: query no params + aci_config_snapshot: + <<: *query_snapshot + export_policy: "{{ fake_var | default(omit) }}" + register: query_all + +- name: query assertion tests + assert: + that: + - query_export.failed == false + - query_export.changed == false + - '"snapshots-[uni/fabric/configexp-anstest].json" in query_export.url' + - 'query_export.existing.0.configSnapshotCont.attributes.name == "anstest"' + - query_export.existing.0.configSnapshotCont.children | length > 1 + - query_export_snapshot.failed == false + - query_export_snapshot.changed == false + - '"snapshots-[uni/fabric/configexp-anstest]/snapshot-{{ test_snapshot }}.json" in query_export_snapshot.url' + - query_export_snapshot.existing | length == 1 + - query_snapshot.failed == false + - query_snapshot.changed == false + - '"class/configSnapshot.json" in query_snapshot.url' + - '"configSnapshot.name, \"{{ test_snapshot }}\"" in query_snapshot.filter_string' + - query_all.failed == false + - query_all.changed == false + - '"class/configSnapshot.json" in query_all.url' + - query_all.existing | length > 1 + +- name: delete works + aci_config_snapshot: &delete + <<: *query_both + state: absent + register: delete_snapshot + +- name: delete works - idempotency + aci_config_snapshot: + <<: *delete + register: delete_idempotent + +- name: delete missing param + aci_config_snapshot: + <<: *delete + snapshot: "{{ fake_var | default(omit) }}" + ignore_errors: yes + register: delete_missing_param + +- name: absent assertion tests + assert: + that: + - delete_snapshot.failed == false + - delete_snapshot.changed == true + - 'delete_snapshot.config == {"configSnapshot": {"attributes": {"retire": "yes"}}}' + - delete_snapshot.existing != [] + - delete_snapshot.existing.0.configSnapshot.attributes.name == test_snapshot + - delete_idempotent.failed == false + - delete_idempotent.changed == false + - delete_idempotent.existing == [] + - delete_missing_param.failed == true + - 'delete_missing_param.msg == "state is absent but the following are missing: snapshot"' diff --git a/test/integration/targets/aci_contract/aliases b/test/integration/targets/aci_contract/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_contract/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_contract/tasks/main.yml b/test/integration/targets/aci_contract/tasks/main.yml new file mode 100644 index 0000000000..9e65da63d2 --- /dev/null +++ b/test/integration/targets/aci_contract/tasks/main.yml @@ -0,0 +1,160 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill 1 + - '"rsp-subtree-class=vzBrCP" in query_tenant.filter_string' + - '"tn-anstest.json" in query_tenant.url' + - query_name.changed == false + - query_name.existing != [] + - '"query-target-filter=eq(vzBrCP.name, \"anstest\")" in query_name.filter_string' + - '"class/vzBrCP.json" in query_name.url' + - query_all.changed == false + - query_all.existing | length > 1 + - '"class/vzBrCP.json" in query_all.url' + +- name: delete contract - check mode works + aci_contract: &aci_contract_absent + <<: *aci_contract_present + state: absent + check_mode: yes + register: absent_check_mode + +- name: delete contract - deletion works + aci_contract: + <<: *aci_contract_absent + register: contract_absent + +- name: delete contract - idempotency works + aci_contract: + <<: *aci_contract_absent + register: absent_idempotent + +- name: delete contract - cleanup second contract + aci_contract: + <<: *aci_contract_absent + contract: anstest2 + +- name: missing param - fail message works + aci_contract: + <<: *aci_contract_absent + tenant: "{{ fakevar | default(omit) }}" + ignore_errors: yes + register: absent_missing_param + +- name: absent assertions + assert: + that: + - absent_check_mode.changed == true + - absent_check_mode.existing != [] + - contract_absent.changed == true + - contract_absent.existing == absent_check_mode.existing + - absent_idempotent.changed == false + - absent_idempotent.existing == [] + - absent_missing_param.failed == true + - 'absent_missing_param.msg == "state is absent but the following are missing: tenant"' + +- name: cleanup tenant + aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present.changed == true diff --git a/test/integration/targets/aci_contract_subject/aliases b/test/integration/targets/aci_contract_subject/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_contract_subject/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_contract_subject/tasks/main.yml b/test/integration/targets/aci_contract_subject/tasks/main.yml new file mode 100644 index 0000000000..6c3af06865 --- /dev/null +++ b/test/integration/targets/aci_contract_subject/tasks/main.yml @@ -0,0 +1,238 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill 1 + - query_all.existing.0.vzSubj is defined + - '"class/vzSubj.json" in query_all.url' + +- name: delete subject - check mode works + aci_contract_subject: &aci_subject_absent + <<: *aci_subject_present + state: absent + check_mode: yes + register: subject_absent_check_mode + +- name: delete subject - deletion works + aci_contract_subject: + <<: *aci_subject_absent + register: subject_absent + +- name: delete subject - idempotency works + aci_contract_subject: + <<: *aci_subject_absent + register: subject_absent_idempotent + +- name: delete subject - cleanup + aci_contract_subject: + <<: *aci_subject_present_2 + state: absent + +- name: missing params - failure message works + aci_contract_subject: + <<: *aci_subject_absent + subject: "{{ fakevar | default(omit) }}" + ignore_errors: yes + register: absent_missing_param + +- name: absent assertions + assert: + that: + - subject_absent_check_mode.changed == true + - subject_absent_check_mode.existing != [] + - subject_absent_check_mode.proposed == {} + - subject_absent.changed == true + - subject_absent.existing == subject_absent_check_mode.existing + - subject_absent_idempotent.changed == false + - subject_absent_idempotent.existing == [] + - absent_missing_param.failed == true + - 'absent_missing_param.msg == "state is absent but the following are missing: subject"' + +- name: cleanup contract + aci_contract: + <<: *aci_contract_present + state: absent + when: contract_present.changed == true + +- name: cleanup tenant + aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present.changed == true diff --git a/test/integration/targets/aci_contract_subject_to_filter/aliases b/test/integration/targets/aci_contract_subject_to_filter/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_contract_subject_to_filter/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_contract_subject_to_filter/tasks/main.yml b/test/integration/targets/aci_contract_subject_to_filter/tasks/main.yml new file mode 100644 index 0000000000..96876b5418 --- /dev/null +++ b/test/integration/targets/aci_contract_subject_to_filter/tasks/main.yml @@ -0,0 +1,190 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill 1 + - query_all.existing.0.vzRsSubjFiltAtt is defined + - query_binding.changed == false + - query_binding.existing != [] + +- name: delete subject filter binding - check mode works + aci_contract_subject_to_filter: &aci_subject_filter_absent + <<: *aci_subject_filter_present + state: absent + check_mode: yes + register: subject_filter_absent_check_mode + +- name: delete subject filter binding - deletion works + aci_contract_subject_to_filter: + <<: *aci_subject_filter_absent + register: subject_filter_absent + +- name: delete subject filter binding - idempotency works + aci_contract_subject_to_filter: + <<: *aci_subject_filter_absent + register: subject_filter_absent_idempotent + +- name: missing param - failure message works + aci_contract_subject_to_filter: + <<: *aci_subject_filter_absent + filter: "{{ fakevar | default(omit) }}" + ignore_errors: yes + register: absent_missing_param + +- name: cleanup subject filter binding + aci_contract_subject_to_filter: + <<: *aci_subject_filter_present_2 + state: absent + +- name: absent assertions + assert: + that: + - subject_filter_absent_check_mode.changed == true + - subject_filter_absent_check_mode.proposed == {} + - subject_filter_absent_check_mode.existing != [] + - subject_filter_absent.changed == true + - subject_filter_absent.existing != [] + - subject_filter_absent_idempotent.changed == false + - subject_filter_absent_idempotent.existing == [] + - absent_missing_param.failed == true + - 'absent_missing_param.msg == "state is absent but the following are missing: filter"' + +- name: cleanup subject + aci_contract_subject: + <<: *aci_subject_present + state: absent + when: subject_present.changed == true + +- name: cleanup contract + aci_contract: + <<: *aci_contract_present + state: absent + when: contract_present.changed == true + +- name: cleanup filter + aci_filter: + <<: *aci_filter_present + state: absent + when: filter_present.changed == true + +- name: cleanup filter + aci_filter: + <<: *aci_filter_present_2 + state: absent + when: filter_present_2.changed == true + +- name: cleanup tenant + aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present.changed == true diff --git a/test/integration/targets/aci_epg/aliases b/test/integration/targets/aci_epg/aliases new file mode 100644 index 0000000000..3c1de7e647 --- /dev/null +++ b/test/integration/targets/aci_epg/aliases @@ -0,0 +1 @@ +# No ACI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_epg/tasks/main.yml b/test/integration/targets/aci_epg/tasks/main.yml new file mode 100644 index 0000000000..64bb236f5e --- /dev/null +++ b/test/integration/targets/aci_epg/tasks/main.yml @@ -0,0 +1,168 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill 1 + - '"rsp-subtree-class=fvRsBd" in epg_query_all.filter_string' + - '"class/fvAEPg.json" in epg_query_all.url' + +- name: delete epg - check mode works + aci_epg: &aci_epg_absent + <<: *aci_epg_present + state: absent + check_mode: yes + register: delete_epg_check_mode + +- name: delete epg - delete works + aci_epg: + <<: *aci_epg_absent + register: delete_epg + +- name: delete epg - idempotency works + aci_epg: + <<: *aci_epg_absent + register: delete_epg_idempotent + +- name: delete epg - cleanup extra epg + aci_epg: + <<: *aci_epg_absent + epg: anstest2 + +- name: delete epg - missing param fails + aci_epg: + <<: *aci_epg_absent + tenant: "{{ fakevar | default(omit) }}" + ignore_errors: yes + register: delete_epg_missing_param + +- name: query assertions + assert: + that: + - delete_epg_check_mode.changed == true + - delete_epg_check_mode.existing != [] + - delete_epg.changed == true + - delete_epg.existing == delete_epg_check_mode.existing + - delete_epg_idempotent.changed == false + - delete_epg_idempotent.existing == [] + - delete_epg_missing_param.failed == true + - 'delete_epg_missing_param.msg == "state is absent but the following are missing: tenant"' + +- name: cleanup bd + aci_bd: + <<: *aci_bd_present + state: absent + when: bd_present.existing == [] + +- name: cleanup ap + aci_ap: + <<: *aci_ap_present + state: absent + when: ap_present.existing == [] + +- name: cleanup tenant + aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present.existing == [] diff --git a/test/integration/targets/aci_epg_to_contract/aliases b/test/integration/targets/aci_epg_to_contract/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_epg_to_contract/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_epg_to_contract/tasks/main.yml b/test/integration/targets/aci_epg_to_contract/tasks/main.yml new file mode 100644 index 0000000000..879bc1637e --- /dev/null +++ b/test/integration/targets/aci_epg_to_contract/tasks/main.yml @@ -0,0 +1,235 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill + +# 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: ensure ap exists for tests to kick off + aci_ap: &aci_ap_present + <<: *aci_tenant_present + ap: anstest + register: ap_present + +- name: ensure epg exists for tests to kick off + aci_epg: &aci_epg_present + <<: *aci_ap_present + epg: anstest + register: epg_present + +- name: ensure phys domain exists for tests to kick off + aci_rest: &aci_rest_phys_domain + hostname: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: no + method: post + path: api/mo/uni/phys-anstest.json + content: {"physDomP": {"attributes": {}}} + register: phys_domain_post + +- name: ensure vmm domain exists for tests to kick off + aci_rest: &aci_rest_vmm_domain + <<: *aci_rest_phys_domain + path: api/mo/uni/vmmp-VMware/dom-anstest.json + content: {"vmmDomP": {"attributes": {}}} + register: vmm_domain_post + +- name: bind phys domain to epg - check mode works + aci_epg_to_domain: &aci_epg_to_domain_present + <<: *aci_epg_present + domain: anstest + domain_type: phys + check_mode: yes + register: phys_check_mode_present + +- name: bind phys domain to epg - creation works + aci_epg_to_domain: + <<: *aci_epg_to_domain_present + register: phys_present + +- name: bind phys domain to epg - idempotency works + aci_epg_to_domain: + <<: *aci_epg_to_domain_present + register: phys_idempotent + +- name: bind phys domain to epg - update works + aci_epg_to_domain: + <<: *aci_epg_to_domain_present + deploy_immediacy: immediate + register: phys_update + +- name: bind vmm domain to epg - creation works + aci_epg_to_domain: &aci_epg_to_domain_vmm_present + <<: *aci_epg_to_domain_present + domain_type: vmm + vm_provider: vmware + resolution_immediacy: pre-provision + register: vmm_present + +- name: bind vmm domain to epg - missing params + aci_epg_to_domain: + <<: *aci_epg_to_domain_vmm_present + vm_provider: "{{ fake_var | default(omit) }}" + ignore_errors: yes + register: present_missing_params + +- name: bind vmm domain to epg - invalid vlan + aci_epg_to_domain: + <<: *aci_epg_to_domain_present + encap: 4097 + ignore_errors: yes + register: invalid_vlan + +- name: bind vmm domain to epg - incompatible params + aci_epg_to_domain: + <<: *aci_epg_to_domain_present + vm_provider: vmware + ignore_errors: yes + register: incompatible_params + +- name: present assertions + assert: + that: + - phys_check_mode_present.changed == true + - phys_present.changed == true + - phys_present.existing == [] + - 'phys_present.config == {"fvRsDomAtt": {"attributes": {}}}' + - '"[uni/phys-anstest].json" in phys_present.url' + - phys_idempotent.changed == false + - phys_idempotent.config == {} + - phys_update.changed == true + - 'phys_update.config == {"fvRsDomAtt": {"attributes": {"instrImedcy": "immediate"}}}' + - vmm_present.changed == true + - 'vmm_present.config == {"fvRsDomAtt": {"attributes": {"resImedcy": "pre-provision"}}}' + - '"[uni/vmmp-VMware/dom-anstest].json" in vmm_present.url' + - present_missing_params.failed == true + - 'present_missing_params.msg == "domain_type is vmm but the following are missing: vm_provider"' + - invalid_vlan.failed == true + - 'invalid_vlan.msg == "Valid VLAN assigments are from 1 to 4096"' + - incompatible_params.failed == true + - incompatible_params.msg == "Domain type 'phys' cannot have a 'vm_provider'" + +- name: get domain epg binding + aci_epg_to_domain: &aci_epg_domain_query + <<: *aci_tenant_present + state: query + tenant: "{{ fake_var | default(omit) }}" + register: binding_query + +- name: query assertions + assert: + that: + - binding_query.changed == false + - binding_query.existing | length > 1 + - '"class/fvRsDomAtt.json" in binding_query.url' + +- name: delete domain epg binding - check mode + aci_epg_to_domain: &aci_epg_to_domain_absent + <<: *aci_epg_to_domain_present + state: absent + check_mode: yes + register: epg_domain_check_mode_absent + +- name: delete phys domain epg binding - delete works + aci_epg_to_domain: + <<: *aci_epg_to_domain_absent + register: epg_domain_absent + +- name: delete vmm domain epg binding - delete works + aci_epg_to_domain: + <<: *aci_epg_to_domain_vmm_present + state: absent + register: epg_vmm_domain_absent + +- name: delete domain epg binding - idempotency works + aci_epg_to_domain: + <<: *aci_epg_to_domain_absent + register: idempotency_absent + +- name: delete domain epg binding - missing param + aci_epg_to_domain: + <<: *aci_tenant_present + state: absent + ignore_errors: true + register: absent_missing_param + +- name: absent assertions + assert: + that: + - epg_domain_check_mode_absent.changed == true + - epg_domain_check_mode_absent.existing != [] + - epg_domain_absent.changed == true + - epg_domain_absent.existing == epg_domain_check_mode_absent.existing + - epg_vmm_domain_absent.changed == true + - idempotency_absent.changed == false + - idempotency_absent.existing == [] + - absent_missing_param.failed == true + - 'absent_missing_param.msg == "state is absent but the following are missing: ap,domain,domain_type,epg"' + +- name: remove vmm domain - cleanup + aci_rest: + <<: *aci_rest_vmm_domain + method: delete + when: vmm_domain_post.changed == true + +- name: remove phys domain - cleanup + aci_rest: + <<: *aci_rest_phys_domain + method: delete + when: phys_domain_post.changed == true + +- name: remove epg - cleanup + aci_epg: + <<: *aci_epg_present + state: absent + when: epg_present.changed == true + +- name: remove ap - cleanup + aci_ap: + <<: *aci_ap_present + state: absent + when: ap_present.changed == true + +- name: remove tenant - cleanup + aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present.changed == true \ No newline at end of file diff --git a/test/integration/targets/aci_filter_entry/aliases b/test/integration/targets/aci_filter_entry/aliases new file mode 100644 index 0000000000..3c1de7e647 --- /dev/null +++ b/test/integration/targets/aci_filter_entry/aliases @@ -0,0 +1 @@ +# No ACI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_filter_entry/tasks/main.yml b/test/integration/targets/aci_filter_entry/tasks/main.yml new file mode 100644 index 0000000000..03599e94d5 --- /dev/null +++ b/test/integration/targets/aci_filter_entry/tasks/main.yml @@ -0,0 +1,279 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill 1 + - query_all.existing.0.vzEntry is defined + - '"class/vzEntry.json" in query_all.url' + +- name: delete entry - check mode works + aci_filter_entry: &aci_entry_absent + <<: *aci_entry_present + state: absent + check_mode: yes + register: entry_absent_check_mode + +- name: delete entry - deletion works + aci_filter_entry: + <<: *aci_entry_absent + register: entry_absent + +- name: delete entry - idempotency works + aci_filter_entry: + <<: *aci_entry_absent + register: entry_absent_idempotent + +- name: missing param - failure message works + aci_filter_entry: + <<: *aci_tenant_present + state: absent + ignore_errors: yes + register: absent_missing_param + +- name: cleanup remaining entries + aci_filter_entry: + <<: *aci_entry_absent + entry: "{{ item }}" + with_items: ["anstest2", "anstest3", "anstest4"] + +- name: absent assertions + assert: + that: + - entry_absent_check_mode.changed == true + - entry_absent_check_mode.existing != [] + - entry_absent.changed == true + - entry_absent.existing == entry_absent_check_mode.existing + - entry_absent.proposed == {} + - entry_absent_idempotent.changed == false + - entry_absent_idempotent.existing == [] + - absent_missing_param.failed == true + - 'absent_missing_param.msg == "state is absent but the following are missing: entry,filter"' + +- name: cleanup filter + aci_filter: + <<: *aci_filter_present + state: absent + when: filter_present.changed == true + +- name: cleanup tenant + aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present.changed == true diff --git a/test/integration/targets/aci_vrf/aliases b/test/integration/targets/aci_vrf/aliases new file mode 100644 index 0000000000..b4e2520c17 --- /dev/null +++ b/test/integration/targets/aci_vrf/aliases @@ -0,0 +1 @@ +# No AcI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_vrf/tasks/main.yml b/test/integration/targets/aci_vrf/tasks/main.yml new file mode 100644 index 0000000000..fa9e1a4064 --- /dev/null +++ b/test/integration/targets/aci_vrf/tasks/main.yml @@ -0,0 +1,171 @@ +# Test code for the ACI modules +# Copyright 2017, Jacob McGill 1 + - query_all.existing.0.fvCtx is defined + - '"class/fvCtx.json" in query_all.url' + - query_tenant.changed == false + - query_tenant.existing | length == 1 + - query_tenant.existing.0.fvTenant.children | length == 2 + - 'query_tenant.existing.0.fvTenant.attributes.name == "anstest"' + - '"rsp-subtree-class=fvCtx" in query_tenant.filter_string' + - '"tn-anstest.json" in query_tenant.url' + - query_vrf_vrf.changed == false + - query_vrf_vrf.existing != [] + - 'query_vrf_vrf.existing.0.fvCtx.attributes.name == "anstest"' + - '"query-target-filter=eq(fvCtx.name, \"anstest\")" in query_vrf_vrf.filter_string' + - '"class/fvCtx.json" in query_vrf_vrf.url' + - query_vrf.changed == false + - query_vrf.existing | length == 1 + - '"tn-anstest/ctx-anstest.json" in query_vrf.url' + +- name: delete vrf - check mode works + aci_vrf: &aci_vrf_absent + <<: *aci_vrf_present + state: absent + check_mode: yes + register: vrf_absent_check_mode + +- name: delete vrf - delete works + aci_vrf: + <<: *aci_vrf_absent + register: vrf_absent + +- name: delete vrf again - idempotency works + aci_vrf: + <<: *aci_vrf_absent + register: vrf_absent_idempotent + +- name: delete vrf - cleanup + aci_vrf: + <<: *aci_vrf_absent + name: anstest2 + +- name: delete vrf missing param - fails properly + aci_vrf: + <<: *aci_vrf_absent + vrf: "{{ fakevar | default(omit) }}" + ignore_errors: yes + register: vrf_absent_missing_param + +- name: asserts for deletion task + assert: + that: + - vrf_absent_check_mode.changed == true + - vrf_absent_check_mode.existing != [] + - vrf_absent_check_mode.proposed == {} + - vrf_absent.changed == true + - vrf_absent.existing == vrf_absent_check_mode.existing + - vrf_absent_idempotent.changed == false + - vrf_absent_idempotent.existing == [] + - vrf_absent_missing_param.failed == true + - 'vrf_absent_missing_param.msg == "state is absent but the following are missing: vrf"' + +- name: delete tenant - cleanup before ending tests + aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present.changed == true