]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_comm_list_match/test_bgp_comm_list_match.py
2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2022 by
6 # Donatas Abraitis <donatas@opensourcerouting.org>
10 Check if BGP community-list works as OR if multiple community entries specified,
13 bgp community-list 1 seq 5 permit 65001:1 65002:2
14 bgp community-list 1 seq 10 permit 65001:3
16 route-map test deny 10
18 route-map test permit 20
20 Here, we should deny routes in/out if the path has:
21 (65001:1 AND 65001:2) OR 65001:3.
30 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
31 sys
.path
.append(os
.path
.join(CWD
, "../"))
33 # pylint: disable=C0413
34 from lib
import topotest
35 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
36 from lib
.common_config
import step
38 pytestmark
= [pytest
.mark
.bgpd
]
42 for routern
in range(1, 3):
43 tgen
.add_router("r{}".format(routern
))
45 switch
= tgen
.add_switch("s1")
46 switch
.add_link(tgen
.gears
["r1"])
47 switch
.add_link(tgen
.gears
["r2"])
50 def setup_module(mod
):
51 tgen
= Topogen(build_topo
, mod
.__name
__)
54 router_list
= tgen
.routers()
56 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
58 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
61 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
67 def teardown_module(mod
):
72 def test_bgp_comm_list_match():
75 if tgen
.routers_have_failure():
76 pytest
.skip(tgen
.errors
)
78 router
= tgen
.gears
["r2"]
83 "show bgp ipv4 unicast neighbors 192.168.0.1 filtered-routes json"
96 return topotest
.json_cmp(output
, expected
)
98 step("Initial BGP converge")
99 test_func
= functools
.partial(_bgp_converge
)
100 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
101 assert result
is None, "Failed to filter BGP UPDATES with community-list on R2"
104 if __name__
== "__main__":
105 args
= ["-s"] + sys
.argv
[1:]
106 sys
.exit(pytest
.main(args
))