sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
173 stars 688 forks source link

[Snappi]: Corrections in calling get_pfcwd_config_attr function and new PFCWD stats function to capture PFCWD statistics. #13469

Open amitpawar12 opened 6 days ago

amitpawar12 commented 6 days ago

Description of PR

PFCWD testcases should capture PFCWD statistics before and after the test.

The function get_pfcwd_config_attr was defined with one of the arguments as 'asic_value' but while calling the function, 'namespace' was being used. Corrected to use 'asic_value" while calling the get_pfcwd_config_attr function.

Summary: Fixes # (issue) Github issue #12900 Github issue #12987

Type of change

Back port request

Approach

What is the motivation for this PR?

The PFCWD statistics should be captured before and after the testcases to ensure that storm detected/restored is incremented during the test.

Similarly, the PFCWD drop counters should be also checked before and after the test to confirm the count of packets dropped during the test.

How did you do it?

Defined a function in tests/common/snappi_tests/common_helper.py to capture PFCWD stats for a given DUT, interface and priority. The function returns back all variables in form of a dictionary. If the stats are not present, then values are returned as zero for all the attributes.

The tests/snappi_tests/multidut/pfcwd/files/pfcwd_multidut_basic_helper.py calls this function before and after the test and calculates the 'loss_packets' on the DUT, which is difference of TX_DROPS returned via PFCWD statistics.

The 'loss_packets' is sent as one of parameters for function 'verify_results'. The 'tgen_loss_packets' is capturing the loss packets which is difference of Tx - Rx packets on IXIA.

We can further enhance this to fail the testcase if the drops do not match.

How did you verify/test it?

Ran the testcases on local T2 chassis setup.

Truncated Code output: | Parameter:4_STORM_DETECTED, Initial Value:5, Final Value:5 | Parameter:4_RESTORED, Initial Value:5, Final Value:5 | Parameter:4_DROP, Initial Value:14092468, Final Value:14092468 | Parameter:4_TX_OK, Initial Value:20241318, Final Value:20241318 | Total PFCWD drop packets before and after the test:0 | TGEN Loss packets:0 `

Any platform specific information?

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

Documentation

mssonicbld commented 6 days ago

The pre-commit check detected issues in the files touched by this pull request. The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

tests/common/snappi_tests/common_helpers.py:35:11: E275 missing whitespace after keyword

flake8...............................................(no files to check)Skipped
check conditional mark sort..........................(no files to check)Skipped

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt docker container.
  2. Ensure that the pre-commit package is installed:
    sudo pip install pre-commit
  3. Go to repository root folder
  4. Install the pre-commit hooks:
    pre-commit install
  5. Use pre-commit to check staged file:
    pre-commit
  6. Alternatively, you can check committed files using:
    pre-commit run --from-ref <commit_id> --to-ref <commit_id>
abdosi commented 5 days ago

@sdszhang Please review.