Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart swss after injecting DualToR subtype #5893

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 14 additions & 5 deletions tests/common/dualtor/dual_tor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,21 @@ def apply_peer_switch_table_to_dut(cleanup_mocked_configs, rand_selected_dut, mo
peer_switch_key = 'PEER_SWITCH|{}'.format(peer_switch_hostname)
device_meta_key = 'DEVICE_METADATA|localhost'

cmd = 'redis-cli -n 4 HSET "{}" "{}" "{}"'.format(device_meta_key, 'subtype', 'DualToR')
neethajohn marked this conversation as resolved.
Show resolved Hide resolved
dut.shell(cmd=cmd)
if dut.get_asic_name() in ['th2', 'td3']:
# 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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if swss restart triggers regenerating config.bcm. Is this confirmed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's confirmed. Restarting swss will trigger syncd being restarted, and the start.sh in syncd docker will regenerate the config.bcm.

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 dut.get_asic_name() in ['th2', 'td3']:
# 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 +366,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 dut.get_asic_name() in ['th2', 'td3']:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These code looks like same, could we form a function to reuse?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks

# 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