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-destination365152443147607246/.
  • Loading branch information
GGN Engprod Team authored and greg-dennis committed Jun 15, 2023
1 parent 8263c56 commit 0ac4563
Show file tree
Hide file tree
Showing 6 changed files with 45,071 additions and 44,989 deletions.
89,950 changes: 44,973 additions & 44,977 deletions gnmi/oc/schema.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/google/go-cmp v0.5.9
github.com/jstemmer/go-junit-report/v2 v2.0.1-0.20220823220451-7b10b4285462
github.com/open-traffic-generator/snappi/gosnappi v0.11.14
github.com/openconfig/entity-naming v0.0.0-20230614015924-e45e47aa9067
github.com/openconfig/entity-naming v0.0.0-20230615134154-46b7e6d34924
github.com/openconfig/gnmi v0.9.1
github.com/openconfig/gnoi v0.0.0-20230221223856-1727ed932554
github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,8 @@ github.com/open-traffic-generator/ixia-c-operator v0.3.0 h1:DFINZYbM9MLNnKvi2+Bg
github.com/open-traffic-generator/ixia-c-operator v0.3.0/go.mod h1:Q+ZXCinXxUKcnrJf5PJC1Q7JxUQc5ZPZA85jwVAqIRQ=
github.com/open-traffic-generator/snappi/gosnappi v0.11.14 h1:AuD13HqZldjtPWvDKaXVDRZ+32Aol5QJCepEqTiukqM=
github.com/open-traffic-generator/snappi/gosnappi v0.11.14/go.mod h1:CRT6BypHa7NOrNlrjw3Crcs9f7eLC4S34ERvyyGIusY=
github.com/openconfig/entity-naming v0.0.0-20230614015924-e45e47aa9067 h1:/SgRsN+wdpKqnuQYEl9dSoSB8vT2TvyP2LyycK49LHU=
github.com/openconfig/entity-naming v0.0.0-20230614015924-e45e47aa9067/go.mod h1:ZRUrfwYYY+pLaOoWPad3p/8J4LLQcSqtXhBCkD2pXJc=
github.com/openconfig/entity-naming v0.0.0-20230615134154-46b7e6d34924 h1:Flw2W/S6peYe4uP1cC/b0gjKRJtNE7++kTVelEaDGxE=
github.com/openconfig/entity-naming v0.0.0-20230615134154-46b7e6d34924/go.mod h1:ZRUrfwYYY+pLaOoWPad3p/8J4LLQcSqtXhBCkD2pXJc=
github.com/openconfig/gnmi v0.0.0-20200414194230-1597cc0f2600/go.mod h1:M/EcuapNQgvzxo1DDXHK4tx3QpYM/uG4l591v33jG2A=
github.com/openconfig/gnmi v0.0.0-20200508230933-d19cebf5e7be/go.mod h1:M/EcuapNQgvzxo1DDXHK4tx3QpYM/uG4l591v33jG2A=
github.com/openconfig/gnmi v0.9.1 h1:hVOdLTaRjdy68oCGJbkf2vrmnUoQ5xbINqBOAMix4xM=
Expand Down
41 changes: 33 additions & 8 deletions netutil/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,25 @@ func loopbackInterface(dut dutIntf, id int) (string, error) {
return entname.LoopbackInterface(dev, id)
}

// NextBundleInterface returns the aggregate interface with the lowest non-zero
// index that, according to the device's telemetry, is not yet configured.
// Deprecated: Use NextAggregateInterface instead.
func NextBundleInterface(t *testing.T, dut *ondatra.DUTDevice) string {
// AggregateInterface returns the vendor-specific name of the aggregate interface with
// the specified zero-based index.
func AggregateInterface(t *testing.T, dut *ondatra.DUTDevice, index int) string {
t.Helper()
batch := gnmi.OCBatch()
batch.AddPaths(gnmi.OC().InterfaceAny().Aggregation())
name, err := nextAggregateInterface(dut, gnmi.Lookup(t, dut, batch.State()))
name, err := aggregateInterface(dut, index)
if err != nil {
t.Fatalf("NextBundleInterface(t, %s): %v", dut.Name(), err)
t.Fatalf("AggregateInterface(t, %s, %d): %v", dut.Name(), index, err)
}
return name
}

func aggregateInterface(dut dutIntf, id int) (string, error) {
dev, err := deviceParams(dut)
if err != nil {
return "", err
}
return entname.AggregateInterface(dev, id)
}

// NextAggregateInterface returns the aggregate interface with the lowest
// non-zero index that according to the dut's telemetry is not yet configured.
func NextAggregateInterface(t *testing.T, dut *ondatra.DUTDevice) string {
Expand Down Expand Up @@ -91,6 +96,26 @@ func nextAggregateInterface(dut dutIntf, currAggsRoot *ygnmi.Value[*oc.Root]) (s
}
}

// CommonTrafficQueues returns the vendors-specific names of common traffic
// class queues. See the definition of common queues here:
// https://github.com/openconfig/entity-naming/blob/main/README.md#traffic-queues
func CommonTrafficQueues(t *testing.T, dut *ondatra.DUTDevice) *entname.CommonTrafficQueueNames {
t.Helper()
ctq, err := commonTrafficQueues(dut)
if err != nil {
t.Fatalf("CommonTrafficQueues(t, %s): %v", dut.Name(), err)
}
return ctq
}

func commonTrafficQueues(dut dutIntf) (*entname.CommonTrafficQueueNames, error) {
dev, err := deviceParams(dut)
if err != nil {
return nil, err
}
return entname.CommonTrafficQueues(dev)
}

var namingVendors map[ondatra.Vendor]entname.Vendor = map[ondatra.Vendor]entname.Vendor{
ondatra.ARISTA: entname.VendorArista,
ondatra.CISCO: entname.VendorCisco,
Expand Down
52 changes: 52 additions & 0 deletions netutil/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,58 @@ func TestLoopbackInterface(t *testing.T) {
}
}

func TestAggregateInterface(t *testing.T) {
tests := []struct {
desc string
vendor ondatra.Vendor
num int
want string
wantErr string
}{{
desc: "arista",
vendor: ondatra.ARISTA,
num: 1,
want: "Port-Channel2",
}, {
desc: "cisco",
vendor: ondatra.CISCO,
num: 2,
want: "Bundle-Ether3",
}, {
desc: "juniper",
vendor: ondatra.JUNIPER,
num: 0,
want: "ae0",
}, {
desc: "nokia",
vendor: ondatra.NOKIA,
num: 4,
want: "lag5",
}, {
desc: "not supported",
vendor: ondatra.IXIA,
wantErr: "not supported",
}, {
desc: "negative index",
vendor: ondatra.ARISTA,
num: -3,
wantErr: "negative",
}}

for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
dut := &fakeDUT{vendor: test.vendor}
got, err := aggregateInterface(dut, test.num)
if (err == nil) != (test.wantErr == "") || (err != nil && !strings.Contains(err.Error(), test.wantErr)) {
t.Errorf("aggregateInterface got err %v, want %s", err, test.wantErr)
}
if got != test.want {
t.Errorf("aggregateInterface got %s, want %s", got, test.want)
}
})
}
}

func TestNextAggregateInterface(t *testing.T) {
tests := []struct {
desc string
Expand Down
11 changes: 10 additions & 1 deletion ondatra.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ var sigc = make(chan os.Signal, 1)
func RunTests(m *testing.M, newBindFn func() (binding.Binding, error)) {
// Careful to only exit at the very end, because exiting skips all pending defers.
if err := runTests(m.Run, newBindFn); err != nil {
log.Exit(err)
// If runTests returns an error, no test cases will be executed and the XML
// result file will be empty. To avoid user confusion over empty XML
// results, print the output of a fake TestMain test case, so that the
// failure will be elevated to the XML, not merely hidden in the test log.
// TODO(team): Consider unconditionally printing a TestMain test case
// with the time until reservation to enable the Ondatra test timing report.
fmt.Println("=== RUN TestMain")
fmt.Printf(" %v\n", err)
fmt.Println("--- FAIL: TestMain (0.00s)")
log.Exit()
}
}

Expand Down

0 comments on commit 0ac4563

Please sign in to comment.