]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_comm_list_delete/test_bgp_comm-list_delete.py
4 # bgp_comm-list_delete.py
5 # Part of NetDEF Topology Tests
7 # Copyright (c) 2019 by
8 # Network Device Education Foundation, Inc. ("NetDEF")
10 # Permission to use, copy, modify, and/or distribute this software
11 # for any purpose with or without fee is hereby granted, provided
12 # that the above copyright notice and this permission notice appear
15 # THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
16 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
18 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
19 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
21 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 bgp_comm-list_delete.py:
28 Test if works the following commands:
29 route-map test permit 10
30 set comm-list <arg> delete
39 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
40 sys
.path
.append(os
.path
.join(CWD
, "../"))
42 # pylint: disable=C0413
43 from lib
import topotest
44 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
46 pytestmark
= [pytest
.mark
.bgpd
]
50 for routern
in range(1, 3):
51 tgen
.add_router("r{}".format(routern
))
53 switch
= tgen
.add_switch("s1")
54 switch
.add_link(tgen
.gears
["r1"])
55 switch
.add_link(tgen
.gears
["r2"])
58 def setup_module(mod
):
59 tgen
= Topogen(build_topo
, mod
.__name
__)
62 router_list
= tgen
.routers()
64 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
66 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
69 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
75 def teardown_module(mod
):
80 def test_bgp_maximum_prefix_invalid():
83 if tgen
.routers_have_failure():
84 pytest
.skip(tgen
.errors
)
89 output
= json
.loads(r2
.vtysh_cmd("show ip bgp neighbor 192.168.255.1 json"))
92 "bgpState": "Established",
93 "addressFamilyInfo": {
95 "acceptedPrefixCounter": 2,
100 return topotest
.json_cmp(output
, expected
)
102 test_func
= functools
.partial(_bgp_converge
)
103 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
104 assert result
is None, "Can't converge initially"
106 def _bgp_comm_list_delete():
107 output
= json
.loads(r2
.vtysh_cmd("show ip bgp 172.16.255.254/32 json"))
108 expected
= {"paths": [{"community": {"list": ["333:333"]}}]}
109 return topotest
.json_cmp(output
, expected
)
111 test_func
= functools
.partial(_bgp_comm_list_delete
)
112 _
, result
= topotest
.run_and_expect(test_func
, not None, count
=60, wait
=0.5)
113 assert result
is not None, "333:333 community SHOULD be stripped from r1"
116 if __name__
== "__main__":
117 args
= ["-s"] + sys
.argv
[1:]
118 sys
.exit(pytest
.main(args
))