]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_rr_ibgp/test_bgp_rr_ibgp_topo1.py
4 # test_bgp_rr_ibgp_topo1.py
6 # Copyright (c) 2019 by
7 # Cumulus Networks, Inc.
10 # Permission to use, copy, modify, and/or distribute this software
11 # for any purpose with or without fee is hereby granted, provided
12 # that the above copyright notice and this permission notice appear
15 # THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
16 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
18 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
19 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
21 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 test_bgp_rr_ibgp_topo1.py: Testing IBGP with RR and no IGP
28 Ensure that a basic rr topology comes up and correctly passes
39 # Save the Current Working Directory to find configuration files.
40 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
41 sys
.path
.append(os
.path
.join(CWD
, '../'))
43 # pylint: disable=C0413
44 # Import topogen and topotest helpers
45 from lib
import topotest
46 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
47 from lib
.topolog
import logger
49 # Required to instantiate the topology builder class.
50 from mininet
.topo
import Topo
52 #####################################################
54 ## Network Topology Definition
56 #####################################################
58 class NetworkTopo(Topo
):
59 "BGP_RR_IBGP Topology 1"
61 def build(self
, **_opts
):
64 tgen
= get_topogen(self
)
66 tgen
.add_router('tor1')
67 tgen
.add_router('tor2')
68 tgen
.add_router('spine1')
70 # First switch is for a dummy interface (for local network)
73 switch
= tgen
.add_switch('sw1')
74 switch
.add_link(tgen
.gears
['tor1'])
76 # 192.168.2.0/24 - tor1 <-> spine1 connection
77 switch
= tgen
.add_switch('sw2')
78 switch
.add_link(tgen
.gears
['tor1'])
79 switch
.add_link(tgen
.gears
['spine1'])
81 # 3rd switch is for a dummy interface (for local netwokr)
82 # 192.168.3.0/24 - tor2
83 switch
= tgen
.add_switch('sw3')
84 switch
.add_link(tgen
.gears
['tor2'])
86 # 192.168.4.0/24 - tor2 <-> spine1 connection
87 switch
= tgen
.add_switch('sw4')
88 switch
.add_link(tgen
.gears
['tor2'])
89 switch
.add_link(tgen
.gears
['spine1'])
92 #####################################################
96 #####################################################
98 def setup_module(module
):
100 tgen
= Topogen(NetworkTopo
, module
.__name
__)
101 tgen
.start_topology()
103 # This is a sample of configuration loading.
104 router_list
= tgen
.routers()
105 for rname
, router
in router_list
.iteritems():
108 os
.path
.join(CWD
, '{}/zebra.conf'.format(rname
))
112 os
.path
.join(CWD
, '{}/bgpd.conf'.format(rname
))
119 def teardown_module(_mod
):
120 "Teardown the pytest environment"
123 # This function tears down the whole topology.
127 def test_converge_protocols():
128 "Wait for protocol convergence"
131 # Don't run this test if we have any failure.
132 if tgen
.routers_have_failure():
133 pytest
.skip(tgen
.errors
)
135 topotest
.sleep(5, 'Waiting for BGP_RR_IBGP convergence')
138 def test_bgp_rr_ibgp_routes():
139 "Test Route Reflection"
142 # Don't run this test if we have any failure.
143 if tgen
.routers_have_failure():
144 pytest
.skip(tgen
.errors
)
146 # Verify BGP_RR_IBGP Status
147 logger
.info("Verifying BGP_RR_IBGP routes")
149 def test_zebra_ipv4_routingTable():
150 "Test 'show ip route'"
153 # Don't run this test if we have any failure.
154 if tgen
.routers_have_failure():
155 pytest
.skip(tgen
.errors
)
158 router_list
= tgen
.routers().values()
159 for router
in router_list
:
160 output
= router
.vtysh_cmd('show ip route json', isjson
=True)
161 refTableFile
= '{}/{}/show_ip_route.json_ref'.format(CWD
, router
.name
)
162 expected
= json
.loads(open(refTableFile
).read())
164 assertmsg
= 'Zebra IPv4 Routing Table verification failed for router {}'.format(router
.name
)
165 assert topotest
.json_cmp(output
, expected
) is None, assertmsg
167 def test_shutdown_check_stderr():
168 if os
.environ
.get('TOPOTESTS_CHECK_STDERR') is None:
169 pytest
.skip('Skipping test for Stderr output and memory leaks')
172 # Don't run this test if we have any failure.
173 if tgen
.routers_have_failure():
174 pytest
.skip(tgen
.errors
)
176 logger
.info("Verifying unexpected STDERR output from daemons")
178 router_list
= tgen
.routers().values()
179 for router
in router_list
:
182 log
= tgen
.net
[router
.name
].getStdErr('bgpd')
184 logger
.error('BGPd StdErr Log:' + log
)
185 log
= tgen
.net
[router
.name
].getStdErr('zebra')
187 logger
.error('Zebra StdErr Log:' + log
)
190 if __name__
== '__main__':
191 args
= ["-s"] + sys
.argv
[1:]
192 sys
.exit(pytest
.main(args
))
195 # Auxiliary Functions