From 0d4a16b7250195b9042a1a8bbd7c5b995e229303 Mon Sep 17 00:00:00 2001 From: Xixue Jia Date: Mon, 14 Jul 2025 12:14:20 +0800 Subject: [PATCH 1/3] Refactor DPU check in device_utils and test_watchdog This changes is because is_dpu method was removed by below PR [smartswitch]: Add is_smartswitch and is_dpu facts to simplify platform-specific test handling (#19313) --- tests/common/platform/device_utils.py | 4 ++-- tests/platform_tests/api/test_watchdog.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/common/platform/device_utils.py b/tests/common/platform/device_utils.py index 0bd89c53e82..678b62fc2d7 100644 --- a/tests/common/platform/device_utils.py +++ b/tests/common/platform/device_utils.py @@ -1148,7 +1148,7 @@ def add_platform_api_server_port_nat_for_dpu( The NAT rule is added before the test and removed after the test. ''' duthost = duthosts[enum_rand_one_per_hwsku_hostname] - if duthost.is_dpu(): + if duthost.dut_basic_facts()['ansible_facts']['dut_basic_facts'].get("is_dpu"): ip_interface_status = duthost.show_and_parse('show ip interface') for item in ip_interface_status: if item['interface'] == "eth0-midplane": @@ -1162,7 +1162,7 @@ def add_platform_api_server_port_nat_for_dpu( yield - if duthost.is_dpu(): + if duthost.dut_basic_facts()['ansible_facts']['dut_basic_facts'].get("is_dpu"): npu_host.command( f'sudo iptables -t nat -D PREROUTING -i eth0 -p tcp --dport \ {SERVER_PORT} -j DNAT --to-destination {dpu_ip}:{SERVER_PORT}') diff --git a/tests/platform_tests/api/test_watchdog.py b/tests/platform_tests/api/test_watchdog.py index 1f1ecd51801..f33d49d3f9d 100644 --- a/tests/platform_tests/api/test_watchdog.py +++ b/tests/platform_tests/api/test_watchdog.py @@ -138,7 +138,8 @@ def test_arm_disarm_states(self, duthosts, enum_rand_one_per_hwsku_hostname, loc self.expect(remaining_time is -1, "Watchdog remaining_time {} seconds is wrong for disarmed state".format(remaining_time)) - ansible_ssh_port = get_ansible_ssh_port(duthost, ansible_adhoc) if duthost.is_dpu() else 22 + is_dpu = duthost.dut_basic_facts()['ansible_facts']['dut_basic_facts'].get("is_dpu") + ansible_ssh_port = get_ansible_ssh_port(duthost, ansible_adhoc) if is_dpu else 22 res = localhost.wait_for(host=duthost.mgmt_ip, port=ansible_ssh_port, state="stopped", delay=5, timeout=watchdog_timeout + TIMEOUT_DEVIATION, module_ignore_errors=True) From 8e993f95493b9187a6c60fb49dc1f23719f3640b Mon Sep 17 00:00:00 2001 From: Cong Hou Date: Fri, 18 Jul 2025 05:56:50 +0300 Subject: [PATCH 2/3] Fix the condition for dpu in techsupport test --- tests/show_techsupport/test_techsupport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/show_techsupport/test_techsupport.py b/tests/show_techsupport/test_techsupport.py index f12068790e5..1ffda8ac736 100644 --- a/tests/show_techsupport/test_techsupport.py +++ b/tests/show_techsupport/test_techsupport.py @@ -89,7 +89,7 @@ def skip_on_dpu(duthosts, enum_rand_one_per_hwsku_frontend_hostname): When dut is dpu, skip the case """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] - if duthost.get_facts().get('is_dpu'): + if duthost.dut_basic_facts()['ansible_facts']['dut_basic_facts'].get("is_dpu"): pytest.skip("Skip the test, as it is not supported on DPU.") From 212318d8741c7abefa39d5f3cf577b1032ec47dd Mon Sep 17 00:00:00 2001 From: Cong Hou Date: Mon, 28 Jul 2025 10:49:46 +0300 Subject: [PATCH 3/3] Fix skip dpu logic in techsupport test --- tests/show_techsupport/test_techsupport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/show_techsupport/test_techsupport.py b/tests/show_techsupport/test_techsupport.py index 1ffda8ac736..657854c3a34 100644 --- a/tests/show_techsupport/test_techsupport.py +++ b/tests/show_techsupport/test_techsupport.py @@ -620,7 +620,7 @@ def test_techsupport_on_dpu(duthosts, enum_rand_one_per_hwsku_frontend_hostname) :param duthosts: DUT host """ duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] - if not duthost.get_facts().get('is_dpu'): + if not duthost.dut_basic_facts()['ansible_facts']['dut_basic_facts'].get("is_dpu"): pytest.skip("Skip the test, as it is supported only on DPU.") since = str(randint(1, 5)) + " minute ago"