]>
Commit | Line | Data |
---|---|---|
b0449478 | 1 | #!/usr/bin/env python |
acddc0ed | 2 | # SPDX-License-Identifier: ISC |
b0449478 DS |
3 | # |
4 | # Copyright (c) 2019 by VMware, Inc. ("VMware") | |
5 | # Used Copyright (c) 2018 by Network Device Education Foundation, Inc. ("NetDEF") | |
6 | # in this file. | |
7 | # | |
b0449478 DS |
8 | |
9 | """ | |
10 | Following tests are covered to test BGP Graceful Restart functionality. | |
11 | Basic Common Test steps for all the test case below : | |
12 | - Create topology (setup module) | |
13 | Creating 7 routers topology | |
14 | - Bring up topology | |
15 | - Verify for bgp to converge | |
16 | - Configure BGP Graceful Restart on both the routers. | |
17 | ||
18 | TC_1_2: | |
19 | Verify that EOR message is sent out only after initial convergence | |
20 | Verify whether EOR message is received from all the peers after restart | |
21 | TC_3: | |
22 | Verify the selection deferral timer functionality when EOR is not sent | |
23 | by the helper router | |
24 | TC_11: | |
25 | Verify that selection-deferral timer sets the maximum time to | |
26 | avoid deadlock during which the best-path | |
27 | TC_10: | |
28 | Test Objective : Test GR scenarios on helper router by enabling | |
29 | Graceful Restart for multiple address families. | |
30 | TC_15: | |
31 | Test Objective : Test GR scenarios by enabling Graceful Restart | |
32 | for multiple address families.. | |
33 | TC_16: | |
34 | Test Objective : Verify BGP-GR feature when restarting node | |
35 | is a transit router for it's iBGP peers. | |
36 | TC_18: | |
37 | Test Objective : Verify that GR helper router deletes stale routes | |
38 | received from restarting node, if GR capability is not present in | |
39 | TC_19: | |
40 | Test Objective : Verify that GR routers keeps all the routes | |
41 | received from restarting node if both the routers are | |
42 | TC_26: | |
43 | Test Objective : Test GR scenarios on helper router by enabling | |
44 | Graceful Restart for multiple address families. | |
45 | TC_28: | |
46 | Test Objective : Verify if helper node goes down before restarting | |
47 | node comes up online, helper node sets the R-bit to avoid dead-lock | |
48 | TC_29: | |
49 | Test Objective : Change timers on the fly, and | |
50 | verify if it takes immediate effect. | |
51 | TC_33: | |
52 | Test Objective : Helper router receives same prefixes from two | |
53 | different routers (GR-restarting and GR-disabled). Keeps the | |
54 | TC_34_1: | |
55 | Test Objective : Restarting node doesn't preserve forwarding | |
56 | state, helper router should not keep the stale entries. | |
57 | TC_34_2: | |
58 | Test Objective : Restarting node doesn't preserve the forwarding | |
59 | state verify the behaviour on helper node, if it still keeps the | |
60 | TC_32: | |
61 | Test Objective : Restarting node is connected to multiple helper | |
62 | nodes, one of them doesn't send EOR to restarting router. Verify | |
63 | TC_37: | |
64 | Test Objective : Verify if helper node restarts before sending the | |
65 | EOR message, restarting node doesn't wait until stale path timer | |
66 | TC_30: | |
67 | Test Objective : Restarting node removes stale routes from Zebra | |
68 | after receiving an EOR from helper router. | |
69 | ||
70 | """ | |
71 | ||
72 | import os | |
73 | import sys | |
74 | import time | |
75 | import pytest | |
76 | from time import sleep | |
77 | ||
78 | # Save the Current Working Directory to find configuration files. | |
79 | CWD = os.path.dirname(os.path.realpath(__file__)) | |
80 | sys.path.append(os.path.join("../")) | |
81 | sys.path.append(os.path.join("../lib/")) | |
82 | ||
83 | # pylint: disable=C0413 | |
84 | # Import topogen and topotest helpers | |
85 | from lib.topogen import Topogen, get_topogen | |
86 | from lib.topolog import logger | |
87 | ||
88 | # Required to instantiate the topology builder class. | |
89 | ||
90 | # Import topoJson from lib, to create topology and initial configuration | |
91 | from lib.topojson import build_config_from_json | |
92 | from lib.bgp import ( | |
93 | clear_bgp, | |
94 | verify_bgp_rib, | |
95 | verify_graceful_restart, | |
96 | create_router_bgp, | |
97 | verify_r_bit, | |
98 | verify_eor, | |
99 | verify_f_bit, | |
100 | verify_bgp_convergence, | |
101 | verify_gr_address_family, | |
102 | modify_bgp_config_when_bgpd_down, | |
103 | verify_graceful_restart_timers, | |
104 | verify_bgp_convergence_from_running_config, | |
105 | ) | |
106 | ||
107 | from lib.common_config import ( | |
108 | write_test_header, | |
109 | reset_config_on_routers, | |
110 | start_topology, | |
111 | kill_router_daemons, | |
112 | start_router_daemons, | |
113 | verify_rib, | |
114 | check_address_types, | |
115 | write_test_footer, | |
116 | check_router_status, | |
117 | step, | |
118 | get_frr_ipv6_linklocal, | |
119 | required_linux_kernel_version, | |
120 | ) | |
121 | ||
122 | pytestmark = [pytest.mark.bgpd] | |
123 | ||
124 | ||
125 | # Global variables | |
126 | BGP_CONVERGENCE = False | |
127 | GR_RESTART_TIMER = 5 | |
128 | GR_SELECT_DEFER_TIMER = 5 | |
129 | GR_STALEPATH_TIMER = 5 | |
130 | PREFERRED_NEXT_HOP = "link_local" | |
131 | NEXT_HOP_4 = ["192.168.1.1", "192.168.4.2"] | |
132 | NEXT_HOP_6 = ["fd00:0:0:1::1", "fd00:0:0:4::2"] | |
133 | ||
134 | ||
135 | def setup_module(mod): | |
136 | """ | |
137 | Sets up the pytest environment | |
138 | ||
139 | * `mod`: module name | |
140 | """ | |
141 | ||
142 | # Required linux kernel version for this suite to run. | |
143 | result = required_linux_kernel_version("4.16") | |
144 | if result is not True: | |
d63c7094 | 145 | pytest.skip("Kernel requirements are not met, kernel version should be >=4.16") |
b0449478 DS |
146 | |
147 | global ADDR_TYPES | |
148 | ||
149 | testsuite_run_time = time.asctime(time.localtime(time.time())) | |
150 | logger.info("Testsuite start time: {}".format(testsuite_run_time)) | |
151 | logger.info("=" * 40) | |
152 | ||
153 | logger.info("Running setup_module to create topology") | |
154 | ||
155 | # This function initiates the topology build with Topogen... | |
156 | json_file = "{}/bgp_gr_topojson_topo2.json".format(CWD) | |
157 | tgen = Topogen(json_file, mod.__name__) | |
158 | global topo | |
159 | topo = tgen.json_topo | |
160 | # ... and here it calls Mininet initialization functions. | |
161 | ||
162 | # Starting topology, create tmp files which are loaded to routers | |
d60a3f0e | 163 | # to start daemons and then start routers |
b0449478 DS |
164 | start_topology(tgen) |
165 | ||
166 | # Creating configuration from JSON | |
167 | build_config_from_json(tgen, topo) | |
168 | ||
169 | # Api call verify whether BGP is converged | |
170 | ADDR_TYPES = check_address_types() | |
171 | ||
172 | for addr_type in ADDR_TYPES: | |
173 | BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo) | |
174 | assert BGP_CONVERGENCE is True, "setup_module : Failed \n Error:" " {}".format( | |
175 | BGP_CONVERGENCE | |
176 | ) | |
177 | ||
178 | logger.info("Running setup_module() done") | |
179 | ||
180 | ||
181 | def teardown_module(mod): | |
182 | """ | |
183 | Teardown the pytest environment | |
184 | ||
185 | * `mod`: module name | |
186 | """ | |
187 | ||
188 | logger.info("Running teardown_module to delete topology") | |
189 | ||
190 | tgen = get_topogen() | |
191 | ||
192 | # Stop toplogy and Remove tmp files | |
193 | tgen.stop_topology() | |
194 | ||
195 | logger.info( | |
196 | "Testsuite end time: {}".format(time.asctime(time.localtime(time.time()))) | |
197 | ) | |
198 | logger.info("=" * 40) | |
199 | ||
200 | ||
201 | def configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut, peer): | |
202 | """ | |
203 | This function groups the repetitive function calls into one function. | |
204 | """ | |
205 | ||
206 | logger.info("configure_gr_followed_by_clear: dut %s peer %s", dut, peer) | |
207 | ||
208 | result = create_router_bgp(tgen, topo, input_dict) | |
209 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
210 | ||
211 | for addr_type in ADDR_TYPES: | |
212 | neighbor = topo["routers"][peer]["links"][dut][addr_type].split("/")[0] | |
213 | clear_bgp(tgen, addr_type, dut, neighbor=neighbor) | |
214 | ||
215 | for addr_type in ADDR_TYPES: | |
216 | neighbor = topo["routers"][dut]["links"][peer][addr_type].split("/")[0] | |
217 | clear_bgp(tgen, addr_type, peer, neighbor=neighbor) | |
218 | ||
219 | result = verify_bgp_convergence_from_running_config(tgen) | |
220 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
221 | ||
222 | return True | |
223 | ||
224 | ||
225 | def next_hop_per_address_family(tgen, dut, peer, addr_type, next_hop_dict): | |
226 | """ | |
227 | This function returns link_local or global next_hop per address-family | |
228 | """ | |
229 | ||
230 | intferface = topo["routers"][peer]["links"]["{}-link1".format(dut)]["interface"] | |
231 | if addr_type == "ipv6" and "link_local" in PREFERRED_NEXT_HOP: | |
232 | next_hop = get_frr_ipv6_linklocal(tgen, peer, intf=intferface) | |
233 | else: | |
234 | next_hop = next_hop_dict[addr_type] | |
235 | ||
236 | return next_hop | |
237 | ||
238 | ||
239 | def test_BGP_GR_chaos_34_1_p1(request): | |
240 | """ | |
241 | Test Objective : Restarting node doesn't preserve forwarding | |
242 | state, helper router should not keep the stale entries. | |
243 | """ | |
244 | ||
245 | tgen = get_topogen() | |
246 | tc_name = request.node.name | |
247 | write_test_header(tc_name) | |
248 | ||
249 | # Check router status | |
250 | check_router_status(tgen) | |
251 | ||
252 | # Don't run this test if we have any failure. | |
253 | if tgen.routers_have_failure(): | |
254 | pytest.skip(tgen.errors) | |
255 | ||
256 | # Creating configuration from JSON | |
257 | reset_config_on_routers(tgen) | |
258 | ||
259 | logger.info( | |
260 | " Test Case : test_BGP_GR_chaos_31 " | |
261 | "BGP GR " | |
262 | "[Restart Mode]R1---R3[Helper Mode]" | |
263 | ) | |
264 | ||
265 | # Configure graceful-restart | |
266 | input_dict = { | |
267 | "r1": { | |
268 | "bgp": { | |
269 | "graceful-restart": { | |
270 | "preserve-fw-state": True, | |
271 | "timer": {"restart-time": GR_RESTART_TIMER}, | |
272 | }, | |
273 | "address_family": { | |
274 | "ipv4": { | |
275 | "unicast": { | |
276 | "neighbor": { | |
277 | "r3": {"dest_link": {"r1": {"graceful-restart": True}}} | |
278 | } | |
279 | } | |
280 | }, | |
281 | "ipv6": { | |
282 | "unicast": { | |
283 | "neighbor": { | |
284 | "r3": {"dest_link": {"r1": {"graceful-restart": True}}} | |
285 | } | |
286 | } | |
287 | }, | |
288 | }, | |
289 | } | |
290 | }, | |
291 | "r3": { | |
292 | "bgp": { | |
293 | "address_family": { | |
294 | "ipv4": { | |
295 | "unicast": { | |
296 | "neighbor": { | |
297 | "r1": { | |
298 | "dest_link": { | |
299 | "r3": {"graceful-restart-helper": True} | |
300 | } | |
301 | } | |
302 | } | |
303 | } | |
304 | }, | |
305 | "ipv6": { | |
306 | "unicast": { | |
307 | "neighbor": { | |
308 | "r1": { | |
309 | "dest_link": { | |
310 | "r3": {"graceful-restart-helper": True} | |
311 | } | |
312 | } | |
313 | } | |
314 | } | |
315 | }, | |
316 | } | |
317 | } | |
318 | }, | |
319 | } | |
320 | ||
321 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r3") | |
322 | ||
323 | for addr_type in ADDR_TYPES: | |
324 | result = verify_graceful_restart( | |
325 | tgen, topo, addr_type, input_dict, dut="r1", peer="r3" | |
326 | ) | |
327 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
328 | tc_name, result | |
329 | ) | |
330 | ||
331 | # Verifying BGP RIB routes after starting BGPd daemon | |
332 | dut = "r3" | |
333 | input_dict_1 = {key: topo["routers"][key] for key in ["r1"]} | |
334 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1) | |
335 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
336 | tc_name, result | |
337 | ) | |
338 | ||
339 | # Verifying RIB routes | |
340 | result = verify_rib(tgen, addr_type, dut, input_dict_1) | |
341 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
342 | tc_name, result | |
343 | ) | |
344 | ||
345 | logger.info( | |
346 | "[Step 1] : Remove the preserve-fw-state command" | |
347 | " from restarting node R1's config" | |
348 | ) | |
349 | ||
350 | # Configure graceful-restart to set f-bit as False | |
351 | input_dict_2 = {"r1": {"bgp": {"graceful-restart": {"preserve-fw-state": False}}}} | |
352 | ||
353 | result = create_router_bgp(tgen, topo, input_dict_2) | |
354 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
355 | ||
356 | logger.info("[Step 2] : Reset the session between R1 and R3..") | |
357 | ||
358 | # Reset sessions | |
359 | for addr_type in ADDR_TYPES: | |
360 | clear_bgp(tgen, addr_type, "r1") | |
361 | ||
362 | result = verify_bgp_convergence_from_running_config(tgen, topo) | |
363 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
364 | ||
365 | for addr_type in ADDR_TYPES: | |
366 | # Verify f-bit after starting BGPd daemon | |
367 | result = verify_f_bit( | |
368 | tgen, topo, addr_type, input_dict_2, "r3", "r1", expected=False | |
369 | ) | |
d63c7094 KK |
370 | assert result is not True, ( |
371 | "Testcase {} : Failed \n " | |
372 | "Expected: F-bit should not be set to True in r3\n" | |
373 | "Found: {}".format(tc_name, result) | |
b0449478 | 374 | ) |
b0449478 DS |
375 | |
376 | logger.info("[Step 3] : Kill BGPd daemon on R1..") | |
377 | ||
378 | # Kill BGPd daemon on R1 | |
379 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
380 | ||
381 | # Waiting for GR_RESTART_TIMER | |
382 | logger.info("Waiting for {} sec..".format(GR_RESTART_TIMER)) | |
383 | sleep(GR_RESTART_TIMER) | |
384 | ||
385 | for addr_type in ADDR_TYPES: | |
386 | # Verifying BGP RIB routes | |
387 | input_dict = {key: topo["routers"][key] for key in ["r1"]} | |
388 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict, expected=False) | |
389 | assert result is not True, ( | |
390 | "Testcase {} : Failed \n " | |
d63c7094 KK |
391 | "Expected: Routes should not be present in {} BGP RIB \n " |
392 | "Found: {}".format(tc_name, dut, result) | |
b0449478 | 393 | ) |
b0449478 DS |
394 | |
395 | # Verifying RIB routes | |
396 | result = verify_rib(tgen, addr_type, dut, input_dict, expected=False) | |
397 | assert result is not True, ( | |
398 | "Testcase {} : Failed \n " | |
d63c7094 KK |
399 | "Expected: Routes should not be present in {} FIB \n " |
400 | "Found: {}".format(tc_name, dut, result) | |
b0449478 | 401 | ) |
b0449478 DS |
402 | |
403 | # Start BGPd daemon on R1 | |
404 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
405 | ||
406 | write_test_footer(tc_name) | |
407 | ||
408 | ||
409 | def test_BGP_GR_chaos_32_p1(request): | |
410 | """ | |
411 | Test Objective : Restarting node is connected to multiple helper | |
412 | nodes, one of them doesn't send EOR to restarting router. Verify | |
413 | that only after SDT restarting node send EOR to all helper peers | |
414 | excluding the prefixes originated by faulty router. | |
415 | """ | |
416 | ||
417 | tgen = get_topogen() | |
418 | tc_name = request.node.name | |
419 | write_test_header(tc_name) | |
420 | ||
421 | # Check router status | |
422 | check_router_status(tgen) | |
423 | ||
424 | # Don't run this test if we have any failure. | |
425 | if tgen.routers_have_failure(): | |
426 | pytest.skip(tgen.errors) | |
427 | ||
428 | # Creating configuration from JSON | |
429 | reset_config_on_routers(tgen) | |
430 | ||
431 | logger.info( | |
432 | " Test Case : test_BGP_GR_chaos_32 " | |
433 | "BGP GR " | |
434 | "[Restart Mode]R1---R3&R5[Helper Mode]" | |
435 | ) | |
436 | ||
437 | logger.info( | |
438 | "[Step 1] : Change the mode on R1 be a restarting" " node on global level" | |
439 | ) | |
440 | ||
441 | # Configure graceful-restart | |
442 | input_dict = { | |
443 | "r1": { | |
444 | "bgp": { | |
445 | "graceful-restart": {"graceful-restart": True}, | |
446 | "address_family": { | |
447 | "ipv4": { | |
448 | "unicast": { | |
449 | "neighbor": { | |
450 | "r3": {"dest_link": {"r1": {"next_hop_self": True}}}, | |
451 | "r5": {"dest_link": {"r1": {"graceful-restart": True}}}, | |
452 | } | |
453 | } | |
454 | }, | |
455 | "ipv6": { | |
456 | "unicast": { | |
457 | "neighbor": { | |
458 | "r3": {"dest_link": {"r1": {"next_hop_self": True}}}, | |
459 | "r5": {"dest_link": {"r1": {"graceful-restart": True}}}, | |
460 | } | |
461 | } | |
462 | }, | |
463 | }, | |
464 | } | |
465 | }, | |
466 | "r5": { | |
467 | "bgp": { | |
468 | "address_family": { | |
469 | "ipv4": { | |
470 | "unicast": { | |
471 | "neighbor": { | |
472 | "r1": { | |
473 | "dest_link": { | |
474 | "r5": {"graceful-restart-helper": True} | |
475 | } | |
476 | } | |
477 | } | |
478 | } | |
479 | }, | |
480 | "ipv6": { | |
481 | "unicast": { | |
482 | "neighbor": { | |
483 | "r1": { | |
484 | "dest_link": { | |
485 | "r5": {"graceful-restart-helper": True} | |
486 | } | |
487 | } | |
488 | } | |
489 | } | |
490 | }, | |
491 | } | |
492 | } | |
493 | }, | |
494 | } | |
495 | ||
496 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r5") | |
497 | ||
498 | for addr_type in ADDR_TYPES: | |
499 | result = verify_graceful_restart( | |
500 | tgen, topo, addr_type, input_dict, dut="r1", peer="r5" | |
501 | ) | |
502 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
503 | tc_name, result | |
504 | ) | |
505 | ||
506 | # Verifying BGP RIB routes after starting BGPd daemon | |
507 | dut = "r3" | |
508 | input_dict_1 = {key: topo["routers"][key] for key in ["r5"]} | |
509 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1) | |
510 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
511 | tc_name, result | |
512 | ) | |
513 | ||
514 | # Verifying RIB routes | |
515 | result = verify_rib(tgen, addr_type, dut, input_dict_1) | |
516 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
517 | tc_name, result | |
518 | ) | |
519 | ||
520 | logger.info("[Step 2] : Kill BGPd daemon on R1..") | |
521 | # Kill BGPd daemon on R1 | |
522 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
523 | ||
524 | logger.info("[Step 3] : Withdraw all the advertised prefixes from R5") | |
525 | ||
526 | # Api call to delete advertised networks | |
527 | network = {"ipv4": "105.0.20.1/32", "ipv6": "5::1/128"} | |
528 | for addr_type in ADDR_TYPES: | |
529 | input_dict_2 = { | |
530 | "r5": { | |
531 | "bgp": { | |
532 | "address_family": { | |
533 | addr_type: { | |
534 | "unicast": { | |
535 | "advertise_networks": [ | |
536 | { | |
537 | "network": network[addr_type], | |
538 | "no_of_network": 5, | |
539 | "delete": True, | |
540 | } | |
541 | ] | |
542 | } | |
543 | } | |
544 | } | |
545 | } | |
546 | } | |
547 | } | |
548 | ||
549 | result = create_router_bgp(tgen, topo, input_dict_2) | |
550 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
551 | tc_name, result | |
552 | ) | |
553 | ||
554 | logger.info( | |
555 | "[Step 4] : Stop the helper router R5 from sending EOR" " message using CLI" | |
556 | ) | |
557 | ||
558 | # Modify graceful-restart config to prevent sending EOR | |
559 | input_dict_3 = {"r5": {"bgp": {"graceful-restart": {"disable-eor": True}}}} | |
560 | ||
561 | result = create_router_bgp(tgen, topo, input_dict_3) | |
562 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
563 | ||
564 | logger.info("[Step 5] : Bring up the BGPd daemon on R1..") | |
565 | ||
566 | # Start BGPd daemon on R1 | |
567 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
568 | ||
569 | for addr_type in ADDR_TYPES: | |
570 | # Verify EOR is disabled | |
571 | result = verify_eor( | |
572 | tgen, topo, addr_type, input_dict_3, dut="r5", peer="r1", expected=False | |
573 | ) | |
d63c7094 KK |
574 | assert result is not True, ( |
575 | "Testcase {} : Failed \n " | |
576 | "Expected: EOR should not be set to True in r5\n" | |
577 | "Found: {}".format(tc_name, result) | |
b0449478 | 578 | ) |
b0449478 DS |
579 | |
580 | # Verifying BGP RIB routes after starting BGPd daemon | |
581 | input_dict_1 = {key: topo["routers"][key] for key in ["r5"]} | |
582 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1, expected=False) | |
583 | assert result is not True, ( | |
584 | "Testcase {} : Failed \n " | |
d63c7094 KK |
585 | "Expected: Routes should not be present in {} BGP RIB \n " |
586 | "Found: {}".format(tc_name, dut, result) | |
b0449478 | 587 | ) |
b0449478 DS |
588 | |
589 | # Verifying RIB routes | |
590 | result = verify_rib(tgen, addr_type, dut, input_dict_1, expected=False) | |
591 | assert result is not True, ( | |
592 | "Testcase {} : Failed \n " | |
d63c7094 KK |
593 | "Expected: Routes should not be present in {} FIB \n " |
594 | "Found: {}".format(tc_name, dut, result) | |
b0449478 | 595 | ) |
b0449478 DS |
596 | |
597 | write_test_footer(tc_name) | |
598 | ||
599 | ||
600 | def test_BGP_GR_chaos_37_p1(request): | |
601 | """ | |
602 | Test Objective : Verify if helper node restarts before sending the | |
603 | EOR message, restarting node doesn't wait until stale path timer | |
604 | expiry to do the best path selection and sends an EOR | |
605 | """ | |
606 | ||
607 | tgen = get_topogen() | |
608 | tc_name = request.node.name | |
609 | write_test_header(tc_name) | |
610 | ||
611 | # Check router status | |
612 | check_router_status(tgen) | |
613 | ||
614 | # Don't run this test if we have any failure. | |
615 | if tgen.routers_have_failure(): | |
616 | pytest.skip(tgen.errors) | |
617 | ||
618 | # Creating configuration from JSON | |
619 | reset_config_on_routers(tgen) | |
620 | ||
621 | logger.info( | |
622 | " Test Case : test_BGP_GR_chaos_37 " | |
623 | "BGP GR " | |
624 | "[Restart Mode]R1---R3[Helper Mode]" | |
625 | ) | |
626 | ||
627 | logger.info( | |
628 | "[Step 1] : Configure restarting router R3 to prevent " "sending an EOR.." | |
629 | ) | |
630 | ||
631 | logger.info("[Step 2] : Reset the session between R3 and R1..") | |
632 | ||
633 | # Configure graceful-restart | |
634 | input_dict = { | |
635 | "r1": { | |
636 | "bgp": { | |
637 | "address_family": { | |
638 | "ipv4": { | |
639 | "unicast": { | |
640 | "neighbor": { | |
641 | "r3": {"dest_link": {"r1": {"graceful-restart": True}}} | |
642 | } | |
643 | } | |
644 | }, | |
645 | "ipv6": { | |
646 | "unicast": { | |
647 | "neighbor": { | |
648 | "r3": {"dest_link": {"r1": {"graceful-restart": True}}} | |
649 | } | |
650 | } | |
651 | }, | |
652 | } | |
653 | } | |
654 | }, | |
655 | "r3": { | |
656 | "bgp": { | |
657 | "graceful-restart": {"disable-eor": True}, | |
658 | "address_family": { | |
659 | "ipv4": { | |
660 | "unicast": { | |
661 | "neighbor": { | |
662 | "r1": { | |
663 | "dest_link": { | |
664 | "r3": {"graceful-restart-helper": True} | |
665 | } | |
666 | } | |
667 | } | |
668 | } | |
669 | }, | |
670 | "ipv6": { | |
671 | "unicast": { | |
672 | "neighbor": { | |
673 | "r1": { | |
674 | "dest_link": { | |
675 | "r3": {"graceful-restart-helper": True} | |
676 | } | |
677 | } | |
678 | } | |
679 | } | |
680 | }, | |
681 | }, | |
682 | } | |
683 | }, | |
684 | } | |
685 | ||
686 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r3") | |
687 | ||
688 | for addr_type in ADDR_TYPES: | |
689 | result = verify_graceful_restart( | |
690 | tgen, topo, addr_type, input_dict, dut="r1", peer="r3" | |
691 | ) | |
692 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
693 | tc_name, result | |
694 | ) | |
695 | ||
696 | # Verify EOR is disabled | |
697 | result = verify_eor( | |
698 | tgen, topo, addr_type, input_dict, dut="r3", peer="r1", expected=False | |
699 | ) | |
d63c7094 KK |
700 | assert result is not True, ( |
701 | "Testcase {} : Failed \n " | |
702 | "Expected: EOR should not be set to True in r3\n" | |
703 | "Found: {}".format(tc_name, result) | |
b0449478 | 704 | ) |
b0449478 DS |
705 | |
706 | # Verifying BGP RIB routes after starting BGPd daemon | |
707 | dut = "r1" | |
708 | input_dict_1 = {key: topo["routers"][key] for key in ["r3"]} | |
709 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1) | |
710 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
711 | tc_name, result | |
712 | ) | |
713 | ||
714 | # Verifying RIB routes | |
715 | result = verify_rib(tgen, addr_type, dut, input_dict_1) | |
716 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
717 | tc_name, result | |
718 | ) | |
719 | ||
720 | logger.info("[Step 3] : Kill BGPd daemon on R1..") | |
721 | ||
722 | # Kill BGPd daemon on R1 | |
723 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
724 | ||
725 | logger.info("[Step 4] : Start BGPd daemon on R1..") | |
726 | ||
727 | # Start BGPd daemon on R1 | |
728 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
729 | ||
730 | logger.info("[Step 5] : Kill BGPd daemon on R3..") | |
731 | ||
732 | # Kill BGPd daemon on R3 | |
733 | kill_router_daemons(tgen, "r3", ["bgpd"]) | |
734 | ||
735 | # Modify graceful-restart config to prevent sending EOR | |
736 | input_dict_2 = {"r3": {"bgp": {"graceful-restart": {"disable-eor": True}}}} | |
737 | ||
738 | result = modify_bgp_config_when_bgpd_down(tgen, topo, input_dict_2) | |
739 | assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result) | |
740 | ||
741 | logger.info("[Step 6] : Start BGPd daemon on R3..") | |
742 | ||
743 | # Start BGPd daemon on R3 | |
744 | start_router_daemons(tgen, "r3", ["bgpd"]) | |
745 | ||
746 | for addr_type in ADDR_TYPES: | |
747 | # Verify r_bit | |
748 | result = verify_r_bit(tgen, topo, addr_type, input_dict, dut="r1", peer="r3") | |
749 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
750 | tc_name, result | |
751 | ) | |
752 | ||
753 | # Verifying RIB routes | |
754 | input_dict_1 = {key: topo["routers"][key] for key in ["r3"]} | |
755 | result = verify_rib(tgen, addr_type, dut, input_dict_1) | |
756 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
757 | tc_name, result | |
758 | ) | |
759 | ||
760 | # Verify EOR is send from R1 to R3 | |
761 | input_dict_3 = {"r1": {"bgp": {"graceful-restart": {"disable-eor": True}}}} | |
762 | ||
763 | result = verify_eor( | |
764 | tgen, topo, addr_type, input_dict_3, dut="r1", peer="r3", expected=False | |
765 | ) | |
d63c7094 KK |
766 | assert result is not True, ( |
767 | "Testcase {} : Failed \n " | |
768 | "Expected: EOR should not be set to True in r1\n" | |
769 | "Found: {}".format(tc_name, result) | |
b0449478 DS |
770 | ) |
771 | ||
772 | write_test_footer(tc_name) | |
773 | ||
774 | ||
775 | def test_BGP_GR_chaos_30_p1(request): | |
776 | """ | |
777 | Test Objective : Restarting node removes stale routes from Zebra | |
778 | after receiving an EOR from helper router. | |
779 | """ | |
780 | ||
781 | tgen = get_topogen() | |
782 | tc_name = request.node.name | |
783 | write_test_header(tc_name) | |
784 | ||
785 | # Check router status | |
786 | check_router_status(tgen) | |
787 | ||
788 | # Don't run this test if we have any failure. | |
789 | if tgen.routers_have_failure(): | |
790 | pytest.skip(tgen.errors) | |
791 | ||
792 | # Creating configuration from JSON | |
793 | reset_config_on_routers(tgen) | |
794 | ||
795 | logger.info( | |
796 | " Test Case : test_BGP_GR_chaos_30 " | |
797 | "BGP GR [Helper Mode]R3-----R1[Restart Mode] " | |
798 | ) | |
799 | ||
800 | # Configure graceful-restart and timers | |
801 | input_dict = { | |
802 | "r1": { | |
803 | "bgp": { | |
804 | "graceful-restart": {"preserve-fw-state": True}, | |
805 | "address_family": { | |
806 | "ipv4": { | |
807 | "unicast": { | |
808 | "neighbor": { | |
809 | "r3": {"dest_link": {"r1": {"graceful-restart": True}}} | |
810 | } | |
811 | } | |
812 | }, | |
813 | "ipv6": { | |
814 | "unicast": { | |
815 | "neighbor": { | |
816 | "r3": {"dest_link": {"r1": {"graceful-restart": True}}} | |
817 | } | |
818 | } | |
819 | }, | |
820 | }, | |
821 | } | |
822 | }, | |
823 | "r3": { | |
824 | "bgp": { | |
825 | "address_family": { | |
826 | "ipv4": { | |
827 | "unicast": { | |
828 | "neighbor": { | |
829 | "r1": { | |
830 | "dest_link": { | |
831 | "r3": {"graceful-restart-helper": True} | |
832 | } | |
833 | } | |
834 | } | |
835 | } | |
836 | }, | |
837 | "ipv6": { | |
838 | "unicast": { | |
839 | "neighbor": { | |
840 | "r1": { | |
841 | "dest_link": { | |
842 | "r3": {"graceful-restart-helper": True} | |
843 | } | |
844 | } | |
845 | } | |
846 | } | |
847 | }, | |
848 | } | |
849 | } | |
850 | }, | |
851 | } | |
852 | ||
853 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r3") | |
854 | ||
855 | for addr_type in ADDR_TYPES: | |
856 | result = verify_graceful_restart( | |
857 | tgen, topo, addr_type, input_dict, dut="r1", peer="r3" | |
858 | ) | |
859 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
860 | tc_name, result | |
861 | ) | |
862 | ||
863 | for addr_type in ADDR_TYPES: | |
864 | # Verifying BGP RIB routes before shutting down BGPd daemon | |
865 | dut = "r1" | |
866 | input_dict = {key: topo["routers"][key] for key in ["r3"]} | |
867 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict) | |
868 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
869 | tc_name, result | |
870 | ) | |
871 | ||
872 | # Verifying RIB routes before shutting down BGPd daemon | |
873 | result = verify_rib(tgen, addr_type, dut, input_dict) | |
874 | assert result is True, "Testcase {} : Failed \n Error {}".format( | |
875 | tc_name, result | |
876 | ) | |
877 | ||
878 | logger.info("[Step 2] : Kill BGPd daemon on R1..") | |
879 | ||
880 | # Kill BGPd daemon on R1 | |
881 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
882 | ||
883 | logger.info("[Step 3] : Withdraw advertised prefixes from R3...") | |
884 | ||
885 | # Api call to delete advertised networks | |
886 | network = {"ipv4": "103.0.20.1/32", "ipv6": "3::1/128"} | |
887 | for addr_type in ADDR_TYPES: | |
888 | input_dict = { | |
889 | "r3": { | |
890 | "bgp": { | |
891 | "address_family": { | |
892 | addr_type: { | |
893 | "unicast": { | |
894 | "advertise_networks": [ | |
895 | { | |
896 | "network": network[addr_type], | |
897 | "no_of_network": 5, | |
898 | "delete": True, | |
899 | } | |
900 | ] | |
901 | } | |
902 | } | |
903 | } | |
904 | } | |
905 | } | |
906 | } | |
907 | ||
908 | result = create_router_bgp(tgen, topo, input_dict) | |
909 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
910 | tc_name, result | |
911 | ) | |
912 | ||
913 | logger.info("[Step 4] : Start BGPd daemon on R1..") | |
914 | ||
915 | # Start BGPd daemon on R1 | |
916 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
917 | ||
918 | for addr_type in ADDR_TYPES: | |
919 | # Verifying BGP RIB routes before shutting down BGPd daemon | |
920 | input_dict = {key: topo["routers"][key] for key in ["r3"]} | |
921 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict, expected=False) | |
922 | assert result is not True, ( | |
923 | "Testcase {} : Failed \n " | |
d63c7094 KK |
924 | "Expected: Routes should not be present in {} BGP RIB \n " |
925 | "Found: {}".format(tc_name, dut, result) | |
b0449478 | 926 | ) |
b0449478 DS |
927 | |
928 | # Verifying RIB routes before shutting down BGPd daemon | |
929 | result = verify_rib(tgen, addr_type, dut, input_dict, expected=False) | |
930 | assert result is not True, ( | |
931 | "Testcase {} : Failed \n " | |
d63c7094 KK |
932 | "Expected: Routes should not be present in {} FIB \n " |
933 | "Found: {}".format(tc_name, dut, result) | |
b0449478 | 934 | ) |
b0449478 DS |
935 | |
936 | write_test_footer(tc_name) | |
937 | ||
938 | ||
939 | def test_BGP_GR_15_p2(request): | |
940 | """ | |
941 | Test Objective : Test GR scenarios by enabling Graceful Restart | |
942 | for multiple address families.. | |
943 | """ | |
944 | ||
945 | tgen = get_topogen() | |
946 | tc_name = request.node.name | |
947 | write_test_header(tc_name) | |
948 | ||
949 | # Check router status | |
950 | check_router_status(tgen) | |
951 | ||
952 | # Don't run this test if we have any failure. | |
953 | if tgen.routers_have_failure(): | |
954 | pytest.skip(tgen.errors) | |
955 | ||
956 | # Creating configuration from JSON | |
957 | reset_config_on_routers(tgen) | |
958 | ||
959 | # Configure graceful-restart | |
960 | input_dict = { | |
961 | "r1": { | |
962 | "bgp": { | |
963 | "address_family": { | |
964 | "ipv4": { | |
965 | "unicast": { | |
966 | "neighbor": { | |
967 | "r6": {"dest_link": {"r1": {"graceful-restart": True}}} | |
968 | } | |
969 | } | |
970 | }, | |
971 | "ipv6": { | |
972 | "unicast": { | |
973 | "neighbor": { | |
974 | "r6": {"dest_link": {"r1": {"graceful-restart": True}}} | |
975 | } | |
976 | } | |
977 | }, | |
978 | } | |
979 | } | |
980 | }, | |
981 | "r6": { | |
982 | "bgp": { | |
983 | "address_family": { | |
984 | "ipv4": { | |
985 | "unicast": { | |
986 | "neighbor": { | |
987 | "r1": { | |
988 | "dest_link": { | |
989 | "r6": {"graceful-restart-helper": True} | |
990 | } | |
991 | } | |
992 | } | |
993 | } | |
994 | }, | |
995 | "ipv6": { | |
996 | "unicast": { | |
997 | "neighbor": { | |
998 | "r1": { | |
999 | "dest_link": { | |
1000 | "r6": {"graceful-restart-helper": True} | |
1001 | } | |
1002 | } | |
1003 | } | |
1004 | } | |
1005 | }, | |
1006 | } | |
1007 | } | |
1008 | }, | |
1009 | } | |
1010 | ||
1011 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r6") | |
1012 | ||
1013 | for addr_type in ADDR_TYPES: | |
1014 | result = verify_graceful_restart( | |
1015 | tgen, topo, addr_type, input_dict, dut="r1", peer="r6" | |
1016 | ) | |
1017 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1018 | ||
1019 | logger.info( | |
1020 | "[Step 2] : Test Setup " | |
1021 | "[Helper Mode]R6-----R1[Restart Mode]" | |
3f1f5852 | 1022 | "--------R2[Helper Mode] Initialized" |
b0449478 DS |
1023 | ) |
1024 | ||
1025 | # Configure graceful-restart | |
1026 | input_dict = { | |
1027 | "r1": { | |
1028 | "bgp": { | |
1029 | "address_family": { | |
1030 | "ipv4": { | |
1031 | "unicast": { | |
1032 | "neighbor": { | |
1033 | "r2": {"dest_link": {"r1": {"graceful-restart": True}}} | |
1034 | } | |
1035 | } | |
1036 | }, | |
1037 | "ipv6": { | |
1038 | "unicast": { | |
1039 | "neighbor": { | |
1040 | "r2": {"dest_link": {"r1": {"graceful-restart": True}}} | |
1041 | } | |
1042 | } | |
1043 | }, | |
1044 | } | |
1045 | } | |
1046 | }, | |
1047 | "r2": { | |
1048 | "bgp": { | |
1049 | "address_family": { | |
1050 | "ipv4": { | |
1051 | "unicast": { | |
1052 | "neighbor": { | |
1053 | "r1": { | |
1054 | "dest_link": { | |
1055 | "r2": {"graceful-restart-helper": True} | |
1056 | } | |
1057 | } | |
1058 | } | |
1059 | } | |
1060 | }, | |
1061 | "ipv6": { | |
1062 | "unicast": { | |
1063 | "neighbor": { | |
1064 | "r1": { | |
1065 | "dest_link": { | |
1066 | "r2": {"graceful-restart-helper": True} | |
1067 | } | |
1068 | } | |
1069 | } | |
1070 | } | |
1071 | }, | |
1072 | } | |
1073 | } | |
1074 | }, | |
1075 | } | |
1076 | ||
1077 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r2") | |
1078 | ||
1079 | for addr_type in ADDR_TYPES: | |
1080 | result = verify_graceful_restart( | |
1081 | tgen, topo, addr_type, input_dict, dut="r1", peer="r2" | |
1082 | ) | |
1083 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1084 | ||
1085 | # Verifying BGP RIB routes | |
1086 | dut = "r6" | |
1087 | input_dict_1 = {key: topo["routers"][key] for key in ["r1"]} | |
1088 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1) | |
1089 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1090 | ||
1091 | # Verifying RIB routes before shutting down BGPd daemon | |
1092 | result = verify_rib(tgen, addr_type, dut, input_dict_1) | |
1093 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1094 | ||
1095 | # Verifying BGP RIB routes | |
1096 | dut = "r6" | |
1097 | input_dict_2 = {key: topo["routers"][key] for key in ["r2"]} | |
1098 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2) | |
1099 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1100 | ||
1101 | # Verifying RIB routes before shutting down BGPd daemon | |
1102 | result = verify_rib(tgen, addr_type, dut, input_dict_2) | |
1103 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1104 | ||
1105 | # Kill BGPd daemon on R1 | |
1106 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
1107 | ||
1108 | for addr_type in ADDR_TYPES: | |
1109 | # Verifying BGP RIB routes | |
1110 | dut = "r6" | |
1111 | input_dict_1 = {key: topo["routers"][key] for key in ["r1"]} | |
1112 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1) | |
1113 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1114 | ||
1115 | # Verifying RIB routes before shutting down BGPd daemon | |
1116 | result = verify_rib(tgen, addr_type, dut, input_dict_1) | |
1117 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1118 | ||
1119 | # Verifying BGP RIB routes | |
1120 | dut = "r6" | |
1121 | input_dict_2 = {key: topo["routers"][key] for key in ["r2"]} | |
1122 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2) | |
1123 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1124 | ||
1125 | # Verifying RIB routes before shutting down BGPd daemon | |
1126 | result = verify_rib(tgen, addr_type, dut, input_dict_2) | |
1127 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1128 | ||
1129 | # Start BGPd daemon on R1 | |
1130 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
1131 | ||
1132 | for addr_type in ADDR_TYPES: | |
1133 | result = verify_bgp_convergence(tgen, topo) | |
1134 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1135 | ||
1136 | # Verifying BGP RIB routes | |
1137 | dut = "r6" | |
1138 | input_dict_1 = {key: topo["routers"][key] for key in ["r1"]} | |
1139 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1) | |
1140 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1141 | ||
1142 | # Verifying RIB routes before shutting down BGPd daemon | |
1143 | result = verify_rib(tgen, addr_type, dut, input_dict_1) | |
1144 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1145 | ||
1146 | # Verifying BGP RIB routes | |
1147 | dut = "r6" | |
1148 | input_dict_2 = {key: topo["routers"][key] for key in ["r2"]} | |
1149 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_2) | |
1150 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1151 | ||
1152 | # Verifying RIB routes before shutting down BGPd daemon | |
1153 | result = verify_rib(tgen, addr_type, dut, input_dict_2) | |
1154 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1155 | ||
1156 | write_test_footer(tc_name) | |
1157 | ||
1158 | ||
1159 | def BGP_GR_TC_7_p1(request): | |
1160 | """ | |
1161 | Verify that BGP restarting node deletes all the routes received from peer | |
1162 | if BGP Graceful capability is not present in BGP Open message from the | |
1163 | peer | |
1164 | """ | |
1165 | ||
1166 | tgen = get_topogen() | |
1167 | tc_name = request.node.name | |
1168 | write_test_header(tc_name) | |
1169 | ||
1170 | # Check router status | |
1171 | check_router_status(tgen) | |
1172 | ||
1173 | # Don't run this test if we have any failure. | |
1174 | if tgen.routers_have_failure(): | |
1175 | pytest.skip(tgen.errors) | |
1176 | ||
1177 | # Creating configuration from JSON | |
1178 | reset_config_on_routers(tgen) | |
1179 | ||
1180 | logger.info( | |
1181 | " Verify route download to RIB: BGP_GR_TC_7 >> " | |
1182 | "BGP GR [Helper Mode]R3-----R1[Restart Mode] " | |
1183 | ) | |
1184 | ||
1185 | # Configure graceful-restart | |
1186 | input_dict = { | |
1187 | "r3": { | |
1188 | "bgp": { | |
1189 | "address_family": { | |
1190 | "ipv4": { | |
1191 | "unicast": { | |
1192 | "neighbor": { | |
1193 | "r1": { | |
1194 | "dest_link": { | |
1195 | "r3": {"graceful-restart-helper": True} | |
1196 | } | |
1197 | } | |
1198 | } | |
1199 | } | |
1200 | }, | |
1201 | "ipv6": { | |
1202 | "unicast": { | |
1203 | "neighbor": { | |
1204 | "r1": { | |
1205 | "dest_link": { | |
1206 | "r3": {"graceful-restart-helper": True} | |
1207 | } | |
1208 | } | |
1209 | } | |
1210 | } | |
1211 | }, | |
1212 | } | |
1213 | } | |
1214 | }, | |
1215 | "r1": { | |
1216 | "bgp": { | |
1217 | "graceful-restart": { | |
1218 | "graceful-restart": True, | |
1219 | "preserve-fw-state": True, | |
1220 | }, | |
1221 | "address_family": { | |
1222 | "ipv4": { | |
1223 | "unicast": { | |
1224 | "neighbor": { | |
1225 | "r3": {"dest_link": {"r1": {"graceful-restart": True}}} | |
1226 | } | |
1227 | } | |
1228 | }, | |
1229 | "ipv6": { | |
1230 | "unicast": { | |
1231 | "neighbor": { | |
1232 | "r3": {"dest_link": {"r1": {"graceful-restart": True}}} | |
1233 | } | |
1234 | } | |
1235 | }, | |
1236 | }, | |
1237 | } | |
1238 | }, | |
1239 | } | |
1240 | ||
1241 | configure_gr_followed_by_clear(tgen, topo, input_dict, tc_name, dut="r1", peer="r3") | |
1242 | ||
1243 | for addr_type in ADDR_TYPES: | |
1244 | result = verify_graceful_restart( | |
1245 | tgen, topo, addr_type, input_dict, dut="r1", peer="r3" | |
1246 | ) | |
1247 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1248 | ||
1249 | # Verifying BGP RIB routes received from router R1 | |
1250 | dut = "r1" | |
1251 | input_dict_1 = {key: topo["routers"][key] for key in ["r3"]} | |
1252 | result = verify_bgp_rib(tgen, addr_type, dut, input_dict_1) | |
1253 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1254 | ||
1255 | # Verifying RIB routes | |
1256 | result = verify_rib(tgen, addr_type, dut, input_dict_1) | |
1257 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1258 | ||
1259 | logger.info("R1 goes for reload") | |
1260 | kill_router_daemons(tgen, "r1", ["bgpd"]) | |
1261 | ||
1262 | # Change the configuration on router R1 | |
1263 | input_dict_2 = { | |
1264 | "r3": { | |
1265 | "bgp": { | |
1266 | "address_family": { | |
1267 | "ipv4": { | |
1268 | "unicast": { | |
1269 | "neighbor": { | |
1270 | "r1": { | |
1271 | "dest_link": { | |
1272 | "r3": {"graceful-restart-disable": True} | |
1273 | } | |
1274 | } | |
1275 | } | |
1276 | } | |
1277 | }, | |
1278 | "ipv6": { | |
1279 | "unicast": { | |
1280 | "neighbor": { | |
1281 | "r1": { | |
1282 | "dest_link": { | |
1283 | "r3": {"graceful-restart-disable": True} | |
1284 | } | |
1285 | } | |
1286 | } | |
1287 | } | |
1288 | }, | |
1289 | } | |
1290 | } | |
1291 | } | |
1292 | } | |
1293 | ||
1294 | result = create_router_bgp(tgen, topo, input_dict_2) | |
1295 | assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) | |
1296 | ||
1297 | # Change the configuration on R1 | |
1298 | network = {"ipv4": "103.0.20.1/32", "ipv6": "3::1/128"} | |
1299 | for addr_type in ADDR_TYPES: | |
1300 | input_dict_2 = { | |
1301 | "r3": { | |
1302 | "bgp": { | |
1303 | "address_family": { | |
1304 | addr_type: { | |
1305 | "unicast": { | |
1306 | "advertise_networks": [ | |
1307 | { | |
1308 | "network": network[addr_type], | |
1309 | "no_of_network": 5, | |
1310 | "delete": True, | |
1311 | } | |
1312 | ] | |
1313 | } | |
1314 | } | |
1315 | } | |
1316 | } | |
1317 | } | |
1318 | } | |
1319 | ||
1320 | result = create_router_bgp(tgen, topo, input_dict_2) | |
1321 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1322 | ||
1323 | logger.info("R1 is about to come up now") | |
1324 | start_router_daemons(tgen, "r1", ["bgpd"]) | |
1325 | logger.info("R1 is UP Now") | |
1326 | ||
1327 | # Wait for RIB stale timeout | |
1328 | logger.info("Verify routes are not present" "in restart router") | |
1329 | ||
1330 | for addr_type in ADDR_TYPES: | |
1331 | # Verifying RIB routes | |
1332 | dut = "r1" | |
1333 | input_dict_1 = {key: topo["routers"][key] for key in ["r3"]} | |
1334 | result = verify_rib(tgen, addr_type, dut, input_dict_1, expected=False) | |
1335 | assert result is not True, ( | |
1336 | "Testcase {} : Failed \n " | |
d63c7094 KK |
1337 | "Expected: Routes should not be present in {} FIB \n " |
1338 | "Found: {}".format(tc_name, dut, result) | |
b0449478 DS |
1339 | ) |
1340 | ||
1341 | write_test_footer(tc_name) | |
1342 | ||
1343 | ||
1344 | if __name__ == "__main__": | |
1345 | args = ["-s"] + sys.argv[1:] | |
1346 | sys.exit(pytest.main(args)) |