Skip to content

Commit

Permalink
System-1: added p4rt capabilities deviation and fixed gnmi call (#2605)
Browse files Browse the repository at this point in the history
* added p4rt capabilities deviation and fixed gnmi call

* gofmt

* fix readme

* add gnmi_get_on_root_unsupported for cisco

* added bug ids
  • Loading branch information
kjahed authored Jan 30, 2025
1 parent 9c19507 commit b02122c
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 78 deletions.
19 changes: 19 additions & 0 deletions feature/system/tests/system_base_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,22 @@ used for mTLS.
2. Each test will then create a client to those services and valid each service is properly
listening on the standard port.
3. Validate client properly connects and execute a simple RPC to validate no errors are returned.

## OpenConfig Path and RPC Coverage

```yaml
paths:
/system/state/motd-banner:
/system/state/login-banner:
/system/state/hostname:
/system/state/current-datetime:
/system/state/boot-time:
/system/clock/state/timezone-name:

rpcs:
gnmi:
gNMI.Set:
replace: true
delete: true
gNMI.Subscribe:
```
35 changes: 32 additions & 3 deletions feature/system/tests/system_base_test/g_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"
"time"

"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/binding/introspect"
"google.golang.org/grpc"
Expand Down Expand Up @@ -58,7 +59,22 @@ func TestGNMIClient(t *testing.T) {
dut := ondatra.DUT(t, "dut")
conn := dialConn(t, dut, introspect.GNMI, 9339)
c := gpb.NewGNMIClient(conn)
if _, err := c.Get(context.Background(), &gpb.GetRequest{Encoding: gpb.Encoding_JSON_IETF, Path: []*gpb.Path{{Elem: []*gpb.PathElem{}}}}); err != nil {

var req *gpb.GetRequest
if deviations.GNMIGetOnRootUnsupported(dut) {
req = &gpb.GetRequest{
Path: []*gpb.Path{{
Elem: []*gpb.PathElem{
{Name: "system"}, {Name: "state"}, {Name: "hostname"}}},
},
Type: gpb.GetRequest_STATE,
Encoding: gpb.Encoding_JSON_IETF,
}
} else {
req = &gpb.GetRequest{Encoding: gpb.Encoding_JSON_IETF, Path: []*gpb.Path{{Elem: []*gpb.PathElem{}}}}
}

if _, err := c.Get(context.Background(), req); err != nil {
t.Fatalf("gnmi.Get failed: %v", err)
}
}
Expand Down Expand Up @@ -105,7 +121,20 @@ func TestP4RTClient(t *testing.T) {
dut := ondatra.DUT(t, "dut")
conn := dialConn(t, dut, introspect.P4RT, 9559)
c := p4rtpb.NewP4RuntimeClient(conn)
if _, err := c.Capabilities(context.Background(), &p4rtpb.CapabilitiesRequest{}); err != nil {
t.Fatalf("p4rt.Capabilites failed: %v", err)
if deviations.P4RTCapabilitiesUnsupported(dut) {
if _, err := c.Read(context.Background(), &p4rtpb.ReadRequest{
DeviceId: 1,
Entities: []*p4rtpb.Entity{
{
Entity: &p4rtpb.Entity_TableEntry{},
},
},
}); err != nil {
t.Fatalf("p4rt.Read failed: %v", err)
}
} else {
if _, err := c.Capabilities(context.Background(), &p4rtpb.CapabilitiesRequest{}); err != nil {
t.Fatalf("p4rt.Capabilites failed: %v", err)
}
}
}
9 changes: 9 additions & 0 deletions feature/system/tests/system_base_test/metadata.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ platform_exceptions: {
cli_takes_precedence_over_oc: true
}
}
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
p4rt_capabilities_unsupported: true
gnmi_get_on_root_unsupported: true
}
}
10 changes: 10 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,3 +1301,13 @@ func QosSchedulerIngressPolicer(dut *ondatra.DUTDevice) bool {
func GribiEncapHeaderUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetGribiEncapHeaderUnsupported()
}

// P4RTCapabilitiesUnsupported returns true for devices that don't support P4RT Capabilities rpc.
func P4RTCapabilitiesUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetP4RtCapabilitiesUnsupported()
}

// GNMIGetOnRootUnsupported returns true if the device does not support gNMI get on root.
func GNMIGetOnRootUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetGnmiGetOnRootUnsupported()
}
8 changes: 8 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,14 @@ message Metadata {
// Devices that do not support gRIBIencap headers.
bool gribi_encap_header_unsupported = 249;

// Device does not support P4RT Capabilities rpc.
// Cisco: b/385298158
bool p4rt_capabilities_unsupported = 250;

// Device does not support gNMI GET on root.
// Cisco: b/385298159
bool gnmi_get_on_root_unsupported = 251;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19, 36, 35, 40, 173;
}
Expand Down
Loading

0 comments on commit b02122c

Please sign in to comment.