sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
200 stars 732 forks source link

[Snappi] Fixing dut/port mapping for counters #15631

Closed sdszhang closed 6 days ago

sdszhang commented 1 week ago

Description of PR

Summary: Fixing dut port mapping when retrieving counter. Otherwise, ingress duthost maybe used to retrieve egress counters.

In Snappi ports, the ingress dut and port maybe different for each port. In current code, it uses same ingress dut for both ports.

    dut_rx_port1 = tx_port[0]['peer_port']
    dut_rx_port2 = tx_port[1]['peer_port']
    rx_pkts_1 = get_interface_stats(ingress_duthost, dut_rx_port1)[ingress_duthost.hostname][dut_rx_port1]['rx_ok']
    rx_pkts_2 = get_interface_stats(ingress_duthost, dut_rx_port2)[ingress_duthost.hostname][dut_rx_port2]['rx_ok']

which results in the counter was retrieved on incorrect dut, and get the following error:

FAILED snappi_tests/multidut/pfc/test_lossless_response_to_throttling_pause_storms.py::test_lossless_response_to_throttling_pause_storms[multidut_port_info0]

......
        pkt_drop = get_interface_stats(egress_duthost, dut_tx_port)[egress_duthost.hostname][dut_tx_port]['tx_drp']
        rx_pkts_1 = get_interface_stats(ingress_duthost, dut_rx_port1)[ingress_duthost.hostname][dut_rx_port1]['rx_ok']
        rx_pkts_2 = get_interface_stats(ingress_duthost, dut_rx_port2)[ingress_duthost.hostname][dut_rx_port2]['rx_ok']
        # Calculate the total received packets
        total_rx_pkts = rx_pkts_1 + rx_pkts_2
        # Calculate the drop percentage
>       drop_percentage = 100 * pkt_drop / total_rx_pkts
E       ZeroDivisionError: division by zero

Type of change

Back port request

Approach

What is the motivation for this PR?

Fixing dut port mapping when retrieving counter.

How did you do it?

How did you verify/test it?

Any platform specific information?

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

Documentation

sdszhang commented 1 week ago

@rraghav-cisco @amitpawar12 can you help to review?

sdszhang commented 1 week ago

All oversubscribed cases passed except 2 different failures which are still under investigation, not related to this change.

snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless_lossy.py::test_m2o_oversubscribe_lossless_lossy[multidut_port_info0] PASSED                                                                   [100%]
snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless_lossy.py::test_m2o_oversubscribe_lossless_lossy[multidut_port_info0] PASSED                                                                   [100%]
snappi_tests/multidut/pfc/test_m2o_fluctuating_lossless.py::test_m2o_fluctuating_lossless[multidut_port_info0]  FAILED                                                                   [100%]
snappi_tests/multidut/pfc/test_lossless_response_to_throttling_pause_storms.py::test_lossless_response_to_throttling_pause_storms[multidut_port_info0]  PASSED                                                                   [100%]
mssonicbld commented 6 days ago

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