Skip to content

Commit

Permalink
gNMI-1.15: gnmi_set_test.go : Added deviation (openconfig#2328)
Browse files Browse the repository at this point in the history
* updated gnmisettest

* Resolving conflicts

* Restored version in metadata.pb.go

* Resolving conflicts

* Resolving conflicts

* updated with deviation

* Resolving conflicts

* Resolving conflicts

* Added deviation back

* Resolved conflicts

* Resolved conflicts

* Updated the verification under the deviation skipStaticNexthopCheck to use wildcard for index instead of specific index

* Updated variable assignment

* Resolving conflicts

* Resolving conflicts

* Resolved conflicts

* Updated code to get AE index

* updated with testbed

* resolved conflicts

* fixed spacing

* fixed spacing

* fixed spacing

* Resolving conclifts

* resolving conflicts

---------

Co-authored-by: mohanasm <[email protected]>
Co-authored-by: Arul Kumar Sekar <[email protected]>
  • Loading branch information
3 people authored Dec 28, 2023
1 parent 9181594 commit f59b129
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 41 deletions.
5 changes: 5 additions & 0 deletions feature/system/gnmi/set/tests/gnmi_set_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

Ensures that the device respects certain gNMI SetRequest corner case behaviors.

## Topology

* ATE port-1 and DUT port-1
* ATE port-2 and DUT port-2

## Procedure

Each test should be implemented as three variants:
Expand Down
68 changes: 65 additions & 3 deletions feature/system/gnmi/set/tests/gnmi_set_test/gnmi_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,29 @@ func TestDeleteInterface(t *testing.T) {

config.DeleteInterface(p1.Name())
config.DeleteInterface(p2.Name())

for _, iname := range scope.interfaces {
iface := config.GetInterface(iname)
if iface == nil {
config.Interface = nil

}
}

op.push(t, dut, config, scope)

t.Run("VerifyAfterDelete", func(t *testing.T) {
if v := gnmi.Lookup(t, dut, q1); v.IsPresent() {
t.Errorf("State got unwanted %v", v)
value, _ := v.Val()
if value != "" {
t.Errorf("State got unwanted %v", v)
}
}
if v := gnmi.Lookup(t, dut, q2); v.IsPresent() {
t.Errorf("State got unwanted %v", v)
value, _ := v.Val()
if value != "" {
t.Errorf("State got unwanted %v", v)
}
}
})
})
Expand Down Expand Up @@ -504,12 +519,32 @@ func TestStaticProtocol(t *testing.T) {
verifyInterface(t, dut, p2.Name(), &ip2)

v1 := gnmi.Lookup(t, dut, q1)
if deviations.SkipStaticNexthopCheck(dut) {

q2 := sp.Static(prefix1).NextHopAny().InterfaceRef().Interface().State()
val := gnmi.LookupAll(t, dut, q2)
if len(val) > 0 {
v1 = val[0]
} else {
t.Fatalf("Did not receive output for static nexthop lookup")
}
}
if got, ok := v1.Val(); !ok || got != p1.Name() {
t.Errorf("State got %v, want %v", v1, p1.Name())
} else {
t.Logf("Verified %v", v1)
}
v2 := gnmi.Lookup(t, dut, q2)
if deviations.SkipStaticNexthopCheck(dut) {

q3 := sp.Static(prefix2).NextHopAny().InterfaceRef().Interface().State()
val := gnmi.LookupAll(t, dut, q3)
if len(val) > 0 {
v2 = val[0]
} else {
t.Fatalf("Did not receive output for static nexthop lookup")
}
}
if got, ok := v2.Val(); !ok || got != p2.Name() {
t.Errorf("State got %v, want %v", v2, p2.Name())
} else {
Expand All @@ -531,12 +566,32 @@ func TestStaticProtocol(t *testing.T) {
verifyInterface(t, dut, p2.Name(), &ip2)

v1 := gnmi.Lookup(t, dut, q1)
if deviations.SkipStaticNexthopCheck(dut) {

q2 := sp.Static(prefix1).NextHopAny().InterfaceRef().Interface().State()
val := gnmi.LookupAll(t, dut, q2)
if len(val) > 0 {
v1 = val[0]
} else {
t.Fatalf("Did not receive output for static nexthop lookup")
}
}
if got, ok := v1.Val(); !ok || got != p2.Name() {
t.Errorf("State got %v, want %v", v1, p2.Name())
} else {
t.Logf("Verified %v", v1)
}
v2 := gnmi.Lookup(t, dut, q2)
if deviations.SkipStaticNexthopCheck(dut) {

q3 := sp.Static(prefix2).NextHopAny().InterfaceRef().Interface().State()
val := gnmi.LookupAll(t, dut, q3)
if len(val) > 0 {
v2 = val[0]
} else {
t.Fatalf("Did not receive output for static nexthop lookup")
}
}
if got, ok := v2.Val(); !ok || got != p1.Name() {
t.Errorf("State got %v, want %v", v2, p1.Name())
} else {
Expand Down Expand Up @@ -581,7 +636,13 @@ func nextAggregates(t *testing.T, dut *ondatra.DUTDevice, n int) []string {
agg := numRE.ReplaceAllStringFunc(firstAgg, func(_ string) string {
return strconv.Itoa(i)
})
aggs = append(aggs, agg)
//some aggregate interface after firstAgg may already be present in the system.
_, present := gnmi.Lookup(t, dut, gnmi.OC().Interface(agg).Name().State()).Val()
if !present {
aggs = append(aggs, agg)
} else {
n++
}
}
return aggs
}
Expand Down Expand Up @@ -648,6 +709,7 @@ func attachInterface(ni *oc.NetworkInstance, name string, sub int) string {
niface := ni.GetOrCreateInterface(id)
niface.Interface = ygot.String(name)
niface.Subinterface = ygot.Uint32(uint32(sub))
id = fmt.Sprintf("%s.%d", id, sub)
return id
}

Expand Down
12 changes: 10 additions & 2 deletions feature/system/gnmi/set/tests/gnmi_set_test/metadata.textproto
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# proto-file: github.com/openconfig/featureprofiles/proto/metadata.proto
# proto-message: Metadata

uuid: "fe01cad6-6775-45cd-a025-d960ca6c04af"
uuid: "e50991a4-bb40-4162-8a86-717e68e10680"
plan_id: "gNMI-1.15"
description: "Set Requests"
testbed: TESTBED_DUT
testbed: TESTBED_DUT_ATE_2LINKS
platform_exceptions: {
platform: {
vendor: CISCO
Expand All @@ -13,6 +13,14 @@ platform_exceptions: {
ipv4_missing_enabled: true
}
}
platform_exceptions: {
platform: {
vendor: JUNIPER
}
deviations: {
skip_static_nexthop_check: true
}
}
platform_exceptions: {
platform: {
vendor: ARISTA
Expand Down
5 changes: 5 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,3 +725,8 @@ func ISISMetricStyleTelemetryUnsupported(dut *ondatra.DUTDevice) bool {
func StaticRouteNextHopInterfaceRefUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetStaticRouteNextHopInterfaceRefUnsupported()
}

// SkipStaticNexthopCheck returns if device needs index starting from non zero
func SkipStaticNexthopCheck(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetSkipStaticNexthopCheck()
}
3 changes: 3 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ message Metadata {
bool isis_metric_style_telemetry_unsupported = 134;
// Devices do not support configuring Interface-ref under Static-Route Next-Hop
bool static_route_next_hop_interface_ref_unsupported = 135;
// Devices which does not support nexthop index state
// Juniper: b/304729237
bool skip_static_nexthop_check = 136;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19;
Expand Down
86 changes: 50 additions & 36 deletions proto/metadata_go_proto/metadata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f59b129

Please sign in to comment.