]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_as_wide_bgp_identifier/test_bgp_as_wide_bgp_identifier.py
2 # SPDX-License-Identifier: ISC
5 # test_bgp_as_wide_bgp_identifier.py
6 # Part of NetDEF Topology Tests
8 # Copyright (c) 2020 by
9 # Donatas Abraitis <donatas.abraitis@gmail.com>
13 rfc6286: Autonomous-System-Wide Unique BGP Identifier for BGP-4
14 Test if 'Bad BGP Identifier' notification is sent only to
15 internal peers (autonomous-system-wide). eBGP peers are not
16 affected and should work.
25 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
26 sys
.path
.append(os
.path
.join(CWD
, "../"))
28 # pylint: disable=C0413
29 from lib
import topotest
30 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
32 pytestmark
= [pytest
.mark
.bgpd
]
36 for routern
in range(1, 4):
37 tgen
.add_router("r{}".format(routern
))
39 switch
= tgen
.add_switch("s1")
40 switch
.add_link(tgen
.gears
["r1"])
41 switch
.add_link(tgen
.gears
["r2"])
42 switch
.add_link(tgen
.gears
["r3"])
45 def setup_module(mod
):
46 tgen
= Topogen(build_topo
, mod
.__name
__)
49 router_list
= tgen
.routers()
51 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
53 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
56 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
62 def teardown_module(mod
):
67 def test_bgp_as_wide_bgp_identifier():
70 if tgen
.routers_have_failure():
71 pytest
.skip(tgen
.errors
)
73 def _bgp_converge(router
):
74 output
= json
.loads(router
.vtysh_cmd("show ip bgp neighbor 192.168.255.1 json"))
75 expected
= {"192.168.255.1": {"bgpState": "Established"}}
76 return topotest
.json_cmp(output
, expected
)
78 def _bgp_failed(router
):
79 output
= json
.loads(router
.vtysh_cmd("show ip bgp neighbor 192.168.255.1 json"))
82 "lastNotificationReason": "OPEN Message Error/Bad BGP Identifier"
85 return topotest
.json_cmp(output
, expected
)
87 test_func
= functools
.partial(_bgp_converge
, tgen
.gears
["r1"])
88 success
, result
= topotest
.run_and_expect(test_func
, None, count
=260, wait
=0.5)
90 assert result
is None, 'Failed to converge: "{}"'.format(tgen
.gears
["r1"])
92 test_func
= functools
.partial(_bgp_failed
, tgen
.gears
["r3"])
93 success
, result
= topotest
.run_and_expect(test_func
, None, count
=260, wait
=0.5)
95 assert result
is None, 'Bad BGP Identifier notification not sent: "{}"'.format(
100 if __name__
== "__main__":
101 args
= ["-s"] + sys
.argv
[1:]
102 sys
.exit(pytest
.main(args
))