Skip to content

TRANSCEIVER-5.2: Restructured using functions from internal library#4908

Open
snaragund wants to merge 11 commits intoopenconfig:mainfrom
nokia:SND-TRANSCEIVER5dot2
Open

TRANSCEIVER-5.2: Restructured using functions from internal library#4908
snaragund wants to merge 11 commits intoopenconfig:mainfrom
nokia:SND-TRANSCEIVER5dot2

Conversation

@snaragund
Copy link
Copy Markdown
Contributor

  • Defined TunableParamsTest which validates optical-channel telemetry.
  • Added 3 more conditions in isOpticalChannelStreamReady func.
  • Added required deviations in metadata.textproto.
  • Used tunableParamsTest func to restructure zrp_tunable_parameters_test.

"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."

…library

-Defined `TunableParamsTest` which validates optical-channel telemetry.
-Added 3 more conditions in `isOpticalChannelStreamReady` func.
-Added required deviations in metadata.textproto.
-Used `tunableParamsTest` func to restructure zrp_tunable_parameters_test.

"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."
@snaragund snaragund requested review from a team as code owners December 9, 2025 18:50
@snaragund snaragund changed the title TRANSCEIVER-5.2: Restructured using itemized functions from internal … TRANSCEIVER-5.2: Restructured using itemized functions from internal library Dec 9, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @snaragund, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the optical transceiver test suite by introducing a new, reusable TunableParamsTest function. This change centralizes the logic for configuring and validating optical channel telemetry, making the tests more modular and easier to maintain. Additionally, it enhances the telemetry validation criteria and adds necessary platform-specific deviations.

Highlights

  • New Test Function: Defined TunableParamsTest to centralize and validate optical-channel telemetry, improving test reusability.
  • Telemetry Validation Enhancement: Added three new conditions to isOpticalChannelStreamReady function for more robust optical channel telemetry validation.
  • Metadata Deviations: Included required deviations for interface_enabled and explicit_dco_config in metadata.textproto for the NOKIA vendor.
  • Test Restructuring: Refactored zrp_tunable_parameters_test to utilize the newly introduced TunableParamsTest function, streamlining the test logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@OpenConfigBot
Copy link
Copy Markdown

OpenConfigBot commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the zrp_tunable_parameters_test.go by extracting common configuration and telemetry validation logic into a new helper function, TunableParamsTest, located in internal/telemetry/transceiver/zr_validation.go. The original test file now utilizes this new helper, leading to the removal of several unused imports and the Test400ZRPlusInterfaceFlap function. The metadata.textproto file was updated to include Nokia-specific platform exceptions for interface_enabled and explicit_dco_config. Additionally, optical_channel_validation.go received minor updates to add new telemetry checks for output power and chromatic dispersion. The review comments suggest further improvements to the TunableParamsTest helper function, recommending passing the dut object as a parameter for explicit dependency management and reducing code duplication by introducing a local helper for telemetry validation.

