policytest

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BGPPath           = ocpath.Root().NetworkInstance(fakedevice.DefaultNetworkInstance).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, fakedevice.BGPRoutingProtocol).Bgp()
	RoutingPolicyPath = ocpath.Root().RoutingPolicy()
)

Functions

func RetryDiff

func RetryDiff(maxN uint, name string, f func() string) string

RetryDiff retries a diff function maxN times or when it returns "". In between each retry there is a five second delay.

func TestPolicy

func TestPolicy(t *testing.T, testspec *TestCase)

TestPolicy is the helper policy integration tests can call to instantiate policy tests.

Types

type Device

type Device struct {
	*ondatra.DUTDevice
	AS       uint32
	RouterID string
}

func (*Device) String

func (d *Device) String() string

type DevicePair

type DevicePair struct {
	First      *Device
	Second     *Device
	FirstPort  *attrs.Attributes
	SecondPort *attrs.Attributes
}

type RoutePathTestCase

type RoutePathTestCase struct {
	Description    string
	ExpectedResult RouteTestResult

	PrevAdjRibOutPreCommunities []string
	// An export policy is applied here by convention.
	PrevAdjRibOutPostCommunities []string

	AdjRibInPreCommunities []string
	// An import policy is applied here by convention.
	AdjRibInPostCommunities  []string
	LocalRibCommunities      []string
	AdjRibOutPreCommunities  []string
	AdjRibOutPostCommunities []string

	NextAdjRibInPreCommunities []string
	NextLocalRibCommunities    []string

	// The next-hop attribute will not be compared (the addresses are not stable between test runs)
	PrevAdjRibOutPreAttrs  *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
	PrevAdjRibOutPostAttrs *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
	AdjRibInPreAttrs       *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
	AdjRibInPostAttrs      *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
	LocalRibAttrs          *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
	AdjRibOutPreAttrs      *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
	AdjRibOutPostAttrs     *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
	NextAdjRibInPreAttrs   *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
	NextAdjRibInPostAttrs  *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
	NextLocalRibAttrs      *oc.NetworkInstance_Protocol_Bgp_Rib_AttrSet
}

type RouteTestCase

type RouteTestCase struct {
	Input                   TestRoute
	RouteTest               *RoutePathTestCase
	AlternatePathRouteTest  *RoutePathTestCase
	LongerPathRouteTest     *RoutePathTestCase
	SkipDUT2RouteValidation bool
}

type RouteTestResult

type RouteTestResult int

The expected result for a RouteTestCase

const (
	// RouteUnspecified should never be the value of an actual test case.
	RouteUnspecified RouteTestResult = iota
	// RouteAccepted means to accept the input TestRoute.
	RouteAccepted
	// RouteDiscarded means to discard the input TestRoute.
	RouteDiscarded
	// RouteNotPreferred means not selected by best path selection.
	RouteNotPreferred
)

type TestCase

type TestCase struct {
	Description             string
	RouteTests              []*RouteTestCase
	InstallPolicies         func(t *testing.T, pair12, pair52, pair23 *DevicePair)
	SkipCheckingCommunities bool
}

TestCase contains the specifications for a single policy test.

Topology:

DUT1 (AS 64500) -> DUT2 (AS 64500) -> DUT3 (AS 64501)
                    ^
                    |
DUT4 (AS 64502) -> DUT5 (AS 64500)

Additionally, DUT0 is present as a neighbour for DUT1, DUT4, and DUT5
to allow a static route to be resolvable.

Currently by convention, all policies are installed on DUT1 (export), DUT5 (export), and DUT2 (import). This is because GoBGP only withdraws routes on import policy change after a soft reset: https://github.com/osrg/gobgp/blob/master/docs/sources/policy.md#policy-and-soft-reset

type TestRoute

type TestRoute struct {
	ReachPrefix string
}

This message represents a single prefix and its associated BGP attributes.

Jump to

Keyboard shortcuts

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