Skip to content

Commit

Permalink
Add UT for port that doe
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZagury committed Dec 19, 2023
1 parent d62f739 commit 3d13de4
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 3 deletions.
55 changes: 52 additions & 3 deletions tests/mock_tables/counters_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -3555,7 +3555,13 @@
"Ethernet8:12": "oid:0x15000000010254",
"Ethernet8:13": "oid:0x15000000010255",
"Ethernet8:14": "oid:0x15000000010256",
"Ethernet8:15": "oid:0x15000000010257"
"Ethernet8:15": "oid:0x15000000010257",
"Ethernet16:0": "oid:0x15000000000260",
"Ethernet16:1": "oid:0x15000000000261",
"Ethernet16:2": "oid:0x15000000000262",
"Ethernet16:3": "oid:0x15000000000263",
"Ethernet16:4": "oid:0x15000000000264",
"Ethernet16:6": "oid:0x15000000000266"
},
"COUNTERS_QUEUE_TYPE_MAP": {
"oid:0x15000000000230": "SAI_QUEUE_TYPE_UNICAST",
Expand Down Expand Up @@ -3605,7 +3611,13 @@
"oid:0x15000000010254": "SAI_QUEUE_TYPE_MULTICAST",
"oid:0x15000000010255": "SAI_QUEUE_TYPE_MULTICAST",
"oid:0x15000000010256": "SAI_QUEUE_TYPE_MULTICAST",
"oid:0x15000000010257": "SAI_QUEUE_TYPE_MULTICAST"
"oid:0x15000000010257": "SAI_QUEUE_TYPE_MULTICAST",
"oid:0x15000000000260": "SAI_QUEUE_TYPE_UNICAST",
"oid:0x15000000000261": "SAI_QUEUE_TYPE_UNICAST",
"oid:0x15000000000262": "SAI_QUEUE_TYPE_UNICAST",
"oid:0x15000000000263": "SAI_QUEUE_TYPE_UNICAST",
"oid:0x15000000000264": "SAI_QUEUE_TYPE_UNICAST",
"oid:0x15000000000266": "SAI_QUEUE_TYPE_UNICAST"
},
"COUNTERS:oid:0x15000000000230": {
"SAI_QUEUE_STAT_PACKETS": "1",
Expand Down Expand Up @@ -3990,4 +4002,41 @@
"SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4",
"SAI_QUEUE_STAT_CURR_OCCUPANCY_BYTES": "5",
"SAI_QUEUE_STAT_WATERMARK_BYTES": "6"
}}
},
"COUNTERS:oid:0x15000000000260": {
"SAI_QUEUE_STAT_PACKETS": "1",
"SAI_QUEUE_STAT_BYTES": "23492723984237432",
"SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4",
"SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0"
},
"COUNTERS:oid:0x15000000000261": {
"SAI_QUEUE_STAT_PACKETS": "1",
"SAI_QUEUE_STAT_BYTES": "2",
"SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4",
"SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0"
},
"COUNTERS:oid:0x15000000000262": {
"SAI_QUEUE_STAT_PACKETS": "1",
"SAI_QUEUE_STAT_BYTES": "2",
"SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4",
"SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0"
},
"COUNTERS:oid:0x15000000000263": {
"SAI_QUEUE_STAT_PACKETS": "1",
"SAI_QUEUE_STAT_BYTES": "2",
"SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4",
"SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0"
},
"COUNTERS:oid:0x15000000000264": {
"SAI_QUEUE_STAT_PACKETS": "1",
"SAI_QUEUE_STAT_BYTES": "2",
"SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4",
"SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0"
},
"COUNTERS:oid:0x15000000000266": {
"SAI_QUEUE_STAT_PACKETS": "1",
"SAI_QUEUE_STAT_BYTES": "2",
"SAI_QUEUE_STAT_DISCARD_DROPPED_PACKETS": "4",
"SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES": "0"
}
}
3 changes: 3 additions & 0 deletions tests/mock_tables/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,8 @@
},
"BUFFER_MAX_PARAM_TABLE|Ethernet8": {
"max_queues": "16"
},
"BUFFER_MAX_PARAM_TABLE|Ethernet16": {
"max_queues": "16"
}
}
26 changes: 26 additions & 0 deletions tests/test_queues_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ def test_getQueueCounters(self):
self.assertEqual(str(value0.name), str(oid))
self.assertEqual(value0.data, 1)

# Test issue https://github.com/sonic-net/sonic-buildimage/issues/17448
# In this Scenario not all counters are created.
# Ethernet16 is created on mock_tables\counters_db.json with only counters for UC 0,1,2,3,4,6
def test_getQueueCountersForPortWithAllCounters(self):
configured_queues = [1,2,3,4,5,7]
for queue_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, 17, 2, queue_id, 1))
get_pdu = GetPDU(
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0),
oids=[oid]
)

encoded = get_pdu.encode()
response = get_pdu.make_response(self.lut)
print(response)
value0 = response.values[0]
if queue_id in configured_queues:
self.assertEqual(value0.type_, ValueType.COUNTER_64)
self.assertEqual(str(value0.name), str(oid))
self.assertEqual(value0.data, 1)
else:
self.assertEqual(value0.type_, ValueType.NO_SUCH_INSTANCE)
self.assertEqual(str(value0.name), str(oid))
self.assertEqual(value0.data, None)


def test_getNextPduForQueueCounter(self):
oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 580, 1, 5, 5, 1, 4, 1, 2, 1, 1))
expected_oid = ObjectIdentifier(8, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 580, 1, 5, 5, 1, 4, 1, 2, 1, 2))
Expand Down

0 comments on commit 3d13de4

Please sign in to comment.