Documentation ¶
Overview ¶
Package netutil provides network-related helper functions for testing.
Among the various utilities in this package are several helpers that wrap functions in the entity naming library to make tests less verbose. For example, production might generate the name of a loopback interface for a device with the following code:
dev := &entname.DeviceParams{ Vendor: devVendor, HardwareModel: devHardwareModel, } lbIntf, err := entname.LoopbackInterface(deviceParams, 0) if err != nil { return err }
Using LoopbackInterface, an Ondatra test can do the equivalent in a single line, reusing an existing Ondatra DUT:
lbIntf := netutil.LoopbackInterface(t, dut, 0)
Index ¶
- Constants
- func AggregateInterface(t *testing.T, dut *ondatra.DUTDevice, index int) string
- func CommonQoSQueues(t *testing.T, dut *ondatra.DUTDevice, qos *entname.QoSParams) *entname.CommonQoSQueueNames
- func CommonTrafficQueues(t *testing.T, dut *ondatra.DUTDevice) *entname.CommonTrafficQueueNames
- func GenCIDRs(t testing.TB, cidr string, count int) <-chan string
- func GenSystemIDs(t testing.TB, startID string, count int) <-chan string
- func LoopbackInterface(t *testing.T, dut *ondatra.DUTDevice, index int) string
- func MeanRate[T constraints.Integer | constraints.Float](t testing.TB, vals []*ygnmi.Value[T]) float64
- func NextAggregateInterface(t *testing.T, dut *ondatra.DUTDevice) string
Constants ¶
const DefaultNetworkInstance = "DEFAULT"
DefaultNetworkInstance is the constant name for referring to the default network instance on the device. It has been standardized in OpenConfig.
Variables ¶
This section is empty.
Functions ¶
func AggregateInterface ¶ added in v0.1.22
AggregateInterface returns the vendor-specific name of the aggregate interface with the specified zero-based index.
func CommonQoSQueues ¶ added in v0.2.8
func CommonQoSQueues(t *testing.T, dut *ondatra.DUTDevice, qos *entname.QoSParams) *entname.CommonQoSQueueNames
CommonQoSQueues returns the vendors-specific names of common QoS queues. See the common QoS queue definitions here: https://github.com/openconfig/entity-naming#common-qos-queues
func CommonTrafficQueues ¶ added in v0.1.22
CommonTrafficQueues returns the vendors-specific names of common traffic class queues. See the definition of common queues here: Deprecated: Use CommonQosQueues instead.
func GenCIDRs ¶ added in v0.4.2
GenCIDRs returns a channel of the specified number of CIDR strings starting from the given CIDR.
func GenSystemIDs ¶ added in v0.4.2
GenSystemIDs returns a channel of the specified number of hex-formatted system IDs.
func LoopbackInterface ¶
LoopbackInterface returns the vendor-specific name of the loopback interface with the specified zero-based index.
func MeanRate ¶
func MeanRate[T constraints.Integer | constraints.Float](t testing.TB, vals []*ygnmi.Value[T]) float64
MeanRate calculates the average rate across the supplied interval from the values supplied in the vals slice. It sorts the values by timestamp and uses the earliest and latest to calculate the rate. Errors are reported using the supplied testing.TB.
Types ¶
This section is empty.