Skip to content

Commit

Permalink
Restart swss after injecting DualToR subtype (#5893)
Browse files Browse the repository at this point in the history
* Restart swss after injecting DualToR subtype
  • Loading branch information
bingwang-ms authored Jul 1, 2022
1 parent fba3731 commit a7430f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion tests/common/devices/sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,8 @@ def get_asic_name(self):
elif ("Broadcom Limited Device b850" in output or
"Broadcom Limited Broadcom BCM56850" in output):
asic = "td2"
elif "Broadcom Limited Device b870" in output:
elif ("Broadcom Limited Device b870" in output or
"Broadcom Inc. and subsidiaries Device b870" in output):
asic = "td3"
elif "Broadcom Limited Device b980" in output:
asic = "th3"
Expand Down
21 changes: 16 additions & 5 deletions tests/common/dualtor/dual_tor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,24 @@ 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 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
logger.info("Restarting swss service to regenerate config.bcm")
dut.shell('systemctl restart swss')
time.sleep(120)

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, 'subtype', 'DualToR'),
'redis-cli -n 4 HSET "{}" "{}" "{}"'.format(device_meta_key, 'peer_switch', peer_switch_hostname)]
dut.shell_cmds(cmds=cmds)
if dut.get_asic_name() == 'th2':
# Restart swss on TH2 platform
if restart_swss:
# Restart swss on TH2 or TD3 platform to apply changes
logger.info("Restarting swss service")
dut.shell('systemctl restart swss')
time.sleep(120)
Expand All @@ -357,8 +368,8 @@ def apply_peer_switch_table_to_dut(cleanup_mocked_configs, rand_selected_dut, mo
'redis-cli -n 4 HDEL"{}" "{}" "{}"'.format(device_meta_key, 'subtype', 'DualToR'),
'redis-cli -n 4 HDEL "{}" "{}" "{}"'.format(device_meta_key, 'peer_switch', peer_switch_hostname)]
dut.shell_cmds(cmds=cmds)
if dut.get_asic_name() == 'th2':
# Restart swss on TH2 platform
if restart_swss:
# Restart swss on TH2 or TD3 platform to remove changes
logger.info("Restarting swss service")
dut.shell('systemctl restart swss')
time.sleep(120)
Expand Down

0 comments on commit a7430f6

Please sign in to comment.