]>
Commit | Line | Data |
---|---|---|
9e3bab5f | 1 | #!/usr/bin/env python |
2 | ||
3 | # | |
4 | # Copyright (c) 2021 by VMware, Inc. ("VMware") | |
5 | # Used Copyright (c) 2018 by Network Device Education Foundation, Inc. | |
6 | # ("NetDEF") in this file. | |
7 | # | |
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 | |
11 | # in all copies. | |
12 | # | |
13 | # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES | |
14 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
15 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE 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 | |
20 | # OF THIS SOFTWARE. | |
21 | # | |
22 | ||
23 | ||
24 | """RFC5549 Automation.""" | |
25 | import os | |
26 | import sys | |
27 | import time | |
28 | import json | |
29 | import pytest | |
30 | import ipaddr | |
31 | from copy import deepcopy | |
32 | from re import search as re_search | |
33 | ||
34 | # Save the Current Working Directory to find configuration files. | |
35 | CWD = os.path.dirname(os.path.realpath(__file__)) | |
36 | sys.path.append(os.path.join(CWD, "../")) | |
37 | sys.path.append(os.path.join(CWD, "../../")) | |
38 | ||
39 | from lib.topogen import Topogen, get_topogen | |
9e3bab5f | 40 | |
41 | from lib.common_config import ( | |
42 | write_test_header, | |
43 | start_topology, | |
44 | create_route_maps, | |
45 | write_test_footer, | |
46 | start_router, | |
47 | stop_router, | |
48 | verify_rib, | |
49 | create_static_routes, | |
50 | check_address_types, | |
51 | reset_config_on_routers, | |
52 | step, | |
53 | shutdown_bringup_interface, | |
54 | create_interfaces_cfg, | |
55 | get_frr_ipv6_linklocal, | |
56 | ) | |
57 | from lib.topolog import logger | |
58 | from lib.bgp import clear_bgp, verify_bgp_convergence, create_router_bgp, verify_bgp_rib | |
59 | ||
60 | from lib.topojson import build_topo_from_json, build_config_from_json | |
61 | ||
62 | # Global variables | |
63 | topo = None | |
9e3bab5f | 64 | |
65 | # Global variables | |
66 | NO_OF_RTES = 2 | |
67 | NETWORK_CMD_IP = "1.0.1.17/32" | |
68 | NETWORK = { | |
69 | "ipv4": [ | |
70 | "11.0.20.1/32", | |
71 | "11.0.20.2/32", | |
72 | "11.0.20.3/32", | |
73 | "11.0.20.4/32", | |
74 | "11.0.20.5/32", | |
75 | ], | |
76 | "ipv6": ["1::1/128", "1::2/128", "1::3/128", "1::4/128", "1::5/128"], | |
77 | } | |
78 | MASK = {"ipv4": "32", "ipv6": "128"} | |
79 | NEXT_HOP = { | |
80 | "ipv4": ["10.0.0.1", "10.0.1.1", "10.0.2.1", "10.0.3.1", "10.0.4.1"], | |
81 | "ipv6": ["Null0", "Null0", "Null0", "Null0", "Null0"], | |
82 | } | |
83 | INTF_LIST = [ | |
84 | "r2-link0", | |
85 | "r2-link1", | |
86 | "r2-link2", | |
87 | "r2-link3", | |
88 | "r2-link4", | |
89 | "r2-link5", | |
90 | "r2-link6", | |
91 | "r2-link7", | |
92 | ] | |
93 | ADDR_TYPES = check_address_types() | |
94 | TOPOOLOGY = """ | |
95 | Please view in a fixed-width font such as Courier. | |
96 | ||
97 | +----+ | |
98 | | R4 | | |
99 | | | | |
100 | +--+-+ | |
101 | | ipv4 nbr | |
102 | no bgp ebgp/ibgp | | |
103 | | ebgp/ibgp | |
104 | +----+ 5links +----+ 8links +--+-+ +----+ | |
105 | |R0 +----------+ R1 +------------+ R2 | ipv6 nbr |R3 | | |
106 | | +----------+ +------------+ +-------------+ | | |
107 | +----+ +----+ ipv6 nbr +----+ +----+ | |
108 | """ | |
109 | ||
110 | TESTCASES = """ | |
111 | 1. Verify IPv4 routes are advertised when IPv6 EBGP loopback session | |
112 | established using Unnumbered interface | |
113 | 2. Verify IPv4 routes are installed with correct nexthop after | |
114 | shut / no shut of nexthop and BGP peer interfaces | |
115 | 3. Verify IPv4 routes are intact after stop and start the FRR services | |
116 | """ | |
117 | ||
118 | ||
9e3bab5f | 119 | def setup_module(mod): |
120 | """Set up the pytest environment.""" | |
121 | global topo, ADDR_TYPES | |
122 | ||
123 | testsuite_run_time = time.asctime(time.localtime(time.time())) | |
124 | logger.info("Testsuite start time: {}".format(testsuite_run_time)) | |
125 | logger.info("=" * 40) | |
126 | ||
127 | logger.info("Running setup_module to create topology") | |
128 | ||
129 | # This function initiates the topology build with Topogen... | |
e82b531d CH |
130 | json_file = "{}/rfc5549_ebgp_unnumbered_nbr.json".format(CWD) |
131 | tgen = Topogen(json_file, mod.__name__) | |
132 | global topo | |
133 | topo = tgen.json_topo | |
9e3bab5f | 134 | |
135 | # Starting topology, create tmp files which are loaded to routers | |
136 | # to start deamons and then start routers | |
137 | start_topology(tgen) | |
138 | ||
139 | # Creating configuration from JSON | |
140 | build_config_from_json(tgen, topo) | |
141 | # Don't run this test if we have any failure. | |
142 | if tgen.routers_have_failure(): | |
143 | pytest.skip(tgen.errors) | |
144 | ||
145 | BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo) | |
146 | assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error:" " {}".format( | |
147 | BGP_CONVERGENCE | |
148 | ) | |
149 | logger.info("Running setup_module() done") | |
150 | ||
151 | ||
152 | def teardown_module(): | |
153 | """Teardown the pytest environment.""" | |
154 | logger.info("Running teardown_module to delete topology") | |
155 | ||
156 | tgen = get_topogen() | |
157 | ||
158 | # Stop toplogy and Remove tmp files | |
159 | tgen.stop_topology() | |
160 | ||
161 | ||
162 | def get_llip(onrouter, intf): | |
163 | """ | |
164 | API to get the link local ipv6 address of a perticular interface | |
165 | ||
166 | Parameters | |
167 | ---------- | |
168 | * `fromnode`: Source node | |
169 | * `tonode` : interface for which link local ip needs to be returned. | |
170 | ||
171 | Usage | |
172 | ----- | |
173 | result = get_llip('r1', 'r2-link0') | |
174 | ||
175 | Returns | |
176 | ------- | |
177 | 1) link local ipv6 address from the interface. | |
178 | 2) errormsg - when link local ip not found. | |
179 | """ | |
180 | tgen = get_topogen() | |
181 | intf = topo["routers"][onrouter]["links"][intf]["interface"] | |
182 | llip = get_frr_ipv6_linklocal(tgen, onrouter, intf) | |
183 | if llip: | |
184 | logger.info("llip ipv6 address to be set as NH is %s", llip) | |
185 | return llip | |
186 | return None | |
187 | ||
188 | ||
189 | def get_glipv6(onrouter, intf): | |
190 | """ | |
191 | API to get the global ipv6 address of a perticular interface | |
192 | ||
193 | Parameters | |
194 | ---------- | |
195 | * `onrouter`: Source node | |
196 | * `intf` : interface for which link local ip needs to be returned. | |
197 | ||
198 | Usage | |
199 | ----- | |
200 | result = get_glipv6('r1', 'r2-link0') | |
201 | ||
202 | Returns | |
203 | ------- | |
204 | 1) global ipv6 address from the interface. | |
205 | 2) errormsg - when link local ip not found. | |
206 | """ | |
207 | glipv6 = (topo["routers"][onrouter]["links"][intf]["ipv6"]).split("/")[0] | |
208 | if glipv6: | |
209 | logger.info("Global ipv6 address to be set as NH is %s", glipv6) | |
210 | return glipv6 | |
211 | return None | |
212 | ||
213 | ||
214 | # ################################## | |
215 | # Test cases start here. | |
216 | # ################################## | |
217 | ||
218 | ||
219 | def test_unnumbered_loopback_ebgp_nbr_p0(request): | |
220 | """ | |
221 | ||
222 | Test extended capability nexthop with un numbered ebgp. | |
223 | ||
224 | Verify IPv4 routes are advertised when IPv6 EBGP loopback | |
225 | session established using Unnumbered interface | |
226 | """ | |
227 | tc_name = request.node.name | |
228 | write_test_header(tc_name) | |
229 | tgen = get_topogen() | |
230 | # Don't run this test if we have any failure. | |
231 | if tgen.routers_have_failure(): | |
232 | pytest.skip(tgen.errors) | |
233 | reset_config_on_routers(tgen) | |
234 | ||
235 | step("Configure IPv6 EBGP Unnumbered session between R1 and R2") | |
236 | step("Enable capability extended-nexthop on both the IPv6 BGP peers") | |
237 | step("Activate same IPv6 nbr from IPv4 unicast family") | |
238 | step("Enable cap ext nh on r1 and r2 and activate in ipv4 addr family") | |
239 | step("Verify bgp convergence as ipv6 nbr is enabled on ipv4 addr family.") | |
240 | ||
241 | bgp_convergence = verify_bgp_convergence(tgen, topo) | |
242 | assert bgp_convergence is True, "Testcase {} :Failed \n Error: {}".format( | |
243 | tc_name, bgp_convergence | |
244 | ) | |
245 | ||
246 | step(" Configure 5 IPv4 static" " routes on R1, Nexthop as different links of R0") | |
247 | for rte in range(0, NO_OF_RTES): | |
248 | # Create Static routes | |
249 | input_dict = { | |
250 | "r1": { | |
251 | "static_routes": [ | |
252 | { | |
253 | "network": NETWORK["ipv4"][rte], | |
254 | "no_of_ip": 1, | |
255 | "next_hop": NEXT_HOP["ipv4"][rte], | |
256 | } | |
257 | ] | |
258 | } | |
259 | } | |
260 | result = create_static_routes(tgen, input_dict) | |
261 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
262 | tc_name, result | |
263 | ) | |
264 | ||
265 | step( | |
266 | "Advertise static routes from IPv4 unicast family and IPv6 " | |
267 | "unicast family respectively from R1 using red static cmd " | |
268 | "Advertise loopback from IPv4 unicast family using network command " | |
269 | "from R1" | |
270 | ) | |
271 | ||
272 | configure_bgp_on_r1 = { | |
273 | "r1": { | |
274 | "bgp": { | |
275 | "address_family": { | |
276 | "ipv4": { | |
277 | "unicast": { | |
278 | "redistribute": [{"redist_type": "static"}], | |
279 | "advertise_networks": [ | |
280 | {"network": NETWORK_CMD_IP, "no_of_network": 1} | |
281 | ], | |
282 | } | |
283 | }, | |
284 | "ipv6": {"unicast": {"redistribute": [{"redist_type": "static"}]}}, | |
285 | } | |
286 | } | |
287 | } | |
288 | } | |
289 | result = create_router_bgp(tgen, topo, configure_bgp_on_r1) | |
290 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
291 | step( | |
292 | "IPv4 routes advertised using static and network command are " | |
293 | " received on R2 BGP and routing table , " | |
294 | "verify using show ip bgp, show ip route for IPv4 routes ." | |
295 | ) | |
296 | ||
297 | llip = get_llip("r1", "r2-link0") | |
298 | assert llip is not None, "Testcase {} : Failed \n Error: {}".format(tc_name, llip) | |
299 | ||
300 | dut = "r2" | |
301 | protocol = "bgp" | |
302 | for rte in range(0, NO_OF_RTES): | |
303 | # verify the routes with nh as ext_nh | |
304 | verify_nh_for_static_rtes = { | |
305 | "r1": { | |
306 | "static_routes": [ | |
307 | {"network": NETWORK["ipv4"][rte], "no_of_ip": 1, "next_hop": llip} | |
308 | ] | |
309 | } | |
310 | } | |
311 | """ interface_list = ['r1-link0','r1-link1'] | |
312 | nh_list =[] | |
313 | for i in range(NO_OF_RTES): | |
314 | nh_list.append(topo['routers']['r2']['links'][i][ | |
315 | 'interface']) """ | |
316 | bgp_rib = verify_rib( | |
317 | tgen, | |
318 | "ipv4", | |
319 | dut, | |
320 | # verify_nh_for_static_rtes, next_hop='r2-r1-eth0') | |
321 | verify_nh_for_static_rtes, | |
322 | next_hop=llip, | |
323 | ) | |
324 | assert bgp_rib is True, "Testcase {} : Failed \n Error: {}".format( | |
325 | tc_name, bgp_rib | |
326 | ) | |
327 | result = verify_rib( | |
328 | tgen, | |
329 | "ipv4", | |
330 | dut, | |
331 | verify_nh_for_static_rtes, | |
332 | next_hop=llip, | |
333 | protocol=protocol, | |
334 | ) | |
335 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
336 | tc_name, result | |
337 | ) | |
338 | ||
339 | # verify the routes with nh as ext_nh | |
340 | verify_nh_for_nw_rtes = { | |
341 | "r1": { | |
342 | "static_routes": [ | |
343 | {"network": NETWORK_CMD_IP, "no_of_ip": 1, "next_hop": llip} | |
344 | ] | |
345 | } | |
346 | } | |
347 | ||
348 | bgp_rib = verify_rib( | |
349 | tgen, | |
350 | "ipv4", | |
351 | dut, | |
352 | # verify_nh_for_nw_rtes, next_hop='r2-r1-eth0') | |
353 | verify_nh_for_nw_rtes, | |
354 | next_hop=llip, | |
355 | ) | |
356 | assert bgp_rib is True, "Testcase {} : Failed \n Error: {}".format(tc_name, bgp_rib) | |
357 | result = verify_rib( | |
358 | tgen, "ipv4", dut, verify_nh_for_nw_rtes, next_hop=llip, protocol=protocol | |
359 | ) | |
360 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
361 | # stop/start -> restart FRR router and verify | |
362 | stop_router(tgen, "r1") | |
363 | stop_router(tgen, "r2") | |
364 | start_router(tgen, "r1") | |
365 | start_router(tgen, "r2") | |
366 | step( | |
367 | "After stop/start of FRR services , verify session up and routes " | |
368 | "came up fine ,nh is proper using show bgp & show ipv6 route on R2 " | |
369 | ) | |
370 | bgp_convergence = verify_bgp_convergence(tgen, topo) | |
371 | assert bgp_convergence is True, "Testcase {} :Failed \n Error: {}".format( | |
372 | tc_name, bgp_convergence | |
373 | ) | |
374 | ||
375 | llip = get_llip("r1", "r2-link0") | |
376 | assert llip is not None, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
377 | ||
378 | # verify the routes with nh as ext_nh | |
379 | verify_nh_for_static_rtes = { | |
380 | "r1": { | |
381 | "static_routes": [ | |
382 | { | |
383 | "network": NETWORK["ipv4"][0], | |
384 | "no_of_ip": NO_OF_RTES, | |
385 | "next_hop": llip, | |
386 | } | |
387 | ] | |
388 | } | |
389 | } | |
390 | bgp_rib = verify_bgp_rib( | |
391 | tgen, | |
392 | "ipv4", | |
393 | dut, | |
394 | # verify_nh_for_static_rtes, next_hop='r2-r1-eth0') | |
395 | verify_nh_for_static_rtes, | |
396 | next_hop=llip, | |
397 | ) | |
398 | assert bgp_rib is True, "Testcase {} : Failed \n Error: {}".format(tc_name, bgp_rib) | |
399 | result = verify_rib( | |
400 | tgen, "ipv4", dut, verify_nh_for_static_rtes, next_hop=llip, protocol=protocol | |
401 | ) | |
402 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
403 | ||
404 | verify_nh_for_nw_rtes = { | |
405 | "r1": { | |
406 | "static_routes": [ | |
407 | {"network": NETWORK_CMD_IP, "no_of_ip": 1, "next_hop": llip} | |
408 | ] | |
409 | } | |
410 | } | |
411 | bgp_rib = verify_rib( | |
412 | tgen, | |
413 | "ipv4", | |
414 | dut, | |
415 | # verify_nh_for_nw_rtes, next_hop='r2-r1-eth0') | |
416 | verify_nh_for_nw_rtes, | |
417 | next_hop=llip, | |
418 | ) | |
419 | assert bgp_rib is True, "Testcase {} : Failed \n Error: {}".format(tc_name, bgp_rib) | |
420 | result = verify_rib( | |
421 | tgen, "ipv4", dut, verify_nh_for_nw_rtes, next_hop=llip, protocol=protocol | |
422 | ) | |
423 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
424 | write_test_footer(tc_name) | |
425 | ||
426 | ||
427 | def test_restart_frr_p2(request): | |
428 | """ | |
429 | ||
430 | Test extended capability nexthop , restart frr. | |
431 | ||
432 | Verify IPv4 routes are intact after stop and start the FRR services | |
433 | """ | |
434 | tc_name = request.node.name | |
435 | write_test_header(tc_name) | |
436 | tgen = get_topogen() | |
437 | # Don't run this test if we have any failure. | |
438 | if tgen.routers_have_failure(): | |
439 | pytest.skip(tgen.errors) | |
440 | reset_config_on_routers(tgen) | |
441 | step("Configure IPv6 EBGP Unnumbered session between R1 and R2") | |
442 | step("Enable capability extended-nexthop on both the IPv6 BGP peers") | |
443 | step("Activate same IPv6 nbr from IPv4 unicast family") | |
444 | step("Enable cap ext nh on r1 and r2 and activate in ipv4 addr family") | |
445 | step("Verify bgp convergence as ipv6 nbr is enabled on ipv4 addr family.") | |
446 | reset_config_on_routers(tgen) | |
447 | bgp_convergence = verify_bgp_convergence(tgen, topo) | |
448 | assert bgp_convergence is True, "Testcase {} :Failed \n Error: {}".format( | |
449 | tc_name, bgp_convergence | |
450 | ) | |
451 | ||
452 | step(" Configure 5 IPv4 static" " routes on R1, Nexthop as different links of R0") | |
453 | for rte in range(0, NO_OF_RTES): | |
454 | # Create Static routes | |
455 | input_dict = { | |
456 | "r1": { | |
457 | "static_routes": [ | |
458 | { | |
459 | "network": NETWORK["ipv4"][rte], | |
460 | "no_of_ip": 1, | |
461 | "next_hop": NEXT_HOP["ipv4"][rte], | |
462 | } | |
463 | ] | |
464 | } | |
465 | } | |
466 | result = create_static_routes(tgen, input_dict) | |
467 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
468 | tc_name, result | |
469 | ) | |
470 | ||
471 | step( | |
472 | "Advertise static routes from IPv4 unicast family and IPv6 " | |
473 | "unicast family respectively from R1 using red static cmd " | |
474 | "Advertise loopback from IPv4 unicast family using network command " | |
475 | "from R1" | |
476 | ) | |
477 | ||
478 | configure_bgp_on_r1 = { | |
479 | "r1": { | |
480 | "bgp": { | |
481 | "address_family": { | |
482 | "ipv4": { | |
483 | "unicast": { | |
484 | "redistribute": [{"redist_type": "static"}], | |
485 | "advertise_networks": [ | |
486 | {"network": NETWORK_CMD_IP, "no_of_network": 1} | |
487 | ], | |
488 | } | |
489 | }, | |
490 | "ipv6": {"unicast": {"redistribute": [{"redist_type": "static"}]}}, | |
491 | } | |
492 | } | |
493 | } | |
494 | } | |
495 | result = create_router_bgp(tgen, topo, configure_bgp_on_r1) | |
496 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
497 | step( | |
498 | "IPv4 routes advertised using static and network command are " | |
499 | " received on R2 BGP and routing table , " | |
500 | "verify using show ip bgp, show ip route for IPv4 routes ." | |
501 | ) | |
502 | ||
503 | llip = get_llip("r1", "r2-link0") | |
504 | assert llip is not None, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
505 | ||
506 | dut = "r2" | |
507 | protocol = "bgp" | |
508 | verify_nh_for_static_rtes = { | |
509 | "r1": { | |
510 | "static_routes": [ | |
511 | { | |
512 | "network": NETWORK["ipv4"][0], | |
513 | "no_of_ip": NO_OF_RTES, | |
514 | "next_hop": llip, | |
515 | } | |
516 | ] | |
517 | } | |
518 | } | |
519 | bgp_rib = verify_rib(tgen, "ipv4", dut, verify_nh_for_static_rtes, next_hop=llip) | |
520 | assert bgp_rib is True, "Testcase {} : Failed \n Error: {}".format(tc_name, bgp_rib) | |
521 | result = verify_rib( | |
522 | tgen, "ipv4", dut, verify_nh_for_static_rtes, next_hop=llip, protocol=protocol | |
523 | ) | |
524 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
525 | ||
526 | verify_nh_for_nw_rtes = { | |
527 | "r1": { | |
528 | "static_routes": [ | |
529 | {"network": NETWORK_CMD_IP, "no_of_ip": 1, "next_hop": llip} | |
530 | ] | |
531 | } | |
532 | } | |
533 | ||
534 | bgp_rib = verify_rib(tgen, "ipv4", dut, verify_nh_for_nw_rtes, next_hop=llip) | |
535 | assert bgp_rib is True, "Testcase {} : Failed \n Error: {}".format(tc_name, bgp_rib) | |
536 | result = verify_rib( | |
537 | tgen, "ipv4", dut, verify_nh_for_nw_rtes, next_hop=llip, protocol=protocol | |
538 | ) | |
539 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
540 | ||
541 | # stop/start -> restart FRR router and verify | |
542 | stop_router(tgen, "r1") | |
543 | stop_router(tgen, "r2") | |
544 | start_router(tgen, "r1") | |
545 | start_router(tgen, "r2") | |
546 | ||
547 | step( | |
548 | "After stop/start of FRR services , verify session up and routes " | |
549 | "came up fine ,nh is proper using show bgp & show ipv6 route on R2 " | |
550 | ) | |
551 | bgp_convergence = verify_bgp_convergence(tgen, topo) | |
552 | assert bgp_convergence is True, "Testcase {} :Failed \n Error: {}".format( | |
553 | tc_name, bgp_convergence | |
554 | ) | |
555 | ||
556 | llip = get_llip("r1", "r2-link0") | |
557 | assert llip is not None, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
558 | ||
559 | # verify the routes with nh as ext_nh | |
560 | verify_nh_for_static_rtes = { | |
561 | "r1": { | |
562 | "static_routes": [ | |
563 | {"network": NETWORK["ipv4"][0], "no_of_ip": 1, "next_hop": llip} | |
564 | ] | |
565 | } | |
566 | } | |
567 | bgp_rib = verify_rib(tgen, "ipv4", dut, verify_nh_for_static_rtes, next_hop=llip) | |
568 | assert bgp_rib is True, "Testcase {} : Failed \n Error: {}".format(tc_name, bgp_rib) | |
569 | result = verify_rib( | |
570 | tgen, "ipv4", dut, verify_nh_for_static_rtes, next_hop=llip, protocol=protocol | |
571 | ) | |
572 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
573 | ||
574 | # verify the routes with nh as ext_nh | |
575 | verify_nh_for_nw_rtes = { | |
576 | "r1": { | |
577 | "static_routes": [ | |
578 | {"network": NETWORK_CMD_IP, "no_of_ip": 1, "next_hop": llip} | |
579 | ] | |
580 | } | |
581 | } | |
582 | bgp_rib = verify_rib(tgen, "ipv4", dut, verify_nh_for_nw_rtes, next_hop=llip) | |
583 | assert bgp_rib is True, "Testcase {} : Failed \n Error: {}".format(tc_name, bgp_rib) | |
584 | result = verify_rib( | |
585 | tgen, "ipv4", dut, verify_nh_for_nw_rtes, next_hop=llip, protocol=protocol | |
586 | ) | |
587 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
588 | write_test_footer(tc_name) | |
589 | ||
590 | ||
591 | if __name__ == "__main__": | |
592 | args = ["-s"] + sys.argv[1:] | |
593 | sys.exit(pytest.main(args)) |