Skip to content

Commit

Permalink
IT: interface var naming change
Browse files Browse the repository at this point in the history
1. The current interface var names did not incorporate a way to encode switch ownership.  Modified the var naming to allow for specifying multiple interfaces per switch in such a way that the switch ownership of an interface is evident.

This is documented in:

playbooks/files/dynamic_inventory.py

2. Modified all dcnm_vrf test cases to align with this convention.

- Updated test case header comments with the new usage
- Updated all test case interface vars
- Ran the following tests
  - deleted.yaml
  - overridden.yaml
  - replaced.yaml
  - query.yaml
  - sanity.yaml

3. dynamic_interface.py

In addition to the changes above:

- Fixed the documentation for environment variable ND_ROLE (previously it was misnamed NDFC_ROLE in the documentation, but was correct -- ND_ROLE -- in the actual usage).

- Fix Markdown heading levels
  • Loading branch information
allenrobel committed Dec 11, 2024
1 parent a565a46 commit 001931e
Show file tree
Hide file tree
Showing 13 changed files with 747 additions and 464 deletions.
86 changes: 59 additions & 27 deletions playbooks/files/dynamic_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
"""
# Summary
Dynamic inventory for DCNM Collection integration tests.
Inventory is built from environment variables.
Optional dynamic inventory for the ansible-dcnm repository
integration tests. This inventory is built from environment
variables.
# Usage
## Usage
## Mandatory general variables
### Mandatory general variables
The following general environment variables are related
to credentials, controller reachability, and role/testcase
Expand All @@ -43,7 +44,7 @@
setup and the roles/testcases you are running.
```bash
export NDFC_ROLE=dcnm_vrf # The role to run
export ND_ROLE=dcnm_vrf # The role to run
export ND_TESTCASE=query # The testcase to run
export ND_IP4=10.1.1.1 # Controller IPv4 address
export ND_PASSWORD=MyPassword # Controller password
Expand All @@ -52,7 +53,7 @@
export NXOS_USERNAME=admin # Switch username
```
## Fabrics
### Fabrics
We can add more fabrics later as the need arises...
Expand All @@ -63,18 +64,48 @@
```
## Interfaces
### Interfaces
Interface usage varies by testcase. See individual
testcase YAML files for details regarding each test's
usage.
#### Interface naming convention
##### Environment variables
ND_INTERFACE_[A][b]
Where:
A - The number of the switch to which the interface belongs
b - An incrementing lower-case letter in range a-z
###### Examples:
```bash
export ND_INTERFACE_1=Ethernet1/1
export ND_INTERFACE_2=Ethernet1/2
export ND_INTERFACE_3=Ethernet1/3
export ND_INTERFACE_1a=Ethernet1/1
export ND_INTERFACE_2a=Ethernet1/1
export ND_INTERFACE_2b=Ethernet1/2
export ND_INTERFACE_3a=Ethernet2/4
```
Above:
- switch_1 has one interface; Ethernet1/1
- switch_2 two interfaces; Ethernet1/1 and Ethernet1/2
- switch_3 has one interface; Ethernet2/4
##### Test case variables
Interface variables within test cases follow the same convention
as above, but are lowercase, and remove the leading ND_.
###### Examples
interface_1a - 1st interface on switch_1
interface_1b - 2st interface on switch_1
etc...
"""
nd_role = environ.get("ND_ROLE", "dcnm_vrf")
Expand Down Expand Up @@ -109,9 +140,10 @@
switch_3 = environ.get("ND_SWITCH_3_IP4", "10.1.1.108")

# Base set of interfaces
interface_1 = environ.get("ND_INTERFACE_1", "Ethernet1/1")
interface_2 = environ.get("ND_INTERFACE_2", "Ethernet1/2")
interface_3 = environ.get("ND_INTERFACE_3", "Ethernet1/3")
interface_1a = environ.get("ND_INTERFACE_1a", "Ethernet1/1")
interface_2a = environ.get("ND_INTERFACE_2a", "Ethernet1/1")
interface_2b = environ.get("ND_INTERFACE_2b", "Ethernet1/2")
interface_3a = environ.get("ND_INTERFACE_3a", "Ethernet1/3")

