Add unit tests for all interface/sub-interface failure modes

This commit is contained in:
Pim van Pelt
2022-03-13 18:35:11 +00:00
parent cc0ec92638
commit 9aec425bc0
9 changed files with 131 additions and 0 deletions

View File

@ -0,0 +1,12 @@
test:
description: "MTU too small on one interface, too large on another"
errors:
expected:
- "mtu.*less than 128"
- "mtu.*greater than 9216"
---
interfaces:
GigabitEthernet1/0/0:
mtu: 9217
GigabitEthernet1/0/1:
mtu: 127

View File

@ -0,0 +1,12 @@
test:
description: "MTU of sub-interfaces cannot be higher than their parent"
errors:
expected:
- "sub-interface .* has MTU 9001 higher than parent MTU 9000"
---
interfaces:
GigabitEthernet1/0/0:
mtu: 9000
sub-interfaces:
100:
mtu: 9001

View File

@ -0,0 +1,17 @@
test:
description: "Two subinterfaces can't have the same encapsulation"
errors:
expected:
- "100 .* unique encapsulation"
- "101 .* unique encapsulation"
---
interfaces:
GigabitEthernet1/0/0:
sub-interfaces:
100:
description: "VLAN 100"
101:
description: "Another VLAN 100"
encapsulation:
dot1q: 100

View File

@ -0,0 +1,13 @@
test:
description: "A subinterface cannot have an LCP if the parent doesn't have one"
errors:
expected:
- "sub-interface .* has LCP but .* does not have LCP"
---
interfaces:
GigabitEthernet1/0/0:
sub-interfaces:
100:
description: "VLAN 100"
lcp: "foo.100"

View File

@ -0,0 +1,13 @@
test:
description: "The length of the LCP name is too long"
errors:
expected:
- "Length .* is greater than 8"
---
interfaces:
GigabitEthernet1/0/0:
lcp: "e01234567"
sub-interfaces:
100:
description: "VLAN 100"

View File

@ -0,0 +1,17 @@
test:
description: "The length of the generated child LCP name is too long"
errors:
expected:
- "sub-interface .* has LCP with too long name"
---
interfaces:
GigabitEthernet1/0/0:
lcp: "e01234"
sub-interfaces:
100:
description: "QinQ subinterface"
addresses: [ 192.0.2.1/24 ]
encapsulation:
dot1q: 1234
inner-dot1q: 2345

View File

@ -0,0 +1,17 @@
test:
description: "Sub-interface with addresses must have an LCP. Gi1/0/0 does this wrong, while Gi2/0/0 does it correctly"
errors:
expected:
- "sub-interface .* has address.* but .* does not have LCP"
---
interfaces:
GigabitEthernet1/0/0:
sub-interfaces:
100:
addresses: [ 192.0.2.1/24 ]
GigabitEthernet2/0/0:
lcp: "xe2-0-0"
sub-interfaces:
100:
addresses: [ 192.0.2.1/24 ]

View File

@ -0,0 +1,20 @@
test:
description: "A bunch of sub-interfaces with incorrect encapsulation"
errors:
expected:
- "has invalid encapsulation"
count: 2
---
interfaces:
GigabitEthernet1/0/0:
sub-interfaces:
100:
encapsulation:
## Cannot have both dot1q and dot1ad
dot1q: 100
dot1ad: 100
101:
encapsulation:
## Missing dot1q or dot1ad
inner-dot1q: 100

View File

@ -0,0 +1,10 @@
test:
description: "A completely empty sub-interface is not allowed"
errors:
expected:
- "sub-interface .* has no config"
---
interfaces:
GigabitEthernet1/0/0:
sub-interfaces:
100: {}