Skip to content

Commit

Permalink
Cisco transceiver part 2: deviations (#3451)
Browse files Browse the repository at this point in the history
* cisco transceiver changes part 2

* cisco transceiver changes part 2

* variable name change

* PR errors' fix

* PR errors' fix
  • Loading branch information
karthikeya-remilla authored Sep 25, 2024
1 parent 8bd1b96 commit 5719862
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ platform_exceptions: {
missing_port_to_optical_channel_component_mapping: true
}
}
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
component_mfg_date_unsupported: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/openconfig/featureprofiles/internal/cfgplugins"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/samplestream"
"github.com/openconfig/ondatra"
Expand All @@ -13,7 +14,6 @@ import (
)

const (
dp16QAM = 1
samplingInterval = 10 * time.Second
timeout = 5 * time.Minute
waitInterval = 30 * time.Second
Expand Down Expand Up @@ -81,11 +81,13 @@ func TestInventory(t *testing.T) {
samplestream.New(t, dut, component1.SerialNo().State(), samplingInterval),
samplestream.New(t, dut, component1.PartNo().State(), samplingInterval),
samplestream.New(t, dut, component1.MfgName().State(), samplingInterval),
samplestream.New(t, dut, component1.MfgDate().State(), samplingInterval),
samplestream.New(t, dut, component1.HardwareVersion().State(), samplingInterval),
samplestream.New(t, dut, component1.FirmwareVersion().State(), samplingInterval),
// samplestream.New(t, dut1, component1.Description().State(), samplingInterval),
)
if !deviations.ComponentMfgDateUnsupported(dut) {
p1StreamsStr = append(p1StreamsStr, samplestream.New(t, dut, component1.MfgDate().State(), samplingInterval))
}
p1StreamsUnion = append(p1StreamsUnion, samplestream.New(t, dut, component1.Type().State(), samplingInterval))

verifyAllInventoryValues(t, p1StreamsStr, p1StreamsUnion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestZrSupplyVoltage(t *testing.T) {
// Disable interface
i.Enabled = ygot.Bool(false)
gnmi.Replace(t, dut, gnmi.OC().Interface(dp.Name()).Config(), i)
// Wait for the cooling off period
// Wait for the cooling-off period
gnmi.Await(t, dut, gnmi.OC().Interface(dp.Name()).OperStatus().State(), intUpdateTime, oc.Interface_OperStatus_DOWN)

volInstNew := verifyVoltageValue(t, streamInst, "Instant")
Expand All @@ -92,7 +92,7 @@ func TestZrSupplyVoltage(t *testing.T) {
// Enable interface again.
i.Enabled = ygot.Bool(true)
gnmi.Replace(t, dut, gnmi.OC().Interface(dp.Name()).Config(), i)
// Wait for the cooling off period
// Wait for the cooling-off period
gnmi.Await(t, dut, gnmi.OC().Interface(dp.Name()).OperStatus().State(), intUpdateTime, oc.Interface_OperStatus_UP)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ platform_exceptions: {
missing_zr_optical_channel_tunable_parameters_telemetry: true
}
}
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
use_parent_component_for_temperature_telemetry: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"testing"
"time"

"github.com/openconfig/featureprofiles/internal/components"
"github.com/openconfig/featureprofiles/internal/cfgplugins"
"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/fptest"
"github.com/openconfig/featureprofiles/internal/samplestream"
Expand All @@ -30,10 +30,7 @@ import (
)

const (
sensorType = oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_SENSOR
dp16QAM = 1
targetOutputPower = -10
frequency = 193500000
sensorType = oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_SENSOR
)

func TestMain(m *testing.M) {
Expand All @@ -44,19 +41,6 @@ func TestMain(m *testing.M) {
//
// dut:port1 <--> port2:dut

func interfaceConfig(t *testing.T, dut1 *ondatra.DUTDevice, dp *ondatra.Port) {
d := &oc.Root{}
i := d.GetOrCreateInterface(dp.Name())
i.Enabled = ygot.Bool(true)
i.Type = oc.IETFInterfaces_InterfaceType_ethernetCsmacd
gnmi.Replace(t, dut1, gnmi.OC().Interface(dp.Name()).Config(), i)
OCcomponent := components.OpticalChannelComponentFromPort(t, dut1, dp)
gnmi.Replace(t, dut1, gnmi.OC().Component(OCcomponent).OpticalChannel().Config(), &oc.Component_OpticalChannel{
TargetOutputPower: ygot.Float64(targetOutputPower),
Frequency: ygot.Uint64(frequency),
})
}

func verifyTemperatureSensorValue(t *testing.T, pStream *samplestream.SampleStream[float64], sensorName string) float64 {
temperatureSample := pStream.Next()
if temperatureSample == nil {
Expand All @@ -83,37 +67,39 @@ func TestZRTemperatureState(t *testing.T) {
t.Logf("dut1: %v", dut1)
t.Logf("dut1 dp1 name: %v", dp1.Name())
intUpdateTime := 2 * time.Minute
interfaceConfig(t, dut1, dp1)
interfaceConfig(t, dut1, dp2)
cfgplugins.InterfaceConfig(t, dut1, dp1)
cfgplugins.InterfaceConfig(t, dut1, dp2)
gnmi.Await(t, dut1, gnmi.OC().Interface(dp1.Name()).OperStatus().State(), intUpdateTime, oc.Interface_OperStatus_UP)
transceiverName := gnmi.Get(t, dut1, gnmi.OC().Interface(dp1.Name()).Transceiver().State())
// Check if TRANSCEIVER is of type 400ZR
if dp1.PMD() != ondatra.PMD400GBASEZR {
t.Fatalf("%s Transceiver is not 400ZR its of type: %v", transceiverName, dp1.PMD())
}
component1 := gnmi.OC().Component(transceiverName)
subcomponents := gnmi.LookupAll[*oc.Component_Subcomponent](t, dut1, component1.SubcomponentAny().State())
for _, s := range subcomponents {
subc, ok := s.Val()
if ok {
sensorComponent := gnmi.Get[*oc.Component](t, dut1, gnmi.OC().Component(subc.GetName()).State())
if sensorComponent.GetType() == sensorType {
scomponent := gnmi.OC().Component(sensorComponent.GetName())
if scomponent != nil {
component1 = scomponent
compWithTemperature := gnmi.OC().Component(transceiverName)
if !deviations.UseParentComponentForTemperatureTelemetry(dut1) {
subcomponents := gnmi.LookupAll[*oc.Component_Subcomponent](t, dut1, compWithTemperature.SubcomponentAny().State())
for _, s := range subcomponents {
subc, ok := s.Val()
if ok {
sensorComponent := gnmi.Get[*oc.Component](t, dut1, gnmi.OC().Component(subc.GetName()).State())
if sensorComponent.GetType() == sensorType {
scomponent := gnmi.OC().Component(sensorComponent.GetName())
if scomponent != nil {
compWithTemperature = scomponent
}
}
}
}
}
p1StreamInstant := samplestream.New(t, dut1, component1.Temperature().Instant().State(), 10*time.Second)
p1StreamInstant := samplestream.New(t, dut1, compWithTemperature.Temperature().Instant().State(), 10*time.Second)
temperatureInstant := verifyTemperatureSensorValue(t, p1StreamInstant, "Instant")
t.Logf("Port1 dut1 %s Instant Temperature: %v", dp1.Name(), temperatureInstant)
if deviations.MissingZROpticalChannelTunableParametersTelemetry(dut1) {
t.Log("Skipping Min/Max/Avg Tunable Parameters Telemetry validation. Deviation MissingZROpticalChannelTunableParametersTelemetry enabled.")
} else {
p1StreamAvg := samplestream.New(t, dut1, component1.Temperature().Avg().State(), 10*time.Second)
p1StreamMin := samplestream.New(t, dut1, component1.Temperature().Min().State(), 10*time.Second)
p1StreamMax := samplestream.New(t, dut1, component1.Temperature().Max().State(), 10*time.Second)
p1StreamAvg := samplestream.New(t, dut1, compWithTemperature.Temperature().Avg().State(), 10*time.Second)
p1StreamMin := samplestream.New(t, dut1, compWithTemperature.Temperature().Min().State(), 10*time.Second)
p1StreamMax := samplestream.New(t, dut1, compWithTemperature.Temperature().Max().State(), 10*time.Second)

temperatureMax := verifyTemperatureSensorValue(t, p1StreamMax, "Max")
t.Logf("Port1 dut1 %s Max Temperature: %v", dp1.Name(), temperatureMax)
Expand All @@ -139,8 +125,8 @@ func TestZRTemperatureStateInterfaceFlap(t *testing.T) {
dp2 := dut1.Port(t, "port2")
t.Logf("dut1: %v", dut1)
t.Logf("dut1 dp1 name: %v", dp1.Name())
interfaceConfig(t, dut1, dp1)
interfaceConfig(t, dut1, dp2)
cfgplugins.InterfaceConfig(t, dut1, dp1)
cfgplugins.InterfaceConfig(t, dut1, dp2)
intUpdateTime := 2 * time.Minute
gnmi.Await(t, dut1, gnmi.OC().Interface(dp1.Name()).OperStatus().State(), intUpdateTime, oc.Interface_OperStatus_UP)
transceiverName := gnmi.Get(t, dut1, gnmi.OC().Interface(dp1.Name()).Transceiver().State())
Expand All @@ -152,26 +138,29 @@ func TestZRTemperatureStateInterfaceFlap(t *testing.T) {
d := &oc.Root{}
i := d.GetOrCreateInterface(dp1.Name())
i.Enabled = ygot.Bool(false)
i.Type = oc.IETFInterfaces_InterfaceType_ethernetCsmacd
gnmi.Replace(t, dut1, gnmi.OC().Interface(dp1.Name()).Config(), i)
component1 := gnmi.OC().Component(transceiverName)
subcomponents := gnmi.LookupAll[*oc.Component_Subcomponent](t, dut1, component1.SubcomponentAny().State())
for _, s := range subcomponents {
subc, ok := s.Val()
if ok {
sensorComponent := gnmi.Get[*oc.Component](t, dut1, gnmi.OC().Component(subc.GetName()).State())
if sensorComponent.GetType() == sensorType {
scomponent := gnmi.OC().Component(sensorComponent.GetName())
if scomponent != nil {
component1 = scomponent
compWithTemperature := gnmi.OC().Component(transceiverName)
if !deviations.UseParentComponentForTemperatureTelemetry(dut1) {
subcomponents := gnmi.LookupAll[*oc.Component_Subcomponent](t, dut1, compWithTemperature.SubcomponentAny().State())
for _, s := range subcomponents {
subc, ok := s.Val()
if ok {
sensorComponent := gnmi.Get[*oc.Component](t, dut1, gnmi.OC().Component(subc.GetName()).State())
if sensorComponent.GetType() == sensorType {
scomponent := gnmi.OC().Component(sensorComponent.GetName())
if scomponent != nil {
compWithTemperature = scomponent
}
}
}
}
}
p1StreamInstant := samplestream.New(t, dut1, component1.Temperature().Instant().State(), 10*time.Second)
p1StreamAvg := samplestream.New(t, dut1, component1.Temperature().Avg().State(), 10*time.Second)
p1StreamMin := samplestream.New(t, dut1, component1.Temperature().Min().State(), 10*time.Second)
p1StreamMax := samplestream.New(t, dut1, component1.Temperature().Max().State(), 10*time.Second)
// Wait 120 sec cooling off period
p1StreamInstant := samplestream.New(t, dut1, compWithTemperature.Temperature().Instant().State(), 10*time.Second)
p1StreamAvg := samplestream.New(t, dut1, compWithTemperature.Temperature().Avg().State(), 10*time.Second)
p1StreamMin := samplestream.New(t, dut1, compWithTemperature.Temperature().Min().State(), 10*time.Second)
p1StreamMax := samplestream.New(t, dut1, compWithTemperature.Temperature().Max().State(), 10*time.Second)
// Wait 120 sec cooling-off period
gnmi.Await(t, dut1, gnmi.OC().Interface(dp1.Name()).OperStatus().State(), intUpdateTime, oc.Interface_OperStatus_DOWN)
temperatureInstant := verifyTemperatureSensorValue(t, p1StreamInstant, "Instant")
t.Logf("Port1 dut1 %s Instant Temperature: %v", dp1.Name(), temperatureInstant)
Expand Down
10 changes: 10 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1140,3 +1140,13 @@ func SflowSourceAddressUpdateUnsupported(dut *ondatra.DUTDevice) bool {
func LinkLocalMaskLen(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetLinkLocalMaskLen()
}

// UseParentComponentForTemperatureTelemetry returns true if parent component supports temperature telemetry
func UseParentComponentForTemperatureTelemetry(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetUseParentComponentForTemperatureTelemetry()
}

// ComponentMfgDateUnsupported returns true if component's mfg-date leaf is unsupported
func ComponentMfgDateUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetComponentMfgDateUnsupported()
}
4 changes: 4 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ message Metadata {
// Linklocal mask length is not 64
// Cisco: b/368271859
bool link_local_mask_len = 218;
// use parent component for temperature telemetry
bool use_parent_component_for_temperature_telemetry = 219;
// component manufactured date is unsupported
bool component_mfg_date_unsupported = 220;
// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19, 36, 35, 40, 173;
}
Expand Down
Loading

0 comments on commit 5719862

Please sign in to comment.