Skip to content

Commit

Permalink
Fix key error caused by platform_asic (#9547)
Browse files Browse the repository at this point in the history
Description of PR
In PR #9054, it will try to get duthost.facts["platform_asic"] in test_crm.py, but in file tests/common/devices/sonic.py, which define the duthost.facts, platform_asic may not exist in duthost.facts. And this will cause KeyError in test_crm.py. In this PR, if platform_asic doesn't exist in duthost.facts, we set it None.

What is the motivation for this PR?
In PR #9054, it will try to get duthost.facts["platform_asic"] in test_crm.py, but in file tests/common/devices/sonic.py, which define the duthost.facts, platform_asic may not exist in duthost.facts. And this will cause KeyError in test_crm.py. In this PR, if platform_asic doesn't exist in duthost.facts, we set it None.

Signed-off-by: Yutong Zhang <yutongzhang@microsoft.com>
  • Loading branch information
yutongzhang-microsoft authored and mssonicbld committed Aug 28, 2023
1 parent a8e3ed9 commit 993d4d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/crm/test_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ def verify_acl_crm_stats(duthost, asichost, enum_rand_one_per_hwsku_frontend_hos
# Reduce ACL to one rule (plus default)
crm_stats_acl_entry_used = 2
apply_acl_config(duthost, asichost, "test_acl_entry", asic_collector, entry_num=1)
if duthost.facts["platform_asic"] == "broadcom-dnx":
if duthost.facts.get("platform_asic", None) == "broadcom-dnx":
# Each ACL rule consumes an acl entry per bind point
asicAclBindings = set()
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
Expand Down

0 comments on commit 993d4d7

Please sign in to comment.