Documentation
¶
Overview ¶
Package gribi provides helper APIs to simplify writing gribi test cases. It uses fluent APIs and provides wrapper functions to manage sessions and change clients roles easily without keep tracking of the server election id. It also packs modify operations with the corresponding verifications to prevent code duplications and increase the test code readability.
Index ¶
- func Flush(client *fluent.GRIBIClient, electionID Uint128, networkInstanceName string) (*gpb.FlushResponse, error)
- func FlushAll(c *fluent.GRIBIClient) error
- func NHEntry(nhIndex uint64, address, instance string, ...) (fluent.GRIBIEntry, *client.OpResult)
- func NHGEntry(nhgIndex uint64, nhWeights map[uint64]uint64, instance string, ...) (fluent.GRIBIEntry, *client.OpResult)
- func UpdateElectionID(t testing.TB, c *fluent.GRIBIClient, electionID Uint128)
- type Client
- func (c *Client) AddEntries(t testing.TB, entries []fluent.GRIBIEntry, expectedResults []*client.OpResult)
- func (c *Client) AddIPv4(t testing.TB, prefix string, nhgIndex uint64, instance, nhgInstance string, ...)
- func (c *Client) AddIPv6(t testing.TB, prefix string, nhgIndex uint64, instance, nhgInstance string, ...)
- func (c *Client) AddNH(t testing.TB, nhIndex uint64, address, instance string, ...)
- func (c *Client) AddNHG(t testing.TB, nhgIndex uint64, nhWeights map[uint64]uint64, instance string, ...)
- func (c *Client) AwaitTimeout(ctx context.Context, t testing.TB, timeout time.Duration) error
- func (c *Client) BecomeLeader(t testing.TB) (electionID Uint128)
- func (c *Client) Close(t testing.TB)
- func (c *Client) DeleteIPv4(t testing.TB, prefix string, instance string, ...)
- func (c *Client) DeleteIPv6(t testing.TB, prefix string, instance string, ...)
- func (c *Client) ElectionID() Uint128
- func (c *Client) Fluent(_ testing.TB) *fluent.GRIBIClient
- func (c *Client) Flush(t testing.TB, electionID Uint128, networkInstanceName string)
- func (c *Client) FlushAll(t testing.TB)
- func (c *Client) LearnElectionID(t testing.TB) (electionID Uint128)
- func (c *Client) Start(t testing.TB) error
- func (c *Client) UpdateElectionID(t testing.TB, electionID Uint128)
- type NHGOptions
- type NHOptions
- type Uint128
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Flush ¶
func Flush(client *fluent.GRIBIClient, electionID Uint128, networkInstanceName string) (*gpb.FlushResponse, error)
Flush flushes gRIBI entries specific to the provided NetworkInstance end electionID.
func NHEntry ¶
func NHEntry(nhIndex uint64, address, instance string, expectedResult fluent.ProgrammingResult, opts ...*NHOptions) (fluent.GRIBIEntry, *client.OpResult)
NHEntry returns a fluent NextHopEntry that can be programmed and the gribigo client OpResult to expect.
func NHGEntry ¶
func NHGEntry(nhgIndex uint64, nhWeights map[uint64]uint64, instance string, expectedResult fluent.ProgrammingResult, opts ...*NHGOptions) (fluent.GRIBIEntry, *client.OpResult)
NHGEntry returns a fluent NextHopGroupEntry that can be programmed and the gribigo client OpResult to expect.
func UpdateElectionID ¶
func UpdateElectionID(t testing.TB, c *fluent.GRIBIClient, electionID Uint128)
UpdateElectionID updates the election id of the dut.
Types ¶
type Client ¶
type Client struct { DUT *ondatra.DUTDevice FIBACK bool Persistence bool // contains filtered or unexported fields }
Client provides access to GRIBI APIs of the DUT.
Usage:
c := &Client{ DUT: ondatra.DUT(t, "dut"), FIBACK: true, Persistence: true, } defer c.Close(t) if err := c.Start(t); err != nil { t.Fatalf("Could not initialize gRIBI: %v", err) }
func (*Client) AddEntries ¶
func (c *Client) AddEntries(t testing.TB, entries []fluent.GRIBIEntry, expectedResults []*client.OpResult)
AddEntries adds the input gRIBI entries and checks the success of the input OperationResults.
func (*Client) AddIPv4 ¶
func (c *Client) AddIPv4(t testing.TB, prefix string, nhgIndex uint64, instance, nhgInstance string, expectedResult fluent.ProgrammingResult)
AddIPv4 adds an IPv4Entry mapping a prefix to a given next hop group index within a given network instance.
func (*Client) AddIPv6 ¶
func (c *Client) AddIPv6(t testing.TB, prefix string, nhgIndex uint64, instance, nhgInstance string, expectedResult fluent.ProgrammingResult)
AddIPv6 adds an IPv6Entry mapping a prefix to a given next hop group index within a given network instance.
func (*Client) AddNH ¶
func (c *Client) AddNH(t testing.TB, nhIndex uint64, address, instance string, expectedResult fluent.ProgrammingResult, opts ...*NHOptions)
AddNH adds a NextHopEntry with a given index to an address within a given network instance.
func (*Client) AddNHG ¶
func (c *Client) AddNHG(t testing.TB, nhgIndex uint64, nhWeights map[uint64]uint64, instance string, expectedResult fluent.ProgrammingResult, opts ...*NHGOptions)
AddNHG adds a NextHopGroupEntry with a given index, and a map of next hop entry indices to the weights, in a given network instance.
func (*Client) AwaitTimeout ¶
AwaitTimeout calls a fluent client Await by adding a timeout to the context.
func (*Client) BecomeLeader ¶
BecomeLeader learns the latest election id and the make the client leader by increasing the election id by one.
func (*Client) Close ¶
Close function closes the gribi session with the dut by stopping the fluent client.
func (*Client) DeleteIPv4 ¶
func (c *Client) DeleteIPv4(t testing.TB, prefix string, instance string, expectedResult fluent.ProgrammingResult)
DeleteIPv4 deletes an IPv4Entry within a network instance, given the route's prefix
func (*Client) DeleteIPv6 ¶
func (c *Client) DeleteIPv6(t testing.TB, prefix string, instance string, expectedResult fluent.ProgrammingResult)
DeleteIPv6 deletes an IPv6Entry within a network instance, given the route's prefix
func (*Client) ElectionID ¶
ElectionID returns the current electionID being set for the client.
func (*Client) Fluent ¶
func (c *Client) Fluent(_ testing.TB) *fluent.GRIBIClient
Fluent resturns the fluent client that can be used to directly call the gribi fluent APIs
func (*Client) Flush ¶
Flush flushes gRIBI entries specific to the provided NetworkInstance end electionID
func (*Client) LearnElectionID ¶
LearnElectionID learns the current server election id by sending a dummy modify request with election id 1.
type NHGOptions ¶
type NHGOptions struct { // BackupNHG specifies the backup next-hop-group to be used when all next-hops are unavailable. BackupNHG uint64 }
NHGOptions are optional parameters to a GRIBI next-hop-group.
type NHOptions ¶
type NHOptions struct { Src string Dest string VrfName string Mac string Interface string SubInterface uint64 }
NHOptions are optional parameters to a GRIBI next-hop.
type Uint128 ¶
Uint128 struct implements a 128 bit unsigned integer required by gRIBI election process
func BecomeLeader ¶
func BecomeLeader(t testing.TB, c *fluent.GRIBIClient) (electionID Uint128)
BecomeLeader learns the latest election id and the make the client leader by increasing the election id by one.
func LearnElectionID ¶
func LearnElectionID(t testing.TB, c *fluent.GRIBIClient) (electionID Uint128)
LearnElectionID learns the current server election id by sending a dummy modify request with election id 1.