Skip to content

Commit

Permalink
Define restart_swss to reuse code
Browse files Browse the repository at this point in the history
  • Loading branch information
bingwang-ms committed Jun 30, 2022
1 parent fd02a81 commit d7dddca
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/common/dualtor/dual_tor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down

0 comments on commit d7dddca

Please sign in to comment.