Documentation
¶
Overview ¶
Package aftcache is a test library for storing a stream of AFT telemetry at full RIB scale in a local cache so we can periodically check if required test conditions are met, such as verifying that all expected prefixes are present.
Index ¶
- Variables
- type AFTData
- type AFTStreamSession
- func (ss *AFTStreamSession) ListenUntil(ctx context.Context, t *testing.T, timeout time.Duration, ...)
- func (ss *AFTStreamSession) ListenUntilPreUpdateHook(ctx context.Context, t *testing.T, timeout time.Duration, ...)
- func (ss *AFTStreamSession) ToAFT(t *testing.T, dut *ondatra.DUTDevice) (*AFTData, error)
- type NotificationHook
- type PeriodicHook
- func AssertNextHopCount(t *testing.T, dut *ondatra.DUTDevice, wantPrefixes map[string]bool, ...) PeriodicHook
- func DeletionStoppingCondition(t *testing.T, dut *ondatra.DUTDevice, wantDeletePrefixes map[string]bool) PeriodicHook
- func InitialSyncStoppingCondition(t *testing.T, dut *ondatra.DUTDevice, ...) PeriodicHook
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotExist is an error returned when expected AFT elements are not found and so AFT is inconsistent. ErrNotExist = errors.New("does not exist") // ErrUnsupported is an error returned when AFT elements are not supported. ErrUnsupported = errors.New("unsupported") )
Functions ¶
This section is empty.
Types ¶
type AFTData ¶
type AFTData struct {
// Prefixes contains a map of prefixes to their corresponding next hop group IDs.
Prefixes map[string]uint64
// NextHopGroups contains a map of next hop group IDs to their corresponding next hop group data.
NextHopGroups map[uint64]*aftNextHopGroup
// NextHops contains a map of next hop IDs to their corresponding next hop data.
NextHops map[uint64]*aftNextHop
}
AFTData represents an AFT and provides methods for resolving routes.
type AFTStreamSession ¶
type AFTStreamSession struct {
Cache *aftCache
// contains filtered or unexported fields
}
AFTStreamSession represents a single gNMI AFT streaming session and cached AFT state. It contains a subscription that can be used across multiple calls to ListenUntil().
func NewAFTStreamSession ¶
func NewAFTStreamSession(ctx context.Context, t *testing.T, c gnmipb.GNMIClient, dut *ondatra.DUTDevice) *AFTStreamSession
NewAFTStreamSession constructs an AFTStreamSession. It subscribes to a given gNMI client.
func (*AFTStreamSession) ListenUntil ¶
func (ss *AFTStreamSession) ListenUntil(ctx context.Context, t *testing.T, timeout time.Duration, stoppingCondition PeriodicHook)
ListenUntil updates AFT with notifications from a gNMI client in streaming mode, and stops listening based on the stoppingCondition hook.
func (*AFTStreamSession) ListenUntilPreUpdateHook ¶
func (ss *AFTStreamSession) ListenUntilPreUpdateHook(ctx context.Context, t *testing.T, timeout time.Duration, preUpdateHooks []NotificationHook, stoppingCondition PeriodicHook)
ListenUntilPreUpdateHook updates AFT with notifications from a gNMI client in streaming mode, and stops listening based on the stoppingCondition hook. It also runs the preUpdateHooks before updating the AFT cache.
type NotificationHook ¶
type NotificationHook struct {
// Description is a human readable description of the hook.
Description string
// NotificationFunc is the function that will be called when each notification is received.
NotificationFunc func(c *aftCache, n *gnmipb.SubscribeResponse) error
}
NotificationHook is a function that will be called when each notification is received, before updating the AFT cache.
func VerifyAtomicFlagHook ¶
func VerifyAtomicFlagHook(t *testing.T) NotificationHook
VerifyAtomicFlagHook returns a NotificationHook which verifies that the atomic flag is set to true.
type PeriodicHook ¶
type PeriodicHook struct {
Description string
PeriodicFunc func(ss *AFTStreamSession) (bool, error)
}
PeriodicHook is a function that will be called on a regular interval with the current AFT cache.
func AssertNextHopCount ¶
func AssertNextHopCount(t *testing.T, dut *ondatra.DUTDevice, wantPrefixes map[string]bool, wantNHCount int) PeriodicHook
AssertNextHopCount returns a PeriodicHook which can be used to check if all the given prefixes resolve to the expected number of next hops.
func DeletionStoppingCondition ¶
func DeletionStoppingCondition(t *testing.T, dut *ondatra.DUTDevice, wantDeletePrefixes map[string]bool) PeriodicHook
DeletionStoppingCondition returns a PeriodicHook which can be used to check if all given prefixes have been deleted.
func InitialSyncStoppingCondition ¶
func InitialSyncStoppingCondition(t *testing.T, dut *ondatra.DUTDevice, wantPrefixes, wantIPV4NHs, wantIPV6NHs map[string]bool) PeriodicHook
InitialSyncStoppingCondition returns a PeriodicHook which can be used to check if all wanted prefixes have been received with given next hop IP addresses.