Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
FolderOrigin-RevId: /usr/local/google/home/gdennis/copybara/temp/folder-destination700944368678497983/.
  • Loading branch information
GGN Engprod Team authored and greg-dennis committed Feb 2, 2022
1 parent fc26c38 commit 565fe6d
Show file tree
Hide file tree
Showing 142 changed files with 53,527 additions and 50,342 deletions.
8 changes: 4 additions & 4 deletions ate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package ondatra

import (
"github.com/open-traffic-generator/snappi/gosnappi"
"github.com/openconfig/ondatra/internal/reservation"
"github.com/openconfig/ondatra/binding"
)

// ATEDevice is an automated test equipment.
Expand All @@ -30,17 +30,17 @@ func (a *ATEDevice) OTG() *OTG {
if a.otg == nil {
// TODO: Replace with a Binding.DialOTG method.
api := gosnappi.NewApi()
a.otg = &OTG{ate: a.res.(*reservation.ATE), api: api}
a.otg = &OTG{ate: a.res.(*binding.ATE), api: api}
}
return a.otg
}

// Topology returns a handle to the topology API.
func (a *ATEDevice) Topology() *Topology {
return &Topology{a.res.(*reservation.ATE)}
return &Topology{a.res.(*binding.ATE)}
}

// Traffic returns a handle to the traffic API.
func (a *ATEDevice) Traffic() *Traffic {
return &Traffic{a.res.(*reservation.ATE)}
return &Traffic{a.res.(*binding.ATE)}
}
108 changes: 75 additions & 33 deletions internal/binding/binding.go → binding/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package binding holds the server binding interface.
// Package binding holds the Ondatra binding interface.
package binding

