]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/zebra_opaque/test_zebra_opaque.py
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 Opaque Data is accessable from other daemons in Zebra
31 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
32 sys
.path
.append(os
.path
.join(CWD
, "../"))
34 # pylint: disable=C0413
35 from lib
import topotest
36 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
38 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.ospfd
, pytest
.mark
.ospf6d
]
41 def setup_module(mod
):
42 topodef
= {"s1": ("r1", "r2"), "s2": ("r3", "r4")}
43 tgen
= Topogen(topodef
, mod
.__name
__)
46 router_list
= tgen
.routers()
48 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
50 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
53 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
56 TopoRouter
.RD_OSPF
, os
.path
.join(CWD
, "{}/ospfd.conf".format(rname
))
59 TopoRouter
.RD_OSPF6
, os
.path
.join(CWD
, "{}/ospf6d.conf".format(rname
))
65 def teardown_module(mod
):
70 def test_zebra_opaque():
73 if tgen
.routers_have_failure():
74 pytest
.skip(tgen
.errors
)
76 def _bgp_converge(router
):
77 output
= json
.loads(router
.vtysh_cmd("show ip route 192.168.1.0/24 json"))
81 "communities": "65002:1 65002:2",
82 "largeCommunities": "65002:1:1 65002:2:1",
86 return topotest
.json_cmp(output
, expected
)
88 def _ospf_converge(router
):
89 output
= json
.loads(router
.vtysh_cmd("show ip route 192.168.1.0/24 json"))
93 "ospfPathType": "Intra-Area",
94 "ospfAreaId": "0.0.0.0",
98 return topotest
.json_cmp(output
, expected
)
100 def _ospf6_converge(router
):
101 output
= json
.loads(router
.vtysh_cmd("show ipv6 route 2001:db8:1::/64 json"))
105 "ospfPathType": "Intra-Area",
106 "ospfAreaId": "0.0.0.0",
110 return topotest
.json_cmp(output
, expected
)
112 router
= tgen
.gears
["r1"]
113 test_func
= functools
.partial(_bgp_converge
, router
)
114 success
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
115 assert result
is None, 'Cannot see BGP community aliases "{}"'.format(router
)
117 router
= tgen
.gears
["r3"]
118 test_func
= functools
.partial(_ospf_converge
, router
)
119 success
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
120 assert result
is None, 'Cannot see OSPFv2 opaque attributes "{}"'.format(router
)
122 router
= tgen
.gears
["r3"]
123 test_func
= functools
.partial(_ospf6_converge
, router
)
124 success
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
125 assert result
is None, 'Cannot see OSPFv3 opaque attributes "{}"'.format(router
)
128 if __name__
== "__main__":
129 args
= ["-s"] + sys
.argv
[1:]
130 sys
.exit(pytest
.main(args
))