diff --git a/tests/common/dualtor/dual_tor_mock.py b/tests/common/dualtor/dual_tor_mock.py index 96bed2e51e5..19afa3c185b 100644 --- a/tests/common/dualtor/dual_tor_mock.py +++ b/tests/common/dualtor/dual_tor_mock.py @@ -339,10 +339,12 @@ def apply_peer_switch_table_to_dut(cleanup_mocked_configs, rand_selected_dut, mo peer_switch_hostname = 'switch_hostname' peer_switch_key = 'PEER_SWITCH|{}'.format(peer_switch_hostname) device_meta_key = 'DEVICE_METADATA|localhost' - + restart_swss = False + if dut.get_asic_name() in ['th2', 'td3']: + restart_swss = True cmd = 'redis-cli -n 4 HSET "{}" "{}" "{}"'.format(device_meta_key, 'subtype', 'DualToR') dut.shell(cmd=cmd) - if dut.get_asic_name() in ['th2', 'td3']: + if restart_swss: # Restart swss on TH2 or TD3 platform to trigger syncd restart to regenerate config.bcm # We actually need to restart syncd only, but restarting syncd will also trigger swss # being restarted, and it costs more time than restarting swss @@ -353,7 +355,7 @@ def apply_peer_switch_table_to_dut(cleanup_mocked_configs, rand_selected_dut, mo cmds = ['redis-cli -n 4 HSET "{}" "address_ipv4" "{}"'.format(peer_switch_key, mock_peer_switch_loopback_ip.ip), 'redis-cli -n 4 HSET "{}" "{}" "{}"'.format(device_meta_key, 'peer_switch', peer_switch_hostname)] dut.shell_cmds(cmds=cmds) - if dut.get_asic_name() in ['th2', 'td3']: + if restart_swss: # Restart swss on TH2 or TD3 platform to apply changes logger.info("Restarting swss service") dut.shell('systemctl restart swss')