Skip to content

Add BGP local-preference test cases for T1 topology#10

Open
bpar9 wants to merge 1 commit into
masterfrom
devin/1771007471-bgp-local-preference-tests
Open

Add BGP local-preference test cases for T1 topology#10
bpar9 wants to merge 1 commit into
masterfrom
devin/1771007471-bgp-local-preference-tests

Conversation

@bpar9
Copy link
Copy Markdown
Owner

@bpar9 bpar9 commented Feb 13, 2026

Description of PR

Summary:
Adds tests/bgp/test_bgp_local_preference.py implementing 21 test cases for BGP local-preference functionality on T1 topology, based on the BGP Local-Preference Test Plan.

Test cases cover:

  1. Default local-preference value (100) for eBGP-learned routes
  2. Setting local-preference via inbound route-map
  3. Best path selection preferring higher local-preference
  4. Local-preference propagation to iBGP peers
  5. Local-preference NOT sent to eBGP peers
  6. Persistence after BGP restart
  7. IPv6 route support
  8. Boundary values (0 and 4294967295)
  9. Local-preference override via route-map update
  10. Multiple prefixes with same local-preference
  11. Multiple paths (3+ neighbors) with different values
  12. Tie-breaking with equal local-preference (AS-path secondary)
  13. Local-preference takes precedence over AS-path length
  14. Local-preference takes precedence over MED
  15. Interaction with weight attribute
  16. Route flapping stability
    17–21. Route reflector scenarios (preservation, setting, best path, multiple clients, client override)

Link to Devin run: https://cisco-demo.devinenterprise.com/sessions/5d7e6751313845458da92a5214eca3b4
Requested by: @bpar9

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Approach

What is the motivation for this PR?

Provide automated test coverage for BGP local-preference attribute behavior, including route-map configuration, best path selection, iBGP/eBGP propagation rules, interaction with other path attributes (AS-path, MED, weight), and route reflector scenarios.

How did you do it?

  • Single new file: tests/bgp/test_bgp_local_preference.py
  • Uses ExaBGP on PTF host to announce/withdraw test routes via HTTP API
  • Uses vtysh commands to configure route-maps and query BGP RIB (JSON output)
  • Module-scoped setup fixture gathers topology info (T0/T2 neighbors, ASN, ExaBGP ports, next-hops)
  • Autouse cleanup fixture ensures route-map removal after each test
  • Helper functions for ExaBGP interaction, route-map config, BGP route queries

How did you verify/test it?

  • Passes flake8 lint checks
  • Note: Not tested on actual testbed - requires T1 topology with ExaBGP running on PTF host

Any platform specific information?

None - uses standard FRR/vtysh commands

Supported testbed topology if it's a new test case?

T1 topology only (@pytest.mark.topology('t1'))

Human Review Checklist

Reviewers should verify:

  • ExaBGP HTTP API pattern (POST to http://<ptfip>:<port> with commands field) matches testbed setup
  • vtysh JSON output structure (paths, locPrf, bestpath, peerId, aspath) matches FRR version
  • T0 neighbors = iBGP peers, T2 neighbors = eBGP peers assumption is correct for T1
  • Test prefixes (10.100.0.0/24, 2001:db8:100::/64, 10.200.x.0/24) don't conflict with testbed routes
  • Route reflector config/cleanup in tests 17-21 is safe for the testbed
  • Variable naming (shortened for 79-char compliance) is acceptable for maintainability

Documentation

N/A - test code only

@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant