Skip to content

Commit

Permalink
Eric comments incorporated:
Browse files Browse the repository at this point in the history
1. operationalMode flag added.
2. InterfaceConfig function updated to use ConfigOpticalChannel.
3. ConfigOpticalChannel function updated to configure in single operation.
4. Removed RequireZrOperMode deviation.

"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."
  • Loading branch information
snaragund committed Jan 24, 2025
1 parent 2652d04 commit 6826c39
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ platform_exceptions: {
}
deviations: {
interface_enabled: true
require_zr_oper_mode: true
explicit_dco_config: true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package zr_supply_voltage_test

import (
"flag"
"fmt"
"reflect"
"testing"
Expand All @@ -34,6 +35,11 @@ const (
intUpdateTime = 2 * time.Minute
)

var (
operationalModeFlag = flag.Int("operational_mode", 1, "vendor-specific operational-mode for the channel")
operationalMode uint16
)

func TestMain(m *testing.M) {
fptest.RunTests(m)
}
Expand All @@ -57,8 +63,15 @@ func verifyVoltageValue(t *testing.T, pStream *samplestream.SampleStream[float64

func TestZrSupplyVoltage(t *testing.T) {
dut := ondatra.DUT(t, "dut")
cfgplugins.InterfaceConfig(t, dut, dut.Port(t, "port1"))
cfgplugins.InterfaceConfig(t, dut, dut.Port(t, "port2"))

if operationalModeFlag != nil {
operationalMode = uint16(*operationalModeFlag)
} else {
t.Fatalf("Please specify the vendor-specific operational-mode flag")
}

cfgplugins.InterfaceConfig(t, dut, dut.Port(t, "port1"), operationalMode)
cfgplugins.InterfaceConfig(t, dut, dut.Port(t, "port2"), operationalMode)

for _, port := range []string{"port1", "port2"} {
t.Run(fmt.Sprintf("Port:%s", port), func(t *testing.T) {
Expand Down
35 changes: 9 additions & 26 deletions internal/cfgplugins/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,8 @@ func InterfaceConfig(t *testing.T, dut *ondatra.DUTDevice, dp *ondatra.Port) {
},
})
}
if deviations.RequireZrOperMode(dut) {
ocComponent := components.OpticalChannelComponentFromPort(t, dut, dp)
t.Logf("Got opticalChannelComponent from port: %s", ocComponent)
var operMode uint16 = 83
gnmi.Replace(t, dut, gnmi.OC().Component(ocComponent).Config(), &oc.Component{
Name: ygot.String(ocComponent),
OpticalChannel: &oc.Component_OpticalChannel{
TargetOutputPower: ygot.Float64(targetOutputPowerdBm),
Frequency: ygot.Uint64(targetFrequencyMHz),
OperationalMode: ygot.Uint16(operMode),
},
})
} else {
ocComponent := components.OpticalChannelComponentFromPort(t, dut, dp)
t.Logf("Got opticalChannelComponent from port: %s", ocComponent)
gnmi.Update(t, dut, gnmi.OC().Component(ocComponent).Name().Config(), ocComponent)
gnmi.Replace(t, dut, gnmi.OC().Component(ocComponent).OpticalChannel().Config(), &oc.Component_OpticalChannel{
TargetOutputPower: ygot.Float64(targetOutputPowerdBm),
Frequency: ygot.Uint64(targetFrequencyMHz),
})
}
oc := components.OpticalChannelComponentFromPort(t, dut, dp)
ConfigOpticalChannel(t, dut, oc, targetFrequencyMHz, targetOutputPowerdBm, operationalMode)

Check failure on line 54 in internal/cfgplugins/interface.go

View workflow job for this annotation

GitHub Actions / build

undefined: operationalMode

Check failure on line 54 in internal/cfgplugins/interface.go

View workflow job for this annotation

GitHub Actions / Static Analysis

undefined: operationalMode

Check failure on line 54 in internal/cfgplugins/interface.go

View workflow job for this annotation

GitHub Actions / test

undefined: operationalMode
}

// ValidateInterfaceConfig validates the output power and frequency for the given port.
Expand Down Expand Up @@ -101,11 +82,13 @@ func ToggleInterface(t *testing.T, dut *ondatra.DUTDevice, intf string, isEnable

// ConfigOpticalChannel configures the optical channel.
func ConfigOpticalChannel(t *testing.T, dut *ondatra.DUTDevice, och string, frequency uint64, targetOpticalPower float64, operationalMode uint16) {
gnmi.Update(t, dut, gnmi.OC().Component(och).Name().Config(), och)
gnmi.Replace(t, dut, gnmi.OC().Component(och).OpticalChannel().Config(), &oc.Component_OpticalChannel{
OperationalMode: ygot.Uint16(operationalMode),
Frequency: ygot.Uint64(frequency),
TargetOutputPower: ygot.Float64(targetOpticalPower),
gnmi.Replace(t, dut, gnmi.OC().Component(och).Config(), &oc.Component{
Name: ygot.String(och),
OpticalChannel: &oc.Component_OpticalChannel{
OperationalMode: ygot.Uint16(operationalMode),
Frequency: ygot.Uint64(frequency),
TargetOutputPower: ygot.Float64(targetOpticalPower),
},
})
}

Expand Down
6 changes: 1 addition & 5 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,12 +1303,8 @@ func QosSchedulerIngressPolicer(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetQosSchedulerIngressPolicerUnsupported()
}

// RequireZrOperMode returns true for the devices that require a mandatory value in operational-mode leaf for optical-channel
func RequireZrOperMode(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetRequireZrOperMode()
}

// ExplicitDcoConfig returns true if a user-configured value is required in module-functional-type for the transceiver
func ExplicitDcoConfig(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetExplicitDcoConfig()
}

5 changes: 1 addition & 4 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,9 @@ message Metadata {
// Arista: b/346557012
// Devices that do not support qos scheduler ingress policer.
bool qos_scheduler_ingress_policer_unsupported = 248;
// Nokia: b/383369830
// RequireZrOperMode returns true if a user-configured value is required in operational-mode for the optical-channel
bool require_zr_oper_mode = 249;
// Nokia: b/383075189
// ExplicitDcoConfig returns true if explicit configurations are required in module-functional-type for the transceiver
bool explicit_dco_config = 250;
bool explicit_dco_config = 249;


// Reserved field numbers and identifiers.
Expand Down
109 changes: 48 additions & 61 deletions proto/metadata_go_proto/metadata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6826c39

Please sign in to comment.