Skip to content

Commit

Permalink
Sanity for DCNM CI (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenramoorthy authored Nov 2, 2023
1 parent e10a923 commit 2229682
Show file tree
Hide file tree
Showing 29 changed files with 4,692 additions and 14 deletions.
8 changes: 8 additions & 0 deletions tests/integration/targets/dcnm_interface/tasks/dcnm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
patterns: "{{ testcase }}.yaml"
connection: local
register: dcnm_cases
tags: sanity

- set_fact:
test_cases:
files: "{{ dcnm_cases.files }}"
tags: sanity

- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
tags: sanity

- name: run test cases (connection=httpapi)
include: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
tags: sanity

###############################################
## FACTS ##
Expand Down Expand Up @@ -130,11 +134,13 @@
- ip: "{{ ansible_switch1 }}"
- ip: "{{ ansible_switch2 }}"
register: result
tags: sanity

- assert:
that:
- 'item["RETURN_CODE"] == 200'
loop: '{{ result.response }}'
tags: sanity

##############################################
## DELETE ALL TEMPLATES ##
Expand All @@ -148,8 +154,10 @@
- name: my_lacp
- name: my_vpc
register: result
tags: sanity

- assert:
that:
- 'item["RETURN_CODE"] == 200'
loop: '{{ result.response }}'
tags: sanity
1,074 changes: 1,074 additions & 0 deletions tests/integration/targets/dcnm_interface/tests/dcnm/dcnm_intf_sanity.yml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions tests/integration/targets/dcnm_inventory/tasks/dcnm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
patterns: "{{ testcase }}.yaml"
connection: local
register: dcnm_cases
tags: sanity

- set_fact:
test_cases:
files: "{{ dcnm_cases.files }}"
tags: sanity

- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
tags: sanity

- name: run test cases (connection=httpapi)
include: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
tags: sanity
8 changes: 7 additions & 1 deletion tests/integration/targets/dcnm_inventory/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,40 @@

- set_fact:
controller_version: "Unable to determine controller version"
tags: sanity

- name: Determine version of DCNM or NDFC
cisco.dcnm.dcnm_rest:
method: GET
path: /appcenter/cisco/ndfc/api/about/version
register: result
ignore_errors: yes
tags: sanity

- set_fact:
controller_version: "{{ result.response['DATA']['version'][0:2] | int }}"
when: ( result.response['DATA']['version'] is search("\d\d.\d+") )
ignore_errors: yes
tags: sanity

- name: Determine version of DCNM or NDFC
cisco.dcnm.dcnm_rest:
method: GET
path: /fm/fmrest/about/version
register: result
ignore_errors: yes
tags: sanity

- set_fact:
controller_version: "{{ result.response['DATA']['version'][0:2] | int }}"
when: ( result.response['DATA']['version'] is search("\d\d.\d+") )
ignore_errors: yes
tags: sanity

# No need to continue if we cannot determine the DCNM/NDFC controller version
- assert:
that:
- 'controller_version != "Unable to determine controller version"'
tags: sanity

- { include: dcnm.yaml, tags: ['dcnm'] }
- { include: dcnm.yaml, tags: ['dcnm'] }
183 changes: 183 additions & 0 deletions tests/integration/targets/dcnm_inventory/tests/dcnm/sanity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
##############################################
## SETUP ##
##############################################

- set_fact:
rest_path: "/rest/control/fabrics/{{ ansible_it_fabric }}"
when: controller_version == "11"
tags: sanity

- set_fact:
rest_path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ ansible_it_fabric }}"
when: controller_version >= "12"
tags: sanity

- name: SANITY- MERGED - Verify if fabric is deployed.
cisco.dcnm.dcnm_rest:
method: GET
path: "{{ rest_path }}"
register: result
tags: sanity

- assert:
that:
- 'result.response.DATA != None'
tags: sanity

- name: SANITY- DELETED - setup - Clean up existing devices
cisco.dcnm.dcnm_inventory:
fabric: "{{ ansible_it_fabric }}"
state: deleted
register: result
tags: sanity

##############################################
## MERGED ##
##############################################

- name: SANITY- MERGED - Merge a Switch using GreenField Deployment
cisco.dcnm.dcnm_inventory: &conf
fabric: "{{ ansible_it_fabric }}"
state: merged
config:
- seed_ip: "{{ ansible_switch1 }}"
auth_proto: MD5 # choose from [MD5, SHA, MD5_DES, MD5_AES, SHA_DES, SHA_AES]
user_name: "{{ switch_username }}"
password: "{{ switch_password }}"
max_hops: 0
role: leaf # default is Leaf - choose from [Leaf, Spine, Border, Border Spine, Border Gateway, Border Gateway Spine
# Super Spine, Border Super Spine, Border Gateway Super Spine]
preserve_config: False # boolean, default is true
register: result
tags: sanity

- assert:
that:
- 'result.changed == true'
tags: sanity

- assert:
that:
- 'item["RETURN_CODE"] == 200'
loop: '{{ result.response }}'
tags: sanity

- name: SANITY- MERGED - conf1 - GF - Idempotence
cisco.dcnm.dcnm_inventory: *conf
register: result
tags: sanity

- assert:
that:
- 'result.changed == false'
- 'result.response == "The switch provided is already part of the fabric and cannot be created again"'
tags: sanity

#############################################
# QUERY ##
#############################################

- name: SANITY- QUERY - Query a Switch - Hostname and Role must match
cisco.dcnm.dcnm_inventory:
fabric: "{{ ansible_it_fabric }}"
state: query
config:
- seed_ip: "{{ ansible_switch1 }}"
role: leaf # default is Leaf - choose from [Leaf, Spine, Border, Border Spine, Border Gateway, Border Gateway Spine
# Super Spine, Border Super Spine, Border Gateway Super Spine]
register: result
tags: sanity

- assert:
that:
- 'result.response[0].ipAddress == "{{ ansible_switch1 }}"'
- 'result.response[0].switchRole == "leaf"'
tags: sanity



##############################################
## OVERRIDDEN ##
##############################################

- name: SANITY- OVERRIDDEN - Update a New Switch using GreenField Deployment - Delete and Create - default role
cisco.dcnm.dcnm_inventory: &conf_over
fabric: "{{ ansible_it_fabric }}"
state: overridden
config:
- seed_ip: "{{ ansible_switch2 }}"
auth_proto: MD5 # choose from [MD5, SHA, MD5_DES, MD5_AES, SHA_DES, SHA_AES]
user_name: "{{ switch_username }}"
password: "{{ switch_password }}"
max_hops: 0
preserve_config: False # boolean, default is true
register: result
tags: sanity

- assert:
that:
- 'result.changed == true'
tags: sanity

- assert:
that:
- 'item["RETURN_CODE"] == 200'
loop: '{{ result.response }}'
tags: sanity

- name: SANITY- OVERRIDDEN - conf1 - OV - Idempotence
cisco.dcnm.dcnm_inventory: *conf_over
register: result
tags: sanity

- assert:
that:
- 'result.changed == false'
- 'result.response == "The switch provided is already part of the fabric and there is no more device to delete in the fabric"'
tags: sanity

##############################################
## CLEAN-UP ##
##############################################

- name: SANITY- DELETED - setup - Clean up existing devices
cisco.dcnm.dcnm_inventory: &clean
fabric: "{{ ansible_it_fabric }}"
state: deleted
config:
- seed_ip: "{{ ansible_switch2 }}"
auth_proto: MD5 # choose from [MD5, SHA, MD5_DES, MD5_AES, SHA_DES, SHA_AES]
user_name: "{{ switch_username }}"
password: "{{ switch_password }}"
max_hops: 0
preserve_config: False # boolean, default is true
register: result
tags: sanity

- name: SANITY- DELETED - conf1 - OV - Idempotence
cisco.dcnm.dcnm_inventory: *clean
register: result
tags: sanity

##############################################
## RESET FABRIC ##
##############################################

- name: SANITY- RESET - setup switches in fabric
cisco.dcnm.dcnm_inventory:
fabric: "{{ ansible_it_fabric }}"
config:
- seed_ip: "{{ ansible_switch1 }}"
auth_proto: MD5 # choose from [MD5, SHA, MD5_DES, MD5_AES, SHA_DES, SHA_AES]
user_name: "{{ switch_username }}"
password: "{{ switch_password }}"
max_hops: 0
preserve_config: False # boolean, default is true
- seed_ip: "{{ ansible_switch2 }}"
auth_proto: MD5 # choose from [MD5, SHA, MD5_DES, MD5_AES, SHA_DES, SHA_AES]
user_name: "{{ switch_username }}"
password: "{{ switch_password }}"
max_hops: 0
preserve_config: False # boolean, default is true
register: result
tags: sanity
4 changes: 4 additions & 0 deletions tests/integration/targets/dcnm_links/tasks/dcnm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
patterns: "{{ testcase }}.yaml"
connection: local
register: dcnm_cases
tags: sanity

- set_fact:
test_cases:
files: "{{ dcnm_cases.files }}"
tags: sanity

- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
tags: sanity

- name: run test cases (connection=httpapi)
include: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
tags: sanity
Loading

0 comments on commit 2229682

Please sign in to comment.