]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_route_map_match_ipv6_nexthop/test_bgp_route_map_match_ipv6_nexthop.py
2 # SPDX-License-Identifier: ISC
4 # Copyright (c) 2021 by
5 # Donatas Abraitis <donatas.abraitis@gmail.com>
9 Test if we can match BGP prefixes by next-hop which is
10 specified by an IPv6 Access-list, prefix-list or just an address.
19 pytestmark
= pytest
.mark
.bgpd
21 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
22 sys
.path
.append(os
.path
.join(CWD
, "../"))
24 # pylint: disable=C0413
25 from lib
import topotest
26 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
28 pytestmark
= [pytest
.mark
.bgpd
]
32 for routern
in range(1, 3):
33 tgen
.add_router("r{}".format(routern
))
35 switch
= tgen
.add_switch("s1")
36 switch
.add_link(tgen
.gears
["r1"])
37 switch
.add_link(tgen
.gears
["r2"])
40 def setup_module(mod
):
41 tgen
= Topogen(build_topo
, mod
.__name
__)
44 router_list
= tgen
.routers()
46 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
48 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
51 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
57 def teardown_module(mod
):
62 def test_bgp_route_map_match_ipv6_next_hop_access_list():
65 if tgen
.routers_have_failure():
66 pytest
.skip(tgen
.errors
)
68 router
= tgen
.gears
["r1"]
70 def _bgp_converge(router
):
71 output
= json
.loads(router
.vtysh_cmd("show ipv6 route json"))
73 "2001:db8:1::1/128": [
75 "communities": "65002:1",
78 "2001:db8:2::1/128": [
80 "communities": "65002:2",
83 "2001:db8:3::1/128": [
85 "communities": "65002:3",
88 "2001:db8:4::1/128": [
90 "communities": "65002:4",
93 "2001:db8:5::1/128": [
95 "communities": "65002:5",
99 return topotest
.json_cmp(output
, expected
)
101 test_func
= functools
.partial(_bgp_converge
, router
)
102 success
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
103 assert result
is None, "Can't match routes using ipv6 next-hop access-list"
106 if __name__
== "__main__":
107 args
= ["-s"] + sys
.argv
[1:]
108 sys
.exit(pytest
.main(args
))