]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py
4 # test_bgp-vrf-route-leak-basic.py
6 # Copyright (c) 2018 Cumulus Networks, Inc.
9 # Permission to use, copy, modify, and/or distribute this software
10 # for any purpose with or without fee is hereby granted, provided
11 # that the above copyright notice and this permission notice appear
14 # THE SOFTWARE IS PROVIDED "AS IS" AND Cumulus Networks DISCLAIMS ALL WARRANTIES
15 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
17 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
18 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
20 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
25 test_bgp-vrf-route-leak-basic.py.py: Test basic vrf route leaking
30 from functools
import partial
33 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
34 sys
.path
.append(os
.path
.join(CWD
, "../"))
36 # pylint: disable=C0413
37 from lib
import topotest
38 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
39 from lib
.topolog
import logger
42 pytestmark
= [pytest
.mark
.bgpd
]
48 for routern
in range(1, 2):
49 tgen
.add_router("r{}".format(routern
))
52 def setup_module(mod
):
53 "Sets up the pytest environment"
54 tgen
= Topogen(build_topo
, mod
.__name
__)
57 # For all registered routers, load the zebra configuration file
58 for rname
, router
in tgen
.routers().items():
59 router
.run("/bin/bash {}/setup_vrfs".format(CWD
))
61 TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "{}/zebra.conf".format(rname
))
64 TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "{}/bgpd.conf".format(rname
))
67 # After loading the configurations, this function loads configured daemons.
72 def teardown_module(mod
):
73 "Teardown the pytest environment"
76 # This function tears down the whole topology.
80 def test_vrf_route_leak():
81 logger
.info("Ensure that routes are leaked back and forth")
83 # Don't run this test if we have any failure.
84 if tgen
.routers_have_failure():
85 pytest
.skip(tgen
.errors
)
93 "protocol": "connected",
97 {"protocol": "bgp", "selected": True, "nexthops": [{"fib": True}]}
99 "10.0.2.0/24": [{"protocol": "connected"}],
101 {"protocol": "bgp", "selected": True, "nexthops": [{"fib": True}]}
106 topotest
.router_json_cmp
, r1
, "show ip route vrf DONNA json", expect
108 result
, diff
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
109 assert result
, "BGP VRF DONNA check failed:\n{}".format(diff
)
114 {"protocol": "bgp", "selected": True, "nexthops": [{"fib": True}]}
118 "protocol": "connected",
122 {"protocol": "bgp", "selected": True, "nexthops": [{"fib": True}]}
126 "protocol": "connected",
132 topotest
.router_json_cmp
, r1
, "show ip route vrf EVA json", expect
134 result
, diff
= topotest
.run_and_expect(test_func
, None, count
=10, wait
=0.5)
135 assert result
, "BGP VRF EVA check failed:\n{}".format(diff
)
138 def test_memory_leak():
139 "Run the memory leak test and report results."
141 if not tgen
.is_memleak_enabled():
142 pytest
.skip("Memory leak test/report is disabled")
144 tgen
.report_memory_leaks()
147 if __name__
== "__main__":
148 args
= ["-s"] + sys
.argv
[1:]
149 sys
.exit(pytest
.main(args
))