Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action] [PR:322] [ciscoPfcExtMIB]: Remove returning first intf index if subid is empty (#322) #328

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/sonic_ax_impl/mibs/vendor/cisco/ciscoPfcExtMIB.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ def get_next(self, sub_id):
:return: the next sub id.
"""
try:
if not sub_id:
return self.if_range[0]

right = bisect_right(self.if_range, sub_id)
if right >= len(self.if_range):
return None
Expand Down
17 changes: 17 additions & 0 deletions tests/namespace/test_pfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import sys
import importlib

if sys.version_info.major == 3:
from unittest import mock
else:
import mock

# noinspection PyUnresolvedReferences
import tests.mock_tables.dbconnector

Expand Down Expand Up @@ -265,6 +270,18 @@ def test_getPfcSubtree(self):
self.assertEqual(str(value0.name), str(expected_oid))
self.assertEqual(value0.data, 209347219842134092490 % pow(2, 64)) # Test integer truncation

def test_no_interfaces(self):
# Test the scenario where there are no interfaces
# like the case of Packet-chassis supervisor
ciscoPfcExtMIB.cpfcIfTable.pfc_updater.if_range = []
importlib.reload(ciscoPfcExtMIB)
oid = ObjectIdentifier(32, 0, 0, 0, (1, 3, 6, 1, 4, 1, 9, 9, 813, 1))
sub_id = ()
with mock.patch('sonic_ax_impl.mibs.logger.error') as mock_logger:
get_pdu = ciscoPfcExtMIB.cpfcIfTable.pfc_updater.get_next(sub_id)
self.assertEqual(get_pdu, None)
mock_logger.assert_not_called()

@classmethod
def tearDownClass(cls):
tests.mock_tables.dbconnector.clean_up_config()
Loading