gnmi-ni-test script updates#5384
Conversation
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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. |
| // Seed the random generator | ||
| rand.Seed(time.Now().UnixNano()) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
- Configuration plugin functions must use a struct for parameters and return a *gnmi.SetBatch. (link)
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"