Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gNMI-1.4 to validate subcomponents paths. #3132

Merged
4 changes: 4 additions & 0 deletions feature/platform/tests/telemetry_inventory_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ paths:
platform_type: ["SENSOR"]
/components/component/state/temperature/max-time:
platform_type: ["SENSOR"]
/components/component/subcomponents/subcomponent/name:
platform_type: ["CHASSIS", "CONTROLLER_CARD", "CPU", "FABRIC", "FAN", "FAN_TRAY", "INTEGRATED_CIRCUIT", "LINECARD", "POWER_SUPPLY", "SENSOR", "STORAGE", "TRANSCEIVER"]
/components/component/subcomponents/subcomponent/state/name:
platform_type: ["CHASSIS", "CONTROLLER_CARD", "CPU", "FABRIC", "FAN", "FAN_TRAY", "INTEGRATED_CIRCUIT", "LINECARD", "POWER_SUPPLY", "SENSOR", "STORAGE", "TRANSCEIVER"]
/components/component/integrated-circuit/backplane-facing-capacity/state/available-pct:
platform_type: ["INTEGRATED_CIRCUIT"]
/components/component/integrated-circuit/backplane-facing-capacity/state/consumed-capacity:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ func TestMain(m *testing.M) {
// - integrated-circuit/backplane-facing-capacity/state/consumed-capacity
// - integrated-circuit/backplane-facing-capacity/state/total
// - integrated-circuit/backplane-facing-capacity/state/total-operational-capacity
// - components/component/subcomponents/subcomponent/name
// - components/component/subcomponents/subcomponent/state/name
// - Transceiver
// - Storage
// - Validate telemetry /components/component/storage exists.
Expand Down Expand Up @@ -577,6 +579,26 @@ func TestControllerCardEmpty(t *testing.T) {
}
}

// validateSubcomponentsExistAsComponents checks that if the given component has subcomponents, that
// those subcomponents exist as components on the device (i.e. the leafref is valid).
func validateSubcomponentsExistAsComponents(c *oc.Component, components []*oc.Component, t *testing.T) {
// Note that this will get the subcomponents regardless of whether they are stored in
// subcomponent/name or subcomponent/state/name.
for _, s := range c.Subcomponent {
sName := s.GetName()
if sName != "" {
for _, component := range components {
if component.GetName() == sName {
continue
}
}
t.Errorf("Subcomponent %s not found in list of components", sName)
} else {
t.Errorf("Component %s has empty subcomponent name", c.GetName())
}
}
}

func ValidateComponentState(t *testing.T, dut *ondatra.DUTDevice, cards []*oc.Component, p properties) {
var validCards []*oc.Component
switch p.pType {
Expand All @@ -601,6 +623,7 @@ func ValidateComponentState(t *testing.T, dut *ondatra.DUTDevice, cards []*oc.Co
}
cName := card.GetName()
t.Run(cName, func(t *testing.T) {
validateSubcomponentsExistAsComponents(card, validCards, t)
if p.descriptionValidation {
t.Logf("Component %s Description: %s", cName, card.GetDescription())
if card.GetDescription() == "" {
Expand Down
Loading