[lldp] Fix LLDP_ENTRY_TABLE key comparison for dualtor topology#23193
Merged
StormLiangMS merged 1 commit intosonic-net:masterfrom Mar 24, 2026
Merged
Conversation
In dualtor-aa topology, uplink ports receive LLDP PDUs from both the T1 neighbor switch and the fanout switch. This causes `show lldp table` to list multiple rows per interface (e.g., Ethernet224 appears twice - once for ARISTA01T1, once for fanout). The test compared sorted lists of interfaces from APPL_DB LLDP_ENTRY_TABLE (which stores one entry per interface) against the parsed `show lldp table` output (which has duplicate entries). This always failed on dualtor testbeds (29 DB keys vs 32 CLI rows). Changes: - Deduplicate interface list in get_show_lldp_table_output() using dict.fromkeys() to handle multiple LLDP neighbors per port - Use set comparison instead of sorted list comparison in check_lldp_table_keys() and assert_lldp_interfaces() - Add diff details to assertion error message for easier debugging Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
StormLiangMS
approved these changes
Mar 24, 2026
Collaborator
StormLiangMS
left a comment
There was a problem hiding this comment.
LGTM — correct fix for dualtor LLDP test. dict.fromkeys() for dedup and set comparison with diff-based error messages are clean improvements. CI all green.
ravaliyel
pushed a commit
to ravaliyel/sonic-mgmt
that referenced
this pull request
Mar 27, 2026
…c-net#23193) In dualtor-aa topology, uplink ports receive LLDP PDUs from both the T1 neighbor switch and the fanout switch. This causes `show lldp table` to list multiple rows per interface (e.g., Ethernet224 appears twice - once for ARISTA01T1, once for fanout). The test compared sorted lists of interfaces from APPL_DB LLDP_ENTRY_TABLE (which stores one entry per interface) against the parsed `show lldp table` output (which has duplicate entries). This always failed on dualtor testbeds (29 DB keys vs 32 CLI rows). Changes: - Deduplicate interface list in get_show_lldp_table_output() using dict.fromkeys() to handle multiple LLDP neighbors per port - Use set comparison instead of sorted list comparison in check_lldp_table_keys() and assert_lldp_interfaces() - Add diff details to assertion error message for easier debugging Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Fix
test_lldp_entry_table_contentfailure on dualtor-aa topology caused by duplicate LLDP neighbors from fanout switches.In dualtor-aa topology, uplink ports (e.g., Ethernet224/232/240) receive LLDP PDUs from both the T1 ARISTA switch and the fanout switch.
show lldp tablelists multiple rows per port, butLLDP_ENTRY_TABLEin APPL_DB stores only one entry per interface. The sorted list comparison (29 DB keys vs 32 CLI rows) always fails.Fixes https://msazure.visualstudio.com/One/_workitems/edit/36796797
Type of change
Back port request
Approach
What is the motivation for this PR?
test_lldp_entry_table_contentconsistently fails on dualtor-aa topology testbeds (e.g., Arista-720DT-48CQ, Cisco-8101-C32) becauseget_show_lldp_table_output()returns duplicate interface entries when a port has multiple LLDP neighbors.Example from
show lldp tableon dualtor-aa:The comparison
sorted(lldp_entry_keys) == sorted(show_lldp_table_int_list)fails because:LLDP_ENTRY_TABLEhas 29 unique interface keysshow lldp tableparsed output has 32 entries (3 interfaces duplicated due to fanout)How did you do it?
get_show_lldp_table_output(): Usedict.fromkeys()to remove duplicate interface names while preserving ordercheck_lldp_table_keys(): Replacesorted()list comparison withset()comparison for robustnessassert_lldp_interfaces(): Use set comparison and include diff details (which interfaces are in DB but not CLI, and vice versa) for easier debuggingHow did you verify/test it?
show lldp table(once for T1 neighbor ARISTA0xT1, once for fanout str3-8101-fanout-10)Any platform specific information?
Affects dualtor-aa topology testbeds where uplink ports are connected through fanout switches that also advertise LLDP. Confirmed on:
Supported testbed topology if it's a new test case?
N/A (bug fix for existing test)
Documentation
N/A