Skip to content

Commit dc25301

Browse files
committed
fix the errors from command execution on DPU
1 parent 7fdb321 commit dc25301

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

tests/dash/test_dash_privatelink_redirect.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,12 @@ def dpu_setup(duthost, dpuhosts, dpu_index, skip_config):
362362
dpu_cmds.append(
363363
f"config int ip add Ethernet0 {dpuhost.dpu_data_port_ip}/31"
364364
)
365-
pt_require(dpuhost.npu_data_port_ip, "DPU data port IP is not set")
366-
dpu_cmds.append(
367-
f"ip route replace default via {dpuhost.npu_data_port_ip}"
368-
)
369-
dpuhost.shell_cmds(cmds=dpu_cmds)
365+
if dpuhost.npu_data_port_ip:
366+
dpu_cmds.append(
367+
f"ip route replace default via {dpuhost.npu_data_port_ip}"
368+
)
369+
if len(dpu_cmds) > 0:
370+
dpuhost.shell_cmds(cmds=dpu_cmds)
370371

371372

372373
@pytest.fixture(scope="class", autouse=True)

tests/dash/test_dash_smartswitch_vnet.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def dpu_setup_vnet(duthost, dpuhosts, dpu_index, skip_config):
4343
dpu_cmds.append("config loopback add Loopback0")
4444
dpu_cmds.append(f"config int ip add Loopback0 {APPLIANCE_VIP}/32")
4545

46-
dpu_cmds.append(f"ip route replace default via {dpuhost.npu_data_port_ip}")
47-
dpuhost.shell_cmds(cmds=dpu_cmds)
46+
if dpuhost.npu_data_port_ip:
47+
dpu_cmds.append(f"ip route replace default via {dpuhost.npu_data_port_ip}")
48+
if len(dpu_cmds) > 0:
49+
dpuhost.shell_cmds(cmds=dpu_cmds)
4850

4951

5052
@pytest.fixture(scope="module", autouse=True)
@@ -54,7 +56,8 @@ def add_npu_static_routes_vnet(duthost, dash_smartswitch_vnet_config, skip_confi
5456
cmds = []
5557
pe_nexthop_ip = get_interface_ip(duthost, dash_smartswitch_vnet_config[REMOTE_DUT_INTF]).ip + 1
5658
cmds.append(f"ip route replace {dash_smartswitch_vnet_config[REMOTE_PA_IP]}/32 via {pe_nexthop_ip}")
57-
cmds.append(f"ip route replace {APPLIANCE_VIP}/32 via {dpuhost.dpu_data_port_ip}")
59+
if dpuhost.dpu_data_port_ip:
60+
cmds.append(f"ip route replace {APPLIANCE_VIP}/32 via {dpuhost.dpu_data_port_ip}")
5861
logger.info(f"Adding static routes: {cmds}")
5962
duthost.shell_cmds(cmds=cmds)
6063

@@ -63,7 +66,8 @@ def add_npu_static_routes_vnet(duthost, dash_smartswitch_vnet_config, skip_confi
6366
if not skip_config and not skip_cleanup:
6467
dpuhost = dpuhosts[dpu_index]
6568
cmds = []
66-
cmds.append(f"ip route del {dash_smartswitch_vnet_config[REMOTE_PA_IP]}/32 via {pe_nexthop_ip}")
69+
if dpuhost.dpu_data_port_ip:
70+
cmds.append(f"ip route del {dash_smartswitch_vnet_config[REMOTE_PA_IP]}/32 via {pe_nexthop_ip}")
6771
cmds.append(f"ip route del {APPLIANCE_VIP}/32 via {dpuhost.dpu_data_port_ip}")
6872
logger.info(f"Removing static routes: {cmds}")
6973
duthost.shell_cmds(cmds=cmds)

0 commit comments

Comments
 (0)