Skip to content

Otg gnpsi-1 update for Cisco run - #5525

Open
ijernoiu wants to merge 7 commits into
openconfig:mainfrom
open-traffic-generator:otg-gnpsi-1-updateCisco
Open

ijernoiu wants to merge 7 commits into
openconfig:mainfrom
open-traffic-generator:otg-gnpsi-1-updateCisco

Conversation

@ijernoiu

@ijernoiu ijernoiu commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@ijernoiu
ijernoiu requested a review from a team as a code owner June 1, 2026 05:55
@OpenConfigBot

OpenConfigBot commented Jun 1, 2026 •

Copy link
Copy Markdown

Pull Request Functional Test Report for #5525 / 0522e6c

Virtual Devices

Device Test Status Test Documentation Job Raw Log
Arista cEOS status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check
Cisco 8000E status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check
Cisco XRd status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check
Juniper ncPTX status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check
Nokia SR Linux status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check
Openconfig Lemming status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check

Hardware Devices

Device Test Status Test Documentation Raw Log
Arista status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check
Cisco status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check
Juniper status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check
Nokia status
gNPSI-1: pending authorization
gNPSI-1: Sampling and Subscription Check

Help

@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 introduces necessary updates to the gNPSI and sFlow testing infrastructure to improve compatibility with Cisco platforms. It includes adjustments to test configuration parameters, dynamic handling of sampling rates, and the addition of platform-specific deviation flags to ensure tests run correctly across different vendor implementations.

Highlights

  • Cisco Platform Support: Added platform-specific deviations for Cisco devices to handle sFlow sampling rates and gNPSI export requirements.
  • gNPSI Configuration: Updated the gNPSI configuration plugin to support OpenConfig-based configuration and added necessary parameters like ServerName and NetworkInstance.
  • sFlow Test Improvements: Refined sFlow sampling tests to use dynamic channel capacities based on device-specific sampling rates and improved validation logic.
  • Infrastructure Updates: Added a new deviation flag 'missing_sflow_gnpsi_export' and updated internal configuration helpers to support CLI-based gNPSI export for specific vendors.
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. ↩

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

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.

Code Review

This pull request introduces support for gNPSI configuration and sFlow gNPSI export, particularly addressing Cisco-specific deviations. It implements gNPSI configuration from OpenConfig (OC) using gNMI, adds a new deviation missing_sflow_gnpsi_export to handle sFlow export configuration via CLI on Cisco devices, and updates the sampling test to dynamically adjust expected sampling rates and channel capacities based on the sflow_ingress_min_sampling_rate deviation. Additionally, a typo was fixed in the topology binding options. The reviewer recommended refactoring duplicated logic for determining the effective sampling rate into a single helper function to improve maintainability.

Comment thread proto/metadata.proto Resolved
Comment thread internal/deviations/deviations.go Resolved
@ijernoiu

ijernoiu commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Updated the deviation details

@ram-mac

ram-mac commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

@ijernoiu - I have validated and the test is not passing. I have attached the logs to the bug 510677651 for reference.

@jayakumarramisetty

Copy link
Copy Markdown
Contributor

/gemini review

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

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.

Code Review

This pull request introduces support for gNPSI sFlow export configurations, adding a new deviation missing_sflow_gnpsi_export for Cisco devices, implementing the ConfigureSflowGnpsiExport helper, and updating the gNPSI configuration plugin to support OpenConfig-based setup. Additionally, the sFlow test is updated to dynamically handle sampling rates and channel capacities, and to wait for samples to stabilize. Feedback from the review highlights style guide violations regarding configuration plugins and state reversion: specifically, ConfigureGNPSI should append configurations to a *gnmi.SetBatch rather than applying them directly, and both the test configuration and the CLI-based sFlow export configuration must register appropriate cleanup operations using t.Cleanup() to ensure mandatory state reversion.

Comment on lines 627 to 633
params := &cfgplugins.GNPSIParams{
Port: gnpsiPort,
Port: uint16(gnpsiPort),
SSLProfile: profileName,
ServerName: serverName,
NIName: deviations.DefaultNetworkInstance(dut),
}
cfgplugins.ConfigureGNPSI(t, dut, params)

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

