raw

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package raw provides low-level access to the raw device APIs, to be used when the other higher-level APIs are not sufficient.

The high-level APIs provided by other Ondatra packages like the gNMI API are not appropriate for every test scenario. For instance, the gNMI API would not be appropriate for low-level testing of a device's conformance to the gNMI specification. It would in fact be difficult, if not impossible, to use it for some negative test cases, and certainly for fuzz testing, since by design the API means to confine tests to constructing valid gNMI requests.

Accessing the Raw Client APIs

For such test scenarios, tests should use the Ondatra "Raw APIs". Calling "dut.RawAPIs()" returns a set of APIs for low-level access to "dut". For example, the calls "dut.RawAPIs().GNMI(t)" and "dut.RawAPIs().GNOI(t)" return handles to the Go gRPC clients that Ondatra uses for gNMI and gNOI interactions, respectively. Similarly, calling "ate.RawAPIs()" returns a set of APIs for low-level access to "ate".

The clients returned by these methods are those returned by the test's binding. As a result, if a test needs to access a proprietary method provided by the binding's implementation of the client, it can simply type assert the client to expose the method, e.g.:

dut.RawAPIs().GNOI(t).(interface {
	MyProprietaryMethod()
}).MyProprietaryMethod()

Accessing the Binding Device

For still other tests, access to the clients that Ondatra has created is insufficient. Some tests may deliberately need to create multiple clients, or they may need fine-grained control over how the client is dialed, such as special context metadata or dial options that the binding does not provide by default. For these situations, a test should retrieve the binding.DUT and binding.ATE instances underlying a DUT or ATE with the calls "dut.RawAPIs().BindingDUT()" and "ate.RawAPIs().BindingATE()," respectively. With these, they can dial the client themselves, like so:

gnmiClient, err := dut.RawAPIs().BindingDUT().DialGNMI(ctx, gnmiDialOpts...)
if err != nil {
	t.Fatal("DialGNMI failed: %v", err)
}
otgClient, err := ate.RawAPIs().BindingATE().DialOTG(ctx, otgDialOpts...)
if err != nil {
	t.Fatal("DialOTG failed: %v", err)
}

If a test needs to dial proprietary clients, it can type assert the device returned by the DUTAPIs.BindingDUT or ATEAPIs.BindingATE functions to one that supports the method of interest. However, because the binding.DUT or binding.ATE instance with the proprietary method may be embedded inside a DUT or ATE wrapper type, a simple type assertion may fail. For that reason, the assertion on a DUT or ATE should use the utility functions binding.DUTAs or binding.ATEAs instead:

var target interface {
	MyProprietaryClient()
}
if err := binding.DUTAs(dut, &target) {
	t.Fatalf("DUT does not support MyProprietaryClient(): ", err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ATEAPIs

type ATEAPIs struct {
	// contains filtered or unexported fields
}

ATEAPIs provides access to raw ATE protocol APIs.

func NewATEAPIs

func NewATEAPIs(ate binding.ATE) *ATEAPIs

NewATEAPIs returns a new instance of raw ATE APIs. Tests must not call this directly.

func (*ATEAPIs) BindingATE added in v0.3.0

func (r *ATEAPIs) BindingATE() binding.ATE

BindingATE returns the underlying binding.ATE.

func (*ATEAPIs) GNMI

func (r *ATEAPIs) GNMI(t testing.TB) gpb.GNMIClient

GNMI returns the default gNMI client for the ATE.

type DUTAPIs

type DUTAPIs struct {
	// contains filtered or unexported fields
}

DUTAPIs provides access to raw DUT protocol APIs.

func NewDUTAPIs

func NewDUTAPIs(dut binding.DUT) *DUTAPIs

NewDUTAPIs returns a new instance of raw DUT APIs. Tests must not call this directly.

func (*DUTAPIs) BindingDUT added in v0.2.8

func (r *DUTAPIs) BindingDUT() binding.DUT

BindingDUT returns the underlying binding.DUT.

func (*DUTAPIs) CLI

func (r *DUTAPIs) CLI(t testing.TB) binding.CLIClient

CLI returns a new streaming CLI client for the DUT.

func (*DUTAPIs) Console

func (r *DUTAPIs) Console(t testing.TB) binding.ConsoleClient

Console returns a new Console client for the DUT.

func (*DUTAPIs) GNMI

func (r *DUTAPIs) GNMI(t testing.TB) gpb.GNMIClient

GNMI returns the default gNMI client for the dut.

func (*DUTAPIs) GNOI

func (r *DUTAPIs) GNOI(t testing.TB) gnoigo.Clients

GNOI returns the default gNOI clients for the dut.

func (*DUTAPIs) GNSI added in v0.2.1

func (r *DUTAPIs) GNSI(t testing.TB) binding.GNSIClients

GNSI returns the default gNSI clients for the dut.

func (*DUTAPIs) GRIBI

func (r *DUTAPIs) GRIBI(t testing.TB) grpb.GRIBIClient

GRIBI returns the default gRIBI client for the dut.

func (*DUTAPIs) P4RT

func (r *DUTAPIs) P4RT(t testing.TB) p4pb.P4RuntimeClient

P4RT returns the default P4RT client for the dut.

Jump to

Keyboard shortcuts

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