gribi

package
v0.0.0-...-e8efe0d Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

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

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 FlushAll

func FlushAll(c *fluent.GRIBIClient) error

FlushAll flushes all the gribi entries.

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

func (c *Client) AwaitTimeout(ctx context.Context, t testing.TB, timeout time.Duration) error

AwaitTimeout calls a fluent client Await by adding a timeout to the context.

func (*Client) BecomeLeader

func (c *Client) BecomeLeader(t testing.TB) (electionID Uint128)

BecomeLeader learns the latest election id and the make the client leader by increasing the election id by one.

func (*Client) Close

func (c *Client) Close(t testing.TB)

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

func (c *Client) ElectionID() Uint128

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

func (c *Client) Flush(t testing.TB, electionID Uint128, networkInstanceName string)

Flush flushes gRIBI entries specific to the provided NetworkInstance end electionID

func (*Client) FlushAll

func (c *Client) FlushAll(t testing.TB)

FlushAll flushes all the gribi entries

func (*Client) LearnElectionID

func (c *Client) LearnElectionID(t testing.TB) (electionID Uint128)

LearnElectionID learns the current server election id by sending a dummy modify request with election id 1.

func (*Client) Start

func (c *Client) Start(t testing.TB) error

Start function start establish a client connection with the gribi server. By default the client is not the leader and for that function BecomeLeader needs to be called.

func (*Client) UpdateElectionID

func (c *Client) UpdateElectionID(t testing.TB, electionID Uint128)

UpdateElectionID updates the election id of the dut. The function fails if the requested election id is less than the server election id.

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

type Uint128 struct {
	Low  uint64
	High uint64
}

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.

func (Uint128) Decrement

func (i Uint128) Decrement() Uint128

Decrement decreases the Uint128 number by 1

func (Uint128) Increment

func (i Uint128) Increment() Uint128

Increment increases the Uint128 number by 1

Jump to

Keyboard shortcuts

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