Skip to content

Commit

Permalink
[test_snmp_queue_counters.py]: queuestat command output change fix fo…
Browse files Browse the repository at this point in the history
…r multi-asic (sonic-net#16072)

queuestat command output change fix for multi-asic

Description of PR
A new fix in queuestat script add extra line for multi-asic system
e.g "For namespace asic0"

Added logic to look for UC or MC string in each line and calculate counters accordingly

Summary:
Fixes # (issue)

Approach
What is the motivation for this PR?
A new fix in queuestat script add extra line for multi-asic system
e.g "For namespace asic0"

How did you do it?
Added logic to look for UC or MC string in each line and calculate counters accordingly

co-authorized by: jianquanye@microsoft.com
  • Loading branch information
harjotsinghpawra authored and mssonicbld committed Dec 14, 2024
1 parent 8797a19 commit de1caa7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/snmp/test_snmp_queue_counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ def get_queue_ctrs(duthost, cmd):
return len(duthost.shell(cmd)["stdout_lines"])


def get_queuestat_ctrs(duthost, cmd):
cmd_output = duthost.shell(cmd)["stdout_lines"]
queue_cnt = 0
for line in cmd_output:
if "UC" in line or "MC" in line:
queue_cnt = queue_cnt + 1
return queue_cnt


def check_snmp_cmd_output(duthost, cmd):
out_len = len(duthost.shell(cmd)["stdout_lines"])
if out_len > 1:
Expand Down Expand Up @@ -124,7 +133,7 @@ def test_snmp_queue_counters(duthosts,
data['DEVICE_METADATA']["localhost"]["create_only_config_db_buffers"] \
= "true"
load_new_cfg(duthost, data)
stat_queue_counters_cnt_pre = (get_queue_ctrs(duthost, get_queue_stat_cmd) - 2) * UNICAST_CTRS
stat_queue_counters_cnt_pre = get_queuestat_ctrs(duthost, get_queue_stat_cmd) * UNICAST_CTRS
wait_until(60, 20, 0, check_snmp_cmd_output, duthost, get_bfr_queue_cntrs_cmd)
queue_counters_cnt_pre = get_queue_ctrs(duthost, get_bfr_queue_cntrs_cmd)

Expand All @@ -136,7 +145,7 @@ def test_snmp_queue_counters(duthosts,
# Remove buffer queue and reload and get number of queue counters of selected interface
del data['BUFFER_QUEUE'][buffer_queue_to_del]
load_new_cfg(duthost, data)
stat_queue_counters_cnt_post = (get_queue_ctrs(duthost, get_queue_stat_cmd) - 2) * UNICAST_CTRS
stat_queue_counters_cnt_post = get_queuestat_ctrs(duthost, get_queue_stat_cmd) * UNICAST_CTRS
wait_until(60, 20, 0, check_snmp_cmd_output, duthost, get_bfr_queue_cntrs_cmd)
queue_counters_cnt_post = get_queue_ctrs(duthost, get_bfr_queue_cntrs_cmd)
pytest_assert((queue_counters_cnt_post == stat_queue_counters_cnt_post),
Expand Down

0 comments on commit de1caa7

Please sign in to comment.