Skip to content

tests(bgp): add BGP allow-as-in test case#20172

Open
sainath-nexthop wants to merge 1 commit intosonic-net:masterfrom
sainath-nexthop:add_bgp_allow_as_in_test_with_pr_scripts
Open

tests(bgp): add BGP allow-as-in test case#20172
sainath-nexthop wants to merge 1 commit intosonic-net:masterfrom
sainath-nexthop:add_bgp_allow_as_in_test_with_pr_scripts

Conversation

@sainath-nexthop
Copy link
Contributor

Description of PR

  • Adds a new test file test_bgp_allow_as_in.py under tests/bgp/ in sonic-mgmt.
  • Implements IPv4 and IPv6 test cases that:
    1. Configure allow_as_in=true on a VS DUT neighbor.
    2. Announce a route with the DUT’s own AS in the AS_PATH.
    3. Verify acceptance when enabled and rejection when disabled.
  • Leverages existing ExaBGP PTF setup and pytest_assert utilities.

Summary:
Fixes #18654

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

Approach

What is the motivation for this PR?

To ensure the BGP allow-as-in feature is correctly implemented and to prevent regressions in SONiC’s BGP behavior.

How did you do it?

  • Created test_bgp_allow_as_in.py using the existing setup_exabgp fixture.
  • Wrote two tests: test_bgp_allow_as_in_ipv4 and test_bgp_allow_as_in_ipv6.
  • Used JSON-PATCH (GCU) and vtysh paths to configure the DUT.
  • Validated route presence via vtysh ... json and helper functions.

How did you verify/test it?

  • Ran pytest --inventory localhost, targeting vs DUTs with topologies t0 and t1.
  • Confirmed both tests pass on CI and locally on a VS build.

Any platform specific information?

  • Only runs on vs device type; skipped on bare-metal platforms.

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

  • Topologies: t0, t1

Documentation

  • Added comments in the test file describing the feature under test.

This commit adds comprehensive testing for the BGP allow-as-in feature:

- Add test_bgp_allow_as_in.py with IPv4 and IPv6 test cases
- Test validates route acceptance when allow_as_in is enabled
- Test validates route rejection when allow_as_in is disabled
- Supports both config_db (GCU) and vtysh configuration methods
- Includes proper setup, verification, and cleanup
- Add test to PR test scripts for t0 and t1-lag topologies

The allow-as-in feature allows a router to accept routes containing
its own AS number in the AS_PATH attribute, which would normally be
dropped to prevent routing loops.

Test coverage:
- IPv4 and IPv6 route handling
- Route announcement with own AS in AS_PATH
- Configuration via JSON-PATCH and vtysh
- Route verification and status checking
- Multi-topology support (t0, t1)

Fixes sonic-net#18654
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bpar9
Copy link
Collaborator

bpar9 commented Jan 14, 2026

doesnt this script/TCs already cover this same allow-as feature - https://github.com/sonic-net/sonic-mgmt/blob/master/tests/bgp/test_bgp_bbr.py ? - #2538

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.

Test Gap: Missing BGP allow-as-in Feature Tests in sonic-mgmt

3 participants