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

[config reload] Fix invalid rstrip. #2157

Merged
merged 3 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def _get_delayed_sonic_services():
services = []
for unit in timer:
if state[timer.index(unit)] == "enabled":
services.append(unit.rstrip(".timer"))
services.append(unit.replace(".timer", ""))
Copy link
Contributor

Choose a reason for hiding this comment

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

replace

Even better, use re.sub?

return services


Expand Down
6 changes: 3 additions & 3 deletions tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ def mock_run_command_side_effect(*args, **kwargs):

if kwargs.get('return_cmd'):
if command == "systemctl list-dependencies --plain sonic-delayed.target | sed '1d'":
return 'snmp.timer'
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep original test case and add a new one?

return 'gnmi.timer'
elif command == "systemctl list-dependencies --plain sonic.target | sed '1d'":
return 'swss'
elif command == "systemctl is-enabled snmp.timer":
elif command == "systemctl is-enabled gnmi.timer":
return 'enabled'
else:
return ''
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_load_minigraph(self, get_cmd_module, setup_single_broadcom_asic):
# Verify "systemctl reset-failed" is called for services under sonic.target
mock_run_command.assert_any_call('systemctl reset-failed swss')
# Verify "systemctl reset-failed" is called for services under sonic-delayed.target
mock_run_command.assert_any_call('systemctl reset-failed snmp')
mock_run_command.assert_any_call('systemctl reset-failed gnmi')
assert mock_run_command.call_count == 11

def test_load_minigraph_with_port_config_bad_format(self, get_cmd_module, setup_single_broadcom_asic):
Expand Down