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-destination11516463478366849363/.
  • Loading branch information
GGN Engprod Team authored and greg-dennis committed May 27, 2022
1 parent be319f7 commit d31d97b
Show file tree
Hide file tree
Showing 108 changed files with 115,958 additions and 124,303 deletions.
5 changes: 5 additions & 0 deletions binding/abstract.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ func (a *AbstractATE) DialIxNetwork(context.Context) (*IxNetwork, error) {
return nil, errors.New("DialIxNetwork unimplemented")
}

// DialGNMI returns an unimplemented error.
func (a *AbstractATE) DialGNMI(context.Context, ...grpc.DialOption) (gpb.GNMIClient, error) {
return nil, errors.New("DialGNMI unimplemented")
}

// DialOTG returns an unimplemented error.
func (a *AbstractATE) DialOTG(context.Context) (gosnappi.GosnappiApi, error) {
return nil, errors.New("DialOTG unimplemented")
Expand Down
6 changes: 6 additions & 0 deletions binding/binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ type ATE interface {
// DialIxNetwork creates a client connection to the ATE's IxNetwork endpoint.
DialIxNetwork(context.Context) (*IxNetwork, error)

// DialGNMI creates a client connection to the ATE's gNMI endpoint.
// Implementations must append transport security options necessary to reach the server.
// This method must be implemented to receive gNMI from OTG but not from IxNetwork;
// Implementing DialIxNetwork is sufficient for gNMI support for IxNetwork.
DialGNMI(context.Context, ...grpc.DialOption) (gpb.GNMIClient, error)

// DialOTG creates a client connection to the ATE's OTG endpoint.
DialOTG(context.Context) (gosnappi.GosnappiApi, error)

Expand Down
33 changes: 33 additions & 0 deletions binding/ixweb/ixnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,39 @@ func (s *Session) Stats() *Stats {
return &Stats{sess: s}
}

// Error represents an error reported by an IxNetwork session.
type Error struct {
ID int `json:"id"`
Level string `json:"errorLevel"`
Code int `json:"errorCode"`
Description string `json:"description"`
Name string `json:"name"`
LastModified string `json:"lastModified"`
InstanceDataColumns []string `json:"sourceColumnsDisplayName"`
Provider string `json:"provider"`
Instances []*ErrorInstance
}

// ErrorInstance represents an error instance reported by an IxNetwork session.
type ErrorInstance struct {
DataRow []string `json:"sourceValues"`
}

// Errors returns the current errors/warnings for this session.
func (s *Session) Errors(ctx context.Context) ([]*Error, error) {
const errEP = "/globals/appErrors/error"
var errors []*Error
if err := s.Get(ctx, errEP, &errors); err != nil {
return nil, fmt.Errorf("error fetching session errors: %w", err)
}
for _, e := range errors {
if err := s.Get(ctx, path.Join(errEP, strconv.Itoa(e.ID), "instance"), &(e.Instances)); err != nil {
return nil, fmt.Errorf("error fetching instances of error with ID %d: %w", e.ID, err)
}
}
return errors, nil
}

func (s *Session) jsonReq(ctx context.Context, method httpMethod, path string, in, out interface{}) error {
s.mu.Lock()
defer s.mu.Unlock()
Expand Down
77 changes: 77 additions & 0 deletions binding/ixweb/ixnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"net/http"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
)

func TestOpArgs(t *testing.T) {
Expand Down Expand Up @@ -79,3 +81,78 @@ func TestDeleteSession(t *testing.T) {
})
}
}

func TestErrors(t *testing.T) {
errorsBody := `[{
"id": 3,
"lastModified": "05/11/2022 11:01:31",
"errorLevel": "kError",
"sourceColumnsDisplayName": [
"Description",
"Time"
],
"description": "some description",
"provider": "ResourceManagerMiddleware",
"errorCode": 0,
"name": "JSON Import Issues"
}]`
errorInstancesBody := `[{
"sourceValues": [
"invalid IP address",
"05/11/2022 11:01:31"
]
}]`
tests := []struct {
desc string
doResps []*http.Response
wantErr string
wantErrors []*Error
}{{
desc: "error fetching errors",
doResps: []*http.Response{fakeResponse(400, "")},
wantErr: "400",
}, {
desc: "error fetching error instances",
doResps: []*http.Response{fakeResponse(200, errorsBody), fakeResponse(500, "")},
wantErr: "500",
}, {
desc: "success",
doResps: []*http.Response{fakeResponse(200, errorsBody), fakeResponse(200, errorInstancesBody)},
wantErrors: []*Error{{
ID: 3,
LastModified: "05/11/2022 11:01:31",
Level: "kError",
Code: 0,
Description: "some description",
Name: "JSON Import Issues",
InstanceDataColumns: []string{"Description", "Time"},
Provider: "ResourceManagerMiddleware",
Instances: []*ErrorInstance{{
DataRow: []string{"invalid IP address", "05/11/2022 11:01:31"},
}},
}},
}}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
sess := &Session{ixweb: &IxWeb{
hostname: "fakeHost",
client: &fakeHTTPClient{
doResps: test.doResps,
},
}}
gotErrors, err := sess.Errors(context.Background())
if got, want := err != nil, test.wantErr != ""; got != want {
t.Fatalf("Errors() got err %v, want err %v", err, want)
}
if err != nil {
if !strings.Contains(err.Error(), test.wantErr) {
t.Errorf("Errors() got err %v, want contains %q", err, test.wantErr)
}
return
}
if diff := cmp.Diff(test.wantErrors, gotErrors); diff != "" {
t.Errorf("Errors() got unexpected diff (-want + got): %s", diff)
}
})
}
}
2 changes: 1 addition & 1 deletion config/acl/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package acl is a generated package which contains definitions
of structs which generate gNMI paths for a YANG schema. The generated paths are
based on a compressed form of the schema.
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.20.1/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.21.0/genutil/names.go
using the following YANG input files:
- gnmi-collector-metadata.yang
- public/release/models/acl/openconfig-acl.yang
Expand Down
19 changes: 1 addition & 18 deletions config/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package device is a generated package which contains definitions
of structs which generate gNMI paths for a YANG schema. The generated paths are
based on a compressed form of the schema.
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.20.1/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.21.0/genutil/names.go
using the following YANG input files:
- gnmi-collector-metadata.yang
- public/release/models/acl/openconfig-acl.yang
Expand Down Expand Up @@ -67,7 +67,6 @@ import (
"github.com/openconfig/ondatra/config/keychain"
"github.com/openconfig/ondatra/config/lacp"
"github.com/openconfig/ondatra/config/lldp"
"github.com/openconfig/ondatra/config/localrouting"
"github.com/openconfig/ondatra/config/networkinstance"
"github.com/openconfig/ondatra/config/platform"
"github.com/openconfig/ondatra/config/qos"
Expand Down Expand Up @@ -238,22 +237,6 @@ func (n *DevicePath) Lldp() *lldp.LldpPath {
}
}

// LocalRoutes (container): Top-level container for local routes
// ----------------------------------------
// Defining module: "openconfig-local-routing"
// Instantiating module: "openconfig-local-routing"
// Path from parent: "local-routes"
// Path from root: "/local-routes"
func (n *DevicePath) LocalRoutes() *localrouting.LocalRoutesPath {
return &localrouting.LocalRoutesPath{
NodePath: ygot.NewNodePath(
[]string{"local-routes"},
map[string]interface{}{},
n,
),
}
}

// Meta (container):
// ----------------------------------------
// Defining module: "gnmi-collector-metadata"
Expand Down
2 changes: 1 addition & 1 deletion config/gnmicollectormetadata/gnmicollectormetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package gnmicollectormetadata is a generated package which contains definitions
of structs which generate gNMI paths for a YANG schema. The generated paths are
based on a compressed form of the schema.
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.20.1/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.21.0/genutil/names.go
using the following YANG input files:
- gnmi-collector-metadata.yang
- public/release/models/acl/openconfig-acl.yang
Expand Down
2 changes: 1 addition & 1 deletion config/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package interfaces is a generated package which contains definitions
of structs which generate gNMI paths for a YANG schema. The generated paths are
based on a compressed form of the schema.
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.20.1/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.21.0/genutil/names.go
using the following YANG input files:
- gnmi-collector-metadata.yang
- public/release/models/acl/openconfig-acl.yang
Expand Down
2 changes: 1 addition & 1 deletion config/keychain/keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package keychain is a generated package which contains definitions
of structs which generate gNMI paths for a YANG schema. The generated paths are
based on a compressed form of the schema.
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.20.1/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.21.0/genutil/names.go
using the following YANG input files:
- gnmi-collector-metadata.yang
- public/release/models/acl/openconfig-acl.yang
Expand Down
2 changes: 1 addition & 1 deletion config/lacp/lacp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package lacp is a generated package which contains definitions
of structs which generate gNMI paths for a YANG schema. The generated paths are
based on a compressed form of the schema.
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.20.1/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.21.0/genutil/names.go
using the following YANG input files:
- gnmi-collector-metadata.yang
- public/release/models/acl/openconfig-acl.yang
Expand Down
2 changes: 1 addition & 1 deletion config/lldp/lldp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package lldp is a generated package which contains definitions
of structs which generate gNMI paths for a YANG schema. The generated paths are
based on a compressed form of the schema.
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.20.1/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.21.0/genutil/names.go
using the following YANG input files:
- gnmi-collector-metadata.yang
- public/release/models/acl/openconfig-acl.yang
Expand Down
Loading

0 comments on commit d31d97b

Please sign in to comment.