Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions ondatra/binding/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

package(
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)

go_library(
name = "pinsbind",
testonly = True,
srcs = ["pins_binding.go"],
importpath = "github.com/sonic-mgmt/sdn_tests/pins_ondatra/infrastructure/binding/pinsbind",
deps = [
":bindingbackend",
"@com_github_golang_glog//:glog",
"@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto",
"@com_github_openconfig_gnoi//file:file_go_proto",
"@com_github_openconfig_gnoi//healthz:healthz_go_proto",
"@com_github_openconfig_gnoi//os:os_go_proto",
"@com_github_openconfig_gnoi//system:system_go_proto",
"@com_github_openconfig_ondatra//binding",
"@com_github_openconfig_ondatra//binding/grpcutil",
"@com_github_openconfig_ondatra//proto:go_default_library",
"@com_github_openconfig_ondatra//proxy",
"@com_github_openconfig_ondatra//proxy/proto/reservation:go_default_library",
"@com_github_p4lang_golang_p4runtime//go/p4/v1:p4",
"@org_golang_google_grpc//:go_default_library",
],
)

go_library(
name = "bindingbackend",
testonly = True,
srcs = ["binding_backend.go"],
importpath = "github.com/sonic-mgmt/sdn_tests/pins_ondatra/infrastructure/binding/bindingbackend",
deps = [
"@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto",
"@com_github_openconfig_ondatra//binding",
"@com_github_openconfig_ondatra//proto:go_default_library",
"@org_golang_google_grpc//:go_default_library",
],
)
74 changes: 74 additions & 0 deletions ondatra/binding/binding_backend.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Package bindingbackend describes the interface to interact with the reservations and devices.
package bindingbackend

import (
"context"
"time"

gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/ondatra/binding"
opb "github.com/openconfig/ondatra/proto"
"google.golang.org/grpc"
)

// ReservedTestbed contains information about reserved testbed.
type ReservedTestbed struct {
id string // Reservation id
name string
}

// Device contains data of reserved switch.
type Device struct {
Name string
ID string
PortMap map[string]*binding.Port
}

// GRPCService contains addresses for services using grpc protocol.
type GRPCService struct {
GRPCAddr string
P4RTAddr string
GNMIAddr string
GNOIAddr string
GNSIAddr string
}

// HTTPService contains addresses for services using HTTP protocol.
type HTTPService struct {
HTTPAddr string
}

// DUTDevice contains device and service addresses for DUT device.
type DUTDevice struct {
*Device
GRPC GRPCService
}

// ATEDevice contains device and service addresses for ATE device.
type ATEDevice struct {
*Device
HTTP HTTPService
}

// ReservedTopology represents the reserved DUT and ATE devices.
type ReservedTopology struct {
ID string
DUTs []*DUTDevice
ATEs []*ATEDevice
}

// Backend exposes functions to interact with reservations and reserved devices.
type Backend interface {
// ReserveTopology returns topology of reserved DUT and ATE devices.
ReserveTopology(ctx context.Context, tb *opb.Testbed, runtime, waittime time.Duration, partial map[string]string) (*ReservedTopology, error)
// Release releases the reserved devices, called during teardown.
Release(ctx context.Context) error
// DialGRPC connects to grpc service and returns the opened grpc client for use.
DialGRPC(ctx context.Context, addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
DialConsole(ctx context.Context, dut *binding.AbstractDUT) (binding.ConsoleClient, error)
// GNMIClient wraps the grpc connection under gnmi client.
GNMIClient(ctx context.Context, dut *binding.AbstractDUT, conn *grpc.ClientConn) (gpb.GNMIClient, error)

// Close closes backend's internal objects.
Close() error
}
Loading