]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_dont_capability_negotiate/test_bgp_dont_capability_negotiate.py
2 # SPDX-License-Identifier: ISC
4 # Copyright (c) 2021 by
5 # Donatas Abraitis <donatas.abraitis@gmail.com>
9 Test if BGP connection is established if at least one peer
10 sets `dont-capability-negotiate`.
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
27 from lib
.common_config
import step
29 pytestmark
= [pytest
.mark
.bgpd
]
32 def setup_module(mod
):
33 topodef
= {"s1": ("r1", "r2")}
34 tgen
= Topogen(topodef
, mod
.__name
__)
37 router_list
= tgen
.routers()
39 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
41 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
44 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
50 def teardown_module(mod
):
55 def bgp_converge(router
):
56 output
= json
.loads(router
.vtysh_cmd("show bgp ipv4 unicast summary json"))
62 "state": "Established",
67 return topotest
.json_cmp(output
, expected
)
70 def test_bgp_dont_capability_negotiate():
73 if tgen
.routers_have_failure():
74 pytest
.skip(tgen
.errors
)
78 test_func
= functools
.partial(bgp_converge
, r1
)
79 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
80 assert result
is None, "Can't converge with dont-capability-negotiate"
83 def test_bgp_check_fqdn():
86 if tgen
.routers_have_failure():
87 pytest
.skip(tgen
.errors
)
92 def _bgp_check_fqdn(fqdn
=None):
93 output
= json
.loads(r1
.vtysh_cmd("show bgp ipv4 unicast 172.16.16.1/32 json"))
108 return topotest
.json_cmp(output
, expected
)
110 step("Enable all capabilities")
115 address-family ipv4 unicast
116 no neighbor 192.168.1.2 dont-capability-negotiate
118 clear bgp 192.168.1.2
122 step("Wait to converge")
123 test_func
= functools
.partial(bgp_converge
, r1
)
124 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
125 assert result
is None, "Can't converge with dont-capability-negotiate"
127 test_func
= functools
.partial(_bgp_check_fqdn
, "r2")
128 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
129 assert result
is None, "FQDN capability enabled, but r1 can't see it"
131 step("Disable sending any capabilities from r2")
136 address-family ipv4 unicast
137 neighbor 192.168.1.1 dont-capability-negotiate
139 clear bgp 192.168.1.1
143 step("Wait to converge")
144 test_func
= functools
.partial(bgp_converge
, r1
)
145 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
146 assert result
is None, "Can't converge with dont-capability-negotiate"
148 step("Make sure FQDN capability is reset")
149 test_func
= functools
.partial(_bgp_check_fqdn
)
150 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
151 assert result
is None, "FQDN capability disabled, but we still have a hostname"
154 if __name__
== "__main__":
155 args
= ["-s"] + sys
.argv
[1:]
156 sys
.exit(pytest
.main(args
))