Skip to content

Commit

Permalink
Added missing deviation and resource name for Nokia (openconfig#3305)
Browse files Browse the repository at this point in the history
* Adding missign deviations for nokia

1. Modifed to verify utilization status for all active Integrate Circuits
2. Added deviations required for Nokia
3. update Nokia Fib resource  name

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."

* Removed speed deviation

* corrected error messages
  • Loading branch information
bkreddy143 authored and ampattan committed Aug 23, 2024
1 parent fd5fd3e commit 541bb73
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ platform_exceptions: {
missing_hardware_resource_telemetry_before_config: true
}
}
platform_exceptions: {
platform: {
vendor: NOKIA
}
deviations: {
explicit_interface_in_default_vrf: true
interface_enabled: true
}
}
tags: TAGS_TRANSIT
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/open-traffic-generator/snappi/gosnappi"
"github.com/openconfig/featureprofiles/internal/attrs"
"github.com/openconfig/featureprofiles/internal/components"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/otgutils"
Expand All @@ -45,6 +46,7 @@ const (
var (
fibResource = map[ondatra.Vendor]string{
ondatra.ARISTA: "Routing/Resource6",
ondatra.NOKIA: "ip-lpm-routes",
}
dutPort1 = attrs.Attributes{
Desc: "dutPort1",
Expand Down Expand Up @@ -105,46 +107,22 @@ func TestResourceUtilization(t *testing.T) {
otgV6Peer, otgPort1, otgConfig := configureOTG(t, otg)

verifyBgpTelemetry(t, dut)

val, ok := gnmi.Watch(t, dut, gnmi.OC().System().Utilization().Resource(fibResource[dut.Vendor()]).ActiveComponentList().State(), time.Minute, func(v *ygnmi.Value[[]string]) bool {
cs, present := v.Val()
return present && len(cs) > 0
}).Await(t)
if !ok {
switch {
case deviations.MissingHardwareResourceTelemetryBeforeConfig(dut):
t.Log("FIB resource is not active in any available components")
default:
t.Fatalf("FIB resource is not active in any available components")
}
}
comps, _ := val.Val()

gnmi.Replace(t, dut, gnmi.OC().System().Utilization().Resource(fibResource[dut.Vendor()]).Config(), &oc.System_Utilization_Resource{
Name: ygot.String(fibResource[dut.Vendor()]),
UsedThresholdUpper: ygot.Uint8(usedThresholdUpper),
UsedThresholdUpperClear: ygot.Uint8(usedThresholdUpperClear),
})

val, ok = gnmi.Watch(t, dut, gnmi.OC().System().Utilization().Resource(fibResource[dut.Vendor()]).ActiveComponentList().State(), time.Minute, func(v *ygnmi.Value[[]string]) bool {
cs, present := v.Val()
return present && len(cs) > 0
}).Await(t)
if !ok {
t.Fatalf("FIB resource is not active in any available components")
}
comps, _ = val.Val()

comps := components.FindActiveComponentsByType(t, dut, oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_INTEGRATED_CIRCUIT)
beforeUtzs := componentUtilizations(t, dut, comps)
if len(beforeUtzs) != len(comps) {
t.Fatalf("Couldn't retrieve Utilization information for all Components in active-component-list")
t.Fatalf("Couldn't retrieve Utilization information for all Active Components")
}

injectBGPRoutes(t, otg, otgV6Peer, otgPort1, otgConfig)

afterUtzs := componentUtilizations(t, dut, comps)
if len(afterUtzs) != len(comps) {
t.Fatalf("Couldn't retrieve Utilization information for all Components in active-component-list")
t.Fatalf("Couldn't retrieve Utilization information for all Active Components")
}

t.Run("Utilization after BGP route installation", func(t *testing.T) {
Expand All @@ -162,7 +140,7 @@ func TestResourceUtilization(t *testing.T) {

afterClearUtzs := componentUtilizations(t, dut, comps)
if len(afterClearUtzs) != len(comps) {
t.Fatalf("Couldn't retrieve Utilization information for all Components in active-component-list")
t.Fatalf("Couldn't retrieve Utilization information for all Active Components")
}

t.Run("Utilization after BGP route clear", func(t *testing.T) {
Expand Down
22 changes: 22 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ func FindComponentsByType(t *testing.T, dut *ondatra.DUTDevice, cType oc.E_Platf
return s
}

// FindActiveComponentsByType finds the list of active components based on hardware type.
func FindActiveComponentsByType(t *testing.T, dut *ondatra.DUTDevice, cType oc.E_PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT) []string {
components := gnmi.GetAll[*oc.Component](t, dut, gnmi.OC().ComponentAny().State())
var s []string
for _, c := range components {
if c.GetType() == nil {
t.Logf("Component %s type is missing from telemetry", c.GetName())
continue
}
t.Logf("Component %s has type: %v", c.GetName(), c.GetType())
switch v := c.GetType().(type) {
case oc.E_PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT:
if v == cType && c.OperStatus == oc.PlatformTypes_COMPONENT_OPER_STATUS_ACTIVE {
s = append(s, c.GetName())
}
default:
t.Logf("Detected non-hardware component: (%T, %v)", c.GetType(), c.GetType())
}
}
return s
}

// FindSWComponentsByType finds the list of SW components based on a type.
func FindSWComponentsByType(t *testing.T, dut *ondatra.DUTDevice, cType oc.E_PlatformTypes_OPENCONFIG_SOFTWARE_COMPONENT) []string {
components := gnmi.GetAll[*oc.Component](t, dut, gnmi.OC().ComponentAny().State())
Expand Down

0 comments on commit 541bb73

Please sign in to comment.