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

Transciever-5 | Add changes/deviations to zr_tunable_parameters_test #3256

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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 @@ -14,3 +14,13 @@ platform_exceptions: {
missing_zr_optical_channel_tunable_parameters_telemetry: true
}
}
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
optical_channel_oper_mode_telemetry_unsupported: true
optical_channel_target_output_power_unsupported: true
optical_channel_frequency_value_unsupported: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
const (
samplingInterval = 10 * time.Second
frequencyTolerance = 1800
dp16QAM = 1
)

var (
Expand All @@ -32,6 +31,7 @@ var (
IPv4: "192.0.2.5",
IPv4Len: 30,
}
dp16QAM uint16 //Vendor operational-mode ID for 16QAM modulation
)

func TestMain(m *testing.M) {
Expand All @@ -42,6 +42,7 @@ func Test400ZRTunableFrequency(t *testing.T) {
p1 := dut.Port(t, "port1")
p2 := dut.Port(t, "port2")
fptest.ConfigureDefaultNetworkInstance(t, dut)
dp16QAM = vendorOpticalChannelOperMode(t)
gnmi.Replace(t, dut, gnmi.OC().Interface(p1.Name()).Config(), dutPort1.NewOCInterface(p1.Name(), dut))
gnmi.Replace(t, dut, gnmi.OC().Interface(p2.Name()).Config(), dutPort2.NewOCInterface(p2.Name(), dut))
oc1 := opticalChannelFromPort(t, dut, p1)
Expand Down Expand Up @@ -76,17 +77,31 @@ func Test400ZRTunableFrequency(t *testing.T) {
targetOutputPower: -9,
},
}
opticalChannelList := []string{oc1, oc2}
//Set config container leaf for optical channel
for _, opticChannel := range opticalChannelList {
setConfigLeaf := gnmi.OC().Component(opticChannel)
gnmi.Update(t, dut, setConfigLeaf.Config(), &oc.Component{
Name: ygot.String(opticChannel),
})
}
for _, tc := range tests {
t.Run(tc.description, func(t *testing.T) {
for freq := tc.startFreq; freq <= tc.endFreq; freq += tc.freqStep {
var targetOutPower float64
if deviations.OpticalChannelTargetOutputPowerUnsupported(dut) {
targetOutPower = tc.targetOutputPower * 100
} else {
targetOutPower = tc.targetOutputPower
}
t.Run(fmt.Sprintf("Freq: %v", freq), func(t *testing.T) {
gnmi.Replace(t, dut, gnmi.OC().Component(oc1).OpticalChannel().Config(), &oc.Component_OpticalChannel{
TargetOutputPower: ygot.Float64(tc.targetOutputPower),
TargetOutputPower: ygot.Float64(targetOutPower),
Frequency: ygot.Uint64(freq),
OperationalMode: ygot.Uint16(dp16QAM),
})
gnmi.Replace(t, dut, gnmi.OC().Component(oc2).OpticalChannel().Config(), &oc.Component_OpticalChannel{
TargetOutputPower: ygot.Float64(tc.targetOutputPower),
TargetOutputPower: ygot.Float64(targetOutPower),
Frequency: ygot.Uint64(freq),
OperationalMode: ygot.Uint16(dp16QAM),
})
Expand All @@ -103,6 +118,7 @@ func Test400ZRTunableOutputPower(t *testing.T) {
p1 := dut.Port(t, "port1")
p2 := dut.Port(t, "port2")
fptest.ConfigureDefaultNetworkInstance(t, dut)
dp16QAM = vendorOpticalChannelOperMode(t)
gnmi.Replace(t, dut, gnmi.OC().Interface(p1.Name()).Config(), dutPort1.NewOCInterface(p1.Name(), dut))
gnmi.Replace(t, dut, gnmi.OC().Interface(p2.Name()).Config(), dutPort2.NewOCInterface(p2.Name(), dut))
oc1 := opticalChannelFromPort(t, dut, p1)
Expand All @@ -111,6 +127,14 @@ func Test400ZRTunableOutputPower(t *testing.T) {
defer streamOC1.Close()
streamOC2 := samplestream.New(t, dut, gnmi.OC().Component(oc2).State(), 10*time.Second)
defer streamOC2.Close()
opticalChannelList := []string{oc1, oc2}
//Set config container leaf for optical channel
for _, opticChannel := range opticalChannelList {
setConfigLeaf := gnmi.OC().Component(opticChannel)
gnmi.Update(t, dut, setConfigLeaf.Config(), &oc.Component{
Name: ygot.String(opticChannel),
})
}
tests := []struct {
description string
frequency uint64
Expand All @@ -131,14 +155,20 @@ func Test400ZRTunableOutputPower(t *testing.T) {
}
for _, tc := range tests {
for top := tc.startTargetOutputPower; top <= tc.endTargetOutputPower; top += tc.targetOutputPowerStep {
var targetOutPower float64
if deviations.OpticalChannelTargetOutputPowerUnsupported(dut) {
targetOutPower = top * 100
} else {
targetOutPower = top
}
t.Run(fmt.Sprintf("Target Power: %v", top), func(t *testing.T) {
gnmi.Replace(t, dut, gnmi.OC().Component(oc1).OpticalChannel().Config(), &oc.Component_OpticalChannel{
TargetOutputPower: ygot.Float64(top),
TargetOutputPower: ygot.Float64(targetOutPower),
Frequency: ygot.Uint64(tc.frequency),
OperationalMode: ygot.Uint16(dp16QAM),
})
gnmi.Replace(t, dut, gnmi.OC().Component(oc2).OpticalChannel().Config(), &oc.Component_OpticalChannel{
TargetOutputPower: ygot.Float64(top),
TargetOutputPower: ygot.Float64(targetOutPower),
Frequency: ygot.Uint64(tc.frequency),
OperationalMode: ygot.Uint16(dp16QAM),
})
Expand All @@ -154,6 +184,7 @@ func Test400ZRInterfaceFlap(t *testing.T) {
p1 := dut.Port(t, "port1")
p2 := dut.Port(t, "port2")
fptest.ConfigureDefaultNetworkInstance(t, dut)
dp16QAM = vendorOpticalChannelOperMode(t)
gnmi.Replace(t, dut, gnmi.OC().Interface(p1.Name()).Config(), dutPort1.NewOCInterface(p1.Name(), dut))
gnmi.Replace(t, dut, gnmi.OC().Interface(p2.Name()).Config(), dutPort2.NewOCInterface(p2.Name(), dut))
oc1 := opticalChannelFromPort(t, dut, p1)
Expand All @@ -164,13 +195,19 @@ func Test400ZRInterfaceFlap(t *testing.T) {
defer streamOC2.Close()
targetPower := float64(-9)
frequency := uint64(193100000)
var targetOutPower float64
if deviations.OpticalChannelTargetOutputPowerUnsupported(dut) {
targetOutPower = 100 * targetPower
} else {
targetOutPower = targetPower
}
gnmi.Replace(t, dut, gnmi.OC().Component(oc1).OpticalChannel().Config(), &oc.Component_OpticalChannel{
TargetOutputPower: ygot.Float64(targetPower),
TargetOutputPower: ygot.Float64(targetOutPower),
Frequency: ygot.Uint64(frequency),
OperationalMode: ygot.Uint16(dp16QAM),
})
gnmi.Replace(t, dut, gnmi.OC().Component(oc2).OpticalChannel().Config(), &oc.Component_OpticalChannel{
TargetOutputPower: ygot.Float64(targetPower),
TargetOutputPower: ygot.Float64(targetOutPower),
Frequency: ygot.Uint64(frequency),
OperationalMode: ygot.Uint16(dp16QAM),
})
Expand Down Expand Up @@ -216,15 +253,33 @@ func validateOpticsTelemetry(t *testing.T, streams []*samplestream.SampleStream[
ocs = append(ocs, v.GetOpticalChannel())
}

// Validate Optical channel operational-mode with Get-Config
if deviations.OpticalChannelOperModeTelemetryUnsupported(dut) {
p1 := dut.Port(t, "port1")
p2 := dut.Port(t, "port2")
oc1 := opticalChannelFromPort(t, dut, p1)
oc2 := opticalChannelFromPort(t, dut, p2)
opticalChannelList := []string{oc1, oc2}
for _, och := range opticalChannelList {
opticChannelOperModeConfig := gnmi.Get(t, dut, gnmi.OC().Component(och).OpticalChannel().OperationalMode().Config())
if got, want := opticChannelOperModeConfig, uint16(dp16QAM); got != want {
t.Errorf("Optical-Channel: operational-mode: got %v, want %v", got, want)
}
}
}

for _, oc := range ocs {
opm := oc.GetOperationalMode()
var opm uint16
if !deviations.OpticalChannelOperModeTelemetryUnsupported(dut) {
opm = oc.GetOperationalMode()
if got, want := opm, uint16(dp16QAM); got != want {
t.Errorf("Optical-Channel: operational-mode: got %v, want %v", got, want)
}
}
inst := oc.GetCarrierFrequencyOffset().GetInstant()
avg := oc.GetCarrierFrequencyOffset().GetAvg()
min := oc.GetCarrierFrequencyOffset().GetMin()
max := oc.GetCarrierFrequencyOffset().GetMax()
if got, want := opm, uint16(dp16QAM); got != want {
t.Errorf("Optical-Channel: operational-mode: got %v, want %v", got, want)
}
// Laser frequency offset should not be more than +/- 1.8 GHz max from the
// configured centre frequency.
if inst < -1*frequencyTolerance || inst > frequencyTolerance {
Expand Down Expand Up @@ -274,7 +329,13 @@ func validateOpticsTelemetry(t *testing.T, streams []*samplestream.SampleStream[
t.Errorf("Optical-Channel: output-power max: %v less than output-power avg: %v", max, avg)
}
}
if got, want := oc.GetFrequency(), frequency; got != want {
var opticalChannelFreq uint64
if deviations.OpticalChannelFrequencyValueUnsupported(dut) {
opticalChannelFreq = frequency / 100
} else {
opticalChannelFreq = frequency
}
if got, want := oc.GetFrequency(), opticalChannelFreq; got != want {
t.Errorf("Optical-Channel: frequency: %v, want: %v", got, want)
}
}
Expand All @@ -286,3 +347,15 @@ func opticalChannelFromPort(t *testing.T, dut *ondatra.DUTDevice, p *ondatra.Por
tr := gnmi.Get(t, dut, gnmi.OC().Interface(p.Name()).Transceiver().State())
return gnmi.Get(t, dut, gnmi.OC().Component(tr).Transceiver().Channel(0).AssociatedOpticalChannel().State())
}

// vendorOpticalChannelOperMode returns the Vendor-specific mode identifier a given vendor.
func vendorOpticalChannelOperMode(t *testing.T) uint16 {
arvbaska1 marked this conversation as resolved.
Show resolved Hide resolved
t.Helper()
dut := ondatra.DUT(t, "dut")
switch dut.Vendor() {
case ondatra.CISCO:
return 5003
default:
return 1
}
}
15 changes: 15 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,3 +1104,18 @@ func BgpDeleteLinkBandwidthUnsupported(dut *ondatra.DUTDevice) bool {
func QOSInQueueDropCounterUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetQosInqueueDropCounterUnsupported()
}

// OpticalChannelOperModeTelemetryUnsupported returns true for Devices that do not support Optical-channel operational-mode telemetry.
func OpticalChannelOperModeTelemetryUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetOpticalChannelOperModeTelemetryUnsupported()
}

// OpticalChannelTargetOutputPowerUnsupported returns true for Devices that do not support Optical-channel target output power config.
func OpticalChannelTargetOutputPowerUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetOpticalChannelTargetOutputPowerUnsupported()
}

// OpticalChannelFrequencyValueUnsupported returns true for Devices that do not support Optical-channel telemetry frequency value in MHz.
func OpticalChannelFrequencyValueUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetOpticalChannelFrequencyValueUnsupported()
}
8 changes: 7 additions & 1 deletion proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,13 @@ message Metadata {
// qos_inqueue_drop_counter_Unsupported is set to true for devices that do not support qos ingress queue drop counters.
// Juniper: b/341130490
bool qos_inqueue_drop_counter_unsupported = 207;

// Devices that do not support Optical-channel operational-mode telemetry.
bool optical_channel_oper_mode_telemetry_unsupported = 208;
// Devices that do not support Optical-channel target output power config.
bool optical_channel_target_output_power_unsupported = 209;
// Devices that do not support Optical-channel telemetry frequency value in MHz.
bool optical_channel_frequency_value_unsupported = 210;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19, 36;
}
Expand Down
Loading
Loading