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

[staticroutebfd] fix an error in error logging #17043

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sonic-bgpcfgd/staticroutebfd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def static_route_set_handler(self, key, data):

valid, is_ipv4, ip = check_ip(ip_prefix)
if not valid:
log_err("invalid ip prefix for static route: ", key)
log_err("invalid ip prefix for static route: '%s'"%(key))
return True

#use lower case if there is letter in IPv6 address string
Expand Down
17 changes: 17 additions & 0 deletions src/sonic-bgpcfgd/tests/test_static_rt_bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,23 @@ def test_set_del_ipv6():
{'del_default:2603:10e2:400::4/128': { }}
)

@patch('staticroutebfd.main.log_err')
def test_invalid_key(mocked_log_err):
dut = constructor()
intf_setup(dut)

set_del_test(dut, "srt",
"SET",
("2.2.2/24", {
"bfd": "true",
"nexthop": "192.168.1.2 , 192.168.2.2, 192.168.3.2",
"ifname": "if1, if2, if3",
}),
{},
{}
)
mocked_log_err.assert_called_with("invalid ip prefix for static route: '2.2.2/24'")

def test_set_del():
dut = constructor()
intf_setup(dut)
Expand Down