Skip to content

Commit

Permalink
Apply GNOISubcomponentPath deviation to the related tests (#853)
Browse files Browse the repository at this point in the history
* apply GNOISubcomponentPath deviation to related tests

* gofmt
  • Loading branch information
mojiiba authored Jan 5, 2023
1 parent 635bad7 commit 5cfe4dc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ func TestStandbyControllerCardReboot(t *testing.T) {
rebootSubComponentRequest := &spb.RebootRequest{
Method: spb.RebootMethod_COLD,
Subcomponents: []*tpb.Path{
{
Elem: []*tpb.PathElem{{Name: rpStandby}},
},
components.GetSubcomponentPath(rpStandby),
},
}

Expand Down Expand Up @@ -161,9 +159,7 @@ func TestLinecardReboot(t *testing.T) {
rebootSubComponentRequest := &spb.RebootRequest{
Method: spb.RebootMethod_COLD,
Subcomponents: []*tpb.Path{
{
Elem: []*tpb.PathElem{{Name: removableLinecard}},
},
components.GetSubcomponentPath(removableLinecard),
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (

"github.com/openconfig/featureprofiles/internal/args"
"github.com/openconfig/featureprofiles/internal/components"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/ondatra"
"github.com/openconfig/testt"

spb "github.com/openconfig/gnoi/system"
tpb "github.com/openconfig/gnoi/types"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ygnmi/ygnmi"
Expand Down Expand Up @@ -102,9 +102,7 @@ func TestSupervisorSwitchover(t *testing.T) {

gnoiClient := dut.RawAPIs().GNOI().New(t)
switchoverRequest := &spb.SwitchControlProcessorRequest{
ControlProcessor: &tpb.Path{
Elem: []*tpb.PathElem{{Name: rpStandbyBeforeSwitch}},
},
ControlProcessor: components.GetSubcomponentPath(rpStandbyBeforeSwitch),
}
t.Logf("switchoverRequest: %v", switchoverRequest)
switchoverResponse, err := gnoiClient.System().SwitchControlProcessor(context.Background(), switchoverRequest)
Expand All @@ -114,7 +112,13 @@ func TestSupervisorSwitchover(t *testing.T) {
t.Logf("gnoiClient.System().SwitchControlProcessor() response: %v, err: %v", switchoverResponse, err)

want := rpStandbyBeforeSwitch
if got := switchoverResponse.GetControlProcessor().GetElem()[0].GetName(); got != want {
got := ""
if *deviations.GNOISubcomponentPath {
got = switchoverResponse.GetControlProcessor().GetElem()[0].GetName()
} else {
got = switchoverResponse.GetControlProcessor().GetElem()[1].GetKey()["name"]
}
if got != want {
t.Fatalf("switchoverResponse.GetControlProcessor().GetElem()[0].GetName(): got %v, want %v", got, want)
}
if got, want := switchoverResponse.GetVersion(), ""; got == want {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/openconfig/ygot/ygot"

spb "github.com/openconfig/gnoi/system"
tpb "github.com/openconfig/gnoi/types"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ygnmi/ygnmi"
Expand Down Expand Up @@ -332,9 +331,7 @@ func TestSupFailure(t *testing.T) {

gnoiClient := dut.RawAPIs().GNOI().Default(t)
switchoverRequest := &spb.SwitchControlProcessorRequest{
ControlProcessor: &tpb.Path{
Elem: []*tpb.PathElem{{Name: secondaryBeforeSwitch}},
},
ControlProcessor: cmp.GetSubcomponentPath(secondaryBeforeSwitch),
}
t.Logf("switchoverRequest: %v", switchoverRequest)
switchoverResponse, err := gnoiClient.System().SwitchControlProcessor(context.Background(), switchoverRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func TestGNMIMetadataAnnotation(t *testing.T) {
accompaniedPath := gnmi.OC().System().Hostname().Config().PathStruct()
accompaniedUpdateVal := gnmi.Get[string](t, dut, gnmi.OC().System().Hostname().Config())
gpbSetRequest.Update = append(gpbSetRequest.Update, buildGNMIUpdate(t, accompaniedPath, &accompaniedUpdateVal))


t.Log("gnmiClient Set metadata annotation")
if _, err = gnmiClient.Set(context.Background(), gpbSetRequest); err != nil {
Expand Down

0 comments on commit 5cfe4dc

Please sign in to comment.