Skip to content

[action] [PR:22186] [sonic-mgmt] Fix sflow/test_sflow.py failures with expected sflow packets not received on collector interface#23335

Merged
mssonicbld merged 1 commit intosonic-net:202511from
mssonicbld:cherry/202511/22186
Mar 26, 2026
Merged

[action] [PR:22186] [sonic-mgmt] Fix sflow/test_sflow.py failures with expected sflow packets not received on collector interface#23335
mssonicbld merged 1 commit intosonic-net:202511from
mssonicbld:cherry/202511/22186

Conversation

@mssonicbld
Copy link
Collaborator

Description of PR

Summary: Fix sflow/test_sflow.py failures with expected sflow packets not received on collector interface
Fixes # #22180

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
  • 202511

Approach

What is the motivation for this PR?

Currenlty bunch of sflow/test_sflow.py test cases are failing with below signatures

  1. AssertionError: False is not true : \.{2,}Packets are not received in active collector +,collector\d+

  2. AssertionError: False is not true : Expected Number of samples are not collected from Interface Ethernet\d+ in collector collector\d+ , Received \d+

  3. KeyError: 'flow_port_count'

Issue #1:
In some cases (like sflow config enabled for first time, device reboot), hsflowd daemon is taking little over 3 mins (See HLD) be fully initialized and process collector config. During this window, hsflowd service won't send sflow packets ('CounterSample', 'FlowSample' etc) to collector interface and thus test expecting sample packets on sflowtool can fail with above two signatures.

hsflowd service is writing to "/etc/hsflowd.auto" once it's processed collector configuration. Thus waiting for collector info to be present in "/etc/hsflowd.auto" seems to be safe option before proceeding with sflow traffic verfication.

Issue #2:
If the test expects flow samples/packets on the collector interface but they aren't seen for some reason, then we are hitting KeyError: 'flow_port_count'. Due to counter samples seen on collector interface, data['total_samples']" will not be zero but data['total_flow_count']will be 0 and lead to KeyError when tried to accessdata['flow_port_count']`.

How did you do it?

For Issue#1:
hsflowd service is writing to /etc/hsflowd.auto once it's processed collector configuration. Thus waiting for collector info to be present in /etc/hsflowd.auto" seems to be safe option before proceeding with sflow traffic verfication.

For Issue#2:
Fix is to have assert on total_flow_count and total_counter_count before calling corresponding sample analyzer functions.

How did you verify/test it?

Test is passing with the fixes.

Any platform specific information?

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

Documentation

…kets not received on collector interface (sonic-net#22186)

* [sonic-mgmt] Fix sflow/test_sflow.py failures with expected sflow packets not received on collector interface

Issue #1:
In some cases (like sflow config enabled for first time, device reboot),
hsflowd daemon is taking little over 3 mins to be fully initialized and
process collector config. During this window, hsflowd service won't send
sflow packets ('CounterSample', 'FlowSample' etc) to collector interface
and thus test can fail with i) "Packets are not received in active
collector, collector\d+" and ii) "Expected Number of samples are not
collected from Interface Ethernet\d+ in collector collector\d+ , Received \d+"

hsflowd service is writing to "/etc/hsflowd.auto" once it's processed
collector configuration. Thus waiting for collector info to be present in
"/etc/hsflowd.auto" seems to be safe option before proceeding with
sflow traffic verfication.

Issue #2:
If the test expects flow samples/packets on the collector interface but they aren't
seen for some reason, then we are hitting "KeyError: 'flow_port_count'". Due to
counter samples seen on collector interface, "data['total_samples']" will not be
zero but "data['total_flow_count']" will be 0 and lead to KeyError when tried to
access "data['flow_port_count']". Fix is to have assert on "total_flow_count" and
"total_counter_count" before calling corresponding sample analyze functions.

Signed-off-by: Vinod <[email protected]>

* Addressing review comments

1) Enhanced "wait_until_hsflowd_ready" to make it wait for all the
   collector IPs (instead of calling it sequentially for each IP)
2) Add docstring for "wait_until_hsflowd_ready" function
3) Updated "ast.literal_eval" usage to handle the case where
   "active_collectors" is passed as empty string ("" instead of "[]")

Signed-off-by: Vinod <[email protected]>

* Fix pre-commit check failures

Signed-off-by: Vinod <[email protected]>

* Revert PR#21674 partially to enable "sflow/test_sflow.py" test

Signed-off-by: Vinod <[email protected]>

---------

Signed-off-by: Vinod <[email protected]>
Signed-off-by: mssonicbld <[email protected]>
@mssonicbld
Copy link
Collaborator Author

Original PR: #22186

@mssonicbld
Copy link
Collaborator Author

/azp run

@github-actions github-actions bot requested a review from mramezani95 March 26, 2026 02:36
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld mssonicbld merged commit 180f937 into sonic-net:202511 Mar 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants