Skip to content

tests: bgp_suppress_duplicates: simplify and split into four tests - #21203

Merged
riw777 merged 1 commit into
FRRouting:masterfrom
enkechen-panw:bgp-dup-test2
Mar 18, 2026
Merged

tests: bgp_suppress_duplicates: simplify and split into four tests#21203
riw777 merged 1 commit into
FRRouting:masterfrom
enkechen-panw:bgp-dup-test2

Conversation

@enkechen-panw

Copy link
Copy Markdown
Contributor

Convert the iBGP session between r1 and r2 to eBGP. This eliminates rmap-to-r2 (which existed solely to normalize local-pref to 100 at r2), next-hop-self, and the now-empty address-family block on r2. Since local-pref is not carried over eBGP, drop the local_pref parameter from _bgp_check_route_attributes().

Add a step to wait for the initial route to appear at r2 before recording the baseline dup count and starting the TCs. Also add an explicit verification that TC4's force update (metric=2000) has been received at r2 before the withdraw+readd sequence, closing a race condition where the MRAI timer could already be expired and the sleep skipped while the BGP UPDATE was still in flight.

Move helper functions to module level and split the single monolithic test function into four separate functions, one per TC. Each captures its own dup_before baseline. TC1 retains session establishment and initial route propagation checks; TC2-TC4 rely on the shared topology state left by the preceding TC.

Convert the iBGP session between r1 and r2 to eBGP. This eliminates
rmap-to-r2 (which existed solely to normalize local-pref to 100 at
r2), next-hop-self, and the now-empty address-family block on r2.
Since local-pref is not carried over eBGP, drop the local_pref
parameter from _bgp_check_route_attributes().

Add a step to wait for the initial route to appear at r2 before
recording the baseline dup count and starting the TCs. Also add an
explicit verification that TC4's force update (metric=2000) has been
received at r2 before the withdraw+readd sequence, closing a race
condition where the MRAI timer could already be expired and the sleep
skipped while the BGP UPDATE was still in flight.

Move helper functions to module level and split the single monolithic
test function into four separate functions, one per TC. Each captures
its own dup_before baseline. TC1 retains session establishment and
initial route propagation checks; TC2-TC4 rely on the shared topology
state left by the preceding TC.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
@frrbot frrbot Bot added the tests Topotests, make check, etc label Mar 16, 2026
@greptile-apps

greptile-apps Bot commented Mar 16, 2026

Copy link
Copy Markdown

Greptile Summary

This PR simplifies the bgp_suppress_duplicates topotest by converting the iBGP session between r1 and r2 to eBGP, which eliminates the need for rmap-to-r2, next-hop-self, and the local_pref parameter in route attribute checks (since local-pref is not carried over eBGP). The single monolithic test function is split into four independent test cases (tc1–tc4), with helper functions promoted to module level for reuse.

  • iBGP β†’ eBGP conversion: r2 is now AS 65002 instead of AS 65001, removing rmap-to-r2 (which only normalized local-pref to 100) and next-hop-self
  • Race condition fix in TC4: Added explicit run_and_expect wait verifying the force update (metric=2000) is received at r2 before the withdraw+readd sequence, closing a race where the MRAI timer could expire while the BGP UPDATE was still in flight
  • Initial route wait in TC1: Added run_and_expect to confirm the initial route has been received at r2 before recording the baseline dup count, preventing premature baseline capture
  • Test splitting: Each TC is now a separate test_bgp_suppress_duplicates_tc{1-4}() function with its own baseline dup count capture
  • Cleanup: Removed trailing semicolons from _bgp_get_mrai_expire_secs calls, fixed indentation in _bgp_check_route_non_exist

Confidence Score: 5/5

  • This PR is safe to merge β€” it's a straightforward test refactor with no production code changes.
  • All changes are confined to topotest files (test code and router configs). The iBGP-to-eBGP conversion correctly eliminates unnecessary configuration, the test logic is preserved, and the new race condition fixes make the tests more robust. No functional code is modified.
  • No files require special attention.

Important Files Changed

Filename Overview
tests/topotests/bgp_suppress_duplicates/test_bgp_suppress_duplicates.py Refactored test: helper functions moved to module level, single monolithic test split into four (tc1-tc4), iBGP→eBGP simplification removes local_pref parameter, adds explicit waits to close race conditions. Clean and correct.
tests/topotests/bgp_suppress_duplicates/r1/frr.conf Converted from iBGP (AS 65001) to eBGP (remote-as 65002), removed rmap-to-r2 and next-hop-self since they are unnecessary with eBGP.
tests/topotests/bgp_suppress_duplicates/r2/frr.conf Changed to AS 65002 with eBGP peering to AS 65001, removed now-empty address-family block and next-hop-self.
tests/topotests/bgp_suppress_duplicates/init.py Standard empty init.py added to make directory a proper Python package.

Sequence Diagram

sequenceDiagram
    participant TC as Test Case
    participant R1 as r1 (AS 65001)
    participant R2 as r2 (AS 65002)

    Note over R1,R2: eBGP Session Setup
    TC->>R1: Check BGP neighbor established
    R1->>R2: BGP UPDATE (metric=2000)
    TC->>R2: Wait for initial route receipt

    Note over TC: TC1: Attr A β†’ Attr A
    TC->>R1: Change local-pref 500β†’600 (metric unchanged)
    TC->>R1: Wait for MRAI expiry
    TC->>R2: Verify no duplicate update sent

    Note over TC: TC2: Attr A β†’ B β†’ A
    TC->>R1: Change metric 2000β†’3000 (force update)
    R1->>R2: BGP UPDATE (metric=3000)
    TC->>R1: Within MRAI: metric 3000β†’2000β†’3000
    TC->>R1: Wait for MRAI expiry
    TC->>R2: Verify no duplicate update sent

    Note over TC: TC3: Attr A β†’ B β†’ B
    TC->>R1: Change metric 3000β†’2000 (force update)
    R1->>R2: BGP UPDATE (metric=2000)
    TC->>R1: Within MRAI: metric→3000, then local-pref change
    TC->>R1: Wait for MRAI expiry
    TC->>R2: Verify single update (metric=3000)

    Note over TC: TC4: Attr A β†’ Withdraw β†’ A
    TC->>R1: Change metric 3000β†’2000 (force update)
    R1->>R2: BGP UPDATE (metric=2000)
    TC->>R2: Explicit wait for update receipt (race fix)
    TC->>R1: Withdraw route, then re-add
    TC->>R1: Wait for MRAI expiry
    TC->>R2: Verify no duplicate/withdraw sent
Loading

Last reviewed commit: 2becd7b

@riw777 riw777 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good

@riw777
riw777 merged commit 05cdd4a into FRRouting:master Mar 18, 2026
23 checks passed
@enkechen-panw
enkechen-panw deleted the bgp-dup-test2 branch March 18, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

master size/L tests Topotests, make check, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants