From 24b58ba1092adc85eddcf9e97ba6f356acfdb2ba Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Wed, 16 Aug 2017 04:05:24 +0200 Subject: [PATCH] aci_filter: Integration tests (#28256) --- test/integration/targets/aci_filter/aliases | 1 + .../targets/aci_filter/tasks/main.yml | 211 ++++++++++++++++++ 2 files changed, 212 insertions(+) create mode 100644 test/integration/targets/aci_filter/aliases create mode 100644 test/integration/targets/aci_filter/tasks/main.yml diff --git a/test/integration/targets/aci_filter/aliases b/test/integration/targets/aci_filter/aliases new file mode 100644 index 00000000000..3c1de7e647f --- /dev/null +++ b/test/integration/targets/aci_filter/aliases @@ -0,0 +1 @@ +# No ACI Simulator yet, so not enabled diff --git a/test/integration/targets/aci_filter/tasks/main.yml b/test/integration/targets/aci_filter/tasks/main.yml new file mode 100644 index 00000000000..06458497351 --- /dev/null +++ b/test/integration/targets/aci_filter/tasks/main.yml @@ -0,0 +1,211 @@ +# 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 + +# CLEAN ENVIRONMENT +- name: Add tenant + aci_tenant: + hostname: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: no + tenant: ansible_test + state: present + +- name: Remove filter + aci_filter: &filter_absent + hostname: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: no + tenant: ansible_test + filter: filter_test + state: absent + +# ADD FILTER +- name: Add filter (check_mode) + aci_filter: &filter_present + hostname: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: no + tenant: ansible_test + filter: filter_test + state: present + check_mode: yes + register: cm_add_filter + +- name: Add filter again (check_mode) + aci_filter: *filter_present + check_mode: yes + register: cm_add_filter_again + +- name: Add filter (normal mode) + aci_filter: *filter_present + register: nm_add_filter + +- name: Add filter again (normal mode) + aci_filter: *filter_present + register: nm_add_filter_again + +- name: Verify add_filter + assert: + that: + - cm_add_filter.changed == true + - cm_add_filter_again.changed == true + - nm_add_filter.changed == true + - nm_add_filter_again.changed == false + +# CHANGE FILTER +- name: Change description of filter (check_mode) + aci_filter: + <<: *filter_present + description: Ansible test filter + check_mode: yes + register: cm_add_filter_descr + +- name: Change description of filter again (check_mode) + aci_filter: + <<: *filter_present + description: Ansible test filter + check_mode: yes + register: cm_add_filter_descr_again + +- name: Change description of filter (normal mode) + aci_filter: + <<: *filter_present + description: Ansible test filter + register: nm_add_filter_descr + +- name: Change description of filter again (normal mode) + aci_filter: + <<: *filter_present + description: Ansible test filter + register: nm_add_filter_descr_again + +- name: Verify add_filter_descr + assert: + that: + - cm_add_filter_descr.changed == true + - cm_add_filter_descr_again.changed == true + - nm_add_filter_descr.changed == true + - nm_add_filter_descr_again.changed == false + +# ADD FILTER AGAIN +- name: Add filter again with no description (check_mode) + aci_filter: *filter_present + check_mode: yes + register: cm_add_filter_again_no_descr + +- name: Add filter again with no description (normal mode) + aci_filter: *filter_present + register: nm_add_filter_again_no_descr + +- name: Verify add_filter_again_no_descr + assert: + that: + - cm_add_filter_again_no_descr.changed == false + - nm_add_filter_again_no_descr.changed == false + +# QUERY ALL FILTERS +- name: Query all filters (check_mode) + aci_filter: &filter_query + hostname: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: no + state: query + check_mode: yes + register: cm_query_all_filters + +- name: Query all filters (normal mode) + aci_filter: *filter_query + register: nm_query_all_filters + +- name: Verify query_all_filters + assert: + that: + - cm_query_all_filters.changed == false + - nm_query_all_filters.changed == false + # NOTE: Order of filters is not stable between calls + #- cm_query_all_filters == nm_query_all_filters + +# QUERY A FILTER +- name: Query our filter + aci_filter: + <<: *filter_query + tenant: ansible_test + filter: filter_test + check_mode: yes + register: cm_query_filter + +- name: Query our filter + aci_filter: + <<: *filter_query + tenant: ansible_test + filter: filter_test + register: nm_query_filter + +- name: Verify query_filter + assert: + that: + - cm_query_filter.changed == false + - nm_query_filter.changed == false + - cm_query_filter == nm_query_filter + +# REMOVE FILTER +- name: Remove filter (check_mode) + aci_filter: *filter_absent + check_mode: yes + register: cm_remove_filter + +- name: Remove filter again (check_mode) + aci_filter: *filter_absent + check_mode: yes + register: cm_remove_filter_again + +- name: Remove filter (normal mode) + aci_filter: *filter_absent + register: nm_remove_filter + +- name: Remove filter again (normal mode) + aci_filter: *filter_absent + register: nm_remove_filter_again + +- name: Verify remove_filter + assert: + that: + - cm_remove_filter.changed == true + - cm_remove_filter_again.changed == true + - nm_remove_filter.changed == true + - nm_remove_filter_again.changed == false + +# QUERY NON-EXISTING FILTER +# FIXME: Should this fail or return empty values ? +- name: Query non-existing filter (check_mode) + aci_filter: + <<: *filter_query + tenant: ansible_test + filter: filter_test + check_mode: yes + register: cm_query_non_filter + +- name: Query non-existing filter (normal mode) + aci_filter: + <<: *filter_query + tenant: ansible_test + filter: filter_test + register: nm_query_non_filter + +- name: Verify query_non_filter + assert: + that: + - cm_query_non_filter.changed == false + - nm_query_non_filter.changed == false + - cm_query_non_filter == nm_query_non_filter