fptest

package
v0.0.0-...-ca63cbe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package fptest provides helper functions for organizing tests and reporting results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignToNetworkInstance

func AssignToNetworkInstance(t testing.TB, d *ondatra.DUTDevice, i string, ni string, si uint32)

AssignToNetworkInstance attaches a subinterface to a network instance.

func ConfigEnableTbNative

func ConfigEnableTbNative(t testing.TB, d *ondatra.DUTDevice)

ConfigEnableTbNative enables admin-state of table-connections in native mode.

func ConfigureDefaultNetworkInstance

func ConfigureDefaultNetworkInstance(t testing.TB, d *ondatra.DUTDevice)

ConfigureDefaultNetworkInstance configures the default network instance name and type.

func CopyDeviceConfig

func CopyDeviceConfig(t testing.TB, dut *ondatra.DUTDevice, config *oc.Root) *oc.Root

CopyDeviceConfig returns a deep copy of a device config but refurbishes it enough so it can be pushed out again

func GetDeviceConfig

func GetDeviceConfig(t testing.TB, dev gnmi.DeviceOrOpts) *oc.Root

GetDeviceConfig gets a full config from a device but refurbishes it enough so it can be pushed out again. Ideally, we should be able to push the config we get from the same device without modification, but this is not explicitly defined in OpenConfig.

func GetIfSpeed

GetIfSpeed returns an explicit speed of an interface in OC format

func LogQuery

func LogQuery(t testing.TB, what string, query LoggableQuery, obj ygot.GoStruct)

LogQuery logs a ygot GoStruct at path as either config or telemetry, depending on the query. It also writes a copy to a *.json file in the directory specified by the -outputs_dir flag.

func NonFatal

func NonFatal(t testing.TB, f func(t testing.TB)) (ok bool)

NonFatal converts fatal to an error so the test could continue.

func RunTests

func RunTests(m *testing.M)

RunTests initializes the appropriate binding and runs the tests. It should be called from every featureprofiles tests like this:

package test

import "github.com/openconfig/featureprofiles/internal/fptest"

func TestMain(m *testing.M) {
  fptest.RunTests(m)
}

func SetPortSpeed

func SetPortSpeed(t testing.TB, p *ondatra.Port)

SetPortSpeed sets the DUT config for the interface port-speed according to ondatra.Prot.Speed()

func WriteOutput

func WriteOutput(filename, suffix string, content string) (string, error)

WriteOutput writes content to a file in --outputs_dir, after sanitizing the filename and making it unique. Returns the sanitized filename relative to --outputs_dir.

func WriteQuery

func WriteQuery(t testing.TB, what string, query LoggableQuery, obj ygot.GoStruct)

WriteQuery is like LogQuery but only writes to test output dir, so it does not pollute the test log.

Types

type LoggableQuery

type LoggableQuery interface {
	PathStruct() ygnmi.PathStruct
	IsState() bool
}

LoggableQuery is a subset of the ygnmi.AnyQuery type used for logging

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL