Skip to content

Add testplan and test implementation for BGP Local-Preference feature#7

Open
bpar9 wants to merge 4 commits into
masterfrom
devin/1768380342-bgp-local-preference-test
Open

Add testplan and test implementation for BGP Local-Preference feature#7
bpar9 wants to merge 4 commits into
masterfrom
devin/1768380342-bgp-local-preference-test

Conversation

@bpar9
Copy link
Copy Markdown
Owner

@bpar9 bpar9 commented Jan 14, 2026

Description of PR

Summary:
This PR adds a comprehensive test plan document and pytest implementation for validating the BGP Local-Preference feature in SONiC. BGP Local-Preference is a well-known path attribute used to influence outbound traffic routing decisions within an AS, where higher values are preferred (default is 100).

Reviewer start point: Begin with the test plan document to understand the test coverage, then review the test implementation for correctness.

Files added:

  • docs/testplan/BGP-Local-Preference-Test-Plan.md - Test plan documenting 21 test cases
  • tests/bgp/test_bgp_local_preference.py - Pytest implementation with 14 test functions

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

Updates since last revision

Type of change

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

Back port request

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

Approach

What is the motivation for this PR?

To provide automated test coverage for the BGP Local-Preference feature, validating that SONiC correctly handles local-preference configuration via route-maps and applies it to BGP path selection.

How did you do it?

How did you verify/test it?

  • Code passes flake8 linting (79 character line limit)
  • Follows existing BGP test patterns in sonic-mgmt

Items for reviewer attention:

  1. Route reflector test cases (Add L3VNI DCI MAC move test cases (L3VNI_dci:59,60,62,63) #17-Review TC47/TC49: align test_base_dci_l3vni_external_connectivity with testplan #21) are documented in testplan but not yet implemented in the test file
  2. test_local_preference_persistence_after_bgp_restart assumes vtysh route-map config persists after BGP restart - please verify this matches expected SONiC/FRR behavior
  3. Tests rely on existing routes from neighbors; if no routes exist, tests skip rather than fail
  4. Multi-path tests (Add Klish AAA CLI validation tests for VS KVM testing #11-Add L3VNI cross-DC test cases (L3VNI_dci:1-2, 6-30, 39-43, 91, 101) + 6 trigger classes #12) require multiple BGP neighbors - tests skip if fewer than required neighbors are available

Any platform specific information?

None - tests use vtysh for route-map configuration which is platform-agnostic.

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

  • t0
  • t0-multi-asic
  • t1
  • t1-multi-asic

Documentation

Test plan document added at docs/testplan/BGP-Local-Preference-Test-Plan.md

This commit adds:
- docs/testplan/BGP-Local-Preference-Test-Plan.md: Comprehensive testplan
  documenting 10 test cases for BGP Local-Preference functionality
- tests/bgp/test_bgp_local_preference.py: pytest implementation with 8 tests

Test cases cover:
- Default local-preference value (100)
- Setting local-preference via route-maps
- IPv6 route support
- Boundary values (0 and max uint32)
- Local-preference override
- Persistence after BGP restart
- Route-map configuration verification

Co-Authored-By: bhavani@cisco.com <bhavani@cisco.com>
@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

devin-ai-integration Bot and others added 3 commits January 14, 2026 09:10
- Add Test Case #11: Local-Preference with Multiple Paths
- Add Test Case #12: Local-Preference with Equal Values (Tie-Breaking)
- Add Test Case #13: Local-Preference Interaction with AS-Path
- Add Test Case #14: Local-Preference Interaction with MED
- Add Test Case #15: Local-Preference Interaction with Weight
- Add Test Case #16: Local-Preference with Route Flapping
- Extend topology support to include t0 and t0-multi-asic
- Update scope section to reflect new test coverage

Co-Authored-By: bhavani@cisco.com <bhavani@cisco.com>
- Add test_local_preference_multiple_paths (Test Case #11)
- Add test_local_preference_equal_values_tiebreaker (Test Case #12)
- Add test_local_preference_vs_aspath (Test Case #13)
- Add test_local_preference_vs_med (Test Case #14)
- Add test_local_preference_vs_weight (Test Case #15)
- Add test_local_preference_route_flapping (Test Case #16)
- Add helper functions for multi-path testing
- Update pytestmark to support t0 and t0-multi-asic topologies

Co-Authored-By: bhavani@cisco.com <bhavani@cisco.com>
…plan

- Test Case #17: Local-Preference Preservation via Route Reflector
- Test Case #18: Local-Preference Set by Route Reflector
- Test Case #19: Local-Preference Best Path Selection via Route Reflector
- Test Case #20: Local-Preference with Multiple Route Reflector Clients
- Test Case #21: Local-Preference Override at Route Reflector Client
- Updated scope section to include route reflector scenarios
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