Following the Repository Style Guide (Section 4, Configuration Plugins Guidelines) and general repository rules, configuration plugins should append OpenConfig configurations to a *gnmi.SetBatch rather than applying them directly. Additionally, all configuration changes must have corresponding cleanup operations registered using t.Cleanup() before executing the configuration push to ensure mandatory state reversion.

	params := &cfgplugins.GNPSIParams{
		Port:       uint16(gnpsiPort),
		SSLProfile: profileName,
		ServerName: serverName,
		NIName:     deviations.DefaultNetworkInstance(dut),
	}
	if sb := cfgplugins.ConfigureGNPSI(t, dut, &gnmi.SetBatch{}, params); sb != nil {
		t.Cleanup(func() {
			gnmi.Delete(t, dut, gnmi.OC().System().GrpcServer(params.ServerName).Config())
		})
		sb.Set(t, dut)
	}
References
  1. Section 4 of the Repository Style Guide requires configuration plugins to append config to a *gnmi.SetBatch object, and the calling test code is responsible for executing batch.Set() to apply the config. (link)
  2. Section 1 of the Repository Style Guide requires all cleanup operations to be registered using t.Cleanup() to guarantee they are executed even if the test fails or panics early. (link)
  3. Always register cleanup operations using 't.Cleanup()' before executing configuration pushes (e.g., 'b.Set()') or destructive operations (e.g., 'gnmi.Delete()').

Comment on lines +135 to +146
func ConfigureSflowGnpsiExport(t *testing.T, dut *ondatra.DUTDevice) {
t.Log("Configuring sFlow gNPSI export from CLI")
switch dut.Vendor() {
case ondatra.CISCO:
addrUnderscored := strings.ReplaceAll(defaultCollectorAddressV4, ".", "_")
exporterName := fmt.Sprintf("OC-FEM-%s-%d", addrUnderscored, defaultCollectorPort)
cli := fmt.Sprintf("flow exporter-map %s\n export protocol gnpsi\n!", exporterName)
helpers.GnmiCLIConfig(t, dut, cli)
default:
t.Logf("ConfigureSflowGnpsiExport: no CLI needed for vendor %s", dut.Vendor())
}
}

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

To adhere to the Repository Style Guide's mandatory state reversion requirement, all configuration changes made during the test must be reverted. For CLI-based configurations, register a corresponding cleanup operation using t.Cleanup() before applying the configuration.

Suggested change
func ConfigureSflowGnpsiExport(t *testing.T, dut *ondatra.DUTDevice) {
t.Log("Configuring sFlow gNPSI export from CLI")
switch dut.Vendor() {
case ondatra.CISCO:
addrUnderscored := strings.ReplaceAll(defaultCollectorAddressV4, ".", "_")
exporterName := fmt.Sprintf("OC-FEM-%s-%d", addrUnderscored, defaultCollectorPort)
cli := fmt.Sprintf("flow exporter-map %s\n export protocol gnpsi\n!", exporterName)
helpers.GnmiCLIConfig(t, dut, cli)
default:
t.Logf("ConfigureSflowGnpsiExport: no CLI needed for vendor %s", dut.Vendor())
}
}
func ConfigureSflowGnpsiExport(t *testing.T, dut *ondatra.DUTDevice) {
t.Log("Configuring sFlow gNPSI export from CLI")
switch dut.Vendor() {
case ondatra.CISCO:
addrUnderscored := strings.ReplaceAll(defaultCollectorAddressV4, ".", "_")
exporterName := fmt.Sprintf("OC-FEM-%s-%d", addrUnderscored, defaultCollectorPort)
cli := fmt.Sprintf("flow exporter-map %s\n export protocol gnpsi\n!", exporterName)
t.Cleanup(func() {
negateCli := fmt.Sprintf("flow exporter-map %s\n no export protocol gnpsi\n!", exporterName)
helpers.GnmiCLIConfig(t, dut, negateCli)
})
helpers.GnmiCLIConfig(t, dut, cli)
default:
t.Logf("ConfigureSflowGnpsiExport: no CLI needed for vendor %s", dut.Vendor())
}
}
References
  1. Section 1 of the Repository Style Guide requires all cleanup operations to be registered using t.Cleanup() to guarantee they are executed even if the test fails or panics early. (link)
  2. Always register cleanup operations using 't.Cleanup()' before executing configuration pushes (e.g., 'b.Set()') or destructive operations (e.g., 'gnmi.Delete()').

Comment on lines 36 to 56
func ConfigureGNPSI(t *testing.T, dut *ondatra.DUTDevice, params *GNPSIParams) {
t.Logf("Using gNPSI port: %d", params.Port)
if deviations.GnpsiOcUnsupported(dut) {
configureGNPSIFromCLI(t, dut, params)
} else {
configureGNPSIFromOC(t, dut)
configureGNPSIFromOC(t, dut, params)
}
}

func configureGNPSIFromOC(t *testing.T, dut *ondatra.DUTDevice) {
// TODO : Implement GNPSI OC configuration when supported in OC (ref: https://github.com/openconfig/public/pull/1385)
t.Fatalf("gNPSI OC configuration is not supported: %s - %s", dut.Version(), dut.Model())
func configureGNPSIFromOC(t *testing.T, dut *ondatra.DUTDevice, params *GNPSIParams) {
t.Log("Configuring gNPSI from OC")
gnmiServerPath := gnmi.OC().System().GrpcServer(params.ServerName)
gnmiServer := &oc.System_GrpcServer{
Name: ygot.String(params.ServerName),
Port: ygot.Uint16(params.Port),
Enable: ygot.Bool(true),
NetworkInstance: ygot.String(params.NIName),
}
gnmiServer.Services = []oc.E_SystemGrpc_GRPC_SERVICE{oc.SystemGrpc_GRPC_SERVICE_GNPSI}
gnmi.Replace(t, dut, gnmiServerPath.Config(), gnmiServer)
}

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

In accordance with the Repository Style Guide (Section 4, Configuration Plugins Guidelines) and general repository rules, configuration plugins should append OpenConfig configurations to a *gnmi.SetBatch rather than applying them directly. This allows the calling test code to batch operations and manage cleanups effectively.

func ConfigureGNPSI(t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, params *GNPSIParams) *gnmi.SetBatch {
	t.Logf("Using gNPSI port: %d", params.Port)
	if deviations.GnpsiOcUnsupported(dut) {
		configureGNPSIFromCLI(t, dut, params)
		return nil
	}
	return configureGNPSIFromOC(t, dut, sb, params)
}

func configureGNPSIFromOC(t *testing.T, dut *ondatra.DUTDevice, sb *gnmi.SetBatch, params *GNPSIParams) *gnmi.SetBatch {
	t.Log("Configuring gNPSI from OC")
	gnmiServerPath := gnmi.OC().System().GrpcServer(params.ServerName)
	gnmiServer := &oc.System_GrpcServer{
		Name:            ygot.String(params.ServerName),
		Port:            ygot.Uint16(params.Port),
		Enable:          ygot.Bool(true),
		NetworkInstance: ygot.String(params.NIName),
	}
	gnmiServer.Services = []oc.E_SystemGrpc_GRPC_SERVICE{oc.SystemGrpc_GRPC_SERVICE_GNPSI}
	gnmi.BatchReplace(sb, gnmiServerPath.Config(), gnmiServer)
	return sb
}
References
  1. Section 4 of the Repository Style Guide requires configuration plugins to append config to a *gnmi.SetBatch object, and the calling test code is responsible for executing batch.Set() to apply the config. (link)
  2. In configuration plugins (cfgplugins), OpenConfig configurations should be appended to a *gnmi.SetBatch. For CLI fallbacks (when OpenConfig is unsupported), the plugin should push the CLI directly (batched to minimize RPCs) and return nil if no OpenConfig configuration is added, preventing the caller from sending an empty SetRequest.

@jayakumarramisetty jayakumarramisetty left a comment

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.

please address all gemini comments

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants