Skip to content

Commit

Permalink
[sonic-mgmt] Fix "fdb/test_fdb_mac_move.py" AttributeError failure (#…
Browse files Browse the repository at this point in the history
…15704)

Test is relying on duthost method "get_crm_resources" method (parses
info from "crm show resources all" output)  to get "fdb_entry" crm
resource values. If output is empty for some reason then
"duthost.get_crm_resources().get("main_resources")" will be empty and thus
lead to "AttributeError: 'NoneType' object has no attribute 'get' during
get_crm_resources()" failure if we try to access "fdb_entry" key.

PR#11127 has introduced retry mechanism in case of empty output but condition is
incorrect ("len(duthost.get_crm_resources())") will never be 0. Correcting this
PR change to check for "main_resources" fixes the issue.
  • Loading branch information
vkjammala-arista authored and mssonicbld committed Nov 27, 2024
1 parent b1efd86 commit 8ddd823
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/fdb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ def IntToMac(intMac):
def get_crm_resources(duthost, resource, status):
retry_count = 5
count = 0
while len(duthost.get_crm_resources()) == 0 and count < retry_count:
while len(duthost.get_crm_resources().get("main_resources")) == 0 and count < retry_count:
logger.debug("CRM resources not fully populated, retry after 2 seconds: count: {}".format(count))
time.sleep(2)
count = count + 1
pytest_assert(resource in duthost.get_crm_resources().get("main_resources"),
"{} not populated in CRM resources".format(resource))
return duthost.get_crm_resources().get("main_resources").get(resource).get(status)


Expand Down

0 comments on commit 8ddd823

Please sign in to comment.