sonic-mgmt icon indicating copy to clipboard operation
sonic-mgmt copied to clipboard

[Snappi] fix Error in get_pg_dropped_packets for T2 testbed

Open sdszhang opened this issue 1 year ago • 2 comments

Description of PR

Summary: Fix the following error when running test case test_multidut_pfc_pause_lossless_with_snappi.py


    def get_pg_dropped_packets(duthost, phys_intf, prio):
        """
        Get number of ingress packets dropped on a specific priority
        of a physical interface
        Args:
            host_ans: Ansible host instance of the device
            phys_intf (str): Name of physical interface ex. Ethernet4
            prio (int): Priority group to check ex. 4
        Returns:
            total number of dropped packets (int)
        """
        oid_cmd = "sonic-db-cli COUNTERS_DB HGET COUNTERS_QUEUE_NAME_MAP " + phys_intf + ":" + str(prio)
        oid_out = duthost.command(oid_cmd)
>       oid_str = str(oid_out["stdout_lines"][0] or 1)
E       IndexError: list index out of range

Type of change

  • [ ] Bug fix
  • [ ] Testbed and Framework(new/improvement)
  • [ ] Test case(new/improvement)

Back port request

  • [ ] 202012
  • [ ] 202205
  • [ ] 202305
  • [ ] 202311
  • [x] 202405

Approach

What is the motivation for this PR?

Fix test case error

How did you do it?

Add asic_value parameter for get_pg_dropped_packets() and verify_in_flight_buffer_pkts

How did you verify/test it?

Tested on T1 and T2 physical testbed.

Any platform specific information?

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

Documentation

sdszhang avatar Sep 10 '24 02:09 sdszhang

@amitpawar12 can you help to review this one? Thanks.

sdszhang avatar Sep 10 '24 02:09 sdszhang

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/traffic_generation.py:529:65: E251 unexpected spaces around keyword / parameter equals
tests/common/snappi_tests/traffic_generation.py:529:67: E251 unexpected spaces around keyword / parameter equals

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
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

mssonicbld avatar Sep 10 '24 02:09 mssonicbld

Cherry-pick PR to 202405: https://github.com/sonic-net/sonic-mgmt/pull/14575

mssonicbld avatar Sep 13 '24 06:09 mssonicbld