-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IT: Fix jinja2 warning, add "deleted" state test, more...
1. Fixed the following with the merged.yaml role: [WARNING]: conditional statements should not include jinja2 templating delimiters ... 2. Adding deleted.yaml role 3. Fix ImageUpgradeTask detach_policy result (found with integration test for "deleted" state)
- Loading branch information
1 parent
21866a4
commit 743a1b5
Showing
3 changed files
with
317 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
251 changes: 251 additions & 0 deletions
251
tests/integration/targets/dcnm_image_upgrade/tests/deleted.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
################################################################################ | ||
# RUNTIME | ||
################################################################################ | ||
|
||
# 45 to 50 minutes | ||
# Some previous runtimes where: | ||
# - 44:07.93 | ||
# - 49:23.53 | ||
|
||
################################################################################ | ||
# STEPS | ||
################################################################################ | ||
|
||
# 1. Create a fabric | ||
# 2. Merge switches into fabric | ||
# 3. Upgrade switches using global config | ||
# 4. Detach policies from switches | ||
# 5. Cleanup | ||
|
||
################################################################################ | ||
# REQUIREMENTS | ||
################################################################################ | ||
|
||
# 1. image policies are already configured on the controller: | ||
# - KR5M (Kerry release maintenance 5) | ||
# - NR3F (Niles release maintenance 3) | ||
# The above include both NX-OS and EPLD images. | ||
# | ||
# TODO: Once dcnm_image_policy module is accepted, use that to | ||
# configure the above policies. | ||
# | ||
# Example vars for dcnm_image_upgrade integration tests | ||
# Add to cisco/dcnm/playbooks/dcnm_tests.yaml) | ||
# | ||
# vars: | ||
# # This testcase field can run any test in the tests directory for the role | ||
# testcase: merged | ||
# fabric_name: f1 | ||
# username: admin | ||
# password: "foobar" | ||
# switch_username: admin | ||
# switch_password: "foobar" | ||
# spine1: 172.22.150.114 | ||
# spine2: 172.22.150.115 | ||
# leaf1: 172.22.150.106 | ||
# leaf2: 172.22.150.107 | ||
# leaf3: 172.22.150.108 | ||
# leaf4: 172.22.150.109 | ||
# # for dcnm_image_upgrade role | ||
# test_fabric: "{{ fabric_name }}" | ||
# ansible_switch1: "{{ leaf1 }}" | ||
# ansible_switch2: "{{ leaf2 }}" | ||
# ansible_switch3: "{{ spine1 }}" | ||
# image_policy_1: "KR5M" | ||
# image_policy_2: "NR3F" | ||
|
||
################################################################################ | ||
# SETUP | ||
################################################################################ | ||
|
||
- set_fact: | ||
rest_fabric_create: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ fabric_name }}" | ||
|
||
- name: DELETED - Verify if fabric is deployed. | ||
cisco.dcnm.dcnm_rest: | ||
method: GET | ||
path: "{{ rest_fabric_create }}" | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
|
||
- assert: | ||
that: | ||
- result.response.DATA != None | ||
|
||
- name: DELETED - setup - Clean up any existing devices | ||
cisco.dcnm.dcnm_inventory: | ||
fabric: "{{ fabric_name }}" | ||
state: deleted | ||
|
||
- name: DELETED - Merge switches | ||
cisco.dcnm.dcnm_inventory: | ||
fabric: "{{ fabric_name }}" | ||
state: merged | ||
config: | ||
- seed_ip: "{{ ansible_switch1 }}" | ||
auth_proto: MD5 | ||
user_name: "{{ switch_username }}" | ||
password: "{{ switch_password }}" | ||
max_hops: 0 | ||
role: leaf | ||
preserve_config: False | ||
- seed_ip: "{{ ansible_switch2 }}" | ||
auth_proto: MD5 | ||
user_name: "{{ switch_username }}" | ||
password: "{{ switch_password }}" | ||
max_hops: 0 | ||
role: leaf | ||
preserve_config: False | ||
- seed_ip: "{{ ansible_switch3 }}" | ||
auth_proto: MD5 | ||
user_name: "{{ switch_username }}" | ||
password: "{{ switch_password }}" | ||
max_hops: 0 | ||
role: spine | ||
preserve_config: False | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result.changed == true | ||
|
||
- assert: | ||
that: | ||
- item["RETURN_CODE"] == 200 | ||
loop: '{{ result.response }}' | ||
|
||
################################################################################ | ||
# DELETED - Upgrade all switches using global_config | ||
################################################################################ | ||
|
||
- name: DELETED - Upgrade all switches using global config | ||
cisco.dcnm.dcnm_image_upgrade: &global_config | ||
state: merged | ||
config: | ||
policy: "{{ image_policy_1 }}" | ||
reboot: false | ||
stage: true | ||
validate: true | ||
upgrade: | ||
nxos: true | ||
epld: false | ||
options: | ||
nxos: | ||
mode: disruptive | ||
bios_force: false | ||
epld: | ||
module: ALL | ||
golden: false | ||
reboot: | ||
config_reload: false | ||
write_erase: false | ||
package: | ||
install: false | ||
uninstall: false | ||
switches: | ||
- ip_address: "{{ leaf1 }}" | ||
- ip_address: "{{ leaf2 }}" | ||
- ip_address: "{{ spine1 }}" | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
|
||
- assert: | ||
that: | ||
- result.changed == true | ||
- result.failed == false | ||
- result.diff.attach_policy[0].policy_name == image_policy_1 | ||
- result.diff.attach_policy[1].policy_name == image_policy_1 | ||
- result.diff.attach_policy[2].policy_name == image_policy_1 | ||
- result.diff.upgrade[0].devices[0].policyName == image_policy_1 | ||
- result.diff.upgrade[1].devices[0].policyName == image_policy_1 | ||
- result.diff.upgrade[2].devices[0].policyName == image_policy_1 | ||
- result.diff.validate[0].policy == image_policy_1 | ||
- result.diff.validate[1].policy == image_policy_1 | ||
- result.diff.validate[2].policy == image_policy_1 | ||
- result.response.attach_policy[0].RETURN_CODE == 200 | ||
- result.response.stage[0].RETURN_CODE == 200 | ||
- result.response.upgrade[0].RETURN_CODE == 200 | ||
- result.response.upgrade[1].RETURN_CODE == 200 | ||
- result.response.upgrade[2].RETURN_CODE == 200 | ||
- result.response.validate[0].RETURN_CODE == 200 | ||
|
||
################################################################################ | ||
# DELETED - Detach policies from two switches and verify | ||
################################################################################ | ||
|
||
- name: DELETED - PAUSE 15 minutes for switches to reboot | ||
ansible.builtin.pause: | ||
minutes: 15 | ||
|
||
- name: DELETED - Detach policies from two switches | ||
cisco.dcnm.dcnm_image_upgrade: | ||
state: deleted | ||
config: | ||
policy: "{{ image_policy_1 }}" | ||
switches: | ||
- ip_address: "{{ leaf1 }}" | ||
- ip_address: "{{ leaf2 }}" | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
|
||
- assert: | ||
that: | ||
- result.changed == true | ||
- result.failed == false | ||
- (result.diff.attach_policy | length) == 0 | ||
- (result.diff.detach_policy | length) == 2 | ||
- (result.diff.stage | length) == 0 | ||
- (result.diff.upgrade | length) == 0 | ||
- (result.diff.validate | length) == 0 | ||
- (result.response.attach_policy | length) == 0 | ||
- (result.response.detach_policy | length) == 1 | ||
- (result.response.stage | length) == 0 | ||
- (result.response.upgrade | length) == 0 | ||
- (result.response.validate | length) == 0 | ||
|
||
|
||
################################################################################ | ||
# DELETED - Detach policies from remaining switch and verify | ||
################################################################################ | ||
|
||
- name: DELETED - Detach policy from one remaining switch | ||
cisco.dcnm.dcnm_image_upgrade: | ||
state: deleted | ||
config: | ||
policy: "{{ image_policy_1 }}" | ||
switches: | ||
- ip_address: "{{ spine1 }}" | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
|
||
- assert: | ||
that: | ||
- result.changed == true | ||
- result.failed == false | ||
- (result.diff.attach_policy | length) == 0 | ||
- (result.diff.detach_policy | length) == 1 | ||
- (result.diff.stage | length) == 0 | ||
- (result.diff.upgrade | length) == 0 | ||
- (result.diff.validate | length) == 0 | ||
- (result.response.attach_policy | length) == 0 | ||
- (result.response.detach_policy | length) == 1 | ||
- (result.response.stage | length) == 0 | ||
- (result.response.upgrade | length) == 0 | ||
- (result.response.validate | length) == 0 | ||
|
||
################################################################################ | ||
# CLEAN-UP | ||
################################################################################ | ||
|
||
- name: DELETED - cleanup - Remove devices from fabric | ||
cisco.dcnm.dcnm_inventory: | ||
fabric: "{{ fabric_name }}" | ||
state: deleted |
Oops, something went wrong.