From c5301b2cf94304deb8e09959d67af6a089155507 Mon Sep 17 00:00:00 2001 From: Justin Wong <51811017+justin-wong-ce@users.noreply.github.com> Date: Sun, 13 Oct 2024 21:00:46 -0700 Subject: [PATCH] Fix SNMP output having fewer unicast queues than expected (#330) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit justin-wong-ce First-time contributor justin-wong-ce commented on Sep 6 • SNMP assumes the first half of the queues to be unicast and the second half to be multicast. This assumption was fine for most hwSkus but not new ones being added to support, i.e. x86_64-arista_7060x6. This change will allow configurations where there are more than half of maximum queues set as unicast. It however does not account for the case where there are more than half of the maximum queues set as multicast - that will cause problems for the sonic-mgmt snmp/test_snmp_queue.py test. If the SNMP is expected to only return unicast queues, then I will make further changes to the unit test and source code to reflect this expectation in functionality. If not, sonic-mgmt's snmp/test_snmp_queue.py should not expect only unicast queues to be returned, and SNMP should return all queues, not half (https://github.com/sonic-net/sonic-mgmt/blob/ac37f7f0fd7c7857559325a61d5ca6e6c4932194/tests/snmp/test_snmp_queue.py#L92) (grep UC) Note: Only tested on Arista hwSkus. - What I did Accommodate for the case where the number of Unicast queues exceed the number of Multicast queues. - How I did it Allow Unicast queues to be added to response when their queue number is greater than half of the total number of queues. - How to verify it Passing unit tests and SNMP tests in sonic-mgmt. Note: Only ran on Arista hwSkus - Description for the changelog --- .../mibs/vendor/cisco/ciscoSwitchQosMIB.py | 13 +- tests/mock_tables/appl_db.json | 21 +- tests/mock_tables/counters_db.json | 263 ++++++++++++++++++ tests/mock_tables/state_db.json | 3 + tests/test_queues_stat.py | 13 +- 5 files changed, 308 insertions(+), 5 deletions(-) diff --git a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoSwitchQosMIB.py b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoSwitchQosMIB.py index 31df647d0..d0a9fb916 100644 --- a/src/sonic_ax_impl/mibs/vendor/cisco/ciscoSwitchQosMIB.py +++ b/src/sonic_ax_impl/mibs/vendor/cisco/ciscoSwitchQosMIB.py @@ -134,11 +134,20 @@ def update_stats(self): if_queues = self.port_queue_list_map[if_index] namespace = self.port_index_namespace[if_index] - # The first half of queue id is for ucast, and second half is for mcast + # Count number of unicast queues + pq_count = 0 + for queue in if_queues: + queue_sai_oid = self.port_queues_map[mibs.queue_key(if_index, queue)] + if self.queue_type_map[namespace].get(queue_sai_oid) == 'SAI_QUEUE_TYPE_UNICAST': + pq_count = pq_count + 1 + + # If there are fewer unicast queues than half of max queues, we use the old assumption of second half mcast # To simulate vendor OID, we wrap queues by max priority groups port_max_queues = Namespace.dbs_get_all(self.db_conn, mibs.STATE_DB, mibs.buffer_max_parm_table(self.oid_name_map[if_index]))['max_queues'] - pq_count = math.ceil(int(port_max_queues) / 2) + max_queues_half = math.ceil(int(port_max_queues) / 2) + if pq_count < max_queues_half: + pq_count = max_queues_half for queue in if_queues: # Get queue type and statistics diff --git a/tests/mock_tables/appl_db.json b/tests/mock_tables/appl_db.json index c76c1e534..cfbb79146 100644 --- a/tests/mock_tables/appl_db.json +++ b/tests/mock_tables/appl_db.json @@ -447,6 +447,20 @@ "lldp_rem_port_id": "Ethernet32", "lldp_rem_man_addr": "10.224.25.131" }, + "LLDP_ENTRY_TABLE:Ethernet78": { + "lldp_rem_port_id_subtype": "5", + "lldp_rem_sys_cap_supported": "28 00", + "lldp_rem_index": "1", + "lldp_rem_chassis_id": "00:11:22:33:44:55", + "lldp_rem_sys_desc": "I'm a little teapot.", + "lldp_rem_time_mark": "4844", + "lldp_rem_sys_cap_enabled": "28 00", + "lldp_rem_port_desc": " ", + "lldp_rem_chassis_id_subtype": "4", + "lldp_rem_sys_name": "switch13", + "lldp_rem_port_id": "Ethernet33", + "lldp_rem_man_addr": "10.224.25.132" + }, "LLDP_ENTRY_TABLE:eth1": { "lldp_rem_port_id_subtype": "5", "lldp_rem_sys_cap_supported": "28 00", @@ -628,8 +642,13 @@ "alias": "etp32", "speed": 100000 }, + "PORT_TABLE:Ethernet78": { + "description": "snowflake", + "alias": "etp33", + "speed": 100000 + }, "ROUTE_TABLE:0.0.0.0/0": { - "ifname": "Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52", + "ifname": "Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet78", "nexthop": "10.0.0.1,10.0.0.3,10.0.0.5,10.0.0.7,10.0.0.9,10.0.0.11,10.0.0.13,10.0.0.15,10.0.0.17,10.0.0.19,10.0.0.21,10.0.0.23,10.0.0.25,10.0.0.27" }, "ROUTE_TABLE:10.1.0.32": { diff --git a/tests/mock_tables/counters_db.json b/tests/mock_tables/counters_db.json index 6d22635d1..94a83829f 100755 --- a/tests/mock_tables/counters_db.json +++ b/tests/mock_tables/counters_db.json @@ -2173,6 +2173,7 @@ "Ethernet64": "oid:0x100000000001f", "Ethernet60": "oid:0x100000000001e", "Ethernet20": "oid:0x1000000000015", + "Ethernet78": "oid:0x1000000000024", "Ethernet68": "oid:0x1000000000020" }, "COUNTERS_LAG_NAME_MAP": { @@ -3507,6 +3508,108 @@ "SAI_PORT_STAT_PFC_7_RX_PKTS": "8", "SAI_PORT_STAT_PFC_7_TX_PKTS": "8" }, + "COUNTERS:oid:0x1000000000024": { + "SAI_PORT_STAT_ETHER_STATS_TX_NO_ERRORS": "0", + "SAI_PORT_STAT_ETHER_STATS_OVERSIZE_PKTS": "0", + "SAI_PORT_STAT_IF_OUT_ERRORS": "0", + "SAI_PORT_STAT_ETHER_TX_OVERSIZE_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_1519_TO_2047_OCTETS": "0", + "SAI_PORT_STAT_IP_IN_RECEIVES": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_64_OCTETS": "0", + "SAI_PORT_STAT_IPV6_OUT_UCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_4096_TO_9216_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_ERRORS": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_BROADCAST_PKTS": "0", + "SAI_PORT_STAT_IF_IN_DISCARDS": "0", + "SAI_PORT_STAT_IP_OUT_DISCARDS": "0", + "SAI_PORT_STAT_IF_IN_UNKNOWN_PROTOS": "0", + "SAI_PORT_STAT_IPV6_IN_DISCARDS": "0", + "SAI_PORT_STAT_IPV6_OUT_DISCARDS": "0", + "SAI_PORT_STAT_IPV6_IN_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_65_TO_127_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_BROADCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_1519_TO_2047_OCTETS": "0", + "SAI_PORT_STAT_IF_OUT_MULTICAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_512_TO_1023_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_256_TO_511_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_9217_TO_16383_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_512_TO_1023_OCTETS": "0", + "SAI_PORT_STAT_IPV6_IN_NON_UCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_4096_TO_9216_OCTETS": "0", + "SAI_PORT_STAT_IF_OUT_BROADCAST_PKTS": "0", + "SAI_PORT_STAT_IPV6_OUT_NON_UCAST_PKTS": "0", + "SAI_PORT_STAT_IF_IN_VLAN_DISCARDS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_65_TO_127_OCTETS": "0", + "SAI_PORT_STAT_IP_IN_NON_UCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_FRAGMENTS": "0", + "SAI_PORT_STAT_IPV6_IN_UCAST_PKTS": "0", + "SAI_PORT_STAT_IPV6_IN_RECEIVES": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_4096_TO_9216_OCTETS": "0", + "SAI_PORT_STAT_IF_OUT_DISCARDS": "0", + "SAI_PORT_STAT_ETHER_STATS_DROP_EVENTS": "0", + "SAI_PORT_STAT_IPV6_OUT_MCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_RX_OVERSIZE_PKTS": "0", + "SAI_PORT_STAT_IF_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_9217_TO_16383_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_1024_TO_1518_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_2048_TO_4095_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_512_TO_1023_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_1519_TO_2047_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_RX_NO_ERRORS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_64_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_COLLISIONS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_1024_TO_1518_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_1024_TO_1518_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_256_TO_511_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_2048_TO_4095_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_OCTETS": "0", + "SAI_PORT_STAT_IF_OUT_UCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_UNDERSIZE_PKTS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_128_TO_255_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_64_OCTETS": "0", + "SAI_PORT_STAT_IP_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_UCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_9217_TO_16383_OCTETS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_2048_TO_4095_OCTETS": "0", + "SAI_PORT_STAT_IP_OUT_NON_UCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_JABBERS": "0", + "SAI_PORT_STAT_IF_IN_OCTETS": "0", + "SAI_PORT_STAT_IPV6_IN_MCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_65_TO_127_OCTETS": "0", + "SAI_PORT_STAT_IF_OUT_QLEN": "0", + "SAI_PORT_STAT_ETHER_STATS_PKTS_128_TO_255_OCTETS": "0", + "SAI_PORT_STAT_IP_IN_DISCARDS": "0", + "SAI_PORT_STAT_IPV6_OUT_OCTETS": "0", + "SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS": "0", + "SAI_PORT_STAT_IP_IN_OCTETS": "0", + "SAI_PORT_STAT_ETHER_OUT_PKTS_256_TO_511_OCTETS": "0", + "SAI_PORT_STAT_ETHER_STATS_CRC_ALIGN_ERRORS": "0", + "SAI_PORT_STAT_IP_OUT_UCAST_PKTS": "0", + "SAI_PORT_STAT_IP_IN_UCAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_STATS_MULTICAST_PKTS": "0", + "SAI_PORT_STAT_ETHER_IN_PKTS_128_TO_255_OCTETS": "0", + "SAI_PORT_STAT_IF_IN_MULTICAST_PKTS": "0", + "SAI_PORT_STAT_PAUSE_RX_PKTS": "0", + "SAI_PORT_STAT_PAUSE_TX_PKTS": "0", + "SAI_PORT_STAT_PFC_0_RX_PKTS": "1", + "SAI_PORT_STAT_PFC_0_TX_PKTS": "1", + "SAI_PORT_STAT_PFC_1_RX_PKTS": "2", + "SAI_PORT_STAT_PFC_1_TX_PKTS": "2", + "SAI_PORT_STAT_PFC_2_RX_PKTS": "3", + "SAI_PORT_STAT_PFC_2_TX_PKTS": "3", + "SAI_PORT_STAT_PFC_3_RX_PKTS": "4", + "SAI_PORT_STAT_PFC_3_TX_PKTS": "4", + "SAI_PORT_STAT_PFC_4_RX_PKTS": "5", + "SAI_PORT_STAT_PFC_4_TX_PKTS": "5", + "SAI_PORT_STAT_PFC_5_RX_PKTS": "6", + "SAI_PORT_STAT_PFC_5_TX_PKTS": "6", + "SAI_PORT_STAT_PFC_6_RX_PKTS": "7", + "SAI_PORT_STAT_PFC_6_TX_PKTS": "7", + "SAI_PORT_STAT_PFC_7_RX_PKTS": "8", + "SAI_PORT_STAT_PFC_7_TX_PKTS": "8" + }, "COUNTERS_QUEUE_NAME_MAP": { "Ethernet0:0": "oid:0x15000000000230", "Ethernet0:1": "oid:0x15000000000231", @@ -3568,6 +3671,22 @@ "Ethernet24:13": "oid:0x15000000010275", "Ethernet24:14": "oid:0x15000000010276", "Ethernet24:15": "oid:0x15000000010277", + "Ethernet78:1": "oid:0x15000000000381", + "Ethernet78:2": "oid:0x15000000000382", + "Ethernet78:3": "oid:0x15000000000383", + "Ethernet78:4": "oid:0x15000000000384", + "Ethernet78:5": "oid:0x15000000000385", + "Ethernet78:6": "oid:0x15000000000386", + "Ethernet78:7": "oid:0x15000000000387", + "Ethernet78:8": "oid:0x15000000000388", + "Ethernet78:9": "oid:0x15000000000389", + "Ethernet78:10": "oid:0x1500000000038a", + "Ethernet78:11": "oid:0x15000000010381", + "Ethernet78:13": "oid:0x15000000010382", + "Ethernet78:12": "oid:0x15000000010383", + "Ethernet78:14": "oid:0x15000000010384", + "Ethernet78:15": "oid:0x15000000010385", + "Ethernet78:16": "oid:0x15000000010386", "Ethernet32:1": "oid:0x15000000000281", "Ethernet32:2": "oid:0x15000000000282", "Ethernet32:4": "oid:0x15000000000284", @@ -3640,6 +3759,22 @@ "oid:0x15000000010275": "SAI_QUEUE_TYPE_MULTICAST", "oid:0x15000000010276": "SAI_QUEUE_TYPE_MULTICAST", "oid:0x15000000010277": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x15000000000381": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000382": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000383": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000384": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000385": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000386": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000387": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000388": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000000389": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x1500000000038a": "SAI_QUEUE_TYPE_UNICAST", + "oid:0x15000000010381": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x15000000010382": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x15000000010383": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x15000000010384": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x15000000010385": "SAI_QUEUE_TYPE_MULTICAST", + "oid:0x15000000010386": "SAI_QUEUE_TYPE_MULTICAST", "oid:0x15000000000281": "SAI_QUEUE_TYPE_UNICAST", "oid:0x15000000000282": "SAI_QUEUE_TYPE_UNICAST", "oid:0x15000000000284": "SAI_QUEUE_TYPE_UNICAST", @@ -4131,6 +4266,134 @@ "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" }, + "COUNTERS:oid:0x15000000000381": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000000382": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000000383": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000000384": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000000385": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000000386": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000000387": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000000388": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000000389": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x1500000000038a": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000010381": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000010382": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000010383": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000010384": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000010385": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, + "COUNTERS:oid:0x15000000010386": { + "SAI_QUEUE_STAT_PACKETS": "1", + "SAI_QUEUE_STAT_BYTES": "2", + "SAI_QUEUE_STAT_DROPPED_PACKETS": "3", + "SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4", + "SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5", + "SAI_QUEUE_STAT_WATERMARK_BYTES": "6" + }, "COUNTERS:oid:0x15000000000281": { "SAI_QUEUE_STAT_PACKETS": "1", "SAI_QUEUE_STAT_BYTES": "2", diff --git a/tests/mock_tables/state_db.json b/tests/mock_tables/state_db.json index ad4cd5eca..7de231f3d 100644 --- a/tests/mock_tables/state_db.json +++ b/tests/mock_tables/state_db.json @@ -213,5 +213,8 @@ }, "BUFFER_MAX_PARAM_TABLE|Ethernet32": { "max_queues": "16" + }, + "BUFFER_MAX_PARAM_TABLE|Ethernet78": { + "max_queues": "16" } } diff --git a/tests/test_queues_stat.py b/tests/test_queues_stat.py index 3ae9695c9..ed9be1592 100644 --- a/tests/test_queues_stat.py +++ b/tests/test_queues_stat.py @@ -21,7 +21,6 @@ class TestQueueCounters(TestCase): @classmethod def setUpClass(cls): cls.lut = MIBTable(ciscoSwitchQosMIB.csqIfQosGroupStatsTable) - # Update MIBs for updater in cls.lut.updater_instances: updater.reinit_data() @@ -49,6 +48,10 @@ def test_getQueueCounters(self): # Ethernet16 is created on mock_tables\counters_db.json with only counters for UC 0,1,2,3,4,6 # Ethernet24 is created on mock_tables\counters_db.json with only counters for MC 0,2,3,5,6,7 # Ethernet32 is created on mock_tables\counters_db.json with only counters for UC 1,2,4,6,7 and MC 0,1,3,5,6 + # Test issue https://github.com/sonic-net/sonic-snmpagent/pull/330 + # Ethernet78 is created on mock_tables\counters_db.json with counters for UC 0,1,2,3,4,5,6,7,8,9,10 and MC 2,3,4,5,6,7 + # It is important there are more UC queues than half of the total number of queues. + # A total of 16 queues for Ethernet78 is defined in mock_tables\state_db.json def test_getQueueCountersForPortWithAllCounters(self): tested_ports_counters_data = { 17: { 1: {1:1, 2:23492723984237432, 5:3,6:0}, 2: {1:1, 2:2, 5:3, 6:0}, @@ -63,11 +66,17 @@ def test_getQueueCountersForPortWithAllCounters(self): 3: {1:1, 2:2, 5:3, 6:0}, 4: {3:1, 4:2, 7:3, 8:0}, 5: {1:1, 2:2, 5:3, 6:0}, 6: {3:1, 4:2, 7:3, 8:0}, 7: {1:1, 2:2, 3:1, 4:2, 5:3, 6:0, 7:3,8:0}, 8: {1:1, 2:2, 5:3, 6:0} + }, + 79: { 1: {1:1, 2:2, 5:3, 6:0}, 2: {1:1, 2:2, 3:1, 4:2, 5:3, 6:0, 7:3, 8:0}, + 3: {1:1, 2:2, 3:1, 4:2, 5:3, 6:0, 7:3, 8:0}, 4: {1:1, 2:2, 3:1, 4:2, 5:3, 6:0, 7:3, 8:0}, + 5: {1:1, 2:2, 3:1, 4:2, 5:3, 6:0, 7:3, 8:0}, 6: {1:1, 2:2, 3:1, 4:2, 5:3, 6:0, 7:3, 8:0}, + 7: {1:1, 2:2, 3:1, 4:2, 5:3, 6:0, 7:3, 8:0}, 8: {1:1, 2:2, 5:3, 6:0}, + 9: {1:1, 2:2, 5:3, 6:0}, 10: {1:1, 2:2, 5:3, 6:0} } } for port, configured_queues in tested_ports_counters_data.items(): - for queue_id in range(1, 8): + for queue_id in range(1, sorted(configured_queues.keys(), reverse=True)[0]): for counter_id in range(1, 8): oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 580, 1, 5, 5, 1, 4, port, 2, queue_id, counter_id)) get_pdu = GetPDU(