Add unit tests for all interface/sub-interface failure modes
This commit is contained in:
		
							
								
								
									
										12
									
								
								unittest/error-interface-mtu1.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								unittest/error-interface-mtu1.yaml
									
									
									
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										12
									
								
								unittest/error-interface-mtu2.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								unittest/error-interface-mtu2.yaml
									
									
									
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										17
									
								
								unittest/error-subinterface1.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								unittest/error-subinterface1.yaml
									
									
									
									
									
										Normal 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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										13
									
								
								unittest/error-subinterface2.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								unittest/error-subinterface2.yaml
									
									
									
									
									
										Normal 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"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										13
									
								
								unittest/error-subinterface3.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								unittest/error-subinterface3.yaml
									
									
									
									
									
										Normal 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"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								unittest/error-subinterface4.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								unittest/error-subinterface4.yaml
									
									
									
									
									
										Normal 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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								unittest/error-subinterface5.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								unittest/error-subinterface5.yaml
									
									
									
									
									
										Normal 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 ]
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										20
									
								
								unittest/error-subinterface6.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								unittest/error-subinterface6.yaml
									
									
									
									
									
										Normal 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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								unittest/error-subinterface7.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								unittest/error-subinterface7.yaml
									
									
									
									
									
										Normal 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: {}
 | 
			
		||||
		Reference in New Issue
	
	Block a user