]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/zebra_opaque/test_zebra_opaque.py
2 # SPDX-License-Identifier: ISC
4 # Copyright (c) 2021 by
5 # Donatas Abraitis <donatas.abraitis@gmail.com>
9 Test if Opaque Data is accessable from other daemons in Zebra
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
, pytest
.mark
.ospfd
, pytest
.mark
.ospf6d
]
28 def setup_module(mod
):
29 topodef
= {"s1": ("r1", "r2"), "s2": ("r3", "r4")}
30 tgen
= Topogen(topodef
, mod
.__name
__)
33 router_list
= tgen
.routers()
35 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
37 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
40 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
43 TopoRouter
.RD_OSPF
, os
.path
.join(CWD
, "{}/ospfd.conf".format(rname
))
46 TopoRouter
.RD_OSPF6
, os
.path
.join(CWD
, "{}/ospf6d.conf".format(rname
))
52 def teardown_module(mod
):
57 def test_zebra_opaque():
60 if tgen
.routers_have_failure():
61 pytest
.skip(tgen
.errors
)
63 def _bgp_converge(router
):
64 output
= json
.loads(router
.vtysh_cmd("show ip route 192.168.1.0/24 json"))
68 "communities": "65002:1 65002:2",
69 "largeCommunities": "65002:1:1 65002:2:1",
73 return topotest
.json_cmp(output
, expected
)
75 def _ospf_converge(router
):
76 output
= json
.loads(router
.vtysh_cmd("show ip route 192.168.1.0/24 json"))
80 "ospfPathType": "Intra-Area",
81 "ospfAreaId": "0.0.0.0",
85 return topotest
.json_cmp(output
, expected
)
87 def _ospf6_converge(router
):
88 output
= json
.loads(router
.vtysh_cmd("show ipv6 route 2001:db8:1::/64 json"))
92 "ospfPathType": "Intra-Area",
93 "ospfAreaId": "0.0.0.0",
97 return topotest
.json_cmp(output
, expected
)
99 router
= tgen
.gears
["r1"]
100 test_func
= functools
.partial(_bgp_converge
, router
)
101 success
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
102 assert result
is None, 'Cannot see BGP community aliases "{}"'.format(router
)
104 router
= tgen
.gears
["r3"]
105 test_func
= functools
.partial(_ospf_converge
, router
)
106 success
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
107 assert result
is None, 'Cannot see OSPFv2 opaque attributes "{}"'.format(router
)
109 router
= tgen
.gears
["r3"]
110 test_func
= functools
.partial(_ospf6_converge
, router
)
111 success
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
112 assert result
is None, 'Cannot see OSPFv3 opaque attributes "{}"'.format(router
)
115 if __name__
== "__main__":
116 args
= ["-s"] + sys
.argv
[1:]
117 sys
.exit(pytest
.main(args
))