]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/zebra_opaque/test_zebra_opaque.py
Merge pull request #9410 from idryzhov/static-show-run-nb
[mirror_frr.git] / tests / topotests / zebra_opaque / test_zebra_opaque.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2021 by
4 # Donatas Abraitis <donatas.abraitis@gmail.com>
5 #
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
9 # in all copies.
10 #
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
18 # OF THIS SOFTWARE.
19 #
20
21 """
22 Test if Opaque Data is accessable from other daemons in Zebra
23 """
24
25 import os
26 import sys
27 import json
28 import pytest
29 import functools
30
31 CWD = os.path.dirname(os.path.realpath(__file__))
32 sys.path.append(os.path.join(CWD, "../"))
33
34 # pylint: disable=C0413
35 from lib import topotest
36 from lib.topogen import Topogen, TopoRouter, get_topogen
37
38 pytestmark = [pytest.mark.bgpd]
39
40
41 def setup_module(mod):
42 topodef = {"s1": ("r1", "r2")}
43 tgen = Topogen(topodef, mod.__name__)
44 tgen.start_topology()
45
46 router_list = tgen.routers()
47
48 for i, (rname, router) in enumerate(router_list.items(), 1):
49 router.load_config(
50 TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
51 )
52 router.load_config(
53 TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
54 )
55
56 tgen.start_router()
57
58
59 def teardown_module(mod):
60 tgen = get_topogen()
61 tgen.stop_topology()
62
63
64 def test_zebra_opaque():
65 tgen = get_topogen()
66
67 if tgen.routers_have_failure():
68 pytest.skip(tgen.errors)
69
70 router = tgen.gears["r1"]
71
72 def _bgp_converge(router):
73 output = json.loads(router.vtysh_cmd("show ip route 192.168.1.0/24 json"))
74 expected = {
75 "192.168.1.0/24": [
76 {
77 "communities": "65002:1 65002:2",
78 "largeCommunities": "65002:1:1 65002:2:1",
79 }
80 ]
81 }
82 return topotest.json_cmp(output, expected)
83
84 test_func = functools.partial(_bgp_converge, router)
85 success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
86
87 assert result is None, 'Cannot see BGP community aliases "{}"'.format(router)
88
89
90 if __name__ == "__main__":
91 args = ["-s"] + sys.argv[1:]
92 sys.exit(pytest.main(args))