Skip to content

Fix pktgen port selection for counters#25484

Open
xwjiang-ms wants to merge 1 commit into
sonic-net:masterfrom
xwjiang-ms:ai-fix-pktgen-38502282
Open

Fix pktgen port selection for counters#25484
xwjiang-ms wants to merge 1 commit into
sonic-net:masterfrom
xwjiang-ms:ai-fix-pktgen-38502282

Conversation

@xwjiang-ms

Copy link
Copy Markdown
Contributor

Description of PR

Summary:
Fix test_pktgen on topologies where minigraph_ports includes ports that are not present in show interface counter output. The test randomly selected such a port and then raised KeyError while indexing int_counter[port].

Type of change

  • Bug fix

Back port request

  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202512
  • 202605

Approach

What is the motivation for this PR?

SONiC nightly master PBI 38502282 reports consistent test_pktgen failures on Arista dualtor with KeyError: 'Ethernet...' at the interface-counter verification step.

How did you do it?

Filter the packet-generation candidate port list to ports present in duthost.show_interface(command="counter")['ansible_facts']['int_counter'] before selecting a random port. The existing no-port skip remains effective if no counter-backed data ports are available.

How did you verify/test it?

  • python -m py_compile tests/test_pktgen.py
  • Verified against the failure stack: the failing line indexes int_counter[port], so selecting only keys present in int_counter prevents the observed KeyError while preserving the counter verification.

Any platform specific information?

Observed on Arista-7260CX3-D108C8 dualtor master nightly.

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

N/A

Documentation

N/A

Filter pktgen candidate ports to ports present in show interface counter
output before randomly selecting a port. This prevents KeyError when
minigraph contains a port that does not appear in int_counter on dualtor
master testbeds.

Signed-off-by: xwjiang-ms <xiaweijiang@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants