Skip to content

RT-7.5: Change extended community verification to wait for expected value#5332

Open
andrewzhang624 wants to merge 1 commit intoopenconfig:mainfrom
andrewzhang624:rt7_5_wait_fix
Open

RT-7.5: Change extended community verification to wait for expected value#5332
andrewzhang624 wants to merge 1 commit intoopenconfig:mainfrom
andrewzhang624:rt7_5_wait_fix

Conversation

@andrewzhang624
Copy link
Copy Markdown

Edited functions validateRouteCommunity(V4|V6)Prefix in link_bandwidth_test.go to move the matching of the link-bandwidth extended community into the predicate of the WatchAll call.
Correspondingly changed the t.Errorf calls to t.Logf calls accompanied by return false in order to retry, and added t.Errorf after WatchAll timeout.

This fixes a test failure where an Arista DUT was failing with ERROR: extended community is empty, expected %v due to a race condition; currently, the function waits for any prefix to be present before grabbing a one-time snapshot with gnmi.GetAll. Because the prefix advertisements are continuously present throughout the test, this snapshot, if too soon, could fail to include the incoming update to implement the policy to add the community.

Precedent for this waiting pattern is seen in featureprofiles/feature/bgp/static_route_bgp_redistribution/otg_tests/static_route_bgp_redistribution_test/static_route_bgp_redistribution_test.go, in function validateLearnedIPv4Prefix.

…alue

Edited functions validateRouteCommunity(V4|V6)Prefix in
link_bandwidth_test.go to move the matching of the link-bandwidth
extended community into the predicate of the WatchAll call.
Correspondingly changed the `t.Errorf` calls to `t.Logf` calls
accompanied by `return false` to retry, and added `t.Errorf` after
WatchAll timeout.
@andrewzhang624 andrewzhang624 requested a review from a team as a code owner April 11, 2026 01:10
@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 addresses a race condition in the link bandwidth test suite where the test would intermittently fail because it attempted to validate route communities before the policy-driven updates were fully propagated. By moving the validation logic into the WatchAll predicate, the test now correctly waits for the expected state, improving overall test stability and reliability.

Highlights

  • Test Reliability Improvement: Refactored validateRouteCommunityV4Prefix and validateRouteCommunityV6Prefix to utilize gnmi.WatchAll for waiting on expected route community values, effectively mitigating race conditions during test execution.
  • Error Handling Update: Transitioned from immediate t.Errorf calls to t.Logf with a return false retry mechanism within the WatchAll predicate, ensuring tests only fail after the timeout period if the expected state is not reached.
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.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 11, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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 refactors the BGP route community validation for IPv4 and IPv6 prefixes by moving the validation logic directly into the gnmi.WatchAll predicate. This change improves the efficiency of the tests and allows for more granular error reporting when a watch fails. The review feedback identifies a potential nil pointer dereference when accessing prefix values, a logic flaw where empty community lists might cause false positives in specific test cases, and suggests aligning error message formatting with Go style conventions by removing redundant prefixes and using lowercase.

Comment on lines +459 to 460
bgpPrefix, _ := v.Val()
if bgpPrefix.GetAddress() == v4Prefix {
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

The code ignores the present boolean returned by v.Val(). If the prefix is deleted during the watch, bgpPrefix will be nil, and calling bgpPrefix.GetAddress() will cause a panic. It is safer to check for presence before accessing the value.

Suggested change
bgpPrefix, _ := v.Val()
if bgpPrefix.GetAddress() == v4Prefix {
bgpPrefix, present := v.Val()
if present && bgpPrefix.GetAddress() == v4Prefix {

Comment on lines 477 to 484
case "100:100":
for _, gotCommunity := range bgpPrefix.Community {
t.Logf("community AS:%d val: %d", gotCommunity.GetCustomAsNumber(), gotCommunity.GetCustomAsValue())
if gotCommunity.GetCustomAsNumber() != 100 || gotCommunity.GetCustomAsValue() != 100 {
t.Errorf("ERROR: community is not 100:100 got AS number:%d AS value:%d", gotCommunity.GetCustomAsNumber(), gotCommunity.GetCustomAsValue())
t.Logf("community is not 100:100 got AS number:%d AS value:%d", gotCommunity.GetCustomAsNumber(), gotCommunity.GetCustomAsValue())
return false
}
}
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 the "100:100" case, if bgpPrefix.Community is empty, the loop is skipped and the function eventually returns true at line 519. This causes the watch to succeed even if the expected community has not arrived yet. You should add a check to ensure the community list is not empty.

Comment on lines +525 to +527
t.Errorf("ERROR: No Route found for prefix %v", v4Prefix)
} else {
t.Errorf("ERROR: For Prefix %v, did not get expected lb Bandwidth", v4Prefix)
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 "ERROR: " prefix in t.Errorf is redundant as the testing framework already identifies the output as an error. Following Go conventions, error messages should be concise and typically start with a lowercase letter.

Suggested change
t.Errorf("ERROR: No Route found for prefix %v", v4Prefix)
} else {
t.Errorf("ERROR: For Prefix %v, did not get expected lb Bandwidth", v4Prefix)
t.Errorf("no route found for prefix %v", v4Prefix)
} else {
t.Errorf("for prefix %v, did not get expected lb bandwidth", v4Prefix)

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