From 51c133f2d171f50a52910e7a94c5b8d0cb9656c7 Mon Sep 17 00:00:00 2001 From: rraghav-cisco <58446052+rraghav-cisco@users.noreply.github.com> Date: Wed, 1 Jan 2025 15:13:11 -0800 Subject: [PATCH] Use natsort instead of sort for sorting the asic list in disable_pfcwd and enable_pfcwd functions. (#16176) Description of PR Summary: Even after #15863, the problem is still seen in RP. The issue is that the sort() function only sorts alphabetically, not numerically. So we need to use natsort module instead of normal sort() in these functions. Approach What is the motivation for this PR? Seeing a lot of loganalyzer messages, but in RP only. How did you do it? Change sort to natsort(). How did you verify/test it? Running in my TB, I don't see the LA error anymore. Any platform specific information? T2 mAsic only. co-authorized by: jianquanye@microsoft.com --- tests/common/snappi_tests/qos_fixtures.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/common/snappi_tests/qos_fixtures.py b/tests/common/snappi_tests/qos_fixtures.py index a7500523c08..4ff4fae4464 100644 --- a/tests/common/snappi_tests/qos_fixtures.py +++ b/tests/common/snappi_tests/qos_fixtures.py @@ -1,6 +1,7 @@ import pytest import time import json +from natsort import natsorted from tests.common.snappi_tests.common_helpers import \ stop_pfcwd, disable_packet_aging, enable_packet_aging from tests.common.utilities import get_running_config @@ -125,7 +126,7 @@ def get_pfcwd_config(duthost): all_configs = [] output = duthost.shell("ip netns | awk '{print $1}'")['stdout'] all_asic_list = output.split("\n") - all_asic_list.sort() + all_asic_list = natsorted(all_asic_list) all_asic_list.insert(0, None) for space in all_asic_list: config = get_running_config(duthost, space) @@ -145,7 +146,7 @@ def reapply_pfcwd(duthost, pfcwd_config): elif type(pfcwd_config) is list: output = duthost.shell("ip netns | awk '{print $1}'")['stdout'] all_asic_list = output.split("\n") - all_asic_list.sort() + all_asic_list = natsorted(all_asic_list) all_asic_list.insert(0, None) all_files = []