Skip to content

Commit

Permalink
gNOI-3.4: fix gnoi path for component and reboot status with empty su…
Browse files Browse the repository at this point in the history
…bcomponent (openconfig#717)

* add InterfaceOperStatus deviation

* Revert "add InterfaceOperStatus deviation"

This reverts commit f9855b4.

* status test is passing

* fix gnoi path and subcomponent name for reboot status
  • Loading branch information
mojiiba authored and singh-prem committed Dec 13, 2022
1 parent ae43b1c commit 6e0223e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ import (
"context"
"testing"

"github.com/openconfig/featureprofiles/internal/components"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
spb "github.com/openconfig/gnoi/system"
tpb "github.com/openconfig/gnoi/types"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/telemetry"
)

const (
Expand Down Expand Up @@ -83,6 +87,16 @@ func TestRebootStatus(t *testing.T) {
},
}

statusReq := &spb.RebootStatusRequest{Subcomponents: []*tpb.Path{}}
if !*deviations.GNOIStatusWithEmptySubcomponent {
supervisors := components.FindComponentsByType(t, dut, telemetry.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_CONTROLLER_CARD)
// the test reboots the chasis, so any subcomponent should be ok to check the status
statusReq = &spb.RebootStatusRequest{
Subcomponents: []*tpb.Path{
components.GetSubcomponentPath(supervisors[0]),
},
}
}
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
if tc.rebootRequest != nil {
Expand All @@ -93,8 +107,7 @@ func TestRebootStatus(t *testing.T) {
t.Fatalf("Failed to request reboot with unexpected err: %v", err)
}
}

resp, err := gnoiClient.System().RebootStatus(context.Background(), &spb.RebootStatusRequest{})
resp, err := gnoiClient.System().RebootStatus(context.Background(), statusReq)
t.Logf("DUT rebootStatus: %v, err: %v", resp, err)
if err != nil {
t.Fatalf("Failed to get reboot status with unexpected err: %v", err)
Expand All @@ -117,6 +130,7 @@ func TestRebootStatus(t *testing.T) {
})

t.Logf("Cancel reboot request after the test")

rebootCancel, err := gnoiClient.System().CancelReboot(context.Background(), &spb.CancelRebootRequest{})
if err != nil {
t.Fatalf("Failed to cancel reboot with unexpected err: %v", err)
Expand Down Expand Up @@ -149,8 +163,17 @@ func TestCancelReboot(t *testing.T) {
if err != nil {
t.Fatalf("Failed to request reboot with unexpected err: %v", err)
}

rebootStatus, err := gnoiClient.System().RebootStatus(context.Background(), &spb.RebootStatusRequest{})
statusReq := &spb.RebootStatusRequest{Subcomponents: []*tpb.Path{}}
if !*deviations.GNOIStatusWithEmptySubcomponent {
supervisors := components.FindComponentsByType(t, dut, telemetry.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_CONTROLLER_CARD)
// the test reboots the chasis, so any subcomponent should be ok to check the status
statusReq = &spb.RebootStatusRequest{
Subcomponents: []*tpb.Path{
components.GetSubcomponentPath(supervisors[0]),
},
}
}
rebootStatus, err := gnoiClient.System().RebootStatus(context.Background(), statusReq)
t.Logf("DUT rebootStatus: %v, err: %v", rebootStatus, err)
if err != nil {
t.Fatalf("Failed to get reboot status with unexpected err: %v", err)
Expand All @@ -166,7 +189,7 @@ func TestCancelReboot(t *testing.T) {
t.Fatalf("Failed to cancel reboot with unexpected err: %v", err)
}

rebootStatus, err = gnoiClient.System().RebootStatus(context.Background(), &spb.RebootStatusRequest{})
rebootStatus, err = gnoiClient.System().RebootStatus(context.Background(), statusReq)
t.Logf("DUT rebootStatus: %v, err: %v", rebootStatus, err)
if err != nil {
t.Fatalf("Failed to get reboot status with unexpected err: %v", err)
Expand Down
18 changes: 18 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"regexp"
"testing"

"github.com/openconfig/featureprofiles/internal/deviations"
tpb "github.com/openconfig/gnoi/types"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/telemetry"
)
Expand Down Expand Up @@ -57,3 +59,19 @@ func FindMatchingStrings(components []string, r *regexp.Regexp) []string {
}
return s
}

// GetSubcomponentPath creates a gNMI path based on the componnent name.
func GetSubcomponentPath(name string) *tpb.Path {
if *deviations.GNOISubcomponentPath {
return &tpb.Path{
Elem: []*tpb.PathElem{{Name: name}},
}
}
return &tpb.Path{
Origin: "openconfig",
Elem: []*tpb.PathElem{
{Name: "components"},
{Name: "component", Key: map[string]string{"name": name}},
},
}
}
4 changes: 4 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,9 @@ var (

StaticProtocolName = flag.String("deviation_static_protocol_name", "DEFAULT", "The name used for the static routing protocol. The default name in OpenConfig is \"DEFAULT\" but some devices use other names.")

GNOISubcomponentPath = flag.Bool("deviation_gnoi_subcomponent_path", false, "Device currently uses component name instead of a full openconfig path, so suppress creating a full oc compliant path for subcomponent.")

GNOIStatusWithEmptySubcomponent = flag.Bool("deviation_gnoi_status_empty_subcomponent", false, "The response of gNOI reboot status is a single value (not a list), so the device requires explict component path to account for a situation when there is more than one active reboot requests.")

DeprecatedVlanID = flag.Bool("deviation_deprecated_vlan_id", false, "Device requires using the deprecated openconfig-vlan:vlan/config/vlan-id or openconfig-vlan:vlan/state/vlan-id leaves.")
)

0 comments on commit 6e0223e

Please sign in to comment.