[staticroutebfd]double commit for PR 15765 (#17973)
* [staticroutebfd]double commit pr 15765 * fix ut, change to single hop in ut
This commit is contained in:
parent
6514cfa262
commit
cfebad6a11
@ -66,6 +66,9 @@ def static_route_split_key(key):
|
||||
:param key: key to split
|
||||
:return: valid, vrf name extracted from the key, ip prefix extracted from the key
|
||||
"""
|
||||
if key is None or len(key) == 0:
|
||||
return False, "", ""
|
||||
|
||||
l = tuple(key.split('|'))
|
||||
|
||||
if len(l) == 1:
|
||||
@ -376,6 +379,11 @@ class StaticRouteBfd(object):
|
||||
log_err("invalid ip prefix for static route: '%s'"%(key))
|
||||
return True
|
||||
|
||||
#use lower case if there is letter in IPv6 address string
|
||||
if 'nexthop' in data:
|
||||
nh = data['nexthop']
|
||||
data['nexthop'] = nh.lower()
|
||||
|
||||
arg_list = lambda v: [x.strip() for x in v.split(',')] if len(v.strip()) != 0 else None
|
||||
bfd_field = arg_list(data['bfd']) if 'bfd' in data else ["false"]
|
||||
|
||||
|
@ -95,6 +95,83 @@ def intf_setup(dut):
|
||||
{}
|
||||
)
|
||||
|
||||
set_del_test(dut, "intf",
|
||||
"SET",
|
||||
("if1|2603:10E2:400:1::1/64",{}
|
||||
),
|
||||
{},
|
||||
{}
|
||||
)
|
||||
set_del_test(dut, "intf",
|
||||
"SET",
|
||||
("if2|2603:10E2:400:2::1/64",{}
|
||||
),
|
||||
{},
|
||||
{}
|
||||
)
|
||||
set_del_test(dut, "intf",
|
||||
"SET",
|
||||
("if3|2603:10E2:400:3::1/64",{}
|
||||
),
|
||||
{},
|
||||
{}
|
||||
)
|
||||
|
||||
def test_set_del_ipv6():
|
||||
dut = constructor()
|
||||
intf_setup(dut)
|
||||
|
||||
set_del_test(dut, "srt",
|
||||
"SET",
|
||||
("2603:10e2:400::4/128", {
|
||||
"bfd": "true",
|
||||
"ifname": "if1, if2, if3",
|
||||
"nexthop": "2603:10E2:400:1::2,2603:10E2:400:2::2,2603:10e2:400:3::2"
|
||||
}),
|
||||
{
|
||||
"set_default:default:2603:10e2:400:1::2" : {'multihop': 'false', 'rx_interval': '50', 'tx_interval': '50', 'multiplier': '3', 'local_addr': '2603:10E2:400:1::1'},
|
||||
"set_default:default:2603:10e2:400:2::2" : {'multihop': 'false', 'rx_interval': '50', 'tx_interval': '50', 'multiplier': '3', 'local_addr': '2603:10E2:400:2::1'},
|
||||
"set_default:default:2603:10e2:400:3::2" : {'multihop': 'false', 'rx_interval': '50', 'tx_interval': '50', 'multiplier': '3', 'local_addr': '2603:10E2:400:3::1'}
|
||||
},
|
||||
{}
|
||||
)
|
||||
|
||||
set_del_test(dut, "bfd",
|
||||
"SET",
|
||||
("2603:10e2:400:1::2", {
|
||||
"state": "Up"
|
||||
}),
|
||||
{},
|
||||
{'set_default:2603:10e2:400::4/128': {'nexthop': '2603:10e2:400:1::2', 'ifname': 'if1', 'nexthop-vrf': 'default', 'expiry': 'false'}}
|
||||
)
|
||||
set_del_test(dut, "bfd",
|
||||
"SET",
|
||||
("2603:10e2:400:2::2", {
|
||||
"state": "Up"
|
||||
}),
|
||||
{},
|
||||
{'set_default:2603:10e2:400::4/128': {'nexthop': '2603:10e2:400:1::2,2603:10e2:400:2::2', 'ifname': 'if1,if2', 'nexthop-vrf': 'default,default', 'expiry': 'false'}}
|
||||
)
|
||||
set_del_test(dut, "bfd",
|
||||
"SET",
|
||||
("2603:10e2:400:3::2", {
|
||||
"state": "Up"
|
||||
}),
|
||||
{},
|
||||
{'set_default:2603:10e2:400::4/128': {'nexthop': '2603:10e2:400:1::2,2603:10e2:400:2::2,2603:10e2:400:3::2', 'ifname': 'if1,if2,if3', 'nexthop-vrf': 'default,default,default', 'expiry': 'false'}}
|
||||
)
|
||||
|
||||
set_del_test(dut, "srt",
|
||||
"DEL",
|
||||
("2603:10e2:400::4/128", { }),
|
||||
{
|
||||
"del_default:default:2603:10e2:400:1::2" : {},
|
||||
"del_default:default:2603:10e2:400:2::2" : {},
|
||||
"del_default:default:2603:10e2:400:3::2" : {}
|
||||
},
|
||||
{'del_default:2603:10e2:400::4/128': { }}
|
||||
)
|
||||
|
||||
@patch('staticroutebfd.main.log_err')
|
||||
def test_invalid_key(mocked_log_err):
|
||||
dut = constructor()
|
||||
|
Loading…
Reference in New Issue
Block a user