Skip to content

Commit

Permalink
apply GNOISubcomponentPath deviation to related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mojiiba committed Dec 7, 2022
1 parent 08889fc commit dfb6d01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func TestMain(m *testing.M) {

func TestStandbyControllerCardReboot(t *testing.T) {
dut := ondatra.DUT(t, "dut")

supervisors := components.FindComponentsByType(t, dut, controlcardType)
t.Logf("Found supervisor list: %v", supervisors)
// Only perform the standby RP rebooting for the chassis with dual RPs/Supervisors.
Expand All @@ -95,9 +94,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 @@ -151,9 +148,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 @@ -20,12 +20,12 @@ import (
"time"

"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 @@ -78,7 +78,6 @@ func TestSupervisorSwitchover(t *testing.T) {
if got, want := len(supervisors), 2; got != want {
t.Skipf("Dual RP/SUP is required on %v: got %v, want %v", dut.Model(), got, want)
}

rpStandbyBeforeSwitch, rpActiveBeforeSwitch := findStandbyRP(t, dut, supervisors)
t.Logf("Detected rpStandby: %v, rpActive: %v", rpStandbyBeforeSwitch, rpActiveBeforeSwitch)

Expand All @@ -97,9 +96,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 @@ -109,7 +106,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

0 comments on commit dfb6d01

Please sign in to comment.