[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 Mar 26, 2026
Conversation
…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]>
12 tasks
Collaborator
Author
|
Original PR: #22186 |
Collaborator
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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 sflow/test_sflow.py failures with expected sflow packets not received on collector interface
Fixes # #22180
Type of change
Back port request
Approach
What is the motivation for this PR?
Currenlty bunch of
sflow/test_sflow.pytest cases are failing with below signaturesAssertionError: False is not true : \.{2,}Packets are not received in active collector +,collector\d+AssertionError: False is not true : Expected Number of samples are not collected from Interface Ethernet\d+ in collector collector\d+ , Received \d+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 butdata['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.autoonce 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_countandtotal_counter_countbefore 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