Add TAP syntax/semantic validator

This commit is contained in:
Pim van Pelt
2022-04-09 19:56:48 +00:00
parent 92a20d0755
commit d6e3496809
12 changed files with 367 additions and 0 deletions

22
unittest/test_tap.yaml Normal file
View File

@ -0,0 +1,22 @@
taps:
tap0:
description: "TAP with MAC, MTU and Bridge"
mac: 00:01:02:03:04:05
host:
mtu: 9216
name: vpp-tap0
bridge: br0
rx-ring-size: 256
tx-ring-size: 256
tap1:
description: "TAP, no config other than mandatory host-name"
host:
name: vpp-tap1
tap2:
description: "TAP, which has an overlapping host-name"
host:
name: vpp-tap
tap3:
description: "TAP, which has an overlapping host-name"
host:
name: vpp-tap

View File

@ -0,0 +1,19 @@
test:
description: "A few correct examples of well formed TAP interfaces"
errors:
count: 0
---
taps:
tap0:
description: "TAP with MAC, MTU and Bridge"
host:
name: vpp-tap0
mac: 00:01:02:03:04:05
mtu: 9216
bridge: br0
rx-ring-size: 256
tx-ring-size: 256
tap1:
description: "TAP, no config other than mandatory host-name"
host:
name: vpp-tap1

View File

@ -0,0 +1,19 @@
test:
description: "Instance id must be between [0..1024]"
errors:
expected:
- "tap .* has instance .* which is too large"
count: 1
---
taps:
tap0:
host:
name: vpp-tap0
tap1024:
description: "Cool"
host:
name: vpp-tap1024
tap1025:
description: "Not cool"
host:
name: vpp-tap1025

View File

@ -0,0 +1,14 @@
test:
description: "RX and TX ring sizes must be power of two, at most 32K"
errors:
expected:
- "tap .* rx-ring-size must be a power of two"
- "tap .* tx-ring-size must be a power of two"
count: 2
---
taps:
tap0:
host:
name: vpp-tap0
rx-ring-size: 1023
tx-ring-size: 32767

View File

@ -0,0 +1,15 @@
test:
description: "TAP host names must be unique"
errors:
expected:
- "tap .* does not have a unique host name .*"
count: 2
---
taps:
tap0:
host:
name: vpp-tap
tap1:
host:
name: vpp-tap

View File

@ -0,0 +1,23 @@
test:
description: "TAP host mac addresses cannot be multicast"
errors:
expected:
- "tap .* host MAC address .* cannot be multicast"
count: 1
---
taps:
tap0:
description: "Cool, local MACs are fine"
host:
mac: 02:00:00:00:00:00
name: vpp-tap0
tap1:
description: "Cool, global unicast MACs are fine"
host:
mac: 04:00:00:00:00:00
name: vpp-tap1
tap2:
description: "Not cool, multicast MACs"
host:
mac: 01:00:00:00:00:00
name: vpp-tap2

View File

@ -0,0 +1,34 @@
test:
description: "Creating bridge or namespace can only be asked if their name is specified"
errors:
expected:
- "tap .* bridge-create can only be set if bridge is set"
- "tap .* namespace-create can only be set if namespace is set"
count: 2
---
taps:
tap0:
description: "Cool, create bridge and namespace"
host:
mac: 02:00:00:00:00:00
name: vpp-tap0
bridge: vpp-br0
bridge-create: True
namespace: vpp-test
namespace-create: True
tap1:
description: "Cool, assuming the operator has created the bridge and namespace beforehand"
host:
name: vpp-tap1
bridge: vpp-br1
namespace: vpp-test
tap2:
description: "Not cool, asking to create a bridge without giving its name"
host:
name: vpp-tap2
bridge-create: True
tap3:
description: "Not cool, asking to create a namespace without giving its name"
host:
name: vpp-tap3
namespace-create: True