Skip to content

gNMI-3 : Updated changes to support Juniper devices#5618

Open
priyaranjannanda wants to merge 2 commits into
openconfig:mainfrom
priyaranjannanda:gNMI-3_1
Open

gNMI-3 : Updated changes to support Juniper devices#5618
priyaranjannanda wants to merge 2 commits into
openconfig:mainfrom
priyaranjannanda:gNMI-3_1

Conversation

@priyaranjannanda

Copy link
Copy Markdown
Contributor
  • Changes to o support Juniper devices

@priyaranjannanda priyaranjannanda requested a review from a team as a code owner June 25, 2026 11:04
@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 adjustments to the gNMI union_replace test suite to ensure compatibility with Juniper network devices. The changes primarily focus on handling Junos-specific configuration hierarchies, managing mandatory YANG statements, and addressing pre-commit conflicts that arise when CLI and OpenConfig operations overlap under config-namespace mode.

Highlights

  • Juniper Device Support: Added comprehensive support for Juniper devices in gNMI union_replace tests, including handling hierarchical configuration blocks and specific YANG requirements.
  • Configuration Stripping: Implemented a utility function to strip specific top-level Junos configuration blocks that contain incompatible wildcards or overlap with OpenConfig-managed paths.
  • Test Adjustments: Updated multiple test cases to account for vendor-specific behaviors, such as skipping CLI overrides when they conflict with OpenConfig state or using direct state reads for non-subscribable paths on Juniper.
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.

@OpenConfigBot

OpenConfigBot commented Jun 25, 2026

Copy link
Copy Markdown

Pull Request Functional Test Report for #5618 / ae3c0e2

Virtual Devices

Device Test Test Documentation Job Raw Log
Arista cEOS status
gNMI-3: union_replace
Cisco 8000E status
gNMI-3: union_replace
Cisco XRd status
gNMI-3: union_replace
Juniper ncPTX status
gNMI-3: union_replace
Nokia SR Linux status
gNMI-3: union_replace
Openconfig Lemming status
gNMI-3: union_replace

Hardware Devices

Device Test Test Documentation Raw Log
Arista 7808 status
gNMI-3: union_replace
Cisco 8808 status
gNMI-3: union_replace
Juniper PTX10008 status
gNMI-3: union_replace
Nokia 7250 IXR-10e status
gNMI-3: union_replace

Help

@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 adapts the union replace tests to support Juniper devices under config-namespace mode. It introduces a helper to strip top-level Junos configuration blocks, adds mandatory interface type statements, and skips CLI overrides that conflict with OpenConfig-managed paths on Juniper. Feedback focuses on improving the block-stripping logic to avoid matching nested blocks, replacing direct vendor checks (dut.Vendor()) with the deviations package while explicitly skipping unsupported test paths, and removing unreachable dead code in TestUnionReplace3_6_1.

Comment on lines +153 to +162
trimmed := strings.TrimSpace(line)
if !inStripped && depth == 0 {
// Check if this line opens one of the blocks to strip.
for blockName := range stripped {
if trimmed == blockName+" {" {
inStripped = true
depth = 1
break
}
}

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

Using strings.TrimSpace(line) before checking if the line starts a block to strip can lead to matching nested blocks (e.g., a nested groups block inside a BGP configuration) rather than only top-level blocks. Since top-level blocks in Junos configuration never have leading whitespace, we should enforce that there is no leading whitespace by using strings.TrimRight instead of strings.TrimSpace.

Suggested change
trimmed := strings.TrimSpace(line)
if !inStripped && depth == 0 {
// Check if this line opens one of the blocks to strip.
for blockName := range stripped {
if trimmed == blockName+" {" {
inStripped = true
depth = 1
break
}
}
if !inStripped && depth == 0 {
// Check if this line opens one of the blocks to strip.
// Top-level blocks in Junos configuration have no leading whitespace.
for blockName := range stripped {
if strings.TrimRight(line, " \r\t") == blockName+" {" {
inStripped = true
depth = 1
break
}
}

Comment on lines +337 to +339
} else {
t.Logf("Skipping CLI mtu override for Juniper: CLI interface mtu conflicts with OC-managed mtu under config-namespace mode.")
}

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

Silently bypassing the core action of a test case (the CLI MTU override) and letting the test pass without executing its assertions is misleading. If a test case or a portion of it cannot be run on a specific platform, it should be explicitly skipped using t.Skip. Additionally, avoid using dut.Vendor() for vendor-specific logic; instead, use the deviations package to maintain test abstraction and portability.

	if deviations.CliMtuOverrideUnsupported(dut) {
		t.Skip("Skipping CLI mtu override: CLI interface mtu conflicts with OC-managed mtu under config-namespace mode.")
	}
References
  1. Avoid using "dut.Vendor()" for vendor-specific logic or configurations in tests. Instead, use the "deviations" package to maintain test abstraction and portability across different vendors.

Comment on lines +541 to +543
} else {
t.Logf("Skipping CLI description override for Juniper: CLI interface description conflicts with OC-managed description under config-namespace mode.")
}

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

Similar to the MTU override test, silently bypassing the CLI description override and letting the test pass without validation is misleading. Use t.Skip to explicitly skip this portion of the test. Ensure you use a deviation check from the deviations package instead of checking dut.Vendor() directly to maintain test portability.

	if deviations.CliDescriptionOverrideUnsupported(dut) {
		t.Skip("Skipping CLI description override: CLI interface description conflicts with OC-managed description under config-namespace mode.")
	}
References
  1. Avoid using "dut.Vendor()" for vendor-specific logic or configurations in tests. Instead, use the "deviations" package to maintain test abstraction and portability across different vendors.

Comment on lines +600 to +617
if dut.Vendor() == ondatra.JUNIPER {
speed := gnmi.Get(t, dut, gnmi.OC().Interface(dp1.Name()).Ethernet().PortSpeed().State())
t.Logf("PortSpeed state after union_replace: %v", speed)
} else {
gnmi.Watch(t, dut, gnmi.OC().Interface(dp1.Name()).Ethernet().PortSpeed().Config(), awaitTimeOut, func(val *ygnmi.Value[oc.E_IfEthernet_ETHERNET_SPEED]) bool {
speed, present := val.Val()
if !present {
t.Logf("PortSpeed config not present. Want: %v, got: not present", targetSpeed)
return false
}
if speed != targetSpeed {
t.Logf("PortSpeed config not set to target speed. Want: %v, got: %v", targetSpeed, speed)
return false
}
t.Logf("PortSpeed config is set to target speed: %v", speed)
return true
}).Await(t)
}

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

Since TestUnionReplace3_6_1 is skipped at the very beginning for Juniper (line 560), the check if dut.Vendor() == ondatra.JUNIPER here is unreachable dead code. Removing this conditional block and directly using the gnmi.Watch call also aligns with avoiding direct vendor checks in favor of portability.

	gnmi.Watch(t, dut, gnmi.OC().Interface(dp1.Name()).Ethernet().PortSpeed().Config(), awaitTimeOut, func(val *ygnmi.Value[oc.E_IfEthernet_ETHERNET_SPEED]) bool {
		speed, present := val.Val()
		if !present {
			t.Logf("PortSpeed config not present. Want: %v, got: not present", targetSpeed)
			return false
		}
		if speed != targetSpeed {
			t.Logf("PortSpeed config not set to target speed. Want: %v, got: %v", targetSpeed, speed)
			return false
		}
		t.Logf("PortSpeed config is set to target speed: %v", speed)
		return true
	}).Await(t)
References
  1. Avoid using "dut.Vendor()" for vendor-specific logic or configurations in tests. Instead, use the "deviations" package to maintain test abstraction and portability across different vendors.

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