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-destination11517545832222761826/.
  • Loading branch information
GGN Engprod Team authored and greg-dennis committed May 31, 2022
1 parent d31d97b commit 343862b
Show file tree
Hide file tree
Showing 85 changed files with 40,586 additions and 40,585 deletions.
2 changes: 1 addition & 1 deletion ate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type ATEDevice struct {
// OTG returns a handle to the OTG API.
func (a *ATEDevice) OTG() *OTG {
if a.otg == nil {
a.otg = &OTG{devID: a.ID(), ate: a.res.(binding.ATE)}
a.otg = &OTG{ate: a.res.(binding.ATE)}
}
return a.otg
}
Expand Down
24 changes: 16 additions & 8 deletions binding/ixweb/ixnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,9 @@ type Error struct {
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"`
InstanceColumnNames []string `json:"sourceColumnsDisplayName"`
InstanceRowValues []map[string]string
}

// Errors returns the current errors/warnings for this session.
Expand All @@ -208,9 +203,22 @@ func (s *Session) Errors(ctx context.Context) ([]*Error, error) {
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 {
var instances []*struct {
DataRow []string `json:"sourceValues"`
}
if err := s.Get(ctx, path.Join(errEP, strconv.Itoa(e.ID), "instance"), &instances); err != nil {
return nil, fmt.Errorf("error fetching instances of error with ID %d: %w", e.ID, err)
}
for i, r := range instances {
if len(r.DataRow) != len(e.InstanceColumnNames) {
return nil, fmt.Errorf("incorrect number of data values for error instance %d of error %d", i, e.ID)
}
row := map[string]string{}
for j, col := range e.InstanceColumnNames {
row[col] = r.DataRow[j]
}
e.InstanceRowValues = append(e.InstanceRowValues, row)
}
}
return errors, nil
}
Expand Down
16 changes: 13 additions & 3 deletions binding/ixweb/ixnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ func TestErrors(t *testing.T) {
"05/11/2022 11:01:31"
]
}]`
invalidValueCountInstancesBody := `[{
"sourceValues": [
"invalid IP address"
]
}]`
tests := []struct {
desc string
doResps []*http.Response
Expand All @@ -115,6 +120,10 @@ func TestErrors(t *testing.T) {
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, invalidValueCountInstancesBody)},
wantErr: "incorrect number of data values",
}, {
desc: "success",
doResps: []*http.Response{fakeResponse(200, errorsBody), fakeResponse(200, errorInstancesBody)},
Expand All @@ -125,10 +134,11 @@ func TestErrors(t *testing.T) {
Code: 0,
Description: "some description",
Name: "JSON Import Issues",
InstanceDataColumns: []string{"Description", "Time"},
InstanceColumnNames: []string{"Description", "Time"},
Provider: "ResourceManagerMiddleware",
Instances: []*ErrorInstance{{
DataRow: []string{"invalid IP address", "05/11/2022 11:01:31"},
InstanceRowValues: []map[string]string{{
"Description": "invalid IP address",
"Time": "05/11/2022 11:01:31",
}},
}},
}}
Expand Down
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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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/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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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/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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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/networkinstance/networkinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package networkinstance 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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package platform 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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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/qos/qos.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package qos 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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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/routingpolicy/routingpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package routingpolicy 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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package system 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.21.0/genutil/names.go
This package was generated by /usr/local/google/home/gdennis/go/pkg/mod/github.com/openconfig/ygot@v0.22.1/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 device.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (v Vendor) String() string {

// Telemetry returns a telemetry path root for the device.
func (d *Device) Telemetry() *device.DevicePath {
root := device.DeviceRoot(d.ID())
root := device.DeviceRoot(d.Name())
// TODO: Add field to root node in ygot instead of using custom data.
root.PutCustomData(genutil.DefaultClientKey, d.clientFn)
return root
Expand Down
8 changes: 4 additions & 4 deletions dut.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ type DUTDevice struct {

// Config returns a handle to the DUT configuration API.
func (d *DUTDevice) Config() *Config {
dev := device.DeviceRoot(d.ID())
root := device.DeviceRoot(d.ID())
if d.Vendor() == CISCO || d.Vendor() == JUNIPER {
dev.PutCustomData(genutil.UseGetForConfigKey, true)
genutil.PutUseGetForConfig(root, true)
}
dev.PutCustomData(genutil.DefaultClientKey, d.Device.clientFn)
root.PutCustomData(genutil.DefaultClientKey, d.Device.clientFn)
return &Config{
dut: d.res.(binding.DUT),
DevicePath: dev,
DevicePath: root,
}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/openconfig/gribi v0.1.1-0.20220126144445-1634932f9fd8
github.com/openconfig/lemming v0.0.0-20220404232244-1dbc2b4c6179
github.com/openconfig/testt v0.0.0-20220311054427-efbb1a32ec07
github.com/openconfig/ygot v0.20.0
github.com/openconfig/ygot v0.22.1
github.com/p4lang/p4runtime v1.3.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pborman/uuid v1.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ github.com/openconfig/ygot v0.6.0/go.mod h1:o30svNf7O0xK+R35tlx95odkDmZWS9JyWWQS
github.com/openconfig/ygot v0.10.4/go.mod h1:oCQNdXnv7dWc8scTDgoFkauv1wwplJn5HspHcjlxSAQ=
github.com/openconfig/ygot v0.13.2/go.mod h1:kJN0yCXIH07dOXvNBEFm3XxXdnDD5NI6K99tnD5x49c=
github.com/openconfig/ygot v0.15.1/go.mod h1:7ZiBFNc4n/1Hkv2v2dAEpxisqDznp0JVpLR13Toe4AY=
github.com/openconfig/ygot v0.20.0 h1:j4VjbdJ2ogXrEsTA7KWMaN/85YNpd+Q8qzPr8Gqjds8=
github.com/openconfig/ygot v0.20.0/go.mod h1:7ZiBFNc4n/1Hkv2v2dAEpxisqDznp0JVpLR13Toe4AY=
github.com/openconfig/ygot v0.22.1 h1:jOpaEuOE1JaLDkDbDTza45YOxhn8ghroK7xxXHt4v0I=
github.com/openconfig/ygot v0.22.1/go.mod h1:7ZiBFNc4n/1Hkv2v2dAEpxisqDznp0JVpLR13Toe4AY=
github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
Expand Down
40 changes: 38 additions & 2 deletions internal/ate/ixate.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type session interface {
Get(context.Context, string, interface{}) error
Patch(context.Context, string, interface{}) error
Post(context.Context, string, interface{}, interface{}) error
Errors(context.Context) ([]*ixweb.Error, error)
Files() files
Stats() stats
}
Expand Down Expand Up @@ -275,6 +276,32 @@ func (ix *ixATE) resetClientCfg() {
ix.resetClientTrafficCfg()
}

// sessionErrors returns a string representing errors reported by the session.
func (ix *ixATE) sessionErrors(ctx context.Context) string {
errors, err := ix.c.Session().Errors(ctx)
if err != nil {
log.Errorf("Could not fetch errors for IxNetwork session: %v", err)
return ""
}
var errBuilder strings.Builder
for i, e := range errors {
if e.Level != "kError" {
continue
}
errBuilder.WriteString(fmt.Sprintf("name: %q, description: %q, instances: ", e.Name, e.Description))
for j, row := range e.InstanceRowValues {
errBuilder.WriteString(fmt.Sprintf("%v", row))
if j != len(e.InstanceRowValues)-1 {
errBuilder.WriteString(", ")
}
}
if i != len(errors)-1 {
errBuilder.WriteRune('\n')
}
}
return errBuilder.String()
}

// importConfig is a wrapper around the config client ImportConfig method.
// It writes configs as test artifacts before pushing.
func (ix *ixATE) importConfig(ctx context.Context, node ixconfig.IxiaCfgNode, overwrite bool, timeout time.Duration) error {
Expand All @@ -295,6 +322,11 @@ func (ix *ixATE) importConfig(ctx context.Context, node ixconfig.IxiaCfgNode, ov
}
log.Infof("IxNetwork config logged to file %s", filePath)
}()
defer func() {
if sErr := ix.sessionErrors(ctx); sErr != "" {
log.Warningf("Errors reported in session after import: %s", sErr)
}
}()

const importDelay = 15 * time.Second
importCtx, cancel := context.WithTimeout(ctx, timeout)
Expand Down Expand Up @@ -792,10 +824,14 @@ func (ix *ixATE) startProtocols(ctx context.Context) error {
// behavior for a topology with RSVP protocols configured after updating to
// IxNetwork 9.10update2 everywhere.
if _, err := validateProtocolStartFn(ctx, ix); err != nil {
sErr := ix.sessionErrors(ctx)
if sErr != "" {
sErr = fmt.Sprintf("\n%s", sErr)
}
if errStart == nil {
return fmt.Errorf("failed to validate protocols: %w", err)
return fmt.Errorf("failed to validate protocols: %w%s", err, sErr)
}
return fmt.Errorf("failed to validate protocols after error on start: %v, %w", err, errStart)
return fmt.Errorf("failed to validate protocols after error on start: %v, %w%s", err, errStart, sErr)
}
return nil
}
Expand Down
8 changes: 8 additions & 0 deletions internal/ate/ixate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ func (c *fakeDelayImportClient) ImportConfig(ctx context.Context, _ *ixconfig.Ix
return ctx.Err()
}

func (c *fakeDelayImportClient) Session() session {
return &fakeSession{}
}

func (c *fakeCfgClient) UpdateIDs(_ context.Context, cfg *ixconfig.Ixnetwork, cns ...ixconfig.IxiaCfgNode) error {
if err := updateXPaths(cfg); err != nil {
return err
Expand Down Expand Up @@ -205,6 +209,10 @@ func (s *fakeSession) Post(_ context.Context, p string, _, out interface{}) erro
return s.postErrs[p]
}

func (s *fakeSession) Errors(_ context.Context) ([]*ixweb.Error, error) {
return nil, nil
}

func (s *fakeSession) Files() files {
return s.files
}
Expand Down
Loading

0 comments on commit 343862b

Please sign in to comment.