Comment on lines +209 to +260
func TunableParamsTest(t *testing.T, tp *TunableParams) {
t.Helper()

dut := ondatra.DUT(t, "dut")

fptest.ConfigureDefaultNetworkInstance(t, dut)

t.Logf("\n*** Configure interfaces with Operational Mode: %v, Optical Frequency: %v, Target Power: %v\n\n\n", tp.OpMode, tp.Freq, tp.OutputPower)
params := &cfgplugins.ConfigParameters{
Enabled: true,
Frequency: tp.Freq,
TargetOpticalPower: tp.OutputPower,
OperationalMode: tp.OpMode,
}
batch := &gnmi.SetBatch{}
cfgplugins.NewInterfaceConfigAll(t, dut, batch, params)
batch.Set(t, dut)

// Create sample steams for each port.
ochStreams := make(map[string]*samplestream.SampleStream[*oc.Component])
interfaceStreams := make(map[string]*samplestream.SampleStream[*oc.Interface])
for _, p := range dut.Ports() {
ochStreams[p.Name()] = samplestream.New(t, dut, gnmi.OC().Component(params.OpticalChannelNames[p.Name()]).State(), samplingInterval)
interfaceStreams[p.Name()] = samplestream.New(t, dut, gnmi.OC().Interface(p.Name()).State(), samplingInterval)
defer ochStreams[p.Name()].Close()
defer interfaceStreams[p.Name()].Close()
}
for _, p := range dut.Ports() {
validateInterfaceTelemetry(t, dut, p, params, oc.Interface_OperStatus_UP, interfaceStreams[p.Name()])
validateOpticalChannelTelemetry(t, p, params, oc.Interface_OperStatus_UP, ochStreams[p.Name()])
}

t.Logf("\n*** Bringing DOWN all interfaces\n\n\n")
for _, p := range dut.Ports() {
params.Enabled = false
cfgplugins.ToggleInterfaceState(t, dut, p, params)
}
for _, p := range dut.Ports() {
validateInterfaceTelemetry(t, dut, p, params, oc.Interface_OperStatus_DOWN, interfaceStreams[p.Name()])
validateOpticalChannelTelemetry(t, p, params, oc.Interface_OperStatus_DOWN, ochStreams[p.Name()])
}

t.Logf("\n*** Bringing UP all interfaces\n\n\n")
for _, p := range dut.Ports() {
params.Enabled = true
cfgplugins.ToggleInterfaceState(t, dut, p, params)
}
for _, p := range dut.Ports() {
validateInterfaceTelemetry(t, dut, p, params, oc.Interface_OperStatus_UP, interfaceStreams[p.Name()])
validateOpticalChannelTelemetry(t, p, params, oc.Interface_OperStatus_UP, ochStreams[p.Name()])
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is a great helper function that encapsulates the tunable parameter testing logic. Here are a couple of suggestions to make it even more robust and maintainable:

  1. Pass dut as a parameter: Instead of retrieving the dut object internally, consider passing it as a parameter. This makes the function's dependencies explicit and avoids repeated lookups.
  2. Reduce code duplication: The validation logic for all ports is repeated three times. This can be extracted into a local helper function to improve readability.

Here is a suggested implementation incorporating these changes. Note that you will also need to update the call sites in zrp_tunable_parameters_test.go to pass the dut object.

func TunableParamsTest(t *testing.T, dut *ondatra.DUTDevice, tp *TunableParams) {
	t.Helper()

	fptest.ConfigureDefaultNetworkInstance(t, dut)

	t.Logf("\n*** Configure interfaces with Operational Mode: %v, Optical Frequency: %v, Target Power: %v\n\n\n", tp.OpMode, tp.Freq, tp.OutputPower)
	params := &cfgplugins.ConfigParameters{
		Enabled:            true,
		Frequency:          tp.Freq,
		TargetOpticalPower: tp.OutputPower,
		OperationalMode:    tp.OpMode,
	}
	batch := &gnmi.SetBatch{}
	cfgplugins.NewInterfaceConfigAll(t, dut, batch, params)
	batch.Set(t, dut)

	// Create sample steams for each port.
	ochStreams := make(map[string]*samplestream.SampleStream[*oc.Component])
	interfaceStreams := make(map[string]*samplestream.SampleStream[*oc.Interface])
	for _, p := range dut.Ports() {
		ochStreams[p.Name()] = samplestream.New(t, dut, gnmi.OC().Component(params.OpticalChannelNames[p.Name()]).State(), samplingInterval)
		interfaceStreams[p.Name()] = samplestream.New(t, dut, gnmi.OC().Interface(p.Name()).State(), samplingInterval)
		defer ochStreams[p.Name()].Close()
		defer interfaceStreams[p.Name()].Close()
	}

	// Helper function to validate telemetry for all ports.
	validateAllPorts := func(wantStatus oc.E_Interface_OperStatus) {
		t.Helper()
		for _, p := range dut.Ports() {
			validateInterfaceTelemetry(t, dut, p, params, wantStatus, interfaceStreams[p.Name()])
			validateOpticalChannelTelemetry(t, p, params, wantStatus, ochStreams[p.Name()])
		}
	}

	validateAllPorts(oc.Interface_OperStatus_UP)

	t.Logf("\n*** Bringing DOWN all interfaces\n\n\n")
	for _, p := range dut.Ports() {
		params.Enabled = false
		cfgplugins.ToggleInterfaceState(t, dut, p, params)
	}
	validateAllPorts(oc.Interface_OperStatus_DOWN)

	t.Logf("\n*** Bringing UP all interfaces\n\n\n")
	for _, p := range dut.Ports() {
		params.Enabled = true
		cfgplugins.ToggleInterfaceState(t, dut, p, params)
	}
	validateAllPorts(oc.Interface_OperStatus_UP)
}

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 9, 2025

Pull Request Test Coverage Report for Build 21852422973

Details

  • 0 of 57 (0.0%) changed or added relevant lines in 2 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.01%) to 9.92%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/telemetry/transceiver/optical_channel_validation.go 0 4 0.0%
internal/telemetry/transceiver/zr_validation.go 0 53 0.0%
Files with Coverage Reduction New Missed Lines %
internal/telemetry/transceiver/zr_validation.go 2 0.0%
Totals Coverage Status
Change from base Build 21848411094: -0.01%
Covered Lines: 2254
Relevant Lines: 22721

💛 - Coveralls

@snaragund snaragund changed the title TRANSCEIVER-5.2: Restructured using itemized functions from internal library TRANSCEIVER-5.2: Restructured using functions from internal library Dec 10, 2025
@dplore
Copy link
Copy Markdown
Member

dplore commented Dec 11, 2025

retriggering github checks

@dplore dplore closed this Dec 11, 2025
@dplore dplore reopened this Dec 11, 2025
@snaragund
Copy link
Copy Markdown
Contributor Author

@dplore PR has been approved by both @rezachit @rohit-rp can this be merged?

@dplore
Copy link
Copy Markdown
Member

dplore commented Feb 10, 2026

@dplore PR has been approved by both @rezachit @rohit-rp can this be merged?

Please fix static checks
https://github.com/openconfig/featureprofiles/actions/runs/21852422973/job/63061952704?pr=4908

Please provide link to test results. Can either use a github gist or privately.

snaragund and others added 4 commits February 22, 2026 01:56
"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."
@snaragund snaragund requested review from rezachit and rohit-rp March 17, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants