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 Extended Optional Parameters Length encoding format works
23 if forced with a knob.
24 https://datatracker.ietf.org/doc/html/rfc9072
33 pytestmark
= pytest
.mark
.bgpd
35 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
36 sys
.path
.append(os
.path
.join(CWD
, "../"))
38 # pylint: disable=C0413
39 from lib
import topotest
40 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
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 test_bgp_extended_optional_parameters_length():
71 if tgen
.routers_have_failure():
72 pytest
.skip(tgen
.errors
)
74 router
= tgen
.gears
["r1"]
76 def _bgp_converge(router
):
77 output
= json
.loads(router
.vtysh_cmd("show bgp ipv4 unicast summary json"))
83 "state": "Established",
88 return topotest
.json_cmp(output
, expected
)
90 test_func
= functools
.partial(_bgp_converge
, router
)
91 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
92 assert result
is None, "Can't converge with extended-optional-parameters"
94 def _bgp_extended_optional_parameters_length(router
):
95 output
= json
.loads(router
.vtysh_cmd("show bgp neighbor 192.168.1.2 json"))
96 expected
= {"192.168.1.2": {"extendedOptionalParametersLength": True}}
97 return topotest
.json_cmp(output
, expected
)
99 test_func
= functools
.partial(_bgp_extended_optional_parameters_length
, router
)
100 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
101 assert result
is None, "Can't see Extended Optional Parameters Length to be used"
104 if __name__
== "__main__":
105 args
= ["-s"] + sys
.argv
[1:]
106 sys
.exit(pytest
.main(args
))