Skip to content

Commit

Permalink
cfgplugins optical changes + Cisco deviations (openconfig#3438)
Browse files Browse the repository at this point in the history
* common cfgplugins code + deviations

* common cfgplugins code + deviations

* space

* cleanup

* test change + updated readmes

* splitting changed files
  • Loading branch information
karthikeya-remilla authored Sep 23, 2024
1 parent 1c7aa54 commit c402011
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 37 deletions.
2 changes: 2 additions & 0 deletions feature/platform/transceiver/tests/zr_cd_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Validate 400ZR optics module reports accurate CD telemetry values.
Chromatic Dispersion is frequency dependent change in signal phase velocity due
to fiber measured in ps/nm

The test must be repeated for each supported operational-mode or as agreed between the vendor and customer.

## Procedure

* Connect two ZR interfaces using a duplex LC fiber jumper such that TX
Expand Down
18 changes: 12 additions & 6 deletions feature/platform/transceiver/tests/zr_cd_test/zr_cd_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zr_cd_test

import (
"flag"
"testing"
"time"

Expand All @@ -13,7 +14,6 @@ import (
)

const (
dp16QAM = 1
samplingInterval = 10 * time.Second
minCDValue = -200
maxCDValue = 2400
Expand All @@ -30,8 +30,10 @@ const (
)

var (
frequencies = []uint64{191400000, 196100000} // 400ZR OIF wavelength range
targetOutputPowers = []float64{-13, -9} // 400ZR OIF Tx power range
frequencies = []uint64{191400000, 196100000} // 400ZR OIF wavelength range
targetOutputPowers = []float64{-13, -9} // 400ZR OIF Tx power range
operationalModeFlag = flag.Int("operational_mode", 1, "vendor-specific operational-mode for the channel")
operationalMode uint16
)

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -93,6 +95,11 @@ func verifyAllCDValues(t *testing.T, dut1 *ondatra.DUTDevice, p1StreamInstant, p

func TestCDValue(t *testing.T) {
dut := ondatra.DUT(t, "dut")
if operationalModeFlag != nil {
operationalMode = uint16(*operationalModeFlag)
} else {
t.Fatalf("Please specify the vendor-specific operational-mode flag")
}
fptest.ConfigureDefaultNetworkInstance(t, dut)

dp1 := dut.Port(t, "port1")
Expand All @@ -105,11 +112,10 @@ func TestCDValue(t *testing.T) {
och1 := gnmi.Get(t, dut, gnmi.OC().Component(tr1).Transceiver().Channel(0).AssociatedOpticalChannel().State())
och2 := gnmi.Get(t, dut, gnmi.OC().Component(tr2).Transceiver().Channel(0).AssociatedOpticalChannel().State())
component1 := gnmi.OC().Component(och1)

for _, frequency := range frequencies {
for _, targetOutputPower := range targetOutputPowers {
cfgplugins.ConfigOpticalChannel(t, dut, och1, frequency, targetOutputPower, dp16QAM)
cfgplugins.ConfigOpticalChannel(t, dut, och2, frequency, targetOutputPower, dp16QAM)
cfgplugins.ConfigOpticalChannel(t, dut, och1, frequency, targetOutputPower, operationalMode)
cfgplugins.ConfigOpticalChannel(t, dut, och2, frequency, targetOutputPower, operationalMode)

// Wait for channels to be up.
gnmi.Await(t, dut, gnmi.OC().Interface(dp1.Name()).OperStatus().State(), timeout, oc.Interface_OperStatus_UP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ power.
* This is the total TX output power
* Is mapped to component/optical-channel/ full path shown below

The test must be repeated for each supported operational-mode or as agreed between the vendor and customer.

## TRANSCEIVER-4.1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package zr_input_output_power_test

import (
"flag"
"testing"
"time"

Expand All @@ -14,7 +15,6 @@ import (
)

const (
dp16QAM = uint16(1)
samplingInterval = 10 * time.Second
inactiveOCHRxPower = -30.0
inactiveOCHTxPower = -30.0
Expand All @@ -27,6 +27,8 @@ const (
var (
frequencies = []uint64{191400000, 196100000}
targetOpticalPowers = []float64{-9, -13}
operationalModeFlag = flag.Int("operational_mode", 1, "vendor-specific operational-mode for the channel")
operationalMode uint16
)

func TestMain(m *testing.M) {
Expand All @@ -35,7 +37,11 @@ func TestMain(m *testing.M) {

func TestOpticalPower(t *testing.T) {
dut := ondatra.DUT(t, "dut")

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

var (
Expand All @@ -58,7 +64,7 @@ func TestOpticalPower(t *testing.T) {
for _, targetOpticalPower := range targetOpticalPowers {
// Configure OCH component and OTN and ETH logical channels.
for _, p := range dut.Ports() {
cfgplugins.ConfigOpticalChannel(t, dut, ochs[p.Name()], frequency, targetOpticalPower, dp16QAM)
cfgplugins.ConfigOpticalChannel(t, dut, ochs[p.Name()], frequency, targetOpticalPower, operationalMode)
}

// Create sample steams for each port.
Expand Down
32 changes: 4 additions & 28 deletions internal/cfgplugins/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
package cfgplugins

import (
"fmt"
"math"
"testing"

"github.com/openconfig/featureprofiles/internal/deviations"
"github.com/openconfig/featureprofiles/internal/components"
"github.com/openconfig/ondatra"
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
Expand All @@ -33,30 +32,6 @@ const (
targetFrequencyToleranceMHz = 100000
)

// opticalChannelComponentFromPort returns the name of the optical channel component for the given
// port.
func opticalChannelComponentFromPort(t *testing.T, dut *ondatra.DUTDevice, p *ondatra.Port) string {
t.Helper()
if deviations.MissingPortToOpticalChannelMapping(dut) {
transceiverName := gnmi.Get(t, dut, gnmi.OC().Interface(p.Name()).Transceiver().State())
return fmt.Sprintf("%s-Optical0", transceiverName)
}
compName := gnmi.Get(t, dut, gnmi.OC().Interface(p.Name()).HardwarePort().State())
for {
comp, ok := gnmi.Lookup(t, dut, gnmi.OC().Component(compName).State()).Val()
if !ok {
t.Fatalf("Recursive optical channel lookup failed for port: %s, component %s not found.", p.Name(), compName)
}
if comp.GetType() == oc.PlatformTypes_OPENCONFIG_HARDWARE_COMPONENT_OPTICAL_CHANNEL {
return compName
}
if comp.GetParent() == "" {
t.Fatalf("Recursive optical channel lookup failed for port: %s, parent of component %s not found.", p.Name(), compName)
}
compName = comp.GetParent()
}
}

// InterfaceConfig configures the interface with the given port.
func InterfaceConfig(t *testing.T, dut *ondatra.DUTDevice, dp *ondatra.Port) {
t.Helper()
Expand All @@ -65,8 +40,9 @@ func InterfaceConfig(t *testing.T, dut *ondatra.DUTDevice, dp *ondatra.Port) {
i.Enabled = ygot.Bool(true)
i.Type = oc.IETFInterfaces_InterfaceType_ethernetCsmacd
gnmi.Replace(t, dut, gnmi.OC().Interface(dp.Name()).Config(), i)
ocComponent := opticalChannelComponentFromPort(t, dut, dp)
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),
Expand All @@ -76,7 +52,7 @@ func InterfaceConfig(t *testing.T, dut *ondatra.DUTDevice, dp *ondatra.Port) {
// ValidateInterfaceConfig validates the output power and frequency for the given port.
func ValidateInterfaceConfig(t *testing.T, dut *ondatra.DUTDevice, dp *ondatra.Port) {
t.Helper()
ocComponent := opticalChannelComponentFromPort(t, dut, dp)
ocComponent := components.OpticalChannelComponentFromPort(t, dut, dp)
t.Logf("Got opticalChannelComponent from port: %s", ocComponent)

outputPower := gnmi.Get(t, dut, gnmi.OC().Component(ocComponent).OpticalChannel().TargetOutputPower().State())
Expand Down

0 comments on commit c402011

Please sign in to comment.