import (
"golang.org/x/net/context"
"fmt"
"io"
"time"

log "github.com/golang/glog"
"google.golang.org/grpc"
"github.com/openconfig/ondatra/internal/ixweb"
"github.com/openconfig/ondatra/internal/reservation"
"github.com/openconfig/ondatra/binding/ixweb"

gpb "github.com/openconfig/gnmi/proto/gnmi"
bpb "github.com/openconfig/gnoi/bgp"
Expand All @@ -44,27 +43,7 @@ import (

)

var (
bind Binding
)

// Init initializes the Ondatra binding.
func Init(b Binding) {
if bind != nil {
log.Fatalf("Binding already initialized")
}
bind = b
}

// Get gets the Ondatra binding.
func Get() Binding {
if bind == nil {
log.Exit("Binding not initialized. Did you forget to call ondatra.RunTests in TestMain?")
}
return bind
}

// Binding is a strategy interface for Ondatra server implementations.
// Binding is a strategy interface for Ondatra vendor implementations.
//
// The framework enforces that at most testbed is reserved at a time, so
// implementations can assume that these methods are never called out of order,
Expand All @@ -91,7 +70,7 @@ type Binding interface {
// resources to become available. Given a zero waitTime, the implementation
// must choose a reasonable duration. The framework has already checked that
// the waitTime is not negative.
Reserve(ctx context.Context, tb *opb.Testbed, runTime, waitTime time.Duration) (*reservation.Reservation, error)
Reserve(ctx context.Context, tb *opb.Testbed, runTime, waitTime time.Duration) (*Reservation, error)

// Release releases the reserved testbed.
Release(ctx context.Context) error
Expand All @@ -103,30 +82,30 @@ type Binding interface {
// If the openconfig option is true, the config is in openconfig JSON syntax.
// If the append option is true, the config is appended to the existing config;
// otherwise the existing config is replaced with the provided config.
PushConfig(ctx context.Context, dut *reservation.DUT, config string, opts *ConfigOptions) error
PushConfig(ctx context.Context, dut *DUT, config string, opts *ConfigOptions) error

// DialGNMI creates a client connection to the specified DUT's gNMI endpoint.
// Implementations must append transport security options necessary to reach the server.
DialGNMI(ctx context.Context, dut *reservation.DUT, opts ...grpc.DialOption) (gpb.GNMIClient, error)
DialGNMI(ctx context.Context, dut *DUT, opts ...grpc.DialOption) (gpb.GNMIClient, error)

// DialGNOI creates a client connection to the specified DUT's gNOI endpoint.
// Implementations must append transport security options necessary to reach the server.
DialGNOI(ctx context.Context, dut *reservation.DUT, opts ...grpc.DialOption) (GNOIClients, error)
DialGNOI(ctx context.Context, dut *DUT, opts ...grpc.DialOption) (GNOIClients, error)

// DialP4RT creates a client connection to the specified DUT's P4RT endpoint.
// Implementations must append transport security options necessary to reach the server.
DialP4RT(ctx context.Context, dut *reservation.DUT, opts ...grpc.DialOption) (p4pb.P4RuntimeClient, error)
DialP4RT(ctx context.Context, dut *DUT, opts ...grpc.DialOption) (p4pb.P4RuntimeClient, error)

// DialConsole creates a client connection to the specified DUT's Console endpoint.
// Implementations must append transport security options necessary to reach the server.
DialConsole(ctx context.Context, dut *reservation.DUT, opts ...grpc.DialOption) (StreamClient, error)
DialConsole(ctx context.Context, dut *DUT, opts ...grpc.DialOption) (StreamClient, error)

// DialCLI creates a client connection to the specified DUT's CLI endpoint.
// Implementations must append transport security options necessary to reach the server.
DialCLI(ctx context.Context, dut *reservation.DUT, opts ...grpc.DialOption) (StreamClient, error)
DialCLI(ctx context.Context, dut *DUT, opts ...grpc.DialOption) (StreamClient, error)

// DialIxNetwork creates a client connection to the specified ATE's IxNetwork endpoint.
DialIxNetwork(ctx context.Context, ate *reservation.ATE) (*IxNetwork, error)
DialIxNetwork(ctx context.Context, ate *ATE) (*IxNetwork, error)

// HandleInfraFail handles the given error as an infrastructure failure.
// If an error is a failure of the Ondatra server or binding implementation
Expand All @@ -138,6 +117,69 @@ type Binding interface {
SetTestMetadata(md *TestMetadata) error
}

// Reservation holds the reserved DUTs and ATEs as an id map.
type Reservation struct {
ID string
DUTs map[string]*DUT
ATEs map[string]*ATE
}

// Device is a reserved DUT or ATE.
type Device interface {
Dimensions() *Dims
}

// Dims contains the dimensions of reserved DUT or ATE.
type Dims struct {
Name string
Vendor opb.Device_Vendor
HardwareModel string
SoftwareVersion string
Ports map[string]*Port
}

func (d *Dims) String() string {
return fmt.Sprintf("Dims%+v", *d)
}

// DUT is a reserved DUT
type DUT struct {
*Dims
}

// Dimensions returns the dimensions of the device.
func (d *DUT) Dimensions() *Dims {
return d.Dims
}

func (d *DUT) String() string {
return fmt.Sprintf("DUT%+v", *d)
}

// ATE is a reserved ATE.
type ATE struct {
*Dims
}

// Dimensions returns the dimensions of the device.
func (a *ATE) Dimensions() *Dims {
return a.Dims
}

func (a *ATE) String() string {
return fmt.Sprintf("ATE%+v", *a)
}

// Port is a reserved Port.
type Port struct {
Name string
Speed opb.Port_Speed
}

func (p *Port) String() string {
return fmt.Sprintf("Port%+v", *p)
}

// ConfigOptions is a set of options for the config push.
type ConfigOptions struct {
OpenConfig, Append bool
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
package usererr

import (
"fmt"
"testing"

"github.com/pkg/errors"
"golang.org/x/xerrors"
)

func TestIn(t *testing.T) {
Expand All @@ -39,20 +39,20 @@ func TestIn(t *testing.T) {
err: errors.Wrap(New("foo"), "bar"),
wantIn: true,
}, {
name: "wrapped with xerrors %w",
err: xerrors.Errorf("foo: %w", New("bar")),
name: "wrapped with fmt %w",
err: fmt.Errorf("foo: %w", New("bar")),
wantIn: true,
}, {
name: "wrapped multiple times",
err: errors.Wrap(xerrors.Errorf("foo: %w", New("bar")), "baz"),
err: errors.Wrap(fmt.Errorf("foo: %w", New("bar")), "baz"),
wantIn: true,
}, {
name: "not user err",
err: errors.New("foo"),
wantIn: false,
}, {
name: "not user error - wrapped",
err: errors.Wrap(xerrors.Errorf("foo: %w", errors.New("bar")), "baz"),
err: errors.Wrap(fmt.Errorf("foo: %w", errors.New("bar")), "baz"),
wantIn: false,
}}
for _, tt := range tests {
Expand Down
1 change: 1 addition & 0 deletions config/acl/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using the following YANG input files:
- public/release/models/optical-transport/openconfig-transport-types.yang
- public/release/models/ospf/openconfig-ospfv2.yang
- public/release/models/platform/openconfig-platform-cpu.yang
- public/release/models/platform/openconfig-platform-integrated-circuit.yang
- public/release/models/platform/openconfig-platform-software.yang
- public/release/models/platform/openconfig-platform-transceiver.yang
- public/release/models/platform/openconfig-platform.yang
Expand Down
1 change: 1 addition & 0 deletions config/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using the following YANG input files:
- public/release/models/optical-transport/openconfig-transport-types.yang
- public/release/models/ospf/openconfig-ospfv2.yang
- public/release/models/platform/openconfig-platform-cpu.yang
- public/release/models/platform/openconfig-platform-integrated-circuit.yang
- public/release/models/platform/openconfig-platform-software.yang
- public/release/models/platform/openconfig-platform-transceiver.yang
- public/release/models/platform/openconfig-platform.yang
Expand Down
1 change: 1 addition & 0 deletions config/gnmicollectormetadata/gnmicollectormetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using the following YANG input files:
- public/release/models/optical-transport/openconfig-transport-types.yang
- public/release/models/ospf/openconfig-ospfv2.yang
- public/release/models/platform/openconfig-platform-cpu.yang
- public/release/models/platform/openconfig-platform-integrated-circuit.yang
- public/release/models/platform/openconfig-platform-software.yang
- public/release/models/platform/openconfig-platform-transceiver.yang
- public/release/models/platform/openconfig-platform.yang
Expand Down
1 change: 1 addition & 0 deletions config/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using the following YANG input files:
- public/release/models/optical-transport/openconfig-transport-types.yang
- public/release/models/ospf/openconfig-ospfv2.yang
- public/release/models/platform/openconfig-platform-cpu.yang
- public/release/models/platform/openconfig-platform-integrated-circuit.yang
- public/release/models/platform/openconfig-platform-software.yang
- public/release/models/platform/openconfig-platform-transceiver.yang
- public/release/models/platform/openconfig-platform.yang
Expand Down
1 change: 1 addition & 0 deletions config/keychain/keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using the following YANG input files:
- public/release/models/optical-transport/openconfig-transport-types.yang
- public/release/models/ospf/openconfig-ospfv2.yang
- public/release/models/platform/openconfig-platform-cpu.yang
- public/release/models/platform/openconfig-platform-integrated-circuit.yang
- public/release/models/platform/openconfig-platform-software.yang
- public/release/models/platform/openconfig-platform-transceiver.yang
- public/release/models/platform/openconfig-platform.yang
Expand Down
1 change: 1 addition & 0 deletions config/lacp/lacp.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using the following YANG input files:
- public/release/models/optical-transport/openconfig-transport-types.yang
- public/release/models/ospf/openconfig-ospfv2.yang
- public/release/models/platform/openconfig-platform-cpu.yang
- public/release/models/platform/openconfig-platform-integrated-circuit.yang
- public/release/models/platform/openconfig-platform-software.yang
- public/release/models/platform/openconfig-platform-transceiver.yang
- public/release/models/platform/openconfig-platform.yang
Expand Down
1 change: 1 addition & 0 deletions config/lldp/lldp.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using the following YANG input files:
- public/release/models/optical-transport/openconfig-transport-types.yang
- public/release/models/ospf/openconfig-ospfv2.yang
- public/release/models/platform/openconfig-platform-cpu.yang
- public/release/models/platform/openconfig-platform-integrated-circuit.yang
- public/release/models/platform/openconfig-platform-software.yang
- public/release/models/platform/openconfig-platform-transceiver.yang
- public/release/models/platform/openconfig-platform.yang
Expand Down
1 change: 1 addition & 0 deletions config/localrouting/localrouting.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using the following YANG input files:
- public/release/models/optical-transport/openconfig-transport-types.yang
- public/release/models/ospf/openconfig-ospfv2.yang
- public/release/models/platform/openconfig-platform-cpu.yang
- public/release/models/platform/openconfig-platform-integrated-circuit.yang
- public/release/models/platform/openconfig-platform-software.yang
- public/release/models/platform/openconfig-platform-transceiver.yang
- public/release/models/platform/openconfig-platform.yang
Expand Down
1 change: 1 addition & 0 deletions config/networkinstance/networkinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using the following YANG input files:
- public/release/models/optical-transport/openconfig-transport-types.yang
- public/release/models/ospf/openconfig-ospfv2.yang
- public/release/models/platform/openconfig-platform-cpu.yang
- public/release/models/platform/openconfig-platform-integrated-circuit.yang
- public/release/models/platform/openconfig-platform-software.yang
- public/release/models/platform/openconfig-platform-transceiver.yang
- public/release/models/platform/openconfig-platform.yang
Expand Down
Loading

0 comments on commit 565fe6d

Please sign in to comment.