48
48
total_ebgp_peers = 20
49
49
50
50
#####################################################
51
- ##
52
- ## Network Topology Definition
53
- ##
51
+ #
52
+ # Network Topology Definition
53
+ #
54
54
#####################################################
55
55
56
+
56
57
class BGPECMPTopo1 (Topo ):
57
58
"BGP ECMP Topology 1"
58
59
@@ -63,13 +64,13 @@ def build(self, **_opts):
63
64
router = tgen .add_router ('r1' )
64
65
65
66
# Setup Switches - 1 switch per 5 peering routers
66
- for swNum in range (1 , (total_ebgp_peers + 4 ) / 5 + 1 ):
67
+ for swNum in range (1 , (total_ebgp_peers + 4 ) / 5 + 1 ):
67
68
switch = tgen .add_switch ('s{}' .format (swNum ))
68
69
switch .add_link (router )
69
70
70
71
# Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
71
72
for peerNum in range (1 , total_ebgp_peers + 1 ):
72
- swNum = ((peerNum - 1 ) / 5 + 1 )
73
+ swNum = ((peerNum - 1 ) / 5 + 1 )
73
74
74
75
peer_ip = '10.0.{}.{}' .format (swNum , peerNum + 100 )
75
76
peer_route = 'via 10.0.{}.1' .format (swNum )
@@ -81,9 +82,9 @@ def build(self, **_opts):
81
82
82
83
83
84
#####################################################
84
- ##
85
- ## Tests starting
86
- ##
85
+ #
86
+ # Tests starting
87
+ #
87
88
#####################################################
88
89
89
90
def setup_module (module ):
@@ -112,10 +113,12 @@ def setup_module(module):
112
113
peer .start (peer_dir , env_file )
113
114
logger .info (pname )
114
115
116
+
115
117
def teardown_module (module ):
116
118
tgen = get_topogen ()
117
119
tgen .stop_topology ()
118
120
121
+
119
122
def test_bgp_convergence ():
120
123
"Test for BGP topology convergence"
121
124
tgen = get_topogen ()
@@ -135,8 +138,8 @@ def test_bgp_convergence():
135
138
136
139
def _output_summary_cmp (router , cmd , data ):
137
140
"""
138
- Runs `cmd` that returns JSON data (normally the command ends with 'json')
139
- and compare with `data` contents.
141
+ Runs `cmd` that returns JSON data (normally the command ends
142
+ with 'json') and compare with `data` contents.
140
143
"""
141
144
output = router .vtysh_cmd (cmd , isjson = True )
142
145
if 'ipv4Unicast' in output :
@@ -153,6 +156,7 @@ def _output_summary_cmp(router, cmd, data):
153
156
assertmsg = 'BGP router network did not converge'
154
157
assert res is None , assertmsg
155
158
159
+
156
160
def test_bgp_ecmp ():
157
161
tgen = get_topogen ()
158
162
@@ -175,11 +179,12 @@ def test_bgp_ecmp():
175
179
expect ['routes' ][netkey ].append (peer )
176
180
177
181
test_func = functools .partial (topotest .router_json_cmp ,
178
- tgen .gears ['r1' ], 'show ip bgp json' , expect )
182
+ tgen .gears ['r1' ], 'show ip bgp json' , expect )
179
183
_ , res = topotest .run_and_expect (test_func , None , count = 10 , wait = 0.5 )
180
184
assertmsg = 'expected multipath routes in "show ip bgp" output'
181
185
assert res is None , assertmsg
182
186
187
+
183
188
if __name__ == '__main__' :
184
189
args = ["-s" ] + sys .argv [1 :]
185
190
sys .exit (pytest .main (args ))
0 commit comments