]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_dont_capability_negotiate/test_bgp_dont_capability_negotiate.py
3 # Copyright (c) 2021 by
4 # Donatas Abraitis <donatas.abraitis@gmail.com>
6 # Permission to use, copy, modify, and/or distribute this software
7 # for any purpose with or without fee is hereby granted, provided
8 # that the above copyright notice and this permission notice appear
11 # THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
15 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
16 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
17 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 Test if BGP connection is established if at least one peer
23 sets `dont-capability-negotiate`.
32 pytestmark
= pytest
.mark
.bgpd
34 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
35 sys
.path
.append(os
.path
.join(CWD
, "../"))
37 # pylint: disable=C0413
38 from lib
import topotest
39 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
40 from lib
.common_config
import step
42 pytestmark
= [pytest
.mark
.bgpd
]
45 def setup_module(mod
):
46 topodef
= {"s1": ("r1", "r2")}
47 tgen
= Topogen(topodef
, mod
.__name
__)
50 router_list
= tgen
.routers()
52 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
54 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
57 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
63 def teardown_module(mod
):
68 def bgp_converge(router
):
69 output
= json
.loads(router
.vtysh_cmd("show bgp ipv4 unicast summary json"))
75 "state": "Established",
80 return topotest
.json_cmp(output
, expected
)
83 def test_bgp_dont_capability_negotiate():
86 if tgen
.routers_have_failure():
87 pytest
.skip(tgen
.errors
)
91 test_func
= functools
.partial(bgp_converge
, r1
)
92 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
93 assert result
is None, "Can't converge with dont-capability-negotiate"
96 def test_bgp_check_fqdn():
99 if tgen
.routers_have_failure():
100 pytest
.skip(tgen
.errors
)
102 r1
= tgen
.gears
["r1"]
103 r2
= tgen
.gears
["r2"]
105 def _bgp_check_fqdn(fqdn
=None):
106 output
= json
.loads(r1
.vtysh_cmd("show bgp ipv4 unicast 172.16.16.1/32 json"))
121 return topotest
.json_cmp(output
, expected
)
123 step("Enable all capabilities")
128 address-family ipv4 unicast
129 no neighbor 192.168.1.2 dont-capability-negotiate
131 clear bgp 192.168.1.2
135 step("Wait to converge")
136 test_func
= functools
.partial(bgp_converge
, r1
)
137 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
138 assert result
is None, "Can't converge with dont-capability-negotiate"
140 test_func
= functools
.partial(_bgp_check_fqdn
, "r2")
141 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
142 assert result
is None, "FQDN capability enabled, but r1 can't see it"
144 step("Disable sending any capabilities from r2")
149 address-family ipv4 unicast
150 neighbor 192.168.1.1 dont-capability-negotiate
152 clear bgp 192.168.1.1
156 step("Wait to converge")
157 test_func
= functools
.partial(bgp_converge
, r1
)
158 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
159 assert result
is None, "Can't converge with dont-capability-negotiate"
161 step("Make sure FQDN capability is reset")
162 test_func
= functools
.partial(_bgp_check_fqdn
)
163 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
164 assert result
is None, "FQDN capability disabled, but we still have a hostname"
167 if __name__
== "__main__":
168 args
= ["-s"] + sys
.argv
[1:]
169 sys
.exit(pytest
.main(args
))