-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial integration tests for merged and deleted state
- Loading branch information
1 parent
ac41637
commit 08ee914
Showing
6 changed files
with
588 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
tests/integration/targets/dcnm_image_policy/defaults/main.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,2 @@ | ||
--- | ||
testcase: "*" |
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 @@ | ||
dependencies: [] |
20 changes: 20 additions & 0 deletions
20
tests/integration/targets/dcnm_image_policy/tasks/dcnm.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,20 @@ | ||
--- | ||
- name: collect dcnm test cases | ||
find: | ||
paths: "{{ role_path }}/tests" | ||
patterns: "{{ testcase }}.yaml" | ||
connection: local | ||
register: dcnm_cases | ||
|
||
- set_fact: | ||
test_cases: | ||
files: "{{ dcnm_cases.files }}" | ||
|
||
- name: set test_items | ||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" | ||
|
||
- name: run test cases (connection=httpapi) | ||
include: "{{ test_case_to_run }}" | ||
with_items: "{{ test_items }}" | ||
loop_control: | ||
loop_var: test_case_to_run |
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,2 @@ | ||
--- | ||
- { include: dcnm.yaml, tags: ['dcnm'] } |
327 changes: 327 additions & 0 deletions
327
tests/integration/targets/dcnm_image_policy/tests/dcnm_image_policy_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,327 @@ | ||
################################################################################ | ||
# RUNTIME | ||
################################################################################ | ||
|
||
# Recent run times (MM:SS.ms): | ||
# 00:30.937 | ||
################################################################################ | ||
# STEPS | ||
################################################################################ | ||
|
||
# SETUP | ||
# 1. The following images must already be uploaded to the controller | ||
# See vars: section in cisco/dcnm/playbooks/dcnm_tests.yaml | ||
# - nxos_image_1 | ||
# - nxos_image_2 | ||
# - epld_image_1 | ||
# - epld_image_2 | ||
# 2. No need for fabric or switches | ||
# 3. Delete image policies under test, if they exist | ||
# - image_policy_1 | ||
# - image_policy_2 | ||
# TEST | ||
# 4. Create image policies and verify result | ||
# - image_policy_1 | ||
# - image_policy_2 | ||
# 5. Delete image_policy_1 and verify result | ||
# 6. Delete image_policy_2 and verify result | ||
# CLEANUP | ||
# 7. No cleanup required | ||
|
||
################################################################################ | ||
# REQUIREMENTS | ||
################################################################################ | ||
|
||
# 1. The following images must already be uploaded to the controller | ||
# See vars: section below | ||
# - nxos_image_1 | ||
# - nxos_image_2 | ||
# - epld_image_1 | ||
# - epld_image_2 | ||
# 2. No need for fabric or switches | ||
# | ||
# Example vars for dcnm_image_policy 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: deleted | ||
# 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_policy role | ||
# image_policy_1: "KR5M" | ||
# image_policy_2: "NR3F" | ||
# epld_image_1: n9000-epld.10.2.5.M.img | ||
# epld_image_2: n9000-epld.10.3.1.F.img | ||
# nxos_image_1: n9000-dk9.10.2.5.M.bin | ||
# nxos_image_2: n9000-dk9.10.3.1.F.bin | ||
# nxos_release_1: 10.2.5_nxos64-cs_64bit | ||
# nxos_release_2: 10.3.1_nxos64-cs_64bit | ||
|
||
################################################################################ | ||
# SETUP | ||
################################################################################ | ||
|
||
- name: DELETED - SETUP - Delete image policies | ||
cisco.dcnm.dcnm_image_policy: | ||
state: deleted | ||
config: | ||
- name: "{{ image_policy_1 }}" | ||
- name: "{{ image_policy_2 }}" | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
################################################################################ | ||
# DELETED - TEST - Create two image policies and verify | ||
################################################################################ | ||
# Expected response | ||
# ok: [dcnm] => { | ||
# "result": { | ||
# "changed": true, | ||
# "diff": { | ||
# "deleted": [], | ||
# "merged": [ | ||
# { | ||
# "action": "create", | ||
# "agnostic": false, | ||
# "epldImgName": "n9000-epld.10.2.5.M.img", | ||
# "nxosVersion": "10.2.5_nxos64-cs_64bit", | ||
# "platform": "N9K", | ||
# "policyDescr": "KR5M", | ||
# "policyName": "KR5M", | ||
# "policyType": "PLATFORM" | ||
# }, | ||
# { | ||
# "action": "create", | ||
# "agnostic": false, | ||
# "epldImgName": "n9000-epld.10.3.1.F.img", | ||
# "nxosVersion": "10.3.1_nxos64-cs_64bit", | ||
# "platform": "N9K", | ||
# "policyDescr": "NR3F", | ||
# "policyName": "NR3F", | ||
# "policyType": "PLATFORM" | ||
# } | ||
# ], | ||
# "overridden": [], | ||
# "query": [], | ||
# "replaced": [] | ||
# }, | ||
# "failed": false, | ||
# "response": { | ||
# "deleted": [], | ||
# "merged": [ | ||
# { | ||
# "MESSAGE": "OK", | ||
# "METHOD": "POST", | ||
# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/imagemanagement/rest/policymgnt/platform-policy", | ||
# "RETURN_CODE": 200 | ||
# }, | ||
# { | ||
# "MESSAGE": "OK", | ||
# "METHOD": "POST", | ||
# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/imagemanagement/rest/policymgnt/platform-policy", | ||
# "RETURN_CODE": 200 | ||
# } | ||
# ], | ||
# "overridden": [], | ||
# "query": [], | ||
# "replaced": [] | ||
# } | ||
# } | ||
# } | ||
|
||
|
||
- name: DELETED - TEST - Create two image policies and verify | ||
cisco.dcnm.dcnm_image_policy: | ||
state: merged | ||
config: | ||
- name: "{{ image_policy_1 }}" | ||
agnostic: false | ||
description: "{{ image_policy_1 }}" | ||
epld_image: "{{ epld_image_1 }}" | ||
platform: N9K | ||
release: "{{ nxos_release_1 }}" | ||
type: PLATFORM | ||
- name: "{{ image_policy_2 }}" | ||
description: "{{ image_policy_2 }}" | ||
platform: N9K | ||
epld_image: "{{ epld_image_2 }}" | ||
release: "{{ nxos_release_2 }}" | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
|
||
- assert: | ||
that: | ||
- result.changed == true | ||
- result.failed == false | ||
- (result.diff.deleted | length) == 0 | ||
- (result.diff.merged | length) == 2 | ||
- (result.diff.overridden | length) == 0 | ||
- (result.diff.query | length) == 0 | ||
- (result.diff.replaced | length) == 0 | ||
- result.diff.merged[0].policyName == image_policy_1 | ||
- result.diff.merged[0].policyDescr == image_policy_1 | ||
- result.diff.merged[0].epldImgName == epld_image_1 | ||
- result.diff.merged[0].nxosVersion == nxos_release_1 | ||
- result.diff.merged[1].policyName == image_policy_2 | ||
- result.diff.merged[1].policyDescr == image_policy_2 | ||
- result.diff.merged[1].epldImgName == epld_image_2 | ||
- result.diff.merged[1].nxosVersion == nxos_release_2 | ||
- (result.response.deleted | length) == 0 | ||
- (result.response.merged | length) == 2 | ||
- (result.response.overridden | length) == 0 | ||
- (result.response.query | length) == 0 | ||
- (result.response.replaced | length) == 0 | ||
- result.response.merged[0].MESSAGE == "OK" | ||
- result.response.merged[0].METHOD == "POST" | ||
- result.response.merged[0].RETURN_CODE == 200 | ||
- result.response.merged[1].MESSAGE == "OK" | ||
- result.response.merged[1].METHOD == "POST" | ||
- result.response.merged[1].RETURN_CODE == 200 | ||
|
||
################################################################################ | ||
# DELETED - TEST - Delete first image policy (image_policy_1) and verify | ||
################################################################################ | ||
# Expected response | ||
# ok: [dcnm] => { | ||
# "result": { | ||
# "changed": true, | ||
# "diff": { | ||
# "deleted": [ | ||
# { | ||
# "action": "delete", | ||
# "policyNames": [ | ||
# "KR5M" | ||
# ] | ||
# } | ||
# ], | ||
# "merged": [], | ||
# "overridden": [], | ||
# "query": [], | ||
# "replaced": [] | ||
# }, | ||
# "failed": false, | ||
# "response": { | ||
# "deleted": [ | ||
# { | ||
# "MESSAGE": "OK", | ||
# "METHOD": "DELETE", | ||
# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/imagemanagement/rest/policymgnt/policy", | ||
# "RETURN_CODE": 200 | ||
# } | ||
# ], | ||
# "merged": [], | ||
# "overridden": [], | ||
# "query": [], | ||
# "replaced": [] | ||
# } | ||
# } | ||
# } | ||
|
||
- name: DELETED - TEST - Delete first image policy (image_policy_1) and verify | ||
cisco.dcnm.dcnm_image_policy: | ||
state: deleted | ||
config: | ||
- name: KR5M | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
|
||
- assert: | ||
that: | ||
- result.changed == true | ||
- result.failed == false | ||
- (result.diff.deleted | length) == 1 | ||
- (result.diff.merged | length) == 0 | ||
- (result.diff.query | length) == 0 | ||
- image_policy_1 in result.diff.deleted[0].policyNames | ||
- (result.response.deleted | length) == 1 | ||
- result.response.deleted[0].MESSAGE == "OK" | ||
- result.response.deleted[0].METHOD == "DELETE" | ||
- result.response.deleted[0].RETURN_CODE == 200 | ||
- (result.response.merged | length) == 0 | ||
- (result.response.overridden | length) == 0 | ||
- (result.response.query | length) == 0 | ||
- (result.response.replaced | length) == 0 | ||
|
||
################################################################################ | ||
# DELETED - TEST - Delete remaining policy (image_policy_2) and verify | ||
################################################################################ | ||
# Expected result | ||
# ok: [dcnm] => { | ||
# "result": { | ||
# "changed": true, | ||
# "diff": { | ||
# "deleted": [ | ||
# { | ||
# "action": "delete", | ||
# "policyNames": [ | ||
# "NR3F" | ||
# ] | ||
# } | ||
# ], | ||
# "merged": [], | ||
# "overridden": [], | ||
# "query": [], | ||
# "replaced": [] | ||
# }, | ||
# "failed": false, | ||
# "response": { | ||
# "deleted": [ | ||
# { | ||
# "MESSAGE": "OK", | ||
# "METHOD": "DELETE", | ||
# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/imagemanagement/rest/policymgnt/policy", | ||
# "RETURN_CODE": 200 | ||
# } | ||
# ], | ||
# "merged": [], | ||
# "overridden": [], | ||
# "query": [], | ||
# "replaced": [] | ||
# } | ||
# } | ||
# } | ||
|
||
- name: DELETED - TEST - Delete remaining image policy (image_policy_2) and verify | ||
cisco.dcnm.dcnm_image_policy: | ||
state: deleted | ||
config: | ||
- name: NR3F | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
|
||
- assert: | ||
that: | ||
- result.changed == true | ||
- result.failed == false | ||
- (result.diff.deleted | length) == 1 | ||
- (result.diff.merged | length) == 0 | ||
- (result.diff.overridden | length) == 0 | ||
- (result.diff.query | length) == 0 | ||
- (result.diff.replaced | length) == 0 | ||
- image_policy_2 in result.diff.deleted[0].policyNames | ||
- (result.response.deleted | length) == 1 | ||
- result.response.deleted[0].MESSAGE == "OK" | ||
- result.response.deleted[0].METHOD == "DELETE" | ||
- result.response.deleted[0].RETURN_CODE == 200 | ||
- (result.response.merged | length) == 0 | ||
- (result.response.overridden | length) == 0 | ||
- (result.response.query | length) == 0 | ||
- (result.response.replaced | length) == 0 | ||
|
Oops, something went wrong.