Skip to content

Tr13newfix#5469

Open
hmod2001 wants to merge 3 commits into
openconfig:mainfrom
hmod2001:tr13newfix
Open

Tr13newfix#5469
hmod2001 wants to merge 3 commits into
openconfig:mainfrom
hmod2001:tr13newfix

Conversation

@hmod2001
Copy link
Copy Markdown
Contributor

5207 change revert

Hammad Khan (hammadkh) and others added 2 commits May 14, 2026 17:06
@hmod2001 hmod2001 requested a review from a team as a code owner May 14, 2026 21:18
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 improves the robustness and accuracy of the low power mode test suite. It introduces necessary configuration validation, refactors the optical channel setup for better clarity, and corrects a timing calculation error that previously incorrectly scaled the sampling interval.

Highlights

  • Operational Mode Validation: Added a mandatory check for the operationalModeFlag to ensure the test fails gracefully if the vendor-specific configuration is missing.
  • Optical Channel Configuration: Refactored the test setup to explicitly configure optical channels using dedicated helper functions instead of generic interface initialization.
  • Sampling Interval Correction: Removed an incorrect time unit conversion when retrieving the sampling interval from the device state to ensure accurate duration handling.
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 the 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 counterproductive. 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.

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.

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 updates the TestLowPowerMode function to configure optical channels directly and modifies the sampling interval logic. However, several issues were identified: removing the * time.Second multiplier introduces a timing bug as the OpenConfig value is in seconds, the new nil check for the operational mode flag is redundant as the flag pointer is never nil, and the implementation of cfgplugins.ConfigOpticalChannel violates the repository's style guide regarding function signatures and the use of gnmi.SetBatch.

currentSamplingInterval := samplingInterval
if !deviations.SkipOpticalChannelOutputPowerInterval(dut) {
currentSamplingInterval = time.Duration(gnmi.Get(t, dut, gnmi.OC().Component(opticalChannelName).OpticalChannel().OutputPower().Interval().State())) * time.Second
currentSamplingInterval = time.Duration(gnmi.Get(t, dut, gnmi.OC().Component(opticalChannelName).OpticalChannel().OutputPower().Interval().State()))
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.

high

Removing the * time.Second multiplier introduces a bug. In Go, time.Duration is an integer count of nanoseconds. Since the OpenConfig leaf output-power/interval typically returns a value in seconds, time.Duration(val) will result in a duration of only a few nanoseconds (e.g., 30ns instead of 30s). This will cause the samplestream to attempt sampling at an extremely high frequency, which is incorrect for transceiver power telemetry and may lead to performance issues or test failures.

Suggested change
currentSamplingInterval = time.Duration(gnmi.Get(t, dut, gnmi.OC().Component(opticalChannelName).OpticalChannel().OutputPower().Interval().State()))
currentSamplingInterval = time.Duration(gnmi.Get(t, dut, gnmi.OC().Component(opticalChannelName).OpticalChannel().OutputPower().Interval().State())) * time.Second

Comment on lines +93 to +97
if operationalModeFlag != nil {
operationalMode = uint16(*operationalModeFlag)
} else {
t.Fatalf("Please specify the vendor-specific operational-mode flag")
}
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

The check if operationalModeFlag != nil is redundant. The flag.Int function returns a pointer to an integer that is allocated during package initialization and will never be nil. If the goal is to ensure that the user explicitly provided a value for this flag, consider checking if the value is non-zero (if 0 is not a valid mode) or using flag.Visit to detect if the flag was set on the command line. As currently implemented, the else block is unreachable dead code.

Comment on lines +105 to +106
cfgplugins.ConfigOpticalChannel(t, dut, och1, targetFrequencyMHz, targetOutputPowerdBm, operationalMode)
cfgplugins.ConfigOpticalChannel(t, dut, och2, targetFrequencyMHz, targetOutputPowerdBm, operationalMode)
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

The usage of cfgplugins.ConfigOpticalChannel does not adhere to the repository's style guide for configuration plugins. According to the guidelines, plugin functions should use a *gnmi.SetBatch for configuration and accept parameters via a configuration struct. The signature should follow the pattern: (t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, cfg MyConfigStruct) *gnmi.SetBatch. Refactoring to parameterized versions helps reduce code duplication.

References
  1. Configuration plugin functions must follow a specific signature: (t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, cfg MyConfigStruct) *gnmi.SetBatch. (link)
  2. Refactor functions to use parameterized versions to reduce code duplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants