Skip to content

bmp-1.1 bmp_base_session_test.go#5202

Open
cprabha wants to merge 1 commit intoopenconfig:mainfrom
cprabha:bmp-1.1
Open

bmp-1.1 bmp_base_session_test.go#5202
cprabha wants to merge 1 commit intoopenconfig:mainfrom
cprabha:bmp-1.1

Conversation

@cprabha
Copy link
Contributor

@cprabha cprabha commented Mar 7, 2026

Hi,

  1. Adding vendor specific cli commands to enable bmp.
  2. Also network instance type is set to default as in other tests.
  3. some of the cli set request is not under vendor specific, moved the code under vendor specific tag.

@cprabha cprabha requested review from a team as code owners March 7, 2026 02:18
@gemini-code-assist
Copy link
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 enhances the BGP Monitoring Protocol (BMP) test suite by introducing vendor-specific configurations, particularly for Juniper devices. It refactors existing BGP configuration logic to support platform-specific CLI commands for features like maximum routes and multipath, and ensures consistent default network instance settings in tests. The changes aim to improve the robustness and compatibility of BGP and BMP configurations across different network device vendors.

Highlights

  • Vendor-Specific BMP Configuration: Added vendor-specific CLI commands to enable BMP (BGP Monitoring Protocol) for Juniper devices, allowing for detailed route monitoring configurations.
  • Default Network Instance Configuration: Ensured that the network instance type is consistently set to default in relevant tests, aligning with existing test patterns.
  • BGP Configuration Refactoring: Moved certain BGP CLI set requests, previously generic, under a vendor-specific tag to improve modularity and platform-specific handling.
Changelog
  • feature/bgp/bmp/otg_tests/bmp_base_session_test/bmp_base_session_test.go
    • Configured the default network instance for the DUT.
  • feature/bgp/bmp/otg_tests/bmp_base_session_test/metadata.textproto
    • Added Juniper-specific platform exception for BMP OpenConfig unsupport.
  • internal/cfgplugins/bgp.go
    • Refactored BGP maximum routes and multipath configuration to be vendor-specific.
    • Implemented Juniper-specific CLI commands for BMP configuration, including pre-policy and post-policy route monitoring.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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
Copy link

Copy link
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 introduces vendor-specific configurations for BMP tests, particularly for Juniper, and refactors the default network instance configuration. The changes are generally good, but I've found a critical bug in the new Juniper BMP configuration logic within internal/cfgplugins/bgp.go. The code incorrectly appends to a string builder without resetting it, which will generate invalid CLI commands and cause test failures. I've also noted a deviation from the repository's style guide for cfgplugins. I've provided detailed comments with suggested fixes for these issues.

Comment on lines +1707 to 1761
case ondatra.JUNIPER:
fmt.Fprintf(bmpConfig, `
routing-options {
autonomous-system %d;
bmp {
statistics-timeout 30;
station r-bmp {
connection-mode active;
route-monitoring {
loc-rib;
pre-policy;
post-policy;
rib-out pre-policy post-policy;
}
station-address %s;
station-port %d;
}
}
}`, cfgParams.DutAS, cfgParams.StationAddr, cfgParams.StationPort)
helpers.GnmiCLIConfig(t, dut, bmpConfig.String())

if cfgParams.PrePolicy {
t.Log("Configured BMP station with pre-policy export")
fmt.Fprintf(bmpConfig, `
routing-options {
bmp {
station r-bmp {
route-monitoring {
pre-policy;
rib-out pre-policy;
}
}
}
}
`)
helpers.GnmiCLIConfig(t, dut, bmpConfig.String())
}

if cfgParams.PostPolicy {
t.Log("Configured BMP station with post-policy export")
fmt.Fprintf(bmpConfig, `
routing-options {
bmp {
station r-bmp {
route-monitoring {
post-policy;
rib-out post-policy;
}
}
}
}
`)
helpers.GnmiCLIConfig(t, dut, bmpConfig.String())
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There is a bug in how the Juniper BMP configuration is constructed. The strings.Builder (bmpConfig) is continuously appended to within the if cfgParams.PrePolicy and if cfgParams.PostPolicy blocks without being reset. This will lead to an invalid CLI configuration string if more than one of these blocks is executed, as it will concatenate multiple routing-options structures.

To fix this, you should call bmpConfig.Reset() before generating the configuration within each conditional block.

Additionally, the configuration logic appears redundant. The initial block configures pre-policy, post-policy, and rib-out pre-policy post-policy. The conditional blocks then re-apply a subset of this configuration. Consider refactoring to build a single configuration block based on the provided flags to avoid sending multiple, potentially overlapping, configuration updates.

case ondatra.JUNIPER:
				fmt.Fprintf(bmpConfig, `
				routing-options {
					autonomous-system %d;
    				bmp {
        				statistics-timeout 30;
						station r-bmp {                
							connection-mode active;
            				route-monitoring {
                				loc-rib;
                				pre-policy;
                				post-policy;
                				rib-out pre-policy post-policy;
             				}
            				station-address %s;
            				station-port %d;
						}	
        			}
				}`, cfgParams.DutAS, cfgParams.StationAddr, cfgParams.StationPort)
				helpers.GnmiCLIConfig(t, dut, bmpConfig.String())

				if cfgParams.PrePolicy {
					bmpConfig.Reset()
					t.Log("Configured BMP station with pre-policy export")
					fmt.Fprintf(bmpConfig, `
					routing-options {
    					bmp {
        					station r-bmp {                
            					route-monitoring {
                					pre-policy;
                					rib-out pre-policy;
            					}
							}	
        				}
					}		
					`)
					helpers.GnmiCLIConfig(t, dut, bmpConfig.String())
				}

				if cfgParams.PostPolicy {
					bmpConfig.Reset()
					t.Log("Configured BMP station with post-policy export")
					fmt.Fprintf(bmpConfig, `
					routing-options {
    					bmp {
        					station r-bmp {                
            					route-monitoring {
                					post-policy;
                					rib-out post-policy;
            					}
							}	
        				}
					}		
					`)
					helpers.GnmiCLIConfig(t, dut, bmpConfig.String())
				}
			}

Comment on lines +1707 to 1761
case ondatra.JUNIPER:
fmt.Fprintf(bmpConfig, `
routing-options {
autonomous-system %d;
bmp {
statistics-timeout 30;
station r-bmp {
connection-mode active;
route-monitoring {
loc-rib;
pre-policy;
post-policy;
rib-out pre-policy post-policy;
}
station-address %s;
station-port %d;
}
}
}`, cfgParams.DutAS, cfgParams.StationAddr, cfgParams.StationPort)
helpers.GnmiCLIConfig(t, dut, bmpConfig.String())

if cfgParams.PrePolicy {
t.Log("Configured BMP station with pre-policy export")
fmt.Fprintf(bmpConfig, `
routing-options {
bmp {
station r-bmp {
route-monitoring {
pre-policy;
rib-out pre-policy;
}
}
}
}
`)
helpers.GnmiCLIConfig(t, dut, bmpConfig.String())
}

if cfgParams.PostPolicy {
t.Log("Configured BMP station with post-policy export")
fmt.Fprintf(bmpConfig, `
routing-options {
bmp {
station r-bmp {
route-monitoring {
post-policy;
rib-out post-policy;
}
}
}
}
`)
helpers.GnmiCLIConfig(t, dut, bmpConfig.String())
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The implementation for Juniper in this case block violates the cfgplugins guidelines from CONTRIBUTING.md (summarized in internal/cfgplugins/README.md). The plugin directly applies configuration using helpers.GnmiCLIConfig instead of appending it to the gnmi.SetBatch.

According to the style guide, cfgplugins should not apply configuration themselves. They should add to the batch, and the calling test should execute batch.Set(). This allows for composing multiple configurations before applying them.

This function should be refactored to create a gnmi.Update with origin: "cli" and add it to the provided batch.

References
  1. cfgplugins functions should append configuration to a gnmi.SetBatch object and return it. The calling test is responsible for applying the configuration. This function directly applies configuration using helpers.GnmiCLIConfig, violating this pattern. (link)

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.

3 participants