From 327905cb59f1aee87462d0bc6ef3111a9f45db87 Mon Sep 17 00:00:00 2001 From: Xu Chen <112069142+XuChen-MSFT@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:58:51 +0800 Subject: [PATCH] fix keyerror of PR #10382 (#11722) What is the motivation for this PR? PR #10382 caused below two KeyError: @pytest.fixture(scope="function", autouse=False) def skip_pacific_dst_asic(self, dutConfig): > if dutConfig['dstDutAsic'] == "pac": E KeyError: 'dstDutAsic' if "wm_pg_shared_lossless" in pgProfile: pktsNumFillShared = qosConfig[pgProfile]["pkts_num_trig_pfc"] elif "wm_pg_shared_lossy" in pgProfile: > if dutConfig['dstDutAsic'] == "pac": E KeyError: 'dstDutAsic' and remove duplicated code in PR #11553 and PR #10838, it will cause pre-commit failure @pytest.fixture(scope="function", autouse=False) def skip_longlink(self, dutQosConfig): portSpeedCableLength = dutQosConfig["portSpeedCableLength"] match = re.search("_([0-9]*)m", portSpeedCableLength) if match and int(match.group(1)) > 2000: pytest.skip( "This test is skipped for longlink.") yield return How did you do it? fix keyerror and remove duplicated code --- tests/qos/qos_sai_base.py | 2 +- tests/qos/test_qos_sai.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qos/qos_sai_base.py b/tests/qos/qos_sai_base.py index 4054fe4fde8..6663fffe4af 100644 --- a/tests/qos/qos_sai_base.py +++ b/tests/qos/qos_sai_base.py @@ -2202,7 +2202,7 @@ def skip_src_dst_different_asic(self, dutConfig): @pytest.fixture(scope="function", autouse=False) def skip_pacific_dst_asic(self, dutConfig): - if dutConfig['dstDutAsic'] == "pac": + if dutConfig.get('dstDutAsic', 'UnknownDstDutAsic') == "pac": pytest.skip( "This test is skipped since egress asic is cisco-8000 Q100.") yield diff --git a/tests/qos/test_qos_sai.py b/tests/qos/test_qos_sai.py index 4f16f540365..370e9af37e9 100644 --- a/tests/qos/test_qos_sai.py +++ b/tests/qos/test_qos_sai.py @@ -1578,7 +1578,7 @@ def testQosSaiPgSharedWatermark( if "wm_pg_shared_lossless" in pgProfile: pktsNumFillShared = qosConfig[pgProfile]["pkts_num_trig_pfc"] elif "wm_pg_shared_lossy" in pgProfile: - if dutConfig['dstDutAsic'] == "pac": + if dutConfig.get('dstDutAsic', 'UnknownDstDutAsic') == "pac": pytest.skip( "PGSharedWatermark: Lossy test is not applicable in " "cisco-8000 Q100 platform.")