Skip to content

gnmi-ni-test script updates#5384

Draft
mnp-juniper wants to merge 2 commits intoopenconfig:mainfrom
mnp-juniper:gnmini
Draft

gnmi-ni-test script updates#5384
mnp-juniper wants to merge 2 commits intoopenconfig:mainfrom
mnp-juniper:gnmini

Conversation

@mnp-juniper
Copy link
Copy Markdown
Contributor

The below listed changes are made to gnmi-ni-test to integrate juniper devices
1.changed hardcoded port arguments in CreateGNMIServer function
2. Added argument transportSecurity in CreateGNMIServer function
3.Added a routine to get unique unused port numbers
4.Deviations for juniper added :
default_ni_gnmi_server_name: "gnxi-mgmt_junos"
default_network_instance: "mgmt_junos"

@mnp-juniper mnp-juniper requested a review from a team as a code owner April 26, 2026 13:48
@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 updates the gnmi-ni-test suite to improve compatibility with Juniper devices. The changes focus on making gNMI server configuration more flexible by removing hardcoded port assignments in favor of a dynamic port generation routine, and introducing necessary vendor-specific deviations to ensure proper device interaction.

Highlights

  • Dynamic Port Assignment: Implemented a mechanism to generate unique, unused port numbers for gNMI server configuration to avoid conflicts.
  • Juniper Device Integration: Added specific deviations and logic to handle Juniper device requirements, including skipping internal system server placeholders and setting custom network instance names.
  • API Updates: Updated the CreateGNMIServer function to accept dynamic port and transport security arguments instead of using hardcoded values.
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.

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 introduces dynamic gNMI port generation and updates the gnmi_ni_test to handle Juniper-specific server naming and skipping. It also modifies the CreateGNMIServer plugin to support custom ports and transport security. Review feedback identifies a violation of the repository style guide for configuration plugins, which requires using a struct for parameters and returning a *gnmi.SetBatch. Additionally, the feedback points out inefficient random number generator seeding and minor comment formatting issues.

customGnmiServerName := "gnxi-" + customVRFName

var defaultValidated, customValidated bool
//if Juniper remove DEFAULT from the list.
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 comment is informal and slightly inaccurate as the code skips the entry rather than removing it from the list. Consider rephrasing for clarity and following standard Go comment style (starting with a space after //).

Comment on lines +213 to +214
// Seed the random generator
rand.Seed(time.Now().UnixNano())
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

Seeding the random number generator inside a function that is called multiple times is inefficient and can lead to non-random results if calls occur within the same nanosecond. Since Go 1.20, the global random generator is seeded automatically. If a manual seed is required for older Go versions, it should be placed in TestMain or init. Removing this call will also make the time import at line 7 unnecessary.


// CreateGNMIServer creates a gNMI server on the DUT on a given network-instance.
func CreateGNMIServer(t testing.TB, d *ondatra.DUTDevice, batch *gnmi.SetBatch, nip *NetworkInstanceParams) {
func CreateGNMIServer(t testing.TB, d *ondatra.DUTDevice, batch *gnmi.SetBatch, nip *NetworkInstanceParams, port uint16, transportSec bool) {
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 function signature for CreateGNMIServer violates the repository style guide for configuration plugins. It should use a configuration struct to pass parameters (such as port and transportSec) and return the *gnmi.SetBatch object. Additionally, adding parameters directly to the signature is a breaking change for other tests using this internal library.

References
  1. Configuration plugin functions must use a struct for parameters and return a *gnmi.SetBatch. (link)

@mnp-juniper mnp-juniper marked this pull request as draft April 26, 2026 17:02
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