[pfcwd] Add unit tests for hardware PFC watchdog#4418
Open
arawat-nexthop wants to merge 9 commits intosonic-net:masterfrom
Open
[pfcwd] Add unit tests for hardware PFC watchdog#4418arawat-nexthop wants to merge 9 commits intosonic-net:masterfrom
arawat-nexthop wants to merge 9 commits intosonic-net:masterfrom
Conversation
Signed-off-by: Abhishek <abhishek@nexthop.ai>
… functions. Signed-off-by: Abhishek <abhishek@nexthop.ai>
Signed-off-by: Abhishek <abhishek@nexthop.ai>
Signed-off-by: Abhishek <abhishek@nexthop.ai>
Signed-off-by: Abhishek <abhishek@nexthop.ai>
Signed-off-by: Abhishek <abhishek@nexthop.ai>
…onality. Signed-off-by: Abhishek <abhishek@nexthop.ai>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
What I did: Add comprehensive unit test coverage for the hardware-based PFC (Priority Flow Control) watchdog orchestration agent (PfcWdHwOrch). Prior to this change, there was no unit test coverage for this critical component. Changes include: 1. **Test infrastructure**: - Created PfcWdHwOrchTest fixture with SAI API mocks for switch, port, and queue operations - Set platform environment variable required by PfcWdBaseOrch constructor - Implemented helper functions: bringUpPorts(), enablePfcOnPort(), deleteHwWdEntry() 2. **30 unit tests covering**: - Configuration validation (7 tests): Invalid ports, time ranges, actions, and parameters - Action management (4 tests): Global action setting, consistency enforcement, reset behavior - Port lifecycle (3 tests): Reconfiguration, STATE_DB lifecycle, warm reboot recovery - Hardware configuration (3 tests): Detection/restoration intervals, DLDR enable/disable - Deadlock handling (6 tests): Callback registration, detection/restoration flow, statistics, edge cases - SAI failure handling (4 tests): Rollback on switch action, interval, and queue DLDR failures - SKU detection (1 test): Hardware PFC watchdog SKU validation Why I did it: Enable verification of correct behavior, catch regressions, and validate error handling for hardware-based PFC watchdog. How to verify it: ```bash cd sonic-swss/tests/mock_tests make tests ./tests --gtest_filter="PfcWdHwOrchTest*" ``` Which release branch to backport (optional): - [ ] 202505 - [ ] 202511 Signed-off-by: Abhishek Rawat <arawat@nexthop.ai>
What I did: Add comprehensive unit tests for the hardware-based PFC watchdog (PFCWD) counter management logic in PfcWdHwOrch. Test coverage includes: - Storm detection and counter initialization (initQueueCounters()) - Periodic counter updates and delta calculation (updateQueueCounters() periodic path) - Storm restoration and counter cleanup (updateQueueCounters() restoration path) - Counter underflow protection - Hardware counter reading from COUNTERS_DB (readHwCounters()) - Queue statistics persistence (getQueueStats()/updateQueueStats()) Implementation details: - Created pfcwdhw_counters_ut.cpp with comprehensive test cases - Updated Makefile.am to include the new test in the build - Follows existing test patterns from flexcounter_ut.cpp - Uses MockOrchTest base fixture for DB infrastructure Why I did it: Ensure correct behavior of hardware counter tracking, delta calculation, and statistics management for hardware-based PFC watchdog. How to verify it: ```bash cd sonic-swss/tests/mock_tests make tests ./tests --gtest_filter="PfcWdHwOrchTest*" ``` Which release branch to backport (optional): - [ ] 202505 - [ ] 202511 Signed-off-by: Abhishek Rawat <arawat@nexthop.ai>
5bfb8f8 to
cb4fcea
Compare
Collaborator
|
/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.
What I did
Add comprehensive unit test coverage for hardware-based PFC (Priority Flow Control) watchdog functionality. This PR includes two sets of tests:
1. PfcWdHwOrch orchestration tests (30 test cases):
2. PfcWdHwOrch counter management tests:
Why I did it
Prior to this change, there was no unit test coverage for the hardware-based PFC watchdog component. These tests enable verification of correct behavior, catch regressions, and validate error handling.
How to verify it
Which release branch to backport (optional)
Dependencies
This PR is based on PR #4412 - [Hw PFCWD feature] Implementation for H/w based PFCWD
Once PR #4412 is merged, this PR will show only the 2 unit test commits.
Related PRs: