Skip to content

Update traffic validation to use otgutils.ExpectedTrafficLoss - #5887

Merged
navaneethyv merged 11 commits into
openconfig:mainfrom
AmrNJ:feature/expected-traffic-loss-retry
Aug 13, 2026
Merged

Update traffic validation to use otgutils.ExpectedTrafficLoss#5887
navaneethyv merged 11 commits into
openconfig:mainfrom
AmrNJ:feature/expected-traffic-loss-retry

Conversation

@AmrNJ

@AmrNJ AmrNJ commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
  1. Refactor all BGP tests to use the new ExpectedTrafficLoss function from otgutils.
  2. Wherever int(lossPct) were used, the function is updated to otgutils.ExpectedTrafficLoss(t, otg, flowName, 0, 0.99) to account for the previously truncated decimal values.

@OpenConfigBot

OpenConfigBot commented Aug 11, 2026

Copy link
Copy Markdown

Pull Request Functional Test Report for #5887 / dbf8f01

Virtual Devices

Device Test Test Documentation Job Raw Log
Arista cEOS status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation
0835182d Log
Cisco 8000E status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation
38cada93 Log
Cisco XRd status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation
f50a7c29 Log
Juniper ncPTX status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation
c743c726 Log
Nokia SR Linux status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation
e79d0251 Log
Openconfig Lemming status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation
de663063 Log

Hardware Devices

Device Test Test Documentation Raw Log
Arista status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation
Cisco status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation
Juniper status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation
Nokia status
status
status
status
status
status
status
status
status
status
status
status
status
RT-1.27: Static route to BGP redistribution
TE-3.31: Hierarchical weight resolution with PBF
RT-1.35: BGP Graceful Restart Extended route retention (ExRR)
RT-7.3: BGP Policy AS Path Set
RT-7.2: BGP Policy Community Set
RT-1.5: BGP Prefix Limit
TE-3.3: Hierarchical weight resolution
SR-1.1: Transit forwarding to Node-SID via ISIS
RT-1.12: BGP always compare MED
RT-1.65: BGP scale test
RT-7.4: BGP Policy AS Path Set and Community Set
RT-7.8: BGP Policy Match Standard Community and Add Community Import/Export Policy
RT-1.2: BGP Policy & Route Installation

Help

@AmrNJ
AmrNJ force-pushed the feature/expected-traffic-loss-retry branch from 5c81c2a to d016763 Compare August 11, 2026 18:13
@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 refactors a wide range of BGP tests to standardize traffic validation. By replacing custom, repetitive validation logic with the centralized otgutils.ExpectedTrafficLoss function, the codebase becomes cleaner and easier to maintain. This change ensures consistent behavior across different test scenarios while reducing the surface area for potential bugs in validation logic.

Highlights

  • Standardized Traffic Validation: Consolidated traffic validation logic across multiple BGP test suites by migrating to the centralized otgutils.ExpectedTrafficLoss function.
  • Code Reduction: Removed redundant gnmi.Watch implementations and manual packet loss calculations, significantly reducing boilerplate code in test files.
  • Improved Maintainability: Enhanced test readability and consistency by leveraging a unified helper for verifying expected traffic loss thresholds.
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 refactors multiple BGP and MPLS/SR OTG tests by replacing custom traffic loss validation logic with the standardized helper function otgutils.ExpectedTrafficLoss. This significantly simplifies the test files and improves code maintainability. The feedback identifies temporary merge artifact files (.rej and .orig) that were accidentally committed and should be deleted before merging. Additionally, a simplification is suggested for an unnecessarily complex type conversion in bgp_always_compare_med_test.go.

I am having trouble creating individual review comments. Click here to see my feedback.

feature/bgp/policybase/otg_tests/aspath_test/aspath_test.go.rej (1)

medium

This .rej file (along with the corresponding .orig file) is a temporary artifact from a patch or merge conflict resolution. These files should not be committed to the repository. Please delete aspath_test.go.rej and aspath_test.go.orig before merging.

feature/bgp/policybase/otg_tests/community_test/community_test.go.rej (1)

medium

This .rej file (along with the corresponding .orig file) is a temporary artifact from a patch or merge conflict resolution. These files should not be committed to the repository. Please delete community_test.go.rej and community_test.go.orig before merging.

feature/bgp/otg_tests/bgp_always_compare_med/bgp_always_compare_med_test.go (375-379)

medium

The conversion float64(100-float32(tolerancePct)) is unnecessarily complex because tolerancePct is an untyped constant. It can be simplified directly to float64(100-tolerancePct).

	if wantLoss {
		otgutils.ExpectedTrafficLoss(t, otg, flowName, float64(100-tolerancePct), 100)
	} else {
		otgutils.ExpectedTrafficLoss(t, otg, flowName, 0, float64(tolerancePct))
	}
References
  1. In Go test assertions, avoid over-complicating arithmetic operations with defensive type casting (e.g., casting uint32 to uint64 to prevent overflow) if the values involved (such as packet mismatch counters) are guaranteed to be extremely small in practice.

@AmrNJ

AmrNJ commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

/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 refactors traffic validation across multiple BGP, MPLS, and ISIS OTG tests by replacing duplicated gnmi.Watch validation blocks with the helper function otgutils.ExpectedTrafficLoss. While this significantly simplifies the codebase, the refactoring left behind unused imports of github.com/openconfig/ygnmi/ygnmi in aspath_and_community_test.go and isis_node_sid_forward_test.go, which will cause Go compilation errors. Additionally, the type conversions in bgp_always_compare_med_test.go can be simplified, and the packet counter query in isis_node_sid_forward_test.go should use gnmi.Watch to prevent flaky test failures.

@AmrNJ
AmrNJ marked this pull request as ready for review August 12, 2026 11:06
@AmrNJ
AmrNJ requested review from a team as code owners August 12, 2026 11:06
@AmrNJ
AmrNJ requested a review from a team as a code owner August 12, 2026 18:33
@AmrNJ

AmrNJ commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

/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 refactors multiple OTG test files to use the helper function otgutils.ExpectedTrafficLoss instead of manually implementing gnmi.Watch loops and calculating traffic loss percentages, standardizing traffic loss verification across BGP, gRIBI, and MPLS tests. The review feedback correctly points out that some outer gnmi.Watch blocks in exrr_test.go are now redundant and should be removed, as otgutils.ExpectedTrafficLoss internally performs the same watch and validation.

Comment thread feature/bgp/gracefulrestart/otg_tests/exrr/exrr_test.go Outdated
Comment thread feature/bgp/gracefulrestart/otg_tests/exrr/exrr_test.go Outdated
@AmrNJ

AmrNJ commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

/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 refactors multiple BGP, gRIBI, and MPLS/SR OTG tests by replacing verbose, custom traffic loss verification blocks with the standardized otgutils.ExpectedTrafficLoss helper function. This significantly reduces boilerplate code and improves test consistency. A review comment was kept for isis_node_sid_forward_test.go which identifies a potential test flakiness issue where flow counters are queried once using gnmi.Get immediately after traffic stops; the reviewer recommends wrapping this query in a gnmi.Watch loop to allow sufficient time for the counters to populate.

@navaneethyv
navaneethyv merged commit 97ebd38 into openconfig:main Aug 13, 2026
23 checks passed
dharanitharanr-cell pushed a commit to dharanitharanr-cell/featureprofiles that referenced this pull request Aug 13, 2026
…nfig#5887)

* Update traffic validation to use otgutils.ExpectedTrafficLoss

* Update bgp_prefix_limit_test.go

* Update aspath_and_community_test.go

* Update isis_node_sid_forward_test.go

* Update aspath_and_community_test.go

* Update isis_node_sid_forward_test.go

* Update bgp_always_compare_med_test.go

* Standardize all traffic validation on otgutils.ExpectedTrafficLoss

* Remove unused imports

* Fix float32 to float64 cast in bgp_prefix_limit_test.go

* Update exrr_test.go
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.

3 participants