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

Updates to Transceiver-8: zr_temprature_test #2894

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ func TestMain(m *testing.M) {
//
// dut:port1 <--> port2:dut

func verifyTemperatureSensorValue(t *testing.T, pStream *samplestream.SampleStream[float64], sensorName string) float64 {
temperatureSample := pStream.Next()
if temperatureSample == nil {
t.Fatalf("Temperature telemetry %s was not streamed in the most recent subscription interval", sensorName)
}
temperatureVal, ok := temperatureSample.Val()
if !ok {
t.Fatalf("Temperature %q telemetry is not present", temperatureSample)
}
func verifyTemperatureSensorValue(t *testing.T, temperatureVal float64, sensorName string) float64 {
//temperatureSample := pStream.Next()
// if temperatureSample == nil {
// t.Fatalf("Temperature telemetry %s was not streamed in the most recent subscription interval", sensorName)
// }
// temperatureVal, ok := temperatureSample.Val()
// if !ok {
// t.Fatalf("Temperature %q telemetry is not present", temperatureSample)
// }
// Check temperature return value of correct type
if reflect.TypeOf(temperatureVal).Kind() != reflect.Float64 {
t.Fatalf("Return value is not type float64")
Expand Down Expand Up @@ -91,32 +91,39 @@ func TestZRTemperatureState(t *testing.T) {
}
}
}
p1StreamInstant := samplestream.New(t, dut1, compWithTemperature.Temperature().Instant().State(), 10*time.Second)
temperatureInstant := verifyTemperatureSensorValue(t, p1StreamInstant, "Instant")
p1Stream := samplestream.New(t, dut1, compWithTemperature.Temperature().State(), 10*time.Second)
defer p1Stream.Close()
currStreamSample := p1Stream.Next()
if currStreamSample == nil {
t.Fatalf("Temperature telemetry data was not streamed in the most recent subscription interval")
}
temprStateData, ok := currStreamSample.Val()
if !ok {
t.Fatalf("Failed to get temperature telemetry value")
}
instantTemp := temprStateData.GetInstant()
temperatureInstant := verifyTemperatureSensorValue(t, instantTemp, "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, 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")
maxTemp := temprStateData.GetMax()
minTemp := temprStateData.GetMin()
avgTemp := temprStateData.GetAvg()
temperatureMax := verifyTemperatureSensorValue(t, maxTemp, "Max")
t.Logf("Port1 dut1 %s Max Temperature: %v", dp1.Name(), temperatureMax)
temperatureMin := verifyTemperatureSensorValue(t, p1StreamMin, "Min")
temperatureMin := verifyTemperatureSensorValue(t, minTemp, "Min")
t.Logf("Port1 dut1 %s Min Temperature: %v", dp1.Name(), temperatureMin)
temperatureAvg := verifyTemperatureSensorValue(t, p1StreamAvg, "Avg")
temperatureAvg := verifyTemperatureSensorValue(t, avgTemp, "Avg")
t.Logf("Port1 dut1 %s Avg Temperature: %v", dp1.Name(), temperatureAvg)
if temperatureAvg >= temperatureMin && temperatureAvg <= temperatureMax {
t.Logf("The average is between the maximum and minimum values")
} else {
t.Fatalf("The average is not between the maximum and minimum values, Avg:%v Max:%v Min:%v", temperatureAvg, temperatureMax, temperatureMin)
}
p1StreamMin.Close()
p1StreamMax.Close()
p1StreamAvg.Close()
}
p1StreamInstant.Close()
p1Stream.Close()
}

func TestZRTemperatureStateInterfaceFlap(t *testing.T) {
Expand Down Expand Up @@ -156,40 +163,59 @@ func TestZRTemperatureStateInterfaceFlap(t *testing.T) {
}
}
}
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)
p1Stream := samplestream.New(t, dut1, compWithTemperature.Temperature().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")
currStreamSample := p1Stream.Next()
if currStreamSample == nil {
t.Fatalf("Temperature telemetry data was not streamed in the most recent subscription interval")
}
temprStateData, ok := currStreamSample.Val()
if !ok {
t.Fatalf("Failed to get temperature telemetry value")
}
instantTemp := temprStateData.GetInstant()
temperatureInstant := verifyTemperatureSensorValue(t, instantTemp, "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 {
temperatureMax := verifyTemperatureSensorValue(t, p1StreamMax, "Max")
maxTemp := temprStateData.GetMax()
minTemp := temprStateData.GetMin()
avgTemp := temprStateData.GetAvg()
temperatureMax := verifyTemperatureSensorValue(t, maxTemp, "Max")
t.Logf("Port1 dut1 %s Max Temperature: %v", dp1.Name(), temperatureMax)
temperatureMin := verifyTemperatureSensorValue(t, p1StreamMin, "Min")
temperatureMin := verifyTemperatureSensorValue(t, minTemp, "Min")
t.Logf("Port1 dut1 %s Min Temperature: %v", dp1.Name(), temperatureMin)
temperatureAvg := verifyTemperatureSensorValue(t, p1StreamAvg, "Avg")
temperatureAvg := verifyTemperatureSensorValue(t, avgTemp, "Avg")
t.Logf("Port1 dut1 %s Avg Temperature: %v", dp1.Name(), temperatureAvg)
if temperatureAvg >= temperatureMin && temperatureAvg <= temperatureMax {
t.Logf("The average is between the maximum and minimum values")
} else {
t.Fatalf("The average is not between the maximum and minimum values")
}
}
i = d.GetOrCreateInterface(dp1.Name())
i.Enabled = ygot.Bool(true)
i.Type = oc.IETFInterfaces_InterfaceType_ethernetCsmacd
// Enable interface
gnmi.Replace(t, dut1, gnmi.OC().Interface(dp1.Name()).Config(), i)
gnmi.Await(t, dut1, gnmi.OC().Interface(dp1.Name()).OperStatus().State(), intUpdateTime, oc.Interface_OperStatus_UP)
temperatureInstant = verifyTemperatureSensorValue(t, p1StreamInstant, "Instant")
temprStateData, _ = p1Stream.Next().Val()
instantTemp = temprStateData.GetInstant()
temperatureInstant = verifyTemperatureSensorValue(t, instantTemp, "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 {
temperatureMax := verifyTemperatureSensorValue(t, p1StreamMax, "Max")
maxTemp := temprStateData.GetMax()
minTemp := temprStateData.GetMin()
avgTemp := temprStateData.GetAvg()
temperatureMax := verifyTemperatureSensorValue(t, maxTemp, "Max")
t.Logf("Port1 dut1 %s Max Temperature: %v", dp1.Name(), temperatureMax)
temperatureMin := verifyTemperatureSensorValue(t, p1StreamMin, "Min")
temperatureMin := verifyTemperatureSensorValue(t, minTemp, "Min")
t.Logf("Port1 dut1 %s Min Temperature: %v", dp1.Name(), temperatureMin)
temperatureAvg := verifyTemperatureSensorValue(t, p1StreamAvg, "Avg")
temperatureAvg := verifyTemperatureSensorValue(t, avgTemp, "Avg")
t.Logf("Port1 dut1 %s Avg Temperature: %v", dp1.Name(), temperatureAvg)
if temperatureAvg >= temperatureMin && temperatureAvg <= temperatureMax {
t.Logf("The average is between the maximum and minimum values")
Expand Down
Loading