2 # SPDX-License-Identifier: ISC
4 # Copyright (c) 2021 by
5 # Takemasa Imada <takemasa.imada@gmail.com>
9 Test if minimum-holdtime works.
18 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
19 sys
.path
.append(os
.path
.join(CWD
, "../"))
21 # pylint: disable=C0413
22 from lib
import topotest
23 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
25 pytestmark
= [pytest
.mark
.bgpd
]
29 for routern
in range(1, 3):
30 tgen
.add_router("r{}".format(routern
))
32 switch
= tgen
.add_switch("s1")
33 switch
.add_link(tgen
.gears
["r1"])
34 switch
.add_link(tgen
.gears
["r2"])
37 def setup_module(mod
):
38 tgen
= Topogen(build_topo
, mod
.__name
__)
41 router_list
= tgen
.routers()
43 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
45 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
48 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
54 def teardown_module(mod
):
59 def test_bgp_minimum_holdtime():
62 if tgen
.routers_have_failure():
63 pytest
.skip(tgen
.errors
)
65 def _bgp_neighbor_check_if_notification_sent():
67 tgen
.gears
["r1"].vtysh_cmd("show ip bgp neighbor 192.168.255.2 json")
71 "connectionsEstablished": 0,
72 "lastNotificationReason": "OPEN Message Error/Unacceptable Hold Time",
73 "lastResetDueTo": "BGP Notification send",
76 return topotest
.json_cmp(output
, expected
)
78 test_func
= functools
.partial(_bgp_neighbor_check_if_notification_sent
)
79 success
, result
= topotest
.run_and_expect(test_func
, None, count
=40, wait
=0.5)
80 assert result
is None, "Failed to send notification message\n"
83 if __name__
== "__main__":
84 args
= ["-s"] + sys
.argv
[1:]
85 sys
.exit(pytest
.main(args
))