1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
|
#!/usr/bin/env python
#
# test_bgp_linkbw_ip.py
#
# Copyright (c) 2020 by
# Cumulus Networks, Inc
# Vivek Venkatraman
#
# Permission to use, copy, modify, and/or distribute this software
# for any purpose with or without fee is hereby granted, provided
# that the above copyright notice and this permission notice appear
# in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THIS SOFTWARE.
#
"""
test_bgp_linkbw_ip.py: Test weighted ECMP using BGP link-bandwidth
"""
import os
import sys
from functools import partial
import pytest
import json
# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, "../"))
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
# Required to instantiate the topology builder class.
pytestmark = [pytest.mark.bgpd]
"""
This topology is for validating one of the primary use cases for
weighted ECMP (a.k.a. Unequal cost multipath) using BGP link-bandwidth:
https://tools.ietf.org/html/draft-mohanty-bess-ebgp-dmz
The topology consists of two PODs. Pod-1 consists of a spine switch
and two leaf switches, with two servers attached to the first leaf and
one to the second leaf. Pod-2 consists of one spine and one leaf, with
one server connected to the leaf. The PODs are connected by a super-spine
switch.
Note that the use of the term "switch" above is in keeping with common
data-center terminology. These devices are all regular routers; for
this scenario, the servers are also routers as they have to announce
anycast IP (VIP) addresses via BGP.
"""
def build_topo(tgen):
"Build function"
# Create 10 routers - 1 super-spine, 2 spines, 3 leafs
# and 4 servers
routers = {}
for i in range(1, 11):
routers[i] = tgen.add_router("r{}".format(i))
# Create 13 "switches" - to interconnect the above routers
switches = {}
for i in range(1, 14):
switches[i] = tgen.add_switch("s{}".format(i))
# Interconnect R1 (super-spine) to R2 and R3 (the two spines)
switches[1].add_link(tgen.gears["r1"])
switches[1].add_link(tgen.gears["r2"])
switches[2].add_link(tgen.gears["r1"])
switches[2].add_link(tgen.gears["r3"])
# Interconnect R2 (spine in pod-1) to R4 and R5 (the associated
# leaf switches)
switches[3].add_link(tgen.gears["r2"])
switches[3].add_link(tgen.gears["r4"])
switches[4].add_link(tgen.gears["r2"])
switches[4].add_link(tgen.gears["r5"])
# Interconnect R3 (spine in pod-2) to R6 (associated leaf)
switches[5].add_link(tgen.gears["r3"])
switches[5].add_link(tgen.gears["r6"])
# Interconnect leaf switches to servers
switches[6].add_link(tgen.gears["r4"])
switches[6].add_link(tgen.gears["r7"])
switches[7].add_link(tgen.gears["r4"])
switches[7].add_link(tgen.gears["r8"])
switches[8].add_link(tgen.gears["r5"])
switches[8].add_link(tgen.gears["r9"])
switches[9].add_link(tgen.gears["r6"])
switches[9].add_link(tgen.gears["r10"])
# Create empty networks for the servers
switches[10].add_link(tgen.gears["r7"])
switches[11].add_link(tgen.gears["r8"])
switches[12].add_link(tgen.gears["r9"])
switches[13].add_link(tgen.gears["r10"])
def setup_module(mod):
"Sets up the pytest environment"
tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
router_list = tgen.routers()
for rname, router in router_list.items():
router.load_config(
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
)
router.load_config(
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
)
# Initialize all routers.
tgen.start_router()
# tgen.mininet_cli()
def teardown_module(mod):
"Teardown the pytest environment"
tgen = get_topogen()
tgen.stop_topology()
def test_bgp_linkbw_adv():
"Test #1: Test BGP link-bandwidth advertisement based on number of multipaths"
logger.info(
"\nTest #1: Test BGP link-bandwidth advertisement based on number of multipaths"
)
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip("skipped because of router(s) failure")
r1 = tgen.gears["r1"]
r2 = tgen.gears["r2"]
# Configure anycast IP on server r7
logger.info("Configure anycast IP on server r7")
tgen.net["r7"].cmd("ip addr add 198.10.1.1/32 dev r7-eth1")
# Check on spine router r2 for link-bw advertisement by leaf router r4
logger.info("Check on spine router r2 for link-bw advertisement by leaf router r4")
json_file = "{}/r2/bgp-route-1.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r2, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on spine router r2"
assert result is None, assertmsg
# Check on spine router r2 that default weight is used as there is no multipath
logger.info(
"Check on spine router r2 that default weight is used as there is no multipath"
)
json_file = "{}/r2/ip-route-1.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r2, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=50, wait=0.5)
assertmsg = "JSON output mismatch on spine router r2"
assert result is None, assertmsg
# Check on super-spine router r1 that link-bw has been propagated by spine router r2
logger.info(
"Check on super-spine router r1 that link-bw has been propagated by spine router r2"
)
json_file = "{}/r1/bgp-route-1.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
def test_bgp_cumul_linkbw():
"Test #2: Test cumulative link-bandwidth propagation"
logger.info("\nTest #2: Test cumulative link-bandwidth propagation")
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip("skipped because of router(s) failure")
r1 = tgen.gears["r1"]
r2 = tgen.gears["r2"]
r4 = tgen.gears["r4"]
# Configure anycast IP on additional server r8
logger.info("Configure anycast IP on server r8")
tgen.net["r8"].cmd("ip addr add 198.10.1.1/32 dev r8-eth1")
# Check multipath on leaf router r4
logger.info("Check multipath on leaf router r4")
json_file = "{}/r4/bgp-route-1.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r4, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on leaf router r4"
assert result is None, assertmsg
# Check regular ECMP is in effect on leaf router r4
logger.info("Check regular ECMP is in effect on leaf router r4")
json_file = "{}/r4/ip-route-1.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r4, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=50, wait=0.5)
assertmsg = "JSON output mismatch on leaf router r4"
assert result is None, assertmsg
# Check on spine router r2 that leaf has propagated the cumulative link-bw based on num-multipaths
logger.info(
"Check on spine router r2 that leaf has propagated the cumulative link-bw based on num-multipaths"
)
json_file = "{}/r2/bgp-route-2.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r2, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on spine router r2"
assert result is None, assertmsg
def test_weighted_ecmp():
"Test #3: Test weighted ECMP - multipath with next hop weights"
logger.info("\nTest #3: Test weighted ECMP - multipath with next hop weights")
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip("skipped because of router(s) failure")
r1 = tgen.gears["r1"]
r2 = tgen.gears["r2"]
r3 = tgen.gears["r3"]
# Configure anycast IP on additional server r9
logger.info("Configure anycast IP on server r9")
tgen.net["r9"].cmd("ip addr add 198.10.1.1/32 dev r9-eth1")
# Check multipath on spine router r2
logger.info("Check multipath on spine router r2")
json_file = "{}/r2/bgp-route-3.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r2, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on spine router r2"
assert result is None, assertmsg
# Check weighted ECMP is in effect on the spine router r2
logger.info("Check weighted ECMP is in effect on the spine router r2")
json_file = "{}/r2/ip-route-2.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r2, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=50, wait=0.5)
assertmsg = "JSON output mismatch on spine router r2"
assert result is None, assertmsg
# Configure anycast IP on additional server r10
logger.info("Configure anycast IP on server r10")
tgen.net["r10"].cmd("ip addr add 198.10.1.1/32 dev r10-eth1")
# Check if bandwidth is properly encoded with non IEEE floatig-point (uint32) format on r3
logger.info(
"Check if bandwidth is properly encoded with non IEEE floatig-point (uint32) format on r3"
)
json_file = "{}/r3/bgp-route-1.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r3, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on r3"
assert result is None, assertmsg
# Check multipath on super-spine router r1
logger.info("Check multipath on super-spine router r1")
json_file = "{}/r1/bgp-route-2.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
# Check weighted ECMP is in effect on the super-spine router r1
logger.info("Check weighted ECMP is in effect on the super-spine router r1")
json_file = "{}/r1/ip-route-1.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=50, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
def test_weighted_ecmp_link_flap():
"Test #4: Test weighted ECMP rebalancing upon change (link flap)"
logger.info("\nTest #4: Test weighted ECMP rebalancing upon change (link flap)")
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip("skipped because of router(s) failure")
r1 = tgen.gears["r1"]
r2 = tgen.gears["r2"]
# Bring down link on server r9
logger.info("Bring down link on server r9")
tgen.net["r9"].cmd("ip link set dev r9-eth1 down")
# Check spine router r2 has only one path
logger.info("Check spine router r2 has only one path")
json_file = "{}/r2/ip-route-3.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r2, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on spine router r2"
assert result is None, assertmsg
# Check link-bandwidth change and weighted ECMP rebalance on super-spine router r1
logger.info(
"Check link-bandwidth change and weighted ECMP rebalance on super-spine router r1"
)
json_file = "{}/r1/bgp-route-3.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
json_file = "{}/r1/ip-route-2.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=50, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
# Bring up link on server r9
logger.info("Bring up link on server r9")
tgen.net["r9"].cmd("ip link set dev r9-eth1 up")
# Check link-bandwidth change and weighted ECMP rebalance on super-spine router r1
logger.info(
"Check link-bandwidth change and weighted ECMP rebalance on super-spine router r1"
)
json_file = "{}/r1/bgp-route-2.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
json_file = "{}/r1/ip-route-1.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=50, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
def test_weighted_ecmp_second_anycast_ip():
"Test #5: Test weighted ECMP for a second anycast IP"
logger.info("\nTest #5: Test weighted ECMP for a second anycast IP")
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip("skipped because of router(s) failure")
r1 = tgen.gears["r1"]
r2 = tgen.gears["r2"]
# Configure anycast IP on additional server r7, r9 and r10
logger.info("Configure anycast IP on server r7, r9 and r10")
tgen.net["r7"].cmd("ip addr add 198.10.1.11/32 dev r7-eth1")
tgen.net["r9"].cmd("ip addr add 198.10.1.11/32 dev r9-eth1")
tgen.net["r10"].cmd("ip addr add 198.10.1.11/32 dev r10-eth1")
# Check link-bandwidth and weighted ECMP on super-spine router r1
logger.info("Check link-bandwidth and weighted ECMP on super-spine router r1")
json_file = "{}/r1/bgp-route-4.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show bgp ipv4 uni 198.10.1.11/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
json_file = "{}/r1/ip-route-3.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.11/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=50, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
def test_paths_with_and_without_linkbw():
"Test #6: Test paths with and without link-bandwidth - receiver should resort to regular ECMP"
logger.info(
"\nTest #6: Test paths with and without link-bandwidth - receiver should resort to regular ECMP"
)
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip("skipped because of router(s) failure")
r1 = tgen.gears["r1"]
# Configure leaf router r6 to not advertise any link-bandwidth
logger.info("Configure leaf router r6 to not advertise any link-bandwidth")
tgen.net["r6"].cmd(
'vtysh -c "conf t" -c "router bgp 65303" -c "address-family ipv4 unicast" -c "no neighbor 11.1.3.1 route-map anycast_ip out"'
)
# Check link-bandwidth change on super-spine router r1
logger.info("Check link-bandwidth change on super-spine router r1")
json_file = "{}/r1/bgp-route-5.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show bgp ipv4 uni 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
# Check super-spine router r1 resorts to regular ECMP
logger.info("Check super-spine router r1 resorts to regular ECMP")
json_file = "{}/r1/ip-route-4.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=50, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
json_file = "{}/r1/ip-route-5.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.11/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=50, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
def test_linkbw_handling_options():
"Test #7: Test different options for processing link-bandwidth on the receiver"
logger.info(
"\nTest #7: Test different options for processing link-bandwidth on the receiver"
)
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip("skipped because of router(s) failure")
r1 = tgen.gears["r1"]
# Configure super-spine r1 to skip multipaths without link-bandwidth
logger.info("Configure super-spine r1 to skip multipaths without link-bandwidth")
tgen.net["r1"].cmd(
'vtysh -c "conf t" -c "router bgp 65101" -c "bgp bestpath bandwidth skip-missing"'
)
# Check super-spine router r1 resorts to only one path as other path is skipped
logger.info(
"Check super-spine router r1 resorts to only one path as other path is skipped"
)
json_file = "{}/r1/ip-route-6.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
json_file = "{}/r1/ip-route-7.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.11/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
# Configure super-spine r1 to use default-weight for multipaths without link-bandwidth
logger.info(
"Configure super-spine r1 to use default-weight for multipaths without link-bandwidth"
)
tgen.net["r1"].cmd(
'vtysh -c "conf t" -c "router bgp 65101" -c "bgp bestpath bandwidth default-weight-for-missing"'
)
# Check super-spine router r1 uses ECMP with weight 1 for path without link-bandwidth
logger.info(
"Check super-spine router r1 uses ECMP with weight 1 for path without link-bandwidth"
)
json_file = "{}/r1/ip-route-8.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.1/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
json_file = "{}/r1/ip-route-9.json".format(CWD)
expected = json.loads(open(json_file).read())
test_func = partial(
topotest.router_json_cmp, r1, "show ip route 198.10.1.11/32 json", expected
)
_, result = topotest.run_and_expect(test_func, None, count=200, wait=0.5)
assertmsg = "JSON output mismatch on super-spine router r1"
assert result is None, assertmsg
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))
|