Skip to content

Commit

Permalink
healthz parameters for cisco (#3326)
Browse files Browse the repository at this point in the history
Add healthz parameters related to Cisco IOS XR

---------

Co-authored-by: Darren Loher <[email protected]>
  • Loading branch information
karthikeya-remilla and dplore authored Oct 17, 2024
1 parent 2d9b0b5 commit bc1eec6
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func getSubCompPath(t *testing.T, dut *ondatra.DUTDevice) *tpb.Path {
}
activeRP := controllerCards[0]
if len(controllerCards) == 2 {
_, activeRP = components.FindStandbyRP(t, dut, controllerCards)
_, activeRP = components.FindStandbyControllerCard(t, dut, controllerCards)
}
useNameOnly := deviations.GNOISubcomponentPath(dut)
return components.GetSubcomponentPath(activeRP, useNameOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,31 @@ import (
"testing"
"time"

comps "github.com/openconfig/featureprofiles/internal/components"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/system"
hpb "github.com/openconfig/gnoi/healthz"
spb "github.com/openconfig/gnoi/system"
tpb "github.com/openconfig/gnoi/types"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi/oc"
)

var (
processName = map[ondatra.Vendor]string{
ondatra.NOKIA: "sr_qos_mgr",
ondatra.ARISTA: "IpRib",
ondatra.JUNIPER: "rpd",
ondatra.CISCO: "ifmgr",
}
components = map[ondatra.Vendor]string{
ondatra.ARISTA: "Chassis",
ondatra.CISCO: "Chassis",
ondatra.CISCO: "Rack 0",
ondatra.JUNIPER: "CHASSIS0",
ondatra.NOKIA: "Chassis",
}
componentName = map[string]string{}
)

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -86,9 +91,29 @@ func TestCopyingDebugFiles(t *testing.T) {
t.Logf("Wait 60 seconds for process to restart ...")
time.Sleep(60 * time.Second)

componentName := map[string]string{"name": components[dut.Vendor()]}
ccList := comps.FindComponentsByType(t, dut, oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_CONTROLLER_CARD)
t.Logf("Found CONTROLLER_CARD list: %v", ccList)
var activeCC string
if deviations.ChassisGetRPCUnsupported(dut) {
if len(ccList) < 2 {
switch dut.Vendor() {
case ondatra.CISCO:
activeCC = "0/RP0/CPU0"
}
} else {
standbyControllerName, activeControllerName := comps.FindStandbyControllerCard(t, dut, ccList)
t.Logf("Standby RP: %v, Active RP: %v", standbyControllerName, activeControllerName)
activeCC = activeControllerName
}
componentName = map[string]string{"name": activeCC + "-" + processName[dut.Vendor()]} // example: 0/RP0/CPU0-ifmgr
} else {
componentName = map[string]string{"name": components[dut.Vendor()]}
}
t.Logf("Component Name: %v", componentName)

req := &hpb.GetRequest{
Path: &tpb.Path{
Origin: "openconfig",
Elem: []*tpb.PathElem{
{
Name: "components",
Expand All @@ -106,10 +131,10 @@ func TestCopyingDebugFiles(t *testing.T) {
case ondatra.ARISTA:
t.Log("Skip logging validResponse for Arista")
default:
t.Logf("Response: %v", (validResponse))
t.Logf("Response: %v", validResponse)
}
if err != nil {
t.Fatalf("Unexpected error on healthz get response after restart of %v: %v", processName[dut.Vendor()], err)
t.Errorf("Unexpected error on healthz get response after restart of %v: %v", processName[dut.Vendor()], err)
}
}

Expand All @@ -120,6 +145,7 @@ func TestChassisComponentArtifacts(t *testing.T) {
// Execute Healthz Check RPC for the chassis component.
chkReq := &hpb.CheckRequest{
Path: &tpb.Path{
Origin: "openconfig",
Elem: []*tpb.PathElem{
{
Name: "components",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ uuid: "3265de19-8fb8-4b0c-8a71-a75df008aa61"
plan_id: "gNOI-5.3"
description: "Copying Debug Files"
testbed: TESTBED_DUT_ATE_2LINKS
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
chassis_get_rpc_unsupported: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestStandbyControllerCardReboot(t *testing.T) {
t.Skipf("Not enough controller cards for the test on %v: got %v, want at least %v", dut.Model(), got, want)
}

rpStandby, rpActive := components.FindStandbyRP(t, dut, controllerCards)
rpStandby, rpActive := components.FindStandbyControllerCard(t, dut, controllerCards)
t.Logf("Detected rpStandby: %v, rpActive: %v", rpStandby, rpActive)

gnoiClient := dut.RawAPIs().GNOI(t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestSupervisorSwitchover(t *testing.T) {
t.Skipf("Not enough controller cards for the test on %v: got %v, want at least %v", dut.Model(), got, want)
}

rpStandbyBeforeSwitch, rpActiveBeforeSwitch := components.FindStandbyRP(t, dut, controllerCards)
rpStandbyBeforeSwitch, rpActiveBeforeSwitch := components.FindStandbyControllerCard(t, dut, controllerCards)
t.Logf("Detected rpStandby: %v, rpActive: %v", rpStandbyBeforeSwitch, rpActiveBeforeSwitch)

switchoverReady := gnmi.OC().Component(rpActiveBeforeSwitch).SwitchoverReady()
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestSupervisorSwitchover(t *testing.T) {
}
t.Logf("RP switchover time: %.2f seconds", time.Since(startSwitchover).Seconds())

rpStandbyAfterSwitch, rpActiveAfterSwitch := components.FindStandbyRP(t, dut, controllerCards)
rpStandbyAfterSwitch, rpActiveAfterSwitch := components.FindStandbyControllerCard(t, dut, controllerCards)
t.Logf("Found standbyRP after switchover: %v, activeRP: %v", rpStandbyAfterSwitch, rpActiveAfterSwitch)

if got, want := rpActiveAfterSwitch, rpStandbyBeforeSwitch; got != want {
Expand Down
18 changes: 9 additions & 9 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ func (y Y) FindByType(ctx context.Context, want oc.Component_Type_Union) ([]stri
return names, nil
}

// FindStandbyRP gets a list of two components and finds out the active and standby rp.
func FindStandbyRP(t *testing.T, dut *ondatra.DUTDevice, supervisors []string) (string, string) {
var activeRP, standbyRP string
// FindStandbyControllerCard gets a list of two components and finds out the active and standby controller_cards.
func FindStandbyControllerCard(t *testing.T, dut *ondatra.DUTDevice, supervisors []string) (string, string) {
var activeCC, standbyCC string
for _, supervisor := range supervisors {
watch := gnmi.Watch(t, dut, gnmi.OC().Component(supervisor).RedundantRole().State(), 10*time.Minute, func(val *ygnmi.Value[oc.E_Platform_ComponentRedundantRole]) bool {
return val.IsPresent()
Expand All @@ -184,19 +184,19 @@ func FindStandbyRP(t *testing.T, dut *ondatra.DUTDevice, supervisors []string) (
role := gnmi.Get(t, dut, gnmi.OC().Component(supervisor).RedundantRole().State())
t.Logf("Component(supervisor).RedundantRole().Get(t): %v, Role: %v", supervisor, role)
if role == standbyController {
standbyRP = supervisor
standbyCC = supervisor
} else if role == activeController {
activeRP = supervisor
activeCC = supervisor
} else {
t.Fatalf("Expected controller %s to be active or standby, got %v", supervisor, role)
}
}
if standbyRP == "" || activeRP == "" {
t.Fatalf("Expected non-empty activeRP and standbyRP, got activeRP: %v, standbyRP: %v", activeRP, standbyRP)
if standbyCC == "" || activeCC == "" {
t.Fatalf("Expected non-empty activeCC and standbyCC, got activeCC: %v, standbyCC: %v", activeCC, standbyCC)
}
t.Logf("Detected activeRP: %v, standbyRP: %v", activeRP, standbyRP)
t.Logf("Detected activeCC: %v, standbyCC: %v", activeCC, standbyCC)

return standbyRP, activeRP
return standbyCC, activeCC
}

// OpticalChannelComponentFromPort finds the optical channel component for a port.
Expand Down
5 changes: 5 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1171,3 +1171,8 @@ func EthChannelIngressParametersUnsupported(dut *ondatra.DUTDevice) bool {
func EthChannelAssignmentCiscoNumbering(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetEthChannelAssignmentCiscoNumbering()
}

// ChassisGetRPCUnsupported returns true if a Healthz Get RPC against the Chassis component is unsupported
func ChassisGetRPCUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetChassisGetRpcUnsupported()
}
2 changes: 2 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ message Metadata {
bool eth_channel_assignment_cisco_numbering = 223;
// Devices needs time to update interface counters.
bool interface_counters_update_delayed = 224;
// device does not support a Healthz GET RPC against Chassis level component like "CHASSIS" or "Rack 0"
bool chassis_get_rpc_unsupported = 225;
// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19, 36, 35, 40, 173;
}
Expand Down
21 changes: 17 additions & 4 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 bc1eec6

Please sign in to comment.