if nd_role == "dcnm_vrf":
# VXLAN/EVPN Fabric Name
Expand All @@ -129,18 +161,17 @@
# - merged
# - NOT vrf-lite capable
switch_3 = leaf_3
# interface_1
# interface_1a
# - no tests
# interface_2
# - all tests
# interface_2a
# - [deleted, merged, overridden, query, replaced, vrf_lite]
# - switch_2 VRF LITE extensions
# interface_2b
# - [vrf_lite]
# - switch_2 VRF LITE extensions
# interface_3
# - merged
# interface_3a
# - [merged, vrf_lite]
# - switch_3 non-vrf-lite capable switch
# - overridden
# - Removed from test due to unrelated IP POOL errors.
# - It appears that fabric would need to have SUBNET
# resource added?
#
elif nd_role == "vrf_lite":
# VXLAN/EVPN Fabric Name
Expand All @@ -149,7 +180,7 @@
switch_1 = spine_1
# switch_2: vrf-lite capable
switch_2 = spine_2
# switch_3: vrf-lite capable
# switch_3: vrf capable
switch_3 = bgw_1
else:
switch_1 = leaf_1
Expand All @@ -170,6 +201,7 @@
"ansible_password": nd_password,
"ansible_python_interpreter": "python",
"ansible_user": nd_username,
"testcase": nd_testcase,
"fabric_1": fabric_1,
"fabric_2": fabric_2,
"fabric_3": fabric_3,
Expand All @@ -192,10 +224,10 @@
"switch_1": switch_1,
"switch_2": switch_2,
"switch_3": switch_3,
"interface_1": interface_1,
"interface_2": interface_2,
"interface_3": interface_3,
"testcase": nd_testcase,
"interface_1a": interface_1a,
"interface_2a": interface_2a,
"interface_2b": interface_2b,
"interface_3a": interface_3a,
},
},
"dcnm": {
Expand Down
26 changes: 15 additions & 11 deletions tests/integration/targets/dcnm_vrf/tests/dcnm/deleted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
## REQUIRED VARS ##
##############################################
# fabric_1
# A VXLAN_EVPN fabric
#
# - A VXLAN_EVPN fabric
#
# switch_1
# A vrf-lite capable switch
# Does not require an interface
#
# - A vrf-lite capable switch
# - Does not require an interface
#
# switch_2
# A vrf-lite capable switch
#
# interface_2
# Ethernet interface on switch_2
# used to test VRF LITE configuration.
# - A vrf-lite capable switch
#
# interface_2a
#
# - Ethernet interface on switch_2
# - Used to test VRF LITE configuration.
#
##############################################

Expand All @@ -36,7 +40,7 @@
- "fabric_1 : {{ fabric_1 }}"
- "switch_1 : {{ switch_1 }}"
- "switch_2 : {{ switch_2 }}"
- "interface_2 : {{ interface_2 }}"
- "interface_2a : {{ interface_2a }}"

- name: SETUP.1 - DELETED - [dcnm_rest.GET] Verify fabric is deployed.
cisco.dcnm.dcnm_rest:
Expand Down Expand Up @@ -157,7 +161,7 @@
- ip_address: "{{ switch_2 }}"
vrf_lite:
- peer_vrf: ansible-vrf-int1 # optional
interface: "{{ interface_2 }}" # mandatory
interface: "{{ interface_2a }}" # mandatory
ipv4_addr: 10.33.0.2/30 # optional
neighbor_ipv4: 10.33.0.1 # optional
ipv6_addr: 2010::10:34:0:7/64 # optional
Expand Down Expand Up @@ -205,7 +209,7 @@
- ip_address: "{{ switch_2 }}"
vrf_lite:
- peer_vrf: ansible-vrf-int1 # optional
interface: "{{ interface_2 }}" # mandatory
interface: "{{ interface_2a }}" # mandatory
ipv4_addr: 10.33.0.2/30 # optional
neighbor_ipv4: 10.33.0.1 # optional
ipv6_addr: 2010::10:34:0:7/64 # optional
Expand Down Expand Up @@ -260,7 +264,7 @@
- ip_address: "{{ switch_2 }}"
vrf_lite:
- peer_vrf: ansible-vrf-int1 # optional
interface: "{{ interface_2 }}" # mandatory
interface: "{{ interface_2a }}" # mandatory
ipv4_addr: 10.33.0.2/30 # optional
neighbor_ipv4: 10.33.0.1 # optional
ipv6_addr: 2010::10:34:0:7/64 # optional
Expand Down
44 changes: 25 additions & 19 deletions tests/integration/targets/dcnm_vrf/tests/dcnm/merged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,29 @@
# A VXLAN_EVPN fabric
#
# switch_1
# A vrf-lite capable switch
# Does not require an interface.
#
# - A vrf-lite capable switch
# - Does not require an interface.
#
# switch_2
# A vrf-lite capable switch
#
# - A vrf-lite capable switch
#
# switch_3
#
# A NON-vrf-lite capable switch
#
# interface_2
# Ethernet interface on switch_2
# Used to test VRF LITE configuration.
# interface_2a
#
# - Ethernet interface on switch_2
# - Used to test VRF LITE configuration.
#
# interface_3a
#
# interface_3
# Ethernet interface on switch_3
# Used to verify error when applied VRF LITE
# extension on a non-vrf-lite capable switch.
# - Ethernet interface on switch_3
# - Used to verify error when applying a
# VRF LITE extension on a non-vrf-lite
# capable switch.
##############################################

##############################################
Expand All @@ -44,8 +50,8 @@
- "switch_1 : {{ switch_1 }}"
- "switch_2 : {{ switch_2 }}"
- "switch_3 : {{ switch_3 }}"
- "interface_2 : {{ interface_2 }}"
- "interface_3 : {{ interface_3 }}"
- "interface_2a : {{ interface_2a }}"
- "interface_3a : {{ interface_3a }}"

- name: SETUP.1 - MERGED - [dcnm_rest.GET] Verify fabric is deployed.
cisco.dcnm.dcnm_rest:
Expand Down Expand Up @@ -132,19 +138,19 @@
- 'result_1c.changed == false'
- 'result_1c.response|length == 0'

- name: TEST.1d - MERGED - [deleted] Delete all VRFs
- name: TEST.1e - MERGED - [deleted] Delete all VRFs
cisco.dcnm.dcnm_vrf:
fabric: "{{ fabric_1 }}"
state: deleted
register: result_1d
register: result_1e

- name: TEST.1e - MERGED - [wait_for] Wait 60 seconds for controller and switch to sync
- name: TEST.1f - MERGED - [wait_for] Wait 60 seconds for controller and switch to sync
# The vrf lite profile removal returns ok for deployment, but the switch
# takes time to remove the profile so wait for some time before creating
# a new vrf, else the switch goes into OUT-OF-SYNC state
wait_for:
timeout: 60
when: result_1d.changed == true
when: result_1e.changed == true

- name: TEST.2 - MERGED - [merged] Create, Attach, Deploy VLAN+VRF (controller provided)
cisco.dcnm.dcnm_vrf: &conf2
Expand Down Expand Up @@ -228,7 +234,7 @@
- ip_address: "{{ switch_2 }}"
vrf_lite:
- peer_vrf: ansible-vrf-int1 # optional
interface: "{{ interface_2 }}" # mandatory
interface: "{{ interface_2a }}" # mandatory
ipv4_addr: 10.33.0.2/30 # optional
neighbor_ipv4: 10.33.0.1 # optional
ipv6_addr: 2010::10:34:0:7/64 # optional
Expand Down Expand Up @@ -304,7 +310,7 @@
- ip_address: "{{ switch_1 }}"
- ip_address: "{{ switch_2 }}"
vrf_lite:
- interface: "{{ interface_2 }}" # mandatory
- interface: "{{ interface_2a }}" # mandatory
deploy: true
register: result_4

Expand Down Expand Up @@ -428,7 +434,7 @@
- ip_address: "{{ switch_3 }}"
vrf_lite:
- peer_vrf: ansible-vrf-int1 # optional
interface: "{{ interface_3 }}" # mandatory
interface: "{{ interface_3a }}" # mandatory
ipv4_addr: 10.33.0.2/30 # optional
neighbor_ipv4: 10.33.0.1 # optional
ipv6_addr: 2010::10:34:0:7/64 # optional
Expand Down
24 changes: 14 additions & 10 deletions tests/integration/targets/dcnm_vrf/tests/dcnm/overridden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
## REQUIRED VARS ##
##############################################
# fabric_1
# A VXLAN_EVPN fabric
#
# - A VXLAN_EVPN fabric
#
# switch_1
# A vrf-lite capable switch
#
# - A vrf-lite capable switch
#
# switch_2
# A vrf-lite capable switch
#
# interface_2
# Ethernet interface on switch_2
# Used to test VRF LITE configuration.
# - A vrf-lite capable switch
#
# interface_2a
#
# - Ethernet interface on switch_2
# - Used to test VRF LITE configuration.
#
##############################################

Expand Down Expand Up @@ -47,7 +51,7 @@
- "fabric_1 : {{ fabric_1 }}"
- "switch_1 : {{ switch_1 }}"
- "switch_2 : {{ switch_2 }}"
- "interface_2 : {{ interface_2 }}"
- "interface_2a : {{ interface_2a }}"

- name: SETUP.1 - OVERRIDDEN - [dcnn_rest.GET] Verify if fabric is deployed.
cisco.dcnm.dcnm_rest:
Expand Down Expand Up @@ -198,7 +202,7 @@
- ip_address: "{{ switch_2 }}"
vrf_lite:
- peer_vrf: ansible-vrf-int2 # optional
interface: "{{ interface_2 }}" # mandatory
interface: "{{ interface_2a }}" # mandatory
ipv4_addr: 10.33.0.1/24 # optional
neighbor_ipv4: 10.33.0.0 # optional
ipv6_addr: 2010::10:34:0:7/64 # optional
Expand Down Expand Up @@ -254,7 +258,7 @@
- ip_address: "{{ switch_2 }}"
vrf_lite:
- peer_vrf: ansible-vrf-int2 # optional
interface: "{{ interface_2 }}" # mandatory
interface: "{{ interface_2a }}" # mandatory
ipv4_addr: 10.33.0.1/24 # optional
neighbor_ipv4: 10.33.0.0 # optional
ipv6_addr: 2010::10:34:0:7/64 # optional
Expand Down Expand Up @@ -330,7 +334,7 @@
- ip_address: "{{ switch_2 }}"
vrf_lite:
- peer_vrf: ansible-vrf-int1 # optional
interface: "{{ interface_2 }}" # mandatory
interface: "{{ interface_2a }}" # mandatory
ipv4_addr: 10.33.0.1/24 # optional
neighbor_ipv4: 10.33.0.0 # optional
ipv6_addr: 2010::10:34:0:1/64 # optional
Expand Down
Loading

0 comments on commit 001931e

Please sign in to comment.