Meraki - Integration tests now clean up on failure (#42227)

* Added block and always support to meraki_network integration test

* Add blocks to admin and vlan integration test

* Resolved bad variable names
pull/42239/head
Kevin Breit 6 years ago committed by Dag Wieers
parent 75c8d8bfc2
commit f9cbdcd426

@ -1,8 +1,9 @@
# Test code for the Meraki Organization module # Test code for the Meraki Admin module
# Copyright: (c) 2018, Kevin Breit (@kbreit) # Copyright: (c) 2018, Kevin Breit (@kbreit)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
--- ---
- block:
- name: Create new administrator - name: Create new administrator
meraki_admin: meraki_admin:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
@ -228,6 +229,10 @@
- query_name.data.name == "Jane Doe" - query_name.data.name == "Jane Doe"
- 'query_email.data.email == "{{email_prefix}}+janedoe@{{email_domain}}"' - 'query_email.data.email == "{{email_prefix}}+janedoe@{{email_domain}}"'
always:
#############################################################################
# Tear down starts here
#############################################################################
- name: Delete administrators - name: Delete administrators
meraki_admin: meraki_admin:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
@ -236,6 +241,7 @@
email: '{{item}}' email: '{{item}}'
delegate_to: localhost delegate_to: localhost
register: delete_all register: delete_all
ignore_errors: yes
loop: loop:
- '{{email_prefix}}+janedoe@{{email_domain}}' - '{{email_prefix}}+janedoe@{{email_domain}}'
- '{{email_prefix}}+johndoe@{{email_domain}}' - '{{email_prefix}}+johndoe@{{email_domain}}'

@ -3,6 +3,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
--- ---
- block:
- name: Create network without type - name: Create network without type
meraki_network: meraki_network:
auth_key: '{{ auth_key }}' auth_key: '{{ auth_key }}'
@ -180,9 +181,13 @@
- name: Query assertions - name: Query assertions
assert: assert:
that: that:
# - net_query_all.data | length == 7
- 'net_query_one.data.name == "IntTestNetworkSwitch"' - 'net_query_one.data.name == "IntTestNetworkSwitch"'
#############################################################################
# Tear down starts here
#############################################################################
always:
- name: Delete network without org - name: Delete network without org
meraki_network: meraki_network:
auth_key: '{{ auth_key }}' auth_key: '{{ auth_key }}'
@ -192,9 +197,6 @@
register: delete_all_no_org register: delete_all_no_org
ignore_errors: yes ignore_errors: yes
- debug:
msg: '{{delete_all_no_org}}'
- name: Delete network by org ID - name: Delete network by org ID
meraki_network: meraki_network:
auth_key: '{{ auth_key }}' auth_key: '{{ auth_key }}'
@ -204,9 +206,6 @@
delegate_to: localhost delegate_to: localhost
register: delete_net_org_id register: delete_net_org_id
- debug:
msg: '{{delete_net_org_id}}'
- name: Query after delete with org ID - name: Query after delete with org ID
meraki_network: meraki_network:
auth_key: '{{ auth_key }}' auth_key: '{{ auth_key }}'
@ -223,6 +222,7 @@
net_name: '{{ item }}' net_name: '{{ item }}'
delegate_to: localhost delegate_to: localhost
register: delete_all register: delete_all
ignore_errors: yes
loop: loop:
- IntTestNetworkSwitch - IntTestNetworkSwitch
- IntTestNetworkWireless - IntTestNetworkWireless
@ -231,17 +231,6 @@
- IntTestNetworkTag - IntTestNetworkTag
- IntTestNetworkTags - IntTestNetworkTags
- name: Query after delete all - assert:
meraki_network:
auth_key: '{{ auth_key }}'
state: query
org_name: '{{test_org_name}}'
delegate_to: localhost
register: query_deleted
- name: Delete assertions
assert:
that: that:
- '"org_name or org_id parameters are required" in delete_all_no_org.msg' - 'delete_all_no_org.msg == "org_name or org_id parameters are required"'
# - query_deleted_org_id.data | length == 6
# - query_deleted.data | length == 0

@ -1,8 +1,9 @@
# Test code for the Meraki Organization module # Test code for the Meraki VLAN module
# Copyright: (c) 2018, Kevin Breit (@kbreit) # Copyright: (c) 2018, Kevin Breit (@kbreit)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
--- ---
- block:
- name: Test an API key is provided - name: Test an API key is provided
fail: fail:
msg: Please define an API key msg: Please define an API key
@ -13,7 +14,7 @@
auth_key: '{{ auth_key }}' auth_key: '{{ auth_key }}'
host: marrrraki.com host: marrrraki.com
state: present state: present
org_name: '{{test_org_name}}' org_name: IntTestOrg
output_level: debug output_level: debug
delegate_to: localhost delegate_to: localhost
register: invalid_domain register: invalid_domain
@ -24,7 +25,6 @@
auth_key: '{{ auth_key }}' auth_key: '{{ auth_key }}'
use_https: false use_https: false
state: query state: query
org_name: '{{test_org_name}}'
output_level: debug output_level: debug
delegate_to: localhost delegate_to: localhost
register: http register: http
@ -160,7 +160,7 @@
that: that:
- update_vlan_add_ip.changed == True - update_vlan_add_ip.changed == True
- update_vlan_add_ip.data.fixedIpAssignments | length == 2 - update_vlan_add_ip.data.fixedIpAssignments | length == 2
- update_vlan_add_ip.data.reservedIpRanges | length == 2 - update_vlan_add_ip.data.reservedIpRange | length == 2
- name: Remove IP assignments and reserved IP ranges - name: Remove IP assignments and reserved IP ranges
meraki_vlan: meraki_vlan:
@ -191,7 +191,7 @@
that: that:
- update_vlan_remove_ip.changed == True - update_vlan_remove_ip.changed == True
- update_vlan_remove_ip.data.fixedIpAssignments | length == 1 - update_vlan_remove_ip.data.fixedIpAssignments | length == 1
- update_vlan_remove_ip.data.reservedIpRanges | length == 1 - update_vlan_remove_ip.data.reservedIpRange | length == 1
- name: Update VLAN with idempotency - name: Update VLAN with idempotency
meraki_vlan: meraki_vlan:
@ -289,6 +289,10 @@
- query_vlan.data.id == 2 - query_vlan.data.id == 2
- query_vlan.changed == False - query_vlan.changed == False
always:
#############################################################################
# Tear down starts here
#############################################################################
- name: Delete VLAN - name: Delete VLAN
meraki_vlan: meraki_vlan:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'

Loading…
Cancel
Save