Skip to content

Bug:[Snappi] TypeError in run_traffic_and_collect_stats when dut_port_config is list-style (pfcwd_actions tests) #25200

@YatishSVC

Description

@YatishSVC

Is it platform specific

generic

Importance or Severity

Medium

Description of the bug

run_traffic_and_collect_stats() and verify_egress_queue_frame_count() in tests/common/snappi_tests/traffic_generation.py assume dut_port_config is always a dict with "Tx" and "Rx" keys. However, when base_flow_config_list is populated via multi_base_traffic_config() (used by pfcwd_actions_helper.py), dut_port_config is a list [tx_dict, rx_dict].

This causes a TypeError when accessing dut_port_config["Rx"] on a list object.

Two functions are affected:

run_traffic_and_collect_stats() — accesses base_flow_config_list[0]["dut_port_config"]["Rx"][0].values()
verify_egress_queue_frame_count() — accesses dut_port_config["Rx"][0].items()
Note: generate_test_flows() already handles both formats correctly using isinstance(dut_port_config, dict) checks, but these two functions were not updated with the same pattern.

Steps to Reproduce

Run any test_pfcwd_actions.py test that uses multi_base_traffic_config via the pfcwd_actions_helper:

All 6 tests in test_pfcwd_actions.py fail with the same error.

Actual Behavior and Expected Behavior

Actual Behavior and Expected Behavior:

Actual:

TypeError: list indices must be integers or slices, not str

at traffic_generation.py in run_traffic_and_collect_stats():

rx_port_config_values = snappi_extra_params.base_flow_config_list[0]["dut_port_config"]["Rx"][0].values()

Expected:
The function should handle both dut_port_config formats:

Dict-style: {"Tx": [{port: prios}], "Rx": [{port: prios}]} (from base_traffic_config())
List-style: [{tx_port: prios}, {rx_port: prios}] (from multi_base_traffic_config())
Fix: Apply the same isinstance pattern already used in generate_test_flows():

rx_port_dicts = dut_port_config["Rx"] if isinstance(dut_port_config, dict) else [dut_port_config[1]]

This needs to be applied in two places:

  1. run_traffic_and_collect_stats() — where base_flow_config_list[0]["dut_port_config"] is accessed
  2. verify_egress_queue_frame_count() — where dut_port_config["Rx"][0].items() is called

Relevant log output

FAILED tests/snappi_tests/pfcwd/test_pfcwd_actions.py::test_pfcwd_drop_90_10 - TypeError: list indices must be integers or slices, not str
FAILED tests/snappi_tests/pfcwd/test_pfcwd_actions.py::test_pfcwd_drop_uni - TypeError: list indices must be integers or slices, not str
FAILED tests/snappi_tests/pfcwd/test_pfcwd_actions.py::test_pfcwd_fwd_90_10 - TypeError: list indices must be integers or slices, not str
FAILED tests/snappi_tests/pfcwd/test_pfcwd_actions.py::test_pfcwd_fwd_uni - TypeError: list indices must be integers or slices, not str
FAILED tests/snappi_tests/pfcwd/test_pfcwd_actions.py::test_pfcwd_disable_90_10 - TypeError: list indices must be integers or slices, not str
FAILED tests/snappi_tests/pfcwd/test_pfcwd_actions.py::test_pfcwd_disable_uni - TypeError: list indices must be integers or slices, not str

Output of show version

N/A — this is a test framework bug, not platform-specific.

Attach files (if any)

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions