]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_suppress_fib/test_bgp_suppress_fib.py
4 # test_bgp_suppress_fib.py
6 # Copyright (c) 2019 by
8 # Permission to use, copy, modify, and/or distribute this software
9 # for any purpose with or without fee is hereby granted, provided
10 # that the above copyright notice and this permission notice appear
13 # THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31 from functools
import partial
32 from time
import sleep
34 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
35 sys
.path
.append(os
.path
.join(CWD
, "../"))
37 # pylint: disable=C0413
38 from lib
import topotest
39 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
40 from lib
.topolog
import logger
41 from lib
.micronet_compat
import Topo
43 pytestmark
= [pytest
.mark
.bgpd
]
47 for routern
in range(1, 4):
48 tgen
.add_router("r{}".format(routern
))
50 switch
= tgen
.add_switch("s1")
51 switch
.add_link(tgen
.gears
["r1"])
52 switch
.add_link(tgen
.gears
["r2"])
54 switch
= tgen
.add_switch("s2")
55 switch
.add_link(tgen
.gears
["r2"])
56 switch
.add_link(tgen
.gears
["r3"])
59 def setup_module(mod
):
60 tgen
= Topogen(build_topo
, mod
.__name
__)
63 router_list
= tgen
.routers()
65 for i
, (rname
, router
) in enumerate(router_list
.items(), 1):
67 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
70 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
76 def teardown_module(mod
):
84 if tgen
.routers_have_failure():
85 pytest
.skip(tgen
.errors
)
91 json_file
= "{}/r3/v4_route.json".format(CWD
)
92 expected
= json
.loads(open(json_file
).read())
95 topotest
.router_json_cmp
,
97 "show ip route 40.0.0.0 json",
100 _
, result
= topotest
.run_and_expect(test_func
, None, count
=2, wait
=0.5)
101 assertmsg
= '"r3" JSON output mismatches'
102 assert result
is None, assertmsg
104 json_file
= "{}/r3/v4_route2.json".format(CWD
)
105 expected
= json
.loads(open(json_file
).read())
108 topotest
.router_json_cmp
,
110 "show ip route 50.0.0.0 json",
113 _
, result
= topotest
.run_and_expect(test_func
, None, count
=3, wait
=0.5)
114 assertmsg
= '"r3" JSON output mismatches'
115 assert result
is None, assertmsg
118 if __name__
== "__main__":
119 args
= ["-s"] + sys
.argv
[1:]
120 sys
.exit(pytest
.main(args
))