fakebind

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package fakebind implements a fake testbed binding, backed by a fake SSH server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ATE

type ATE struct {
	*binding.AbstractATE
	DialIxNetworkFn func(context.Context) (*binding.IxNetwork, error)
	DialGNMIFn      func(context.Context, ...grpc.DialOption) (gpb.GNMIClient, error)
	DialOTGFn       func(context.Context, ...grpc.DialOption) (gosnappi.GosnappiApi, error)
}

ATE is a fake implementation of binding.ATE comprised of stubs.

func (*ATE) DialGNMI

func (a *ATE) DialGNMI(ctx context.Context, opts ...grpc.DialOption) (gpb.GNMIClient, error)

DialGNMI delegates to a.DialGNMIFn.

func (*ATE) DialIxNetwork

func (a *ATE) DialIxNetwork(ctx context.Context) (*binding.IxNetwork, error)

DialIxNetwork delegates to a.DialIxNetworkFn.

func (*ATE) DialOTG

func (a *ATE) DialOTG(ctx context.Context, opts ...grpc.DialOption) (gosnappi.GosnappiApi, error)

DialOTG delegates to a.DialOTGFn.

type Binding

type Binding struct {
	ReserveFn          func(context.Context, *opb.Testbed, time.Duration, time.Duration, map[string]string) (*binding.Reservation, error)
	ReleaseFn          func(context.Context) error
	FetchReservationFn func(context.Context, string) (*binding.Reservation, error)
}

Binding is a fake binding.Binding implementation comprised of stubs.

func Setup

func Setup() *Binding

Setup initializes Ondatra with a new fake binding, initializes the testbed to an unreserved state, and returns the fake binding for further stubbing.

func (*Binding) FetchReservation

func (b *Binding) FetchReservation(ctx context.Context, id string) (*binding.Reservation, error)

FetchReservation delegates to b.FetchReservationFn.

func (*Binding) Release

func (b *Binding) Release(ctx context.Context) error

Release delegates to b.ReleaseFN.

func (*Binding) Reserve

func (b *Binding) Reserve(ctx context.Context, tb *opb.Testbed, runTime, waitTime time.Duration, partial map[string]string) (*binding.Reservation, error)

Reserve delegates to b.ReserveFn.

func (*Binding) WithReservation

func (b *Binding) WithReservation(res *binding.Reservation) *Binding

WithReservation sets Ondatra to a state in which the specified reservation has been reserved. It does not alter the implementation of this binding's stub functions in any way. If a nil reservation is supplied, Ondatra is set to an unreserved state.

type DUT

type DUT struct {
	*binding.AbstractDUT
	PushConfigFn  func(context.Context, string, bool) error
	DialCLIFn     func(context.Context) (binding.StreamClient, error)
	DialConsoleFn func(context.Context) (binding.StreamClient, error)
	DialGNMIFn    func(context.Context, ...grpc.DialOption) (gpb.GNMIClient, error)
	DialGNOIFn    func(context.Context, ...grpc.DialOption) (binding.GNOIClients, error)
	DialGRIBIFn   func(context.Context, ...grpc.DialOption) (grpb.GRIBIClient, error)
	DialP4RTFn    func(context.Context, ...grpc.DialOption) (p4pb.P4RuntimeClient, error)
}

DUT is a fake implementation of binding.DUT comprised of stubs.

func (*DUT) DialCLI

func (d *DUT) DialCLI(ctx context.Context) (binding.StreamClient, error)

DialCLI delegates to d.DialCLIFn.

func (*DUT) DialConsole

func (d *DUT) DialConsole(ctx context.Context) (binding.StreamClient, error)

DialConsole delegates to d.DialConsoleFn.

func (*DUT) DialGNMI

func (d *DUT) DialGNMI(ctx context.Context, opts ...grpc.DialOption) (gpb.GNMIClient, error)

DialGNMI delegates to d.DialGNMIFn.

func (*DUT) DialGNOI

func (d *DUT) DialGNOI(ctx context.Context, opts ...grpc.DialOption) (binding.GNOIClients, error)

DialGNOI delegates to d.DialGNOIFn.

func (*DUT) DialGRIBI

func (d *DUT) DialGRIBI(ctx context.Context, opts ...grpc.DialOption) (grpb.GRIBIClient, error)

DialGRIBI delegates to d.DialGRIBIFn.

func (*DUT) DialP4RT

func (d *DUT) DialP4RT(ctx context.Context, opts ...grpc.DialOption) (p4pb.P4RuntimeClient, error)

DialP4RT delegates to d.DialP4RTFn.

func (*DUT) PushConfig

func (d *DUT) PushConfig(ctx context.Context, config string, reset bool) error

PushConfig delegates to d.PushConfigFn.

type StreamClient

type StreamClient struct {
	*binding.AbstractStreamClient

	InReader  *io.PipeReader
	OutWriter *io.PipeWriter
	ErrWriter *io.PipeWriter
	// contains filtered or unexported fields
}

StreamClient is a fake implementation of StreamClient for use in testing.

func NewStreamClient

func NewStreamClient() *StreamClient

NewStreamClient returns a new StreamClient. Users should just access the test sides of the pipes for testing via exported fields.

func (*StreamClient) Close

func (f *StreamClient) Close() error

Close will return a configured err.

func (*StreamClient) SendCommand

func (f *StreamClient) SendCommand(_ context.Context, cmd string) (string, error)

SendCommand will echo whatever command is sent. If the cmd is "error" an error till be returned.

func (*StreamClient) Stderr

func (f *StreamClient) Stderr() io.ReadCloser

Stderr returns the configured stderr buffer.

func (*StreamClient) Stdin

func (f *StreamClient) Stdin() io.WriteCloser

Stdin returns the configured stdin buffer.

func (*StreamClient) Stdout

func (f *StreamClient) Stdout() io.ReadCloser

Stdout returns the configured stdout buffer.

Jump to

Keyboard shortcuts

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