From 515e5b75cc7159db0f49a08035124bd190cb5124 Mon Sep 17 00:00:00 2001 From: Yutong Zhang <90831468+yutongzhang-microsoft@users.noreply.github.com> Date: Fri, 18 Aug 2023 13:46:45 +0800 Subject: [PATCH] Fix key error caused by platform_asic (#9547) 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 --- tests/crm/test_crm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/crm/test_crm.py b/tests/crm/test_crm.py index b9e0127a31..22ec7e99e6 100755 --- a/tests/crm/test_crm.py +++ b/tests/crm/test_crm.py @@ -928,7 +928,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)