From 6fb2bbe2b725b414ca555eb8179ae5aad7e0556d Mon Sep 17 00:00:00 2001 From: Vivek Kumar Verma Date: Wed, 14 May 2025 10:11:20 +0000 Subject: [PATCH] Enable pfc at global level for snappi tests --- tests/common/snappi_tests/common_helpers.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) mode change 100644 => 100755 tests/common/snappi_tests/common_helpers.py diff --git a/tests/common/snappi_tests/common_helpers.py b/tests/common/snappi_tests/common_helpers.py old mode 100644 new mode 100755 index 6175b63c7f5..e44f1c204b1 --- a/tests/common/snappi_tests/common_helpers.py +++ b/tests/common/snappi_tests/common_helpers.py @@ -795,6 +795,21 @@ def get_pfcwd_stats(duthost, port, prio, asic_value=None): return pfcwd_stats +def enable_default_pfcwd_status(duthost, asic_value=None): + """ + Enable PFC watchdog default status. + Note: "pfcwd start_default" has no effect on config without enabling + "default_pfcwd_status". + """ + cmd_prefix = f'sudo ip netns exec {asic_value} ' if asic_value is not None else '' + cmd = cmd_prefix + 'sonic-db-dump -n CONFIG_DB -y -k \"DEVICE_METADATA|localhost\"' + res = duthost.shell(cmd) + meta_data = json.loads(res["stdout"]) + pfc_status = meta_data["DEVICE_METADATA|localhost"]["value"].get("default_pfcwd_status", "") + if pfc_status == 'disable': + cmd = cmd_prefix + 'sonic-db-cli CONFIG_DB hset \"DEVICE_METADATA|localhost\" default_pfcwd_status enable' + duthost.shell(cmd) + def start_pfcwd(duthost, asic_value=None): """ Start PFC watchdog with default setting @@ -805,6 +820,7 @@ def start_pfcwd(duthost, asic_value=None): Returns: N/A """ + enable_default_pfcwd_status(duthost, asic_value) if asic_value is None: duthost.shell('sudo pfcwd start_default') else: