From 43e36f0e6ba31fbaa360c192244264d30999d135 Mon Sep 17 00:00:00 2001 From: rhalstea Date: Wed, 20 Sep 2023 14:03:22 -0700 Subject: [PATCH 1/2] [sdn-tests] Adding ondatra gpins binding. --- ondatra/binding/BUILD.bazel | 44 ++ ondatra/binding/binding_backend.go | 75 ++++ ondatra/binding/pins_binding.go | 420 ++++++++++++++++++ ondatra/binding_deps.bzl | 269 +++++++++++ .../bazel/patches/ondatra/ghodss_yaml.patch | 12 + .../bazel/patches/ondatra/gnmi.patch | 392 ++++++++++++++++ .../bazel/patches/ondatra/gnoi.patch | 32 ++ .../bazel/patches/ondatra/gnsi.patch | 13 + .../bazel/patches/ondatra/gribi.patch | 48 ++ .../bazel/patches/ondatra/ondatra.patch | 77 ++++ .../bazel/patches/ondatra/p4lang.patch | 25 ++ .../bazel/patches/ondatra/snappi.patch | 54 +++ .../bazel/patches/ondatra/ygnmi.patch | 13 + .../bazel/patches/ondatra/ygot.patch | 85 ++++ 14 files changed, 1559 insertions(+) create mode 100644 ondatra/binding/BUILD.bazel create mode 100644 ondatra/binding/binding_backend.go create mode 100644 ondatra/binding/pins_binding.go create mode 100644 ondatra/binding_deps.bzl create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/ghodss_yaml.patch create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/gnmi.patch create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/gnoi.patch create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/gnsi.patch create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/gribi.patch create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/ondatra.patch create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/p4lang.patch create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/snappi.patch create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/ygnmi.patch create mode 100644 sdn_tests/pins_ondatra/bazel/patches/ondatra/ygot.patch diff --git a/ondatra/binding/BUILD.bazel b/ondatra/binding/BUILD.bazel new file mode 100644 index 00000000000..6c4e9fe64c5 --- /dev/null +++ b/ondatra/binding/BUILD.bazel @@ -0,0 +1,44 @@ +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"], + data = [ + ], + 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", + ], +) diff --git a/ondatra/binding/binding_backend.go b/ondatra/binding/binding_backend.go new file mode 100644 index 00000000000..034fb8b5b1a --- /dev/null +++ b/ondatra/binding/binding_backend.go @@ -0,0 +1,75 @@ +// 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) + // GNSIClient wraps the grpc connection under gnsi client. + GNSIClient(ctx context.Context, dut *binding.AbstractDUT, conn *grpc.ClientConn) (binding.GNSIClients, error) + // Close closes backend's internal objects. + Close() error +} diff --git a/ondatra/binding/pins_binding.go b/ondatra/binding/pins_binding.go new file mode 100644 index 00000000000..47021f23e57 --- /dev/null +++ b/ondatra/binding/pins_binding.go @@ -0,0 +1,420 @@ +// Package pinsbind contains all the code related to the PINS project's binding to Ondatra. +package pinsbind + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "time" + + log "github.com/golang/glog" + + "github.com/openconfig/ondatra/binding" + "github.com/openconfig/ondatra/binding/grpcutil" + "google.golang.org/grpc" + + opb "github.com/openconfig/ondatra/proto" + "github.com/openconfig/ondatra/proxy" + "github.com/sonic-mgmt/sdn_tests/pins_ondatra/infrastructure/binding/bindingbackend" + + gpb "github.com/openconfig/gnmi/proto/gnmi" + filepb "github.com/openconfig/gnoi/file" + healthzpb "github.com/openconfig/gnoi/healthz" + ospb "github.com/openconfig/gnoi/os" + syspb "github.com/openconfig/gnoi/system" + + rpb "github.com/openconfig/ondatra/proxy/proto/reservation" + p4pb "github.com/p4lang/p4runtime/go/p4/v1" +) + +var ( + // validate that the Binding fulfills both binding.Binding and proxy.Dialer + // interfaces. + _ binding.Binding = &Binding{} + _ proxy.Dialer = &Binding{} +) + +var backend bindingbackend.Backend + +// Binding is a binding for PINS switches. +type Binding struct { + resv *binding.Reservation + httpDialer func(target string) (proxy.HTTPDoCloser, error) +} + +// Option are configurable inputs to the binding. +type Option func(b *Binding) + +// WithHTTPDialer provides a custom http dialer that is capable of dialing specific targets. +func WithHTTPDialer(f func(target string) (proxy.HTTPDoCloser, error)) Option { + return func(b *Binding) { + b.httpDialer = f + } +} + +// New returns a new instance of a PINS Binding. +func New() (binding.Binding, error) { + return NewWithOpts() +} + +type httpClient struct { + *http.Client +} + +func (h *httpClient) Close() error { + return nil +} + +func defaultHTTPDialer(target string) (proxy.HTTPDoCloser, error) { + return &httpClient{http.DefaultClient}, nil +} + +// NewWithOpts returns a new instance of a PINS Binding. +func NewWithOpts(opts ...Option) (*Binding, error) { + b := &Binding{ + httpDialer: defaultHTTPDialer, + } + + for _, opt := range opts { + opt(b) + } + + return b, nil +} + +// SetBackend sets the backend for binding. +func SetBackend(b bindingbackend.Backend) { + backend = b +} + +// CloseBackend closes the backend. +func CloseBackend() { + if backend != nil { + backend.Close() + } + backend = nil +} + +// Reserve returns a testbed meeting requirements of testbed proto. +func (b *Binding) Reserve(ctx context.Context, tb *opb.Testbed, runtime, waittime time.Duration, partial map[string]string) (*binding.Reservation, error) { + if backend == nil { + return nil, fmt.Errorf("backend is not set") + } + + reservedtopology, err := backend.ReserveTopology(ctx, tb, runtime, waittime, partial) + if err != nil { + return nil, fmt.Errorf("failed to reserve topology: %v", err) + } + + resv := &binding.Reservation{ID: reservedtopology.ID, DUTs: map[string]binding.DUT{}} + for _, dut := range reservedtopology.DUTs { + resv.DUTs[dut.ID] = &pinsDUT{ + AbstractDUT: &binding.AbstractDUT{&binding.Dims{ + Name: dut.Name, + Ports: dut.PortMap, + }}, + bind: b, + grpc: dut.GRPC, + } + } + + if len(reservedtopology.ATEs) != 0 { + resv.ATEs = map[string]binding.ATE{} + } + for _, ate := range reservedtopology.ATEs { + resv.ATEs[ate.ID] = &pinsATE{ + AbstractATE: &binding.AbstractATE{&binding.Dims{ + Name: ate.Name, + Ports: ate.PortMap, + }}, + http: ate.HTTP, + } + } + + b.resv = resv + return resv, nil +} + +// Release returns the testbed to a pool of resources. +func (b *Binding) Release(ctx context.Context) error { + return backend.Release(ctx) +} + +type pinsDUT struct { + *binding.AbstractDUT + bind *Binding + grpc bindingbackend.GRPCService +} + +type pinsATE struct { + *binding.AbstractATE + bind *Binding + http bindingbackend.HTTPService +} + +// DialGRPC will return a gRPC client conn for the target. This method should +// be used by any new service definitions which create underlying gRPC +// connections. +func (b *Binding) DialGRPC(ctx context.Context, addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error) { + if backend == nil { + return nil, fmt.Errorf("backend is not set") + } + + return backend.DialGRPC(ctx, addr, opts...) +} + +// HTTPClient returns a http client that is capable of dialing the provided target. +func (b *Binding) HTTPClient(target string) (proxy.HTTPDoCloser, error) { + return b.httpDialer(target) +} + +// DialGNMI connects directly to the switch's proxy. +func (d *pinsDUT) DialGNMI(ctx context.Context, opts ...grpc.DialOption) (gpb.GNMIClient, error) { + if d.grpc.GNMIAddr == "" { + return nil, fmt.Errorf("service gnmi not registered on DUT %q", d.Name()) + } + + const defaultTimeout = time.Minute + opts = append(opts, grpcutil.WithUnaryDefaultTimeout(defaultTimeout), grpcutil.WithStreamDefaultTimeout(defaultTimeout)) + conn, err := d.bind.DialGRPC(ctx, d.grpc.GNMIAddr, opts...) + if err != nil { + return nil, err + } + + cli, err := backend.GNMIClient(ctx, d.AbstractDUT, conn) + if err != nil { + return nil, err + } + return &clientWrap{GNMIClient: cli}, nil +} + +type clientWrap struct { + gpb.GNMIClient +} + +// wrapValueInUpdate wraps the typed value in the provided update into a +// serialized JSON node., e.g. +// - 123 -> {"foo": 123} +// - [{"str": "one"}] -> {"foo": [{"str": "one"}]} +// - {"str": "test-string"} -> {"foo": {"str": "test-string"}} +func wrapValueInUpdate(up *gpb.Update) error { + elems := up.GetPath().GetElem() + if len(elems) == 0 { + // root path case + return nil + } + name := elems[len(elems)-1].GetName() + var i any + if err := json.Unmarshal(up.GetVal().GetJsonIetfVal(), &i); err != nil { + return fmt.Errorf("unable to unmarshal config: %v", err) + } + + // For list paths such as /interfaces/interface[name=], JSON IETF value + // needs to be an array instead of an object. Ondatra returns value for such paths + // as an object, which need to be translated into a JSON array. E.g. + // - {"str": "test-string"} -> [{"str": "test-string"}] + if len(elems[len(elems)-1].GetKey()) > 0 { + // The path is a list node. Perform translation to JSON array. + var arr []any + arr = append(arr, i) + arrVal, err := json.Marshal(arr) + if err != nil { + return fmt.Errorf("unable to marshal value %v as a JSON array: %v", arr, err) + } + if err := json.Unmarshal(arrVal, &i); err != nil { + return fmt.Errorf("unable to unmarshal JSON array config: %v", err) + } + } + js, err := json.MarshalIndent(map[string]any{name: i}, "", " ") + if err != nil { + return fmt.Errorf("unable to marshal config with wrapping container: %v", err) + } + up.GetVal().Value = &gpb.TypedValue_JsonIetfVal{js} + return nil +} + +func (c *clientWrap) Set(ctx context.Context, in *gpb.SetRequest, opts ...grpc.CallOption) (*gpb.SetResponse, error) { + for _, up := range in.GetReplace() { + if err := wrapValueInUpdate(up); err != nil { + return nil, err + } + } + for _, up := range in.GetUpdate() { + if err := wrapValueInUpdate(up); err != nil { + return nil, err + } + } + + return c.GNMIClient.Set(ctx, in, opts...) +} + +func (c *clientWrap) Get(ctx context.Context, in *gpb.GetRequest, opts ...grpc.CallOption) (*gpb.GetResponse, error) { + return c.GNMIClient.Get(ctx, in, opts...) +} + +func (c *clientWrap) Subscribe(ctx context.Context, opts ...grpc.CallOption) (gpb.GNMI_SubscribeClient, error) { + return c.GNMIClient.Subscribe(ctx, opts...) +} + +func (c *clientWrap) Capabilities(ctx context.Context, in *gpb.CapabilityRequest, opts ...grpc.CallOption) (*gpb.CapabilityResponse, error) { + return c.GNMIClient.Capabilities(ctx, in, opts...) +} + +// DialGNOI connects directly to the switch's proxy. +func (d *pinsDUT) DialGNOI(ctx context.Context, opts ...grpc.DialOption) (binding.GNOIClients, error) { + if d.grpc.GNOIAddr == "" { + return nil, fmt.Errorf("service gnoi not registered on DUT %q", d.Name()) + } + + opts = append(opts, grpcutil.WithUnaryDefaultTimeout(30*time.Second), grpcutil.WithStreamDefaultTimeout(2*time.Minute)) + conn, err := d.bind.DialGRPC(ctx, d.grpc.GNOIAddr, opts...) + if err != nil { + return nil, err + } + + log.Infof("GNOI dial success Address:%s, Switch:%s", conn.Target(), d.Name()) + return &GNOIClients{ + os: ospb.NewOSClient(conn), + system: syspb.NewSystemClient(conn), + healthz: healthzpb.NewHealthzClient(conn), + file: filepb.NewFileClient(conn), + }, nil +} + +// GNOIClients consist of the GNOI clients supported by GPINs. +type GNOIClients struct { + *binding.AbstractGNOIClients + os ospb.OSClient + system syspb.SystemClient + healthz healthzpb.HealthzClient + file filepb.FileClient +} + +// OS returns OS gNOI client. +func (g *GNOIClients) OS() ospb.OSClient { + return g.os +} + +// System returns system gNOI client. +func (g *GNOIClients) System() syspb.SystemClient { + return g.system +} + +// Healthz returns healthz gNOI client. +func (g *GNOIClients) Healthz() healthzpb.HealthzClient { + return g.healthz +} + +// File returns file gNOI client. +func (g *GNOIClients) File() filepb.FileClient { + return g.file +} + +// DialP4RT connects directly to the switch's proxy. +func (d *pinsDUT) DialP4RT(ctx context.Context, opts ...grpc.DialOption) (p4pb.P4RuntimeClient, error) { + opts = append(opts, grpcutil.WithUnaryDefaultTimeout(30*time.Second), grpcutil.WithStreamDefaultTimeout(2*time.Minute)) + conn, err := d.bind.DialGRPC(ctx, d.grpc.P4RTAddr, opts...) + if err != nil { + return nil, err + } + + log.Infof("P4RT dial success Address:%s, Switch:%s", conn.Target(), d.Name()) + return p4pb.NewP4RuntimeClient(conn), nil +} + +// DialConsole returns a StreamClient for the DUT. +func (d *pinsDUT) DialConsole(ctx context.Context) (binding.ConsoleClient, error) { + return backend.DialConsole(ctx, d.AbstractDUT) +} + +// FetchReservation unimplemented for experimental purposes. +func (*Binding) FetchReservation(context.Context, string) (*binding.Reservation, error) { + return nil, nil +} + +// Resolve will return a concrete reservation with services defined. +func (b *Binding) Resolve() (*rpb.Reservation, error) { + devices := map[string]*rpb.ResolvedDevice{} + for k, d := range b.resv.DUTs { + rD, err := b.resolveDUT(k, d.(*pinsDUT)) + if err != nil { + return nil, err + } + devices[k] = rD + } + ates := map[string]*rpb.ResolvedDevice{} + for k, a := range b.resv.ATEs { + rD, err := b.resolveATE(k, a.(*pinsATE)) + if err != nil { + return nil, err + } + ates[k] = rD + } + return &rpb.Reservation{ + Id: b.resv.ID, + Ates: ates, + Devices: devices, + }, nil +} + +func resolvePort(k string, p *binding.Port) *rpb.ResolvedPort { + return &rpb.ResolvedPort{ + Id: k, + Speed: p.Speed, + Name: p.Name, + } +} + +func (b *Binding) resolveDUT(key string, d *pinsDUT) (*rpb.ResolvedDevice, error) { + ports := map[string]*rpb.ResolvedPort{} + for k, p := range d.Ports() { + ports[k] = resolvePort(k, p) + } + services := map[string]*rpb.Service{ + "grpc": &rpb.Service{ + Id: "grpc", + Endpoint: &rpb.Service_ProxiedGrpc{ + ProxiedGrpc: &rpb.ProxiedGRPCEndpoint{ + Address: d.grpc.GRPCAddr, + Proxy: nil, + }, + }, + }, + } + return &rpb.ResolvedDevice{ + Id: key, + HardwareModel: d.HardwareModel(), + Vendor: d.Vendor(), + SoftwareVersion: d.SoftwareVersion(), + Name: d.Name(), + Ports: ports, + Services: services, + }, nil +} + +func (b *Binding) resolveATE(key string, d *pinsATE) (*rpb.ResolvedDevice, error) { + ports := map[string]*rpb.ResolvedPort{} + for k, p := range d.Ports() { + ports[k] = resolvePort(k, p) + } + services := map[string]*rpb.Service{ + "http": &rpb.Service{ + Id: "http", + Endpoint: &rpb.Service_HttpOverGrpc{ + HttpOverGrpc: &rpb.HTTPOverGRPCEndpoint{ + Address: d.http.HTTPAddr, + }, + }, + }, + } + return &rpb.ResolvedDevice{ + Id: key, + HardwareModel: d.HardwareModel(), + Vendor: d.Vendor(), + SoftwareVersion: d.SoftwareVersion(), + Name: d.Name(), + Ports: ports, + Services: services, + }, nil +} diff --git a/ondatra/binding_deps.bzl b/ondatra/binding_deps.bzl new file mode 100644 index 00000000000..c55d0a7834c --- /dev/null +++ b/ondatra/binding_deps.bzl @@ -0,0 +1,269 @@ +"""Third party dependencies. + +Please read carefully before adding new dependencies: +- Any dependency can break all of xxx. Please be mindful of that before + adding new dependencies. Try to stick to stable versions of widely used libraries. + Do not depend on private repositories and forks. +- Fix dependencies to a specific version or commit, so upstream changes cannot break + xxx. Prefer releases over arbitrary commits when both are available. +""" + +load("@bazel_gazelle//:deps.bzl", "go_repository") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +def binding_deps(): + """Sets up 3rd party workspaces needed to build ondatra infrastructure.""" + repo_map = { + "@com_github_p4lang_p4runtime": "@com_github_p4lang_golang_p4runtime", + } + + build_directives = [ + "gazelle:resolve go github.com/openconfig/gnmi/proto/gnmi @com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/bgp @com_github_openconfig_gnoi//bgp:bgp_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/cert @com_github_openconfig_gnoi//cert:cert_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/diag @com_github_openconfig_gnoi//diag:diag_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/factory_reset @com_github_openconfig_gnoi//factory_reset:factory_reset_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/file @com_github_openconfig_gnoi//file:file_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/healthz @com_github_openconfig_gnoi//healthz:healthz_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/layer2 @com_github_openconfig_gnoi//layer2:layer2_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/mpls @com_github_openconfig_gnoi//mpls:mpls_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/os @com_github_openconfig_gnoi//os:os_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/otdr @com_github_openconfig_gnoi//otdr:otdr_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/system @com_github_openconfig_gnoi//system:system_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/wavelength_router @com_github_openconfig_gnoi//wavelength_router:wavelength_router_go_proto", + "gazelle:resolve go github.com/openconfig/gnoi/packet_link_qualification @com_github_openconfig_gnoi//packet_link_qualification:linkqual_go_proto", + "gazelle:resolve go github.com/openconfig/gnsi/acctz @com_github_openconfig_gnsi//acctz:acctz_go_proto", + "gazelle:resolve go github.com/openconfig/gnsi/pathz @com_github_openconfig_gnsi//pathz:pathz_go_proto", + "gazelle:resolve go github.com/openconfig/gnsi/credentialz @com_github_openconfig_gnsi//credentialz:credentialz", + "gazelle:resolve go github.com/openconfig/gribi/v1/proto/service @com_github_openconfig_gribi//v1/proto/service:go_default_library", + "gazelle:resolve go github.com/p4lang/p4runtime/go/p4/v1 @com_github_p4lang_p4runtime//go/p4/v1:go_default_library", + "gazelle:resolve go github.com/openconfig/gnsi/authz @com_github_openconfig_gnsi//authz", + "gazelle:resolve go github.com/openconfig/gnsi/certz @com_github_openconfig_gnsi//certz", + "gazelle:resolve go github.com/open-traffic-generator/snappi/gosnappi @com_github_open_traffic_generator_snappi//gosnappi:go_default_library", + "gazelle:resolve go github.com/openconfig/gnoi/types @com_github_openconfig_gnoi//types:types_go_proto", + ] + + go_repository( + name = "com_github_ghodss_yaml", + importpath = "github.com/ghodss/yaml", + repo_mapping = repo_map, + sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=", + version = "v1.0.0", + patches = ["//:bazel/patches/ondatra/ghodss_yaml.patch"], + patch_args = ["-p1"], + ) + + go_repository( + name = "com_github_golang_glog", + importpath = "github.com/golang/glog", + repo_mapping = repo_map, + sum = "h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=", + version = "v1.0.0", + ) + + go_repository( + name = "com_github_golang_groupcache", + importpath = "github.com/golang/groupcache", + repo_mapping = repo_map, + sum = "h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=", + version = "v0.0.0-20210331224755-41bb18bfe9da", + ) + + go_repository( + name = "com_github_golang_protobuf", + importpath = "github.com/golang/protobuf", + repo_mapping = repo_map, + sum = "h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=", + version = "v1.5.3", + ) + + go_repository( + name = "com_github_google_go_cmp", + importpath = "github.com/google/go-cmp", + repo_mapping = repo_map, + sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=", + version = "v0.5.9", + ) + + go_repository( + name = "com_github_kylelemons_godebug", + importpath = "github.com/kylelemons/godebug", + repo_mapping = repo_map, + sum = "h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=", + version = "v1.1.0", + ) + + go_repository( + name = "com_github_masterminds_semver_v3", + importpath = "github.com/Masterminds/semver/v3", + repo_mapping = repo_map, + sum = "h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=", + version = "v3.2.1", + ) + + go_repository( + name = "com_github_open_traffic_generator_snappi", + importpath = "github.com/open-traffic-generator/snappi", + repo_mapping = repo_map, + commit = "d272ee37b49b870c08f0c8e6a7491341ae2a5fb2", # v0.11.16 + patches = ["//:bazel/patches/ondatra/snappi.patch"], + patch_args = ["-p1"], + ) + + go_repository( + name = "com_github_openconfig_gnmi", + build_file_proto_mode = "disable", + importpath = "github.com/openconfig/gnmi", + repo_mapping = repo_map, + commit = "5473f2ef722ee45c3f26eee3f4a44a7d827e3575", #v0.10.0 + patches = ["//:bazel/patches/ondatra/gnmi.patch"], + patch_args = ["-p1"], + ) + + go_repository( + name = "com_github_openconfig_gnoi", + build_file_proto_mode = "disable", + importpath = "github.com/openconfig/gnoi", + repo_mapping = repo_map, + sum = "h1:7Odq6UyieHuXW3PYfDBj/dUWgFrL9KVMm0iooQoFLdw=", + version = "v0.1.0", + patches = ["//:bazel/patches/ondatra/gnoi.patch"], + patch_args = ["-p1", "--verbose"], + ) + + go_repository( + name = "com_github_openconfig_gnsi", + build_file_proto_mode = "disable", + importpath = "github.com/openconfig/gnsi", + repo_mapping = repo_map, + commit = "3fe65e6609a435adaa8dabbce236ad04b243c5c8", + patches = ["//:bazel/patches/ondatra/gnsi.patch"], + patch_args = ["-p1"], + ) + + go_repository( + name = "com_github_openconfig_gocloser", + importpath = "github.com/openconfig/gocloser", + repo_mapping = repo_map, + sum = "h1:NSYuxdlOWLldNpid1dThR6Dci96juXioUguMho6aliI=", + version = "v0.0.0-20220310182203-c6c950ed3b0b", + ) + + go_repository( + name = "com_github_openconfig_goyang", + importpath = "github.com/openconfig/goyang", + repo_mapping = repo_map, + sum = "h1:mChUZvp1kCWq6Q00wVCtOToddFzEsGlMGG+V+wNXva8=", + version = "v1.2.0", + ) + + go_repository( + name = "com_github_openconfig_gribi", + importpath = "github.com/openconfig/gribi", + repo_mapping = repo_map, + commit = "0f369fbcc905def3a2e744afb77b5ea4a336b0a2", # v1.0.0 + patches = ["//:bazel/patches/ondatra/gribi.patch"], + patch_args = ["-p1"], + ) + + go_repository( + name = "com_github_openconfig_ygot", + importpath = "github.com/openconfig/ygot", + repo_mapping = repo_map, + build_file_proto_mode = "disable", + commit = "ec273a725045c821914771593e72390dfa4a389c", + patches = ["//:bazel/patches/ondatra/ygot.patch"], + patch_args = ["-p1"], + ) + + go_repository( + name = "com_github_p4lang_golang_p4runtime", + importpath = "github.com/p4lang/p4runtime", + repo_mapping = repo_map, + build_file_proto_mode = "disable", + patches = ["//:bazel/patches/ondatra/p4lang.patch"], + patch_args = ["-p1"], + commit = "d76a3640a223f47a43dc34e5565b72e43796ba57", + ) + + go_repository( + name = "in_gopkg_yaml_v2", + importpath = "gopkg.in/yaml.v2", + repo_mapping = repo_map, + sum = "h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=", + version = "v2.4.0", + ) + + go_repository( + name = "io_opencensus_go", + importpath = "go.opencensus.io", + repo_mapping = repo_map, + sum = "h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=", + version = "v0.24.0", + ) + + go_repository( + name = "org_golang_google_grpc", + importpath = "google.golang.org/grpc", + repo_mapping = repo_map, + sum = "h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag=", + version = "v1.54.0", + ) + + go_repository( + name = "org_golang_google_grpc_cmd_protoc_gen_go_grpc", + importpath = "google.golang.org/grpc/cmd/protoc-gen-go-grpc", + repo_mapping = repo_map, + sum = "h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE=", + version = "v1.1.0", + ) + + go_repository( + name = "org_golang_google_protobuf", + importpath = "google.golang.org/protobuf", + repo_mapping = repo_map, + sum = "h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=", + version = "v1.30.0", + ) + + go_repository( + name = "org_golang_x_net", + importpath = "golang.org/x/net", + repo_mapping = repo_map, + sum = "h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=", + version = "v0.9.0", + ) + + go_repository( + name = "org_golang_x_sys", + importpath = "golang.org/x/sys", + repo_mapping = repo_map, + sum = "h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=", + version = "v0.7.0", + ) + + go_repository( + name = "org_golang_x_text", + importpath = "golang.org/x/text", + repo_mapping = repo_map, + sum = "h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=", + version = "v0.9.0", + ) + + go_repository( + name = "com_github_openconfig_ondatra", + importpath = "github.com/openconfig/ondatra", + repo_mapping = repo_map, + build_file_proto_mode = "disable", + build_directives = build_directives, + patches = ["//:bazel/patches/ondatra/ondatra.patch"], + patch_args = ["-p1", "--verbose"], + commit = "699d044932bdfbd1c28750221cb475a44a5bc8fe", #main as of 09/07/2023 + ) + + git_repository( + name = "com_google_googleapis", + remote = "https://github.com/googleapis/googleapis", + commit = "9fe00a1330817b5ce00919bf2861cd8a9cea1a00", + shallow_since = "1642638275 -0800", + ) diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/ghodss_yaml.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ghodss_yaml.patch new file mode 100644 index 00000000000..011d484f3e8 --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ghodss_yaml.patch @@ -0,0 +1,12 @@ +diff --git a/BUILD.bazel b/BUILD.bazel +index 4f4ecec..ee196e8 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -6,6 +6,7 @@ go_library( + "fields.go", + "yaml.go", + ], ++ deps = ["@in_gopkg_yaml_v2//:yaml_v2"], + importpath = "github.com/ghodss/yaml", + visibility = ["//visibility:public"], + ) diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/gnmi.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/gnmi.patch new file mode 100644 index 00000000000..3e62f2c04f5 --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/gnmi.patch @@ -0,0 +1,392 @@ +diff --git a/BUILD.bazel b/BUILD.bazel +index ca5484e..238dde9 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -13,6 +13,7 @@ + # limitations under the License. + # + # Supporting infrastructure for implementing and testing PINS. ++load("@bazel_gazelle//:def.bzl", "gazelle") + + package( + default_visibility = ["//visibility:public"], +@@ -20,3 +21,6 @@ package( + ) + + exports_files(["LICENSE"]) ++ ++# gazelle:prefix github.com/openconfig/gnmi ++gazelle(name = "gazelle") +diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel +deleted file mode 100644 +index 2f385f7..0000000 +--- a/WORKSPACE.bazel ++++ /dev/null +@@ -1,45 +0,0 @@ +-# Copyright 2021 Google LLC +-# +-# Licensed under the Apache License, Version 2.0 (the "License"); +-# you may not use this file except in compliance with the License. +-# You may obtain a copy of the License at +-# +-# https://www.apache.org/licenses/LICENSE-2.0 +-# +-# Unless required by applicable law or agreed to in writing, software +-# distributed under the License is distributed on an "AS IS" BASIS, +-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-# See the License for the specific language governing permissions and +-# limitations under the License. +- +-workspace(name = "gnmi") +- +-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +- +-http_archive( +- name = "io_bazel_rules_go", +- sha256 = "d6b2513456fe2229811da7eb67a444be7785f5323c6708b38d851d2b51e54d83", +- urls = [ +- "https://github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip", +- "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip", +- ], +-) +- +-load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +- +-go_rules_dependencies() +- +-go_register_toolchains(version = "1.17") +- +-# -- Load Dependencies --------------------------------------------------------- +-load("gnmi_deps.bzl", "gnmi_deps") +- +-gnmi_deps() +- +-load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") +- +-grpc_deps() +- +-load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") +- +-grpc_extra_deps() +diff --git a/proto/gnmi/BUILD.bazel b/proto/gnmi/BUILD.bazel +index f471488..f6bd3bd 100644 +--- a/proto/gnmi/BUILD.bazel ++++ b/proto/gnmi/BUILD.bazel +@@ -16,6 +16,9 @@ + # + + load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library") ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") ++load("@rules_proto//proto:defs.bzl", "proto_library") + + package( + default_visibility = ["//visibility:public"], +@@ -45,3 +48,13 @@ cc_grpc_library( + grpc_only = True, + deps = [":gnmi_cc_proto"], + ) ++ ++go_proto_library( ++ name = "gnmi_go_proto", ++ compilers = ["@io_bazel_rules_go//proto:go_grpc"], ++ importpath = "github.com/openconfig/gnmi/proto/gnmi", ++ proto = ":gnmi_proto", ++ deps = [ ++ "//proto/gnmi_ext:gnmi_ext_go_proto", ++ ], ++) +diff --git a/proto/gnmi_ext/BUILD.bazel b/proto/gnmi_ext/BUILD.bazel +index 2e0e9b4..5dcf6fb 100644 +--- a/proto/gnmi_ext/BUILD.bazel ++++ b/proto/gnmi_ext/BUILD.bazel +@@ -14,6 +14,7 @@ + # + # Supporting infrastructure for implementing and testing PINS. + # ++load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") + package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +@@ -29,3 +30,10 @@ cc_proto_library( + name = "gnmi_ext_cc_proto", + deps = [":gnmi_ext_proto"], + ) ++ ++go_proto_library( ++ name = "gnmi_ext_go_proto", ++ compilers = ["@io_bazel_rules_go//proto:go_grpc"], ++ importpath = "github.com/openconfig/gnmi/proto/gnmi_ext", ++ proto = ":gnmi_ext_proto", ++) +\ No newline at end of file +diff --git a/errlist/BUILD.bazel b/errlist/BUILD.bazel +new file mode 100644 +index 0000000..2b112a8 +--- /dev/null ++++ b/errlist/BUILD.bazel +@@ -0,0 +1,16 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "errlist", ++ srcs = [ ++ "errlist.go", ++ ], ++ importpath = "github.com/openconfig/gnmi/errlist", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":errlist", ++ visibility = ["//visibility:public"], ++) + +diff --git a/value/BUILD.bazel b/value/BUILD.bazel +new file mode 100644 +index 0000000..1b5e851 +--- /dev/null ++++ b/value/BUILD.bazel +@@ -0,0 +1,19 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "value", ++ srcs = [ ++ "value.go", ++ ], ++ importpath = "github.com/openconfig/gnmi/value", ++ visibility = ["//visibility:public"], ++ deps = [ ++ "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", ++ ] ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":value", ++ visibility = ["//visibility:public"], ++) + +diff --git a/cache/BUILD.bazel b/cache/BUILD.bazel +new file mode 100644 +index 0000000..07971dd +--- /dev/null ++++ b/cache/BUILD.bazel +@@ -0,0 +1,33 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "cache", ++ srcs = [ ++ "cache.go", ++ ], ++ deps = [ ++ "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", ++ "@com_github_openconfig_gnmi//path", ++ "@com_github_openconfig_gnmi//ctree", ++ "@com_github_openconfig_gnmi//errlist", ++ "@com_github_openconfig_gnmi//value", ++ "@com_github_openconfig_gnmi//latency", ++ "@com_github_openconfig_gnmi//metadata", ++ "@org_golang_google_grpc//:go_default_library", ++ "@org_golang_google_grpc//codes:go_default_library", ++ "@org_golang_google_grpc//peer:go_default_library", ++ "@org_golang_google_grpc//status:go_default_library", ++ "@org_golang_x_net//context", ++ "@com_github_golang_glog//:glog", ++ "@org_golang_google_protobuf//encoding/prototext", ++ "@org_golang_google_protobuf//proto", ++ ], ++ importpath = "github.com/openconfig/gnmi/cache", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":cache", ++ visibility = ["//visibility:public"], ++) + +diff --git a/subscribe/BUILD.bazel b/subscribe/BUILD.bazel +new file mode 100644 +index 0000000..05b9be3 +--- /dev/null ++++ b/subscribe/BUILD.bazel +@@ -0,0 +1,35 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "subscribe", ++ srcs = [ ++ "subscribe.go", ++ "stats.go" ++ ], ++ importpath = "github.com/openconfig/gnmi/subscribe", ++ deps = [ ++ "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", ++ "@com_github_openconfig_gnmi//path", ++ "@com_github_openconfig_gnmi//ctree", ++ "@com_github_openconfig_gnmi//errlist", ++ "@com_github_openconfig_gnmi//value", ++ "@com_github_openconfig_gnmi//latency", ++ "@com_github_openconfig_gnmi//cache", ++ "@com_github_openconfig_gnmi//coalesce", ++ "@com_github_openconfig_gnmi//match", ++ "@org_golang_google_grpc//:go_default_library", ++ "@org_golang_google_grpc//codes:go_default_library", ++ "@org_golang_google_grpc//peer:go_default_library", ++ "@org_golang_google_grpc//status:go_default_library", ++ "@org_golang_x_net//context", ++ "@org_golang_google_protobuf//proto", ++ "@com_github_golang_glog//:glog", ++ ], ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":subscribe", ++ visibility = ["//visibility:public"], ++) + +diff --git a/ctree/BUILD.bazel b/ctree/BUILD.bazel +new file mode 100644 +index 0000000..510cc34 +--- /dev/null ++++ b/ctree/BUILD.bazel +@@ -0,0 +1,16 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "ctree", ++ srcs = [ ++ "tree.go", ++ ], ++ importpath = "github.com/openconfig/gnmi/ctree", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":ctree", ++ visibility = ["//visibility:public"], ++) +diff --git a/latency/BUILD.bazel b/latency/BUILD.bazel +new file mode 100644 +index 0000000..d110090 +--- /dev/null ++++ b/latency/BUILD.bazel +@@ -0,0 +1,16 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "latency", ++ srcs = [ ++ "latency.go", ++ ], ++ importpath = "github.com/openconfig/gnmi/latency", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":latency", ++ visibility = ["//visibility:public"], ++) +diff --git a/metadata/BUILD.bazel b/metadata/BUILD.bazel +new file mode 100644 +index 0000000..aa715a9 +--- /dev/null ++++ b/metadata/BUILD.bazel +@@ -0,0 +1,19 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "metadata", ++ srcs = [ ++ "metadata.go", ++ ], ++ deps = [ ++ "@com_github_openconfig_gnmi//latency", ++ ], ++ importpath = "github.com/openconfig/gnmi/metadata", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":metadata", ++ visibility = ["//visibility:public"], ++) +diff --git a/path/BUILD.bazel b/path/BUILD.bazel +new file mode 100644 +index 0000000..65a7efd +--- /dev/null ++++ b/path/BUILD.bazel +@@ -0,0 +1,19 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "path", ++ srcs = [ ++ "path.go", ++ ], ++ deps = [ ++ "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", ++ ], ++ importpath = "github.com/openconfig/gnmi/path", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":path", ++ visibility = ["//visibility:public"], ++) + +diff --git a/coalesce/BUILD.bazel b/coalesce/BUILD.bazel +new file mode 100644 +index 0000000..887440e +--- /dev/null ++++ b/coalesce/BUILD.bazel +@@ -0,0 +1,16 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "coalesce", ++ srcs = [ ++ "coalesce.go", ++ ], ++ importpath = "github.com/openconfig/gnmi/coalesce", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":coalesce", ++ visibility = ["//visibility:public"], ++) +diff --git a/match/BUILD.bazel b/match/BUILD.bazel +new file mode 100644 +index 0000000..b09b9f3 +--- /dev/null ++++ b/match/BUILD.bazel +@@ -0,0 +1,16 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library") ++ ++go_library( ++ name = "match", ++ srcs = [ ++ "match.go", ++ ], ++ importpath = "github.com/openconfig/gnmi/match", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":match", ++ visibility = ["//visibility:public"], ++) diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/gnoi.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/gnoi.patch new file mode 100644 index 00000000000..903a2a51898 --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/gnoi.patch @@ -0,0 +1,32 @@ +diff --git a/healthz/BUILD.bazel b/healthz/BUILD.bazel +index 039f3b5..7c9940b 100644 +--- a/healthz/BUILD.bazel ++++ b/healthz/BUILD.bazel +@@ -34,7 +34,7 @@ proto_library( + ], + ) + +-go_proto_library( ++go_grpc_library( + name = "healthz_go_proto", + compilers = ["@io_bazel_rules_go//proto:go_grpc"], + importpath = "github.com/openconfig/gnoi/healthz", + +diff --git a/types/BUILD.bazel b/types/BUILD.bazel +index 921d7c1..995dd1e 100644 +--- a/types/BUILD.bazel ++++ b/types/BUILD.bazel +@@ -32,6 +32,13 @@ proto_library( + deps = ["@com_google_protobuf//:descriptor_proto"], + ) + ++proto_library( ++ name = "gnoi_types_proto", ++ srcs = ["types.proto"], ++ import_prefix = "github.com/openconfig/gnoi", ++ deps = ["@com_google_protobuf//:descriptor_proto"], ++) ++ + cc_proto_library( + name = "types_cc_proto", + deps = [":types_proto"], diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/gnsi.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/gnsi.patch new file mode 100644 index 00000000000..c676b322ae6 --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/gnsi.patch @@ -0,0 +1,13 @@ +diff --git a/version/BUILD.bazel b/version/BUILD.bazel +index e047013..5dbb1c6 100644 +--- a/version/BUILD.bazel ++++ b/version/BUILD.bazel +@@ -11,7 +11,7 @@ proto_library( + srcs = [ + "version.proto", + ], +- deps = ["@com_github_openconfig_gnoi//types:types_proto"], ++ deps = ["@com_github_openconfig_gnoi//types:gnoi_types_proto"], + import_prefix = "github.com/openconfig/gnsi", + visibility = ["//visibility:public"], + ) diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/gribi.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/gribi.patch new file mode 100644 index 00000000000..e129cfd1ba8 --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/gribi.patch @@ -0,0 +1,48 @@ +diff --git a/v1/proto/gribi_aft/BUILD.bazel b/v1/proto/gribi_aft/BUILD.bazel +index fdb39a2..3ddfc19 100644 +--- a/v1/proto/gribi_aft/BUILD.bazel ++++ b/v1/proto/gribi_aft/BUILD.bazel +@@ -7,8 +7,8 @@ proto_library( + srcs = ["gribi_aft.proto"], + visibility = ["//visibility:public"], + deps = [ +- "//github.com/openconfig/ygot/proto/yext:yext_proto", +- "//github.com/openconfig/ygot/proto/ywrapper:ywrapper_proto", ++ "@com_github_openconfig_ygot//proto/yext:yext_proto", ++ "@com_github_openconfig_ygot//proto/ywrapper:ywrapper_proto", + "//v1/proto/gribi_aft/enums:enums_proto", + ], + ) +@@ -19,8 +19,8 @@ go_proto_library( + proto = ":gribi_aft_proto", + visibility = ["//visibility:public"], + deps = [ +- "//github.com/openconfig/ygot/proto/yext:yext_proto", +- "//github.com/openconfig/ygot/proto/ywrapper:ywrapper_proto", ++ "@com_github_openconfig_ygot//proto/yext:go_default_library", ++ "@com_github_openconfig_ygot//proto/ywrapper:go_default_library", + "//v1/proto/gribi_aft/enums", + ], + ) +diff --git a/v1/proto/gribi_aft/enums/BUILD.bazel b/v1/proto/gribi_aft/enums/BUILD.bazel +index 7ef4d9d..18f7324 100644 +--- a/v1/proto/gribi_aft/enums/BUILD.bazel ++++ b/v1/proto/gribi_aft/enums/BUILD.bazel +@@ -6,7 +6,7 @@ proto_library( + name = "enums_proto", + srcs = ["enums.proto"], + visibility = ["//visibility:public"], +- deps = ["//github.com/openconfig/ygot/proto/yext:yext_proto"], ++ deps = ["@com_github_openconfig_ygot//proto/yext:yext_proto"], + ) + + go_proto_library( +@@ -14,7 +14,7 @@ go_proto_library( + importpath = "github.com/openconfig/gribi/v1/proto/gribi_aft/enums", + proto = ":enums_proto", + visibility = ["//visibility:public"], +- deps = ["//github.com/openconfig/ygot/proto/yext:yext_proto"], ++ deps = ["@com_github_openconfig_ygot//proto/yext:go_default_library"], + ) + + go_library( diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/ondatra.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ondatra.patch new file mode 100644 index 00000000000..14f895abc67 --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ondatra.patch @@ -0,0 +1,77 @@ +diff --git a/binding/abstract.go b/binding/abstract.go +index 9e54e9a..643dbc6 100644 +--- a/binding/abstract.go ++++ b/binding/abstract.go +@@ -36,18 +36,18 @@ import ( + mpb "github.com/openconfig/gnoi/mpls" + ospb "github.com/openconfig/gnoi/os" + otpb "github.com/openconfig/gnoi/otdr" +- plqpb "github.com/openconfig/gnoi/packet_link_qualification" ++ plqpb "github.com/openconfig/gnoi/linkqual" + spb "github.com/openconfig/gnoi/system" + wpb "github.com/openconfig/gnoi/wavelength_router" + acctzpb "github.com/openconfig/gnsi/acctz" + authzpb "github.com/openconfig/gnsi/authz" + certzpb "github.com/openconfig/gnsi/certz" + credzpb "github.com/openconfig/gnsi/credentialz" + pathzpb "github.com/openconfig/gnsi/pathz" + +- grpb "github.com/openconfig/gribi/v1/proto/service" ++ grpb "github.com/openconfig/gribi/proto/service" + opb "github.com/openconfig/ondatra/proto" + p4pb "github.com/p4lang/p4runtime/go/p4/v1" + ) + + +diff --git a/binding/binding.go b/binding/binding.go +index ccc3601..175efee 100644 +--- a/binding/binding.go ++++ b/binding/binding.go +@@ -37,18 +37,18 @@ import ( + mpb "github.com/openconfig/gnoi/mpls" + ospb "github.com/openconfig/gnoi/os" + otpb "github.com/openconfig/gnoi/otdr" +- plqpb "github.com/openconfig/gnoi/packet_link_qualification" ++ plqpb "github.com/openconfig/gnoi/linkqual" + spb "github.com/openconfig/gnoi/system" + wpb "github.com/openconfig/gnoi/wavelength_router" + acctzpb "github.com/openconfig/gnsi/acctz" + authzpb "github.com/openconfig/gnsi/authz" + certzpb "github.com/openconfig/gnsi/certz" + credzpb "github.com/openconfig/gnsi/credentialz" + pathzpb "github.com/openconfig/gnsi/pathz" +- grpb "github.com/openconfig/gribi/v1/proto/service" ++ grpb "github.com/openconfig/gribi/proto/service" + opb "github.com/openconfig/ondatra/proto" + p4pb "github.com/p4lang/p4runtime/go/p4/v1" + ) + + + +diff --git a/internal/rawapis/rawapis.go b/internal/rawapis/rawapis.go +index 4f57ed9..6f5b468 100644 +--- a/internal/rawapis/rawapis.go ++++ b/internal/rawapis/rawapis.go +@@ -33,7 +33,7 @@ import ( + "google.golang.org/grpc" + + gpb "github.com/openconfig/gnmi/proto/gnmi" +- grpb "github.com/openconfig/gribi/v1/proto/service" ++ grpb "github.com/openconfig/gribi/proto/service" + p4pb "github.com/p4lang/p4runtime/go/p4/v1" + ) + + +diff --git a/raw/raw.go b/raw/raw.go +index ce85c92..5739128 100644 +--- a/raw/raw.go ++++ b/raw/raw.go +@@ -26,7 +26,7 @@ import ( + "github.com/openconfig/ondatra/internal/rawapis" + + gpb "github.com/openconfig/gnmi/proto/gnmi" +- grpb "github.com/openconfig/gribi/v1/proto/service" ++ grpb "github.com/openconfig/gribi/proto/service" + p4pb "github.com/p4lang/p4runtime/go/p4/v1" + ) + diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/p4lang.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/p4lang.patch new file mode 100644 index 00000000000..f6cc319b6fa --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/p4lang.patch @@ -0,0 +1,25 @@ +diff --git a/proto/p4/config/v1/p4info.proto b/proto/p4/config/v1/p4info.proto +index badddd9..079f258 100644 +--- a/proto/p4/config/v1/p4info.proto ++++ b/proto/p4/config/v1/p4info.proto +@@ -15,7 +15,7 @@ + syntax = "proto3"; + + import "google/protobuf/any.proto"; +-import "p4/config/v1/p4types.proto"; ++import "proto/p4/config/v1/p4types.proto"; + + // This package and its contents are a work-in-progress. + +diff --git a/go/p4/v1/BUILD.bazel b/go/p4/v1/BUILD.bazel +index 6445fff..17a350c 100644 +--- a/go/p4/v1/BUILD.bazel ++++ b/go/p4/v1/BUILD.bazel +@@ -17,6 +17,7 @@ go_library( + "@org_golang_google_protobuf//reflect/protoreflect:go_default_library", + "@org_golang_google_protobuf//runtime/protoimpl:go_default_library", + "@org_golang_google_protobuf//types/known/anypb:go_default_library", ++ "@com_github_p4lang_p4runtime//go/p4/config/v1:go_default_library" + ], + ) + \ No newline at end of file diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/snappi.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/snappi.patch new file mode 100644 index 00000000000..98d9439b33f --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/snappi.patch @@ -0,0 +1,54 @@ +diff --git a/gosnappi/BUILD.bazel b/gosnappi/BUILD.bazel +index d72ce05..91b14e9 100644 +--- a/gosnappi/BUILD.bazel ++++ b/gosnappi/BUILD.bazel +@@ -10,7 +10,17 @@ go_library( + ], + importpath = "github.com/open-traffic-generator/snappi/gosnappi", + visibility = ["//visibility:public"], +- deps = ["@org_golang_google_grpc//:go_default_library"], ++ deps = [ ++ "@com_github_ghodss_yaml//:yaml", ++ "@com_github_masterminds_semver_v3//:semver", ++ "@com_github_open_traffic_generator_snappi//gosnappi/otg:go_default_library", ++ "@org_golang_google_grpc//:go_default_library", ++ "@org_golang_google_grpc//credentials/insecure", ++ "@org_golang_google_grpc//status", ++ "@org_golang_google_protobuf//encoding/protojson", ++ "@org_golang_google_protobuf//proto", ++ "@org_golang_google_protobuf//types/known/emptypb", ++ ], + ) + + alias( + +diff --git a/gosnappi/otg/BUILD.bazel b/gosnappi/otg/BUILD.bazel +index c0c81d6..5c4fc59 100644 +--- a/gosnappi/otg/BUILD.bazel ++++ b/gosnappi/otg/BUILD.bazel +@@ -5,6 +5,7 @@ load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") + proto_library( + name = "otg_proto", + srcs = ["otg.proto"], ++ import_prefix = "github.com/open-traffic-generator/snappi", + visibility = ["//visibility:public"], + deps = [ + "@com_google_protobuf//:descriptor_proto", +@@ -15,7 +16,7 @@ proto_library( + go_proto_library( + name = "otg_go_proto", + compilers = ["@io_bazel_rules_go//proto:go_grpc"], +- importpath = "./otg", ++ importpath = "github.com/open-traffic-generator/snappi/gosnappi/otg_go_proto", + proto = ":otg_proto", + visibility = ["//visibility:public"], + ) +@@ -23,7 +24,7 @@ go_proto_library( + go_library( + name = "otg", + embed = [":otg_go_proto"], +- importpath = "./otg", ++ importpath = "github.com/open-traffic-generator/snappi/gosnappi/otg", + visibility = ["//visibility:public"], + ) + diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygnmi.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygnmi.patch new file mode 100644 index 00000000000..43b3a22bd61 --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygnmi.patch @@ -0,0 +1,13 @@ +diff --git a/ygnmi/BUILD.bazel b/ygnmi/BUILD.bazel +index 5760c6a..e9a5923 100644 +--- a/ygnmi/BUILD.bazel ++++ b/ygnmi/BUILD.bazel +@@ -15,7 +15,7 @@ go_library( + "//internal/logutil", + "@com_github_golang_glog//:glog", + "@com_github_openconfig_gnmi//errlist", +- "@com_github_openconfig_gnmi//proto/gnmi", ++ "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", + "@com_github_openconfig_gocloser//:gocloser", + "@com_github_openconfig_goyang//pkg/yang", + "@com_github_openconfig_ygot//util", diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygot.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygot.patch new file mode 100644 index 00000000000..3579b8f394a --- /dev/null +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygot.patch @@ -0,0 +1,85 @@ +diff --git a/proto/yext/BUILD.bazel b/proto/yext/BUILD.bazel +index 4ebd593..cd1f209 100644 +--- a/proto/yext/BUILD.bazel ++++ b/proto/yext/BUILD.bazel +@@ -1,5 +1,13 @@ + load("@io_bazel_rules_go//go:def.bzl", "go_library") + ++proto_library( ++ name = "yext_proto", ++ srcs = ["yext.proto"], ++ visibility = ["//visibility:public"], ++ import_prefix = "github.com/openconfig/ygot", ++ deps = ["@com_google_protobuf//:descriptor_proto"], ++) ++ + go_library( + name = "yext", + srcs = [ +@@ -20,3 +28,4 @@ alias( + actual = ":yext", + visibility = ["//visibility:public"], + ) ++ +diff --git a/proto/ywrapper/BUILD.bazel b/proto/ywrapper/BUILD.bazel +index 4537c63..51fb410 100644 +--- a/proto/ywrapper/BUILD.bazel ++++ b/proto/ywrapper/BUILD.bazel +@@ -1,5 +1,12 @@ + load("@io_bazel_rules_go//go:def.bzl", "go_library") + ++proto_library( ++ name = "ywrapper_proto", ++ srcs = ["ywrapper.proto"], ++ visibility = ["//visibility:public"], ++ import_prefix = "github.com/openconfig/ygot", ++) ++ + go_library( + name = "ywrapper", + srcs = [ +@@ -19,3 +26,4 @@ alias( + actual = ":ywrapper", + visibility = ["//visibility:public"], + ) ++ + +diff --git a/util/BUILD.bazel b/util/BUILD.bazel +index af907f2..8b45361 100644 +--- a/util/BUILD.bazel ++++ b/util/BUILD.bazel +@@ -18,7 +18,7 @@ go_library( + "//internal/yreflect", + "@com_github_golang_glog//:go_default_library", + "@com_github_kylelemons_godebug//pretty:go_default_library", +- "@com_github_openconfig_gnmi//proto/gnmi:go_default_library", ++ "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", + "@com_github_openconfig_goyang//pkg/yang:go_default_library", + "@org_golang_google_protobuf//proto:go_default_library", + ], +diff --git a/ygot/BUILD.bazel b/ygot/BUILD.bazel +index 96d93c2..7023807 100644 +--- a/ygot/BUILD.bazel ++++ b/ygot/BUILD.bazel +@@ -20,7 +20,7 @@ go_library( + "//util", + "@com_github_kylelemons_godebug//pretty:go_default_library", + "@com_github_openconfig_gnmi//errlist:go_default_library", +- "@com_github_openconfig_gnmi//proto/gnmi:go_default_library", ++ "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", + "@com_github_openconfig_gnmi//value:go_default_library", + "@com_github_openconfig_goyang//pkg/yang:go_default_library", + "@org_golang_google_protobuf//encoding/prototext:go_default_library", +diff --git a/ytypes/BUILD.bazel b/ytypes/BUILD.bazel +index d468783..99d604c 100644 +--- a/ytypes/BUILD.bazel ++++ b/ytypes/BUILD.bazel +@@ -35,7 +35,7 @@ go_library( + "//ygot", + "@com_github_golang_glog//:go_default_library", + "@com_github_kylelemons_godebug//pretty:go_default_library", +- "@com_github_openconfig_gnmi//proto/gnmi:go_default_library", ++ "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", + "@com_github_openconfig_goyang//pkg/yang:go_default_library", + "@org_golang_google_grpc//codes:go_default_library", + "@org_golang_google_grpc//status:go_default_library", From 49a3c2aa20086cca5b74e7d5dbe886e787dcbd0e Mon Sep 17 00:00:00 2001 From: divyagayathri-hcl Date: Tue, 13 Aug 2024 12:50:52 -0700 Subject: [PATCH 2/2] [sdn_tests] pins binding cleanup & Project import generated by Copybara. --- ondatra/binding/BUILD.bazel | 2 -- ondatra/binding/binding_backend.go | 3 +- ondatra/binding/pins_binding.go | 19 ++++++++---- ondatra/binding_deps.bzl | 30 +++++++++++++++++++ .../bazel/patches/ondatra/ygnmi.patch | 14 ++++----- .../infrastructure/testhelper/BUILD.bazel | 7 ++--- .../infrastructure/testhelper/p4rt.go | 10 ------- 7 files changed, 54 insertions(+), 31 deletions(-) diff --git a/ondatra/binding/BUILD.bazel b/ondatra/binding/BUILD.bazel index 6c4e9fe64c5..c5742ca514b 100644 --- a/ondatra/binding/BUILD.bazel +++ b/ondatra/binding/BUILD.bazel @@ -9,8 +9,6 @@ go_library( name = "pinsbind", testonly = True, srcs = ["pins_binding.go"], - data = [ - ], importpath = "github.com/sonic-mgmt/sdn_tests/pins_ondatra/infrastructure/binding/pinsbind", deps = [ ":bindingbackend", diff --git a/ondatra/binding/binding_backend.go b/ondatra/binding/binding_backend.go index 034fb8b5b1a..1696657d12c 100644 --- a/ondatra/binding/binding_backend.go +++ b/ondatra/binding/binding_backend.go @@ -68,8 +68,7 @@ type Backend interface { 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) - // GNSIClient wraps the grpc connection under gnsi client. - GNSIClient(ctx context.Context, dut *binding.AbstractDUT, conn *grpc.ClientConn) (binding.GNSIClients, error) + // Close closes backend's internal objects. Close() error } diff --git a/ondatra/binding/pins_binding.go b/ondatra/binding/pins_binding.go index 47021f23e57..c701a9ecf82 100644 --- a/ondatra/binding/pins_binding.go +++ b/ondatra/binding/pins_binding.go @@ -97,12 +97,12 @@ func CloseBackend() { } // Reserve returns a testbed meeting requirements of testbed proto. -func (b *Binding) Reserve(ctx context.Context, tb *opb.Testbed, runtime, waittime time.Duration, partial map[string]string) (*binding.Reservation, error) { +func (b *Binding) Reserve(ctx context.Context, tb *opb.Testbed, runtime, waitTime time.Duration, partial map[string]string) (*binding.Reservation, error) { if backend == nil { return nil, fmt.Errorf("backend is not set") } - reservedtopology, err := backend.ReserveTopology(ctx, tb, runtime, waittime, partial) + reservedtopology, err := backend.ReserveTopology(ctx, tb, runtime, waitTime, partial) if err != nil { return nil, fmt.Errorf("failed to reserve topology: %v", err) } @@ -372,11 +372,20 @@ func (b *Binding) resolveDUT(key string, d *pinsDUT) (*rpb.ResolvedDevice, error ports[k] = resolvePort(k, p) } services := map[string]*rpb.Service{ - "grpc": &rpb.Service{ - Id: "grpc", + "gnmi.gNMI": &rpb.Service{ + Id: "gnmi.gNMI", Endpoint: &rpb.Service_ProxiedGrpc{ ProxiedGrpc: &rpb.ProxiedGRPCEndpoint{ - Address: d.grpc.GRPCAddr, + Address: d.grpc.GNMIAddr, + Proxy: nil, + }, + }, + }, + "p4.v1.P4Runtime": &rpb.Service{ + Id: "p4.v1.P4Runtime", + Endpoint: &rpb.Service_ProxiedGrpc{ + ProxiedGrpc: &rpb.ProxiedGRPCEndpoint{ + Address: d.grpc.P4RTAddr, Proxy: nil, }, }, diff --git a/ondatra/binding_deps.bzl b/ondatra/binding_deps.bzl index c55d0a7834c..727487bba3a 100644 --- a/ondatra/binding_deps.bzl +++ b/ondatra/binding_deps.bzl @@ -120,6 +120,15 @@ def binding_deps(): patch_args = ["-p1"], ) + go_repository( + name = "com_github_openconfig_ygnmi", + importpath = "github.com/openconfig/ygnmi", + build_file_proto_mode = "disable", + commit = "09b506cc94e5c0d69208991b54fbf30de05a13ff", #v0.8.7 + patches = ["//:bazel/patches/ondatra/ygnmi.patch"], + patch_args = ["-p1"], + ) + go_repository( name = "com_github_openconfig_gnoi", build_file_proto_mode = "disable", @@ -267,3 +276,24 @@ def binding_deps(): commit = "9fe00a1330817b5ce00919bf2861cd8a9cea1a00", shallow_since = "1642638275 -0800", ) + + go_repository( + name = "com_github_jstemmer_go_junit_report_v2", + importpath = "github.com/jstemmer/go-junit-report/v2", + sum = "h1:BVBb1o0TfOuRCMykVAYJ1r2yoZ+ByE0f19QNF4ngQ0M=", + version = "v2.0.1-0.20220823220451-7b10b4285462", + ) + + go_repository( + name = "com_github_patrickmn_go_cache", + importpath = "github.com/patrickmn/go-cache", + sum = "h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=", + version = "v2.1.0+incompatible", + ) + + go_repository( + name = "com_github_pkg_errors", + importpath = "github.com/pkg/errors", + sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=", + version = "v0.9.1", + ) diff --git a/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygnmi.patch b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygnmi.patch index 43b3a22bd61..38252ca93c5 100644 --- a/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygnmi.patch +++ b/sdn_tests/pins_ondatra/bazel/patches/ondatra/ygnmi.patch @@ -1,13 +1,13 @@ diff --git a/ygnmi/BUILD.bazel b/ygnmi/BUILD.bazel -index 5760c6a..e9a5923 100644 +index a152057..3a2ee21 100644 --- a/ygnmi/BUILD.bazel +++ b/ygnmi/BUILD.bazel @@ -15,7 +15,7 @@ go_library( "//internal/logutil", - "@com_github_golang_glog//:glog", - "@com_github_openconfig_gnmi//errlist", -- "@com_github_openconfig_gnmi//proto/gnmi", + "@com_github_golang_glog//:go_default_library", + "@com_github_openconfig_gnmi//errlist:go_default_library", +- "@com_github_openconfig_gnmi//proto/gnmi:go_default_library", + "@com_github_openconfig_gnmi//proto/gnmi:gnmi_go_proto", - "@com_github_openconfig_gocloser//:gocloser", - "@com_github_openconfig_goyang//pkg/yang", - "@com_github_openconfig_ygot//util", + "@com_github_openconfig_gocloser//:go_default_library", + "@com_github_openconfig_goyang//pkg/yang:go_default_library", + "@com_github_openconfig_ygot//util:go_default_library", diff --git a/sdn_tests/pins_ondatra/infrastructure/testhelper/BUILD.bazel b/sdn_tests/pins_ondatra/infrastructure/testhelper/BUILD.bazel index 7a52aa9bb8f..9358932d9cd 100644 --- a/sdn_tests/pins_ondatra/infrastructure/testhelper/BUILD.bazel +++ b/sdn_tests/pins_ondatra/infrastructure/testhelper/BUILD.bazel @@ -7,10 +7,10 @@ package( go_library( name = "testhelper", - testonly = 1, + testonly = True, srcs = [ "augment.go", - "gnmi.go", + "gnmi.go", "gnoi.go", "lacp.go", "p4rt.go", @@ -22,9 +22,6 @@ go_library( "ssh.go", "//infrastructure/testhelper/platform_info:platform_info", ], - data = [ - "//infrastructure/data", - ], importpath = "github.com/sonic-net/sonic-mgmt/sdn_tests/pins_ondatra/infrastructure/testhelper/testhelper", deps = [ "@com_github_golang_glog//:glog", diff --git a/sdn_tests/pins_ondatra/infrastructure/testhelper/p4rt.go b/sdn_tests/pins_ondatra/infrastructure/testhelper/p4rt.go index fc723d86f4e..578ac40340d 100644 --- a/sdn_tests/pins_ondatra/infrastructure/testhelper/p4rt.go +++ b/sdn_tests/pins_ondatra/infrastructure/testhelper/p4rt.go @@ -6,7 +6,6 @@ import ( "context" "encoding/hex" "fmt" - "os" "strconv" "testing" "time" @@ -17,7 +16,6 @@ import ( "github.com/openconfig/ondatra/gnmi" "github.com/pkg/errors" "google.golang.org/grpc/codes" - "google.golang.org/protobuf/encoding/prototext" p4infopb "github.com/p4lang/p4runtime/go/p4/config/v1" p4pb "github.com/p4lang/p4runtime/go/p4/v1" @@ -139,14 +137,6 @@ func (p *P4RTClient) P4Info() (*p4infopb.P4Info, error) { var p4Info *p4infopb.P4Info err := fmt.Errorf("P4Info is not implemented") - // Read P4Info from file. - p4Info = &p4infopb.P4Info{} - data, err := os.ReadFile("ondatra/data/p4rtconfig.prototext") - if err != nil { - return nil, err - } - err = prototext.Unmarshal(data, p4Info) - return p4Info, err }