]>
Commit | Line | Data |
---|---|---|
468b867f KK |
1 | #!/usr/bin/env python |
2 | ||
3 | # | |
4 | # Copyright (c) 2019 by VMware, Inc. ("VMware") | |
5 | # Used Copyright (c) 2018 by Network Device Education Foundation, | |
6 | # Inc. ("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 | ||
468b867f | 23 | import sys |
468b867f KK |
24 | import time |
25 | import pytest | |
468b867f | 26 | import os |
468b867f KK |
27 | |
28 | # Save the Current Working Directory to find configuration files. | |
29 | CWD = os.path.dirname(os.path.realpath(__file__)) | |
b9f80297 | 30 | sys.path.append(os.path.join(CWD, "../")) |
468b867f KK |
31 | |
32 | # pylint: disable=C0413 | |
33 | # Import topogen and topotest helpers | |
468b867f | 34 | from lib.topogen import Topogen, get_topogen |
468b867f KK |
35 | |
36 | # Required to instantiate the topology builder class. | |
468b867f | 37 | from lib.common_config import ( |
787e7624 | 38 | start_topology, |
39 | write_test_header, | |
40 | write_test_footer, | |
787e7624 | 41 | verify_rib, |
787e7624 | 42 | create_route_maps, |
25b43d56 | 43 | create_static_routes, |
787e7624 | 44 | create_prefix_lists, |
787e7624 | 45 | check_address_types, |
787e7624 | 46 | reset_config_on_routers, |
47 | ) | |
468b867f KK |
48 | from lib.topolog import logger |
49 | from lib.bgp import ( | |
787e7624 | 50 | verify_bgp_convergence, |
51 | create_router_bgp, | |
787e7624 | 52 | verify_bgp_attributes, |
53 | ) | |
4953ca97 | 54 | from lib.topojson import build_config_from_json |
468b867f | 55 | |
bf3a0a9a DS |
56 | pytestmark = [pytest.mark.bgpd, pytest.mark.staticd] |
57 | ||
58 | ||
25b43d56 KK |
59 | ################################# |
60 | # TOPOLOGY | |
61 | ################################# | |
62 | """ | |
63 | ||
64 | +-------+ | |
65 | +------- | R2 | | |
66 | | +-------+ | |
67 | | | | |
68 | +-------+ | | |
69 | | R1 | | | |
70 | +-------+ | | |
71 | | | | |
72 | | +-------+ +-------+ | |
73 | +---------- | R3 |----------| R4 | | |
74 | +-------+ +-------+ | |
75 | ||
76 | """ | |
77 | ||
78 | ################################# | |
79 | # TEST SUMMARY | |
80 | ################################# | |
81 | """ | |
82 | Following tests are covered to test route-map functionality: | |
83 | TC_34: | |
84 | Verify if route-maps is applied in both inbound and | |
85 | outbound direction to same neighbor/interface. | |
86 | TC_36: | |
87 | Test permit/deny statements operation in route-maps with a | |
88 | permutation and combination of permit/deny in prefix-lists | |
89 | TC_35: | |
90 | Test multiple sequence numbers in a single route-map for different | |
91 | match/set clauses. | |
92 | TC_37: | |
93 | Test add/remove route-maps with multiple set | |
94 | clauses and without any match statement.(Set only) | |
95 | TC_38: | |
96 | Test add/remove route-maps with multiple match | |
97 | clauses and without any set statement.(Match only) | |
98 | """ | |
468b867f KK |
99 | |
100 | # Global variables | |
101 | bgp_convergence = False | |
102 | BGP_CONVERGENCE = False | |
103 | ADDR_TYPES = check_address_types() | |
468b867f KK |
104 | |
105 | # Global variables | |
106 | bgp_convergence = False | |
787e7624 | 107 | NETWORK = {"ipv4": ["11.0.20.1/32", "20.0.20.1/32"], "ipv6": ["1::1/128", "2::1/128"]} |
468b867f | 108 | MASK = {"ipv4": "32", "ipv6": "128"} |
787e7624 | 109 | NEXT_HOP = {"ipv4": "10.0.0.2", "ipv6": "fd00::2"} |
468b867f KK |
110 | ADDR_TYPES = check_address_types() |
111 | ||
112 | ||
468b867f KK |
113 | def setup_module(mod): |
114 | """ | |
115 | Sets up the pytest environment | |
116 | ||
117 | * `mod`: module name | |
118 | """ | |
119 | global ADDR_TYPES | |
120 | testsuite_run_time = time.asctime(time.localtime(time.time())) | |
121 | logger.info("Testsuite start time: {}".format(testsuite_run_time)) | |
122 | logger.info("=" * 40) | |
123 | ||
124 | logger.info("Running setup_module to create topology") | |
125 | ||
126 | # This function initiates the topology build with Topogen... | |
e82b531d CH |
127 | json_file = "{}/bgp_route_map_topo1.json".format(CWD) |
128 | tgen = Topogen(json_file, mod.__name__) | |
129 | global topo | |
130 | topo = tgen.json_topo | |
468b867f KK |
131 | # ... and here it calls Mininet initialization functions. |
132 | ||
133 | # Starting topology, create tmp files which are loaded to routers | |
134 | # to start deamons and then start routers | |
135 | start_topology(tgen) | |
136 | ||
137 | # Creating configuration from JSON | |
138 | build_config_from_json(tgen, topo) | |
139 | ||
140 | # Checking BGP convergence | |
141 | global bgp_convergence | |
142 | ||
143 | # Don"t run this test if we have any failure. | |
144 | if tgen.routers_have_failure(): | |
145 | pytest.skip(tgen.errors) | |
146 | ||
147 | # Api call verify whether BGP is converged | |
148 | bgp_convergence = verify_bgp_convergence(tgen, topo) | |
787e7624 | 149 | assert bgp_convergence is True, "setup_module :Failed \n Error:" " {}".format( |
150 | bgp_convergence | |
151 | ) | |
468b867f KK |
152 | |
153 | logger.info("Running setup_module() done") | |
154 | ||
155 | ||
156 | def teardown_module(): | |
157 | """ | |
158 | Teardown the pytest environment | |
159 | ||
160 | * `mod`: module name | |
161 | """ | |
162 | ||
163 | logger.info("Running teardown_module to delete topology") | |
164 | ||
165 | tgen = get_topogen() | |
166 | ||
167 | # Stop toplogy and Remove tmp files | |
168 | tgen.stop_topology() | |
169 | ||
787e7624 | 170 | logger.info( |
171 | "Testsuite end time: {}".format(time.asctime(time.localtime(time.time()))) | |
172 | ) | |
468b867f KK |
173 | logger.info("=" * 40) |
174 | ||
175 | ||
176 | def test_route_map_inbound_outbound_same_neighbor_p0(request): | |
177 | """ | |
178 | TC_34: | |
179 | Verify if route-maps is applied in both inbound and | |
180 | outbound direction to same neighbor/interface. | |
181 | """ | |
182 | ||
183 | tc_name = request.node.name | |
184 | write_test_header(tc_name) | |
185 | tgen = get_topogen() | |
186 | ||
187 | # Don"t run this test if we have any failure. | |
188 | if tgen.routers_have_failure(): | |
189 | pytest.skip(tgen.errors) | |
190 | ||
191 | # Creating configuration from JSON | |
192 | reset_config_on_routers(tgen) | |
193 | ||
194 | for adt in ADDR_TYPES: | |
195 | ||
196 | # Create Static routes | |
197 | input_dict = { | |
198 | "r1": { | |
199 | "static_routes": [ | |
200 | { | |
201 | "network": NETWORK[adt][0], | |
202 | "no_of_ip": 9, | |
203 | "next_hop": NEXT_HOP[adt], | |
204 | } | |
205 | ] | |
206 | } | |
207 | } | |
208 | ||
209 | result = create_static_routes(tgen, input_dict) | |
210 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 211 | tc_name, result |
212 | ) | |
468b867f KK |
213 | |
214 | # Api call to redistribute static routes | |
215 | input_dict_1 = { | |
216 | "r1": { | |
217 | "bgp": { | |
218 | "local_as": 100, | |
219 | "address_family": { | |
220 | "ipv4": { | |
221 | "unicast": { | |
222 | "redistribute": [ | |
223 | {"redist_type": "static"}, | |
787e7624 | 224 | {"redist_type": "connected"}, |
468b867f KK |
225 | ] |
226 | } | |
227 | }, | |
228 | "ipv6": { | |
229 | "unicast": { | |
230 | "redistribute": [ | |
231 | {"redist_type": "static"}, | |
787e7624 | 232 | {"redist_type": "connected"}, |
468b867f KK |
233 | ] |
234 | } | |
787e7624 | 235 | }, |
236 | }, | |
468b867f KK |
237 | } |
238 | } | |
239 | } | |
240 | ||
241 | result = create_router_bgp(tgen, topo, input_dict_1) | |
242 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 243 | tc_name, result |
244 | ) | |
468b867f KK |
245 | |
246 | input_dict_2 = { | |
247 | "r4": { | |
248 | "static_routes": [ | |
249 | { | |
250 | "network": NETWORK[adt][1], | |
251 | "no_of_ip": 9, | |
252 | "next_hop": NEXT_HOP[adt], | |
253 | } | |
254 | ] | |
255 | } | |
256 | } | |
257 | ||
258 | result = create_static_routes(tgen, input_dict_2) | |
259 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 260 | tc_name, result |
261 | ) | |
468b867f KK |
262 | |
263 | # Api call to redistribute static routes | |
264 | input_dict_5 = { | |
265 | "r1": { | |
266 | "bgp": { | |
267 | "address_family": { | |
268 | "ipv4": { | |
269 | "unicast": { | |
270 | "redistribute": [ | |
271 | {"redist_type": "static"}, | |
787e7624 | 272 | {"redist_type": "connected"}, |
468b867f KK |
273 | ] |
274 | } | |
275 | }, | |
276 | "ipv6": { | |
277 | "unicast": { | |
278 | "redistribute": [ | |
279 | {"redist_type": "static"}, | |
787e7624 | 280 | {"redist_type": "connected"}, |
468b867f KK |
281 | ] |
282 | } | |
787e7624 | 283 | }, |
468b867f KK |
284 | } |
285 | } | |
286 | } | |
287 | } | |
288 | result = create_router_bgp(tgen, topo, input_dict_5) | |
289 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 290 | tc_name, result |
291 | ) | |
468b867f KK |
292 | |
293 | input_dict_2 = { | |
294 | "r3": { | |
295 | "prefix_lists": { | |
296 | "ipv4": { | |
787e7624 | 297 | "pf_list_1_ipv4": [ |
298 | { | |
299 | "seqid": 10, | |
300 | "action": "permit", | |
301 | "network": NETWORK["ipv4"][0], | |
302 | } | |
303 | ], | |
304 | "pf_list_2_ipv4": [ | |
305 | { | |
306 | "seqid": 10, | |
307 | "action": "permit", | |
308 | "network": NETWORK["ipv4"][1], | |
309 | } | |
310 | ], | |
468b867f KK |
311 | }, |
312 | "ipv6": { | |
787e7624 | 313 | "pf_list_1_ipv6": [ |
314 | { | |
315 | "seqid": 100, | |
316 | "action": "permit", | |
317 | "network": NETWORK["ipv6"][0], | |
318 | } | |
319 | ], | |
320 | "pf_list_2_ipv6": [ | |
321 | { | |
322 | "seqid": 100, | |
323 | "action": "permit", | |
324 | "network": NETWORK["ipv6"][1], | |
325 | } | |
326 | ], | |
327 | }, | |
468b867f KK |
328 | } |
329 | } | |
330 | } | |
331 | result = create_prefix_lists(tgen, input_dict_2) | |
332 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 333 | tc_name, result |
334 | ) | |
468b867f KK |
335 | |
336 | # Create route map | |
337 | for addr_type in ADDR_TYPES: | |
338 | input_dict_6 = { | |
787e7624 | 339 | "r3": { |
340 | "route_maps": { | |
341 | "rmap_match_tag_1_{}".format(addr_type): [ | |
342 | { | |
343 | "action": "deny", | |
344 | "match": { | |
345 | addr_type: { | |
346 | "prefix_lists": "pf_list_1_{}".format(addr_type) | |
347 | } | |
348 | }, | |
468b867f | 349 | } |
787e7624 | 350 | ], |
351 | "rmap_match_tag_2_{}".format(addr_type): [ | |
352 | { | |
353 | "action": "permit", | |
354 | "match": { | |
355 | addr_type: { | |
356 | "prefix_lists": "pf_list_2_{}".format(addr_type) | |
357 | } | |
358 | }, | |
468b867f | 359 | } |
787e7624 | 360 | ], |
361 | } | |
468b867f KK |
362 | } |
363 | } | |
468b867f KK |
364 | result = create_route_maps(tgen, input_dict_6) |
365 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 366 | tc_name, result |
367 | ) | |
468b867f KK |
368 | |
369 | # Configure neighbor for route map | |
370 | input_dict_7 = { | |
371 | "r3": { | |
372 | "bgp": { | |
373 | "address_family": { | |
374 | "ipv4": { | |
375 | "unicast": { | |
376 | "neighbor": { | |
377 | "r4": { | |
378 | "dest_link": { | |
379 | "r3": { | |
380 | "route_maps": [ | |
787e7624 | 381 | { |
382 | "name": "rmap_match_tag_1_ipv4", | |
383 | "direction": "in", | |
384 | }, | |
385 | { | |
386 | "name": "rmap_match_tag_1_ipv4", | |
387 | "direction": "out", | |
388 | }, | |
468b867f KK |
389 | ] |
390 | } | |
391 | } | |
392 | } | |
393 | } | |
394 | } | |
395 | }, | |
396 | "ipv6": { | |
397 | "unicast": { | |
398 | "neighbor": { | |
399 | "r4": { | |
400 | "dest_link": { | |
401 | "r3": { | |
402 | "route_maps": [ | |
787e7624 | 403 | { |
404 | "name": "rmap_match_tag_1_ipv6", | |
405 | "direction": "in", | |
406 | }, | |
407 | { | |
408 | "name": "rmap_match_tag_1_ipv6", | |
409 | "direction": "out", | |
410 | }, | |
468b867f KK |
411 | ] |
412 | } | |
413 | } | |
414 | } | |
415 | } | |
416 | } | |
787e7624 | 417 | }, |
468b867f KK |
418 | } |
419 | } | |
420 | } | |
421 | } | |
422 | ||
423 | result = create_router_bgp(tgen, topo, input_dict_7) | |
424 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 425 | tc_name, result |
426 | ) | |
468b867f KK |
427 | |
428 | for adt in ADDR_TYPES: | |
429 | # Verifying RIB routes | |
430 | dut = "r3" | |
431 | protocol = "bgp" | |
432 | input_dict_2 = { | |
433 | "r4": { | |
434 | "static_routes": [ | |
435 | { | |
436 | "network": [NETWORK[adt][1]], | |
437 | "no_of_ip": 9, | |
787e7624 | 438 | "next_hop": NEXT_HOP[adt], |
468b867f KK |
439 | } |
440 | ] | |
441 | } | |
442 | } | |
443 | ||
787e7624 | 444 | result = verify_rib( |
445 | tgen, adt, dut, input_dict_2, protocol=protocol, expected=False | |
446 | ) | |
8031b96e DS |
447 | assert ( |
448 | result is not True | |
449 | ), "Testcase {} : Failed \nroutes are not present in rib \n Error: {}".format( | |
450 | tc_name, result | |
a53c08bc | 451 | ) |
b9f80297 | 452 | logger.info("Expected behaviour: {}".format(result)) |
468b867f KK |
453 | |
454 | # Verifying RIB routes | |
455 | dut = "r4" | |
456 | input_dict = { | |
457 | "r1": { | |
458 | "static_routes": [ | |
459 | { | |
460 | "network": [NETWORK[adt][0]], | |
461 | "no_of_ip": 9, | |
787e7624 | 462 | "next_hop": NEXT_HOP[adt], |
468b867f KK |
463 | } |
464 | ] | |
465 | } | |
466 | } | |
787e7624 | 467 | result = verify_rib( |
468 | tgen, adt, dut, input_dict, protocol=protocol, expected=False | |
469 | ) | |
8031b96e DS |
470 | assert ( |
471 | result is not True | |
472 | ), "Testcase {} : Failed \nroutes are not present in rib \n Error: {}".format( | |
473 | tc_name, result | |
a53c08bc | 474 | ) |
b9f80297 | 475 | logger.info("Expected behaviour: {}".format(result)) |
468b867f KK |
476 | |
477 | write_test_footer(tc_name) | |
478 | ||
479 | ||
787e7624 | 480 | @pytest.mark.parametrize( |
481 | "prefix_action, rmap_action", | |
482 | [("permit", "permit"), ("permit", "deny"), ("deny", "permit"), ("deny", "deny")], | |
483 | ) | |
468b867f | 484 | def test_route_map_with_action_values_combination_of_prefix_action_p0( |
787e7624 | 485 | request, prefix_action, rmap_action |
486 | ): | |
468b867f KK |
487 | """ |
488 | TC_36: | |
489 | Test permit/deny statements operation in route-maps with a permutation and | |
490 | combination of permit/deny in prefix-lists | |
491 | """ | |
492 | tc_name = request.node.name | |
493 | write_test_header(tc_name) | |
494 | tgen = get_topogen() | |
495 | ||
496 | # Don"t run this test if we have any failure. | |
497 | if tgen.routers_have_failure(): | |
498 | pytest.skip(tgen.errors) | |
499 | ||
500 | # Creating configuration from JSON | |
501 | reset_config_on_routers(tgen) | |
502 | ||
503 | for adt in ADDR_TYPES: | |
504 | # Create Static routes | |
505 | input_dict = { | |
506 | "r1": { | |
507 | "static_routes": [ | |
508 | { | |
509 | "network": NETWORK[adt][0], | |
510 | "no_of_ip": 9, | |
787e7624 | 511 | "next_hop": NEXT_HOP[adt], |
468b867f KK |
512 | } |
513 | ] | |
514 | } | |
515 | } | |
516 | ||
517 | result = create_static_routes(tgen, input_dict) | |
518 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 519 | tc_name, result |
520 | ) | |
468b867f KK |
521 | |
522 | # Api call to redistribute static routes | |
523 | input_dict_1 = { | |
524 | "r1": { | |
525 | "bgp": { | |
526 | "local_as": 100, | |
527 | "address_family": { | |
528 | "ipv4": { | |
529 | "unicast": { | |
530 | "redistribute": [ | |
531 | {"redist_type": "static"}, | |
787e7624 | 532 | {"redist_type": "connected"}, |
468b867f KK |
533 | ] |
534 | } | |
535 | }, | |
536 | "ipv6": { | |
537 | "unicast": { | |
538 | "redistribute": [ | |
539 | {"redist_type": "static"}, | |
787e7624 | 540 | {"redist_type": "connected"}, |
468b867f KK |
541 | ] |
542 | } | |
787e7624 | 543 | }, |
544 | }, | |
468b867f KK |
545 | } |
546 | } | |
547 | } | |
548 | ||
549 | result = create_router_bgp(tgen, topo, input_dict_1) | |
550 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 551 | tc_name, result |
552 | ) | |
468b867f KK |
553 | |
554 | # Permit in perfix list and route-map | |
555 | input_dict_2 = { | |
556 | "r3": { | |
557 | "prefix_lists": { | |
558 | "ipv4": { | |
787e7624 | 559 | "pf_list_1_ipv4": [ |
560 | {"seqid": 10, "network": "any", "action": prefix_action} | |
561 | ] | |
468b867f KK |
562 | }, |
563 | "ipv6": { | |
787e7624 | 564 | "pf_list_1_ipv6": [ |
565 | {"seqid": 100, "network": "any", "action": prefix_action} | |
566 | ] | |
567 | }, | |
468b867f KK |
568 | } |
569 | } | |
570 | } | |
571 | result = create_prefix_lists(tgen, input_dict_2) | |
572 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 573 | tc_name, result |
574 | ) | |
468b867f KK |
575 | |
576 | # Create route map | |
577 | for addr_type in ADDR_TYPES: | |
578 | input_dict_3 = { | |
787e7624 | 579 | "r3": { |
580 | "route_maps": { | |
581 | "rmap_match_pf_1_{}".format(addr_type): [ | |
582 | { | |
583 | "action": rmap_action, | |
584 | "match": { | |
585 | addr_type: { | |
586 | "prefix_lists": "pf_list_1_{}".format(addr_type) | |
587 | } | |
588 | }, | |
468b867f | 589 | } |
787e7624 | 590 | ] |
591 | } | |
468b867f KK |
592 | } |
593 | } | |
468b867f KK |
594 | result = create_route_maps(tgen, input_dict_3) |
595 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 596 | tc_name, result |
597 | ) | |
468b867f KK |
598 | |
599 | # Configure neighbor for route map | |
600 | input_dict_7 = { | |
601 | "r3": { | |
602 | "bgp": { | |
603 | "address_family": { | |
604 | "ipv4": { | |
605 | "unicast": { | |
606 | "neighbor": { | |
607 | "r1": { | |
608 | "dest_link": { | |
609 | "r3": { | |
610 | "route_maps": [ | |
787e7624 | 611 | { |
612 | "name": "rmap_match_pf_1_ipv4", | |
613 | "direction": "in", | |
614 | } | |
468b867f KK |
615 | ] |
616 | } | |
617 | } | |
618 | } | |
619 | } | |
620 | } | |
621 | }, | |
622 | "ipv6": { | |
623 | "unicast": { | |
624 | "neighbor": { | |
625 | "r1": { | |
626 | "dest_link": { | |
627 | "r3": { | |
628 | "route_maps": [ | |
787e7624 | 629 | { |
630 | "name": "rmap_match_pf_1_ipv6", | |
631 | "direction": "in", | |
632 | } | |
468b867f KK |
633 | ] |
634 | } | |
635 | } | |
636 | } | |
637 | } | |
638 | } | |
787e7624 | 639 | }, |
468b867f KK |
640 | } |
641 | } | |
642 | } | |
643 | } | |
644 | ||
645 | result = create_router_bgp(tgen, topo, input_dict_7) | |
646 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 647 | tc_name, result |
648 | ) | |
468b867f KK |
649 | |
650 | dut = "r3" | |
651 | protocol = "bgp" | |
652 | input_dict_2 = { | |
653 | "r1": { | |
654 | "static_routes": [ | |
655 | { | |
656 | "network": [NETWORK[adt][0]], | |
657 | "no_of_ip": 9, | |
658 | "next_hop": NEXT_HOP[adt], | |
659 | } | |
660 | ] | |
661 | } | |
662 | } | |
663 | ||
787e7624 | 664 | # tgen.mininet_cli() |
468b867f | 665 | if "deny" in [prefix_action, rmap_action]: |
25b43d56 KK |
666 | result = verify_rib( |
667 | tgen, adt, dut, input_dict_2, protocol=protocol, expected=False | |
668 | ) | |
8031b96e DS |
669 | assert ( |
670 | result is not True | |
671 | ), "Testcase {} : Failed \nRoutes are still present \n Error: {}".format( | |
672 | tc_name, result | |
a53c08bc | 673 | ) |
b9f80297 | 674 | logger.info("Expected behaviour: {}".format(result)) |
468b867f | 675 | else: |
a53c08bc | 676 | result = verify_rib(tgen, adt, dut, input_dict_2, protocol=protocol) |
468b867f | 677 | assert result is True, "Testcase {} : Failed \n Error: {}".format( |
787e7624 | 678 | tc_name, result |
679 | ) | |
468b867f KK |
680 | |
681 | ||
682 | def test_route_map_multiple_seq_different_match_set_clause_p0(request): | |
683 | """ | |
684 | TC_35: | |
685 | Test multiple sequence numbers in a single route-map for different | |
686 | match/set clauses. | |
687 | """ | |
688 | ||
689 | tgen = get_topogen() | |
690 | # test case name | |
691 | tc_name = request.node.name | |
692 | write_test_header(tc_name) | |
693 | ||
694 | # Creating configuration from JSON | |
695 | reset_config_on_routers(tgen) | |
696 | ||
697 | for adt in ADDR_TYPES: | |
698 | # Create Static routes | |
699 | input_dict = { | |
700 | "r1": { | |
787e7624 | 701 | "static_routes": [ |
702 | { | |
703 | "network": NETWORK[adt][0], | |
704 | "no_of_ip": 1, | |
705 | "next_hop": NEXT_HOP[adt], | |
706 | } | |
707 | ] | |
468b867f KK |
708 | } |
709 | } | |
710 | result = create_static_routes(tgen, input_dict) | |
711 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 712 | tc_name, result |
713 | ) | |
468b867f KK |
714 | |
715 | # Api call to redistribute static routes | |
716 | input_dict_1 = { | |
717 | "r1": { | |
718 | "bgp": { | |
719 | "address_family": { | |
720 | "ipv4": { | |
721 | "unicast": { | |
722 | "redistribute": [ | |
723 | {"redist_type": "static"}, | |
787e7624 | 724 | {"redist_type": "connected"}, |
468b867f KK |
725 | ] |
726 | } | |
727 | }, | |
728 | "ipv6": { | |
729 | "unicast": { | |
730 | "redistribute": [ | |
731 | {"redist_type": "static"}, | |
787e7624 | 732 | {"redist_type": "connected"}, |
468b867f KK |
733 | ] |
734 | } | |
787e7624 | 735 | }, |
468b867f KK |
736 | } |
737 | } | |
738 | } | |
739 | } | |
740 | result = create_router_bgp(tgen, topo, input_dict_1) | |
741 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 742 | tc_name, result |
743 | ) | |
468b867f KK |
744 | |
745 | # Create ip prefix list | |
746 | input_dict_2 = { | |
747 | "r3": { | |
748 | "prefix_lists": { | |
749 | "ipv4": { | |
787e7624 | 750 | "pf_list_1_ipv4": [ |
751 | {"seqid": 10, "network": "any", "action": "permit"} | |
752 | ] | |
468b867f KK |
753 | }, |
754 | "ipv6": { | |
787e7624 | 755 | "pf_list_1_ipv6": [ |
756 | {"seqid": 100, "network": "any", "action": "permit"} | |
757 | ] | |
758 | }, | |
468b867f KK |
759 | } |
760 | } | |
761 | } | |
762 | result = create_prefix_lists(tgen, input_dict_2) | |
763 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 764 | tc_name, result |
765 | ) | |
468b867f KK |
766 | |
767 | # Create route map | |
768 | for addr_type in ADDR_TYPES: | |
769 | input_dict_3 = { | |
787e7624 | 770 | "r3": { |
771 | "route_maps": { | |
772 | "rmap_match_pf_1_{}".format(addr_type): [ | |
773 | { | |
774 | "action": "permit", | |
775 | "match": { | |
776 | addr_type: { | |
777 | "prefix_lists": "pf_list_2_{}".format(addr_type) | |
778 | } | |
779 | }, | |
780 | "set": {"path": {"as_num": 500}}, | |
468b867f | 781 | }, |
787e7624 | 782 | { |
783 | "action": "permit", | |
784 | "match": { | |
785 | addr_type: { | |
786 | "prefix_lists": "pf_list_2_{}".format(addr_type) | |
787 | } | |
788 | }, | |
9fa6ec14 | 789 | "set": { |
790 | "locPrf": 150, | |
791 | }, | |
468b867f | 792 | }, |
787e7624 | 793 | { |
794 | "action": "permit", | |
795 | "match": { | |
796 | addr_type: { | |
797 | "prefix_lists": "pf_list_1_{}".format(addr_type) | |
798 | } | |
799 | }, | |
800 | "set": {"metric": 50}, | |
468b867f | 801 | }, |
787e7624 | 802 | ] |
803 | } | |
804 | } | |
468b867f KK |
805 | } |
806 | result = create_route_maps(tgen, input_dict_3) | |
807 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 808 | tc_name, result |
809 | ) | |
468b867f KK |
810 | |
811 | # Configure neighbor for route map | |
812 | input_dict_4 = { | |
813 | "r3": { | |
814 | "bgp": { | |
815 | "address_family": { | |
816 | "ipv4": { | |
817 | "unicast": { | |
818 | "neighbor": { | |
819 | "r1": { | |
820 | "dest_link": { | |
821 | "r3": { | |
787e7624 | 822 | "route_maps": [ |
823 | { | |
824 | "name": "rmap_match_pf_1_ipv4", | |
825 | "direction": "in", | |
826 | } | |
827 | ] | |
468b867f KK |
828 | } |
829 | } | |
830 | }, | |
831 | "r4": { | |
832 | "dest_link": { | |
833 | "r3": { | |
787e7624 | 834 | "route_maps": [ |
835 | { | |
836 | "name": "rmap_match_pf_1_ipv4", | |
837 | "direction": "out", | |
838 | } | |
839 | ] | |
468b867f KK |
840 | } |
841 | } | |
787e7624 | 842 | }, |
468b867f KK |
843 | } |
844 | } | |
845 | }, | |
846 | "ipv6": { | |
847 | "unicast": { | |
848 | "neighbor": { | |
849 | "r1": { | |
850 | "dest_link": { | |
851 | "r3": { | |
787e7624 | 852 | "route_maps": [ |
853 | { | |
854 | "name": "rmap_match_pf_1_ipv6", | |
855 | "direction": "in", | |
856 | } | |
857 | ] | |
468b867f KK |
858 | } |
859 | } | |
860 | }, | |
861 | "r4": { | |
862 | "dest_link": { | |
863 | "r3": { | |
787e7624 | 864 | "route_maps": [ |
865 | { | |
866 | "name": "rmap_match_pf_1_ipv6", | |
867 | "direction": "out", | |
868 | } | |
869 | ] | |
468b867f KK |
870 | } |
871 | } | |
787e7624 | 872 | }, |
468b867f KK |
873 | } |
874 | } | |
787e7624 | 875 | }, |
468b867f KK |
876 | } |
877 | } | |
878 | } | |
879 | } | |
880 | result = create_router_bgp(tgen, topo, input_dict_4) | |
881 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 882 | tc_name, result |
883 | ) | |
468b867f KK |
884 | |
885 | for adt in ADDR_TYPES: | |
886 | # Verifying RIB routes | |
887 | dut = "r3" | |
888 | protocol = "bgp" | |
889 | input_dict = { | |
9fa6ec14 | 890 | "r3": { |
891 | "route_maps": { | |
892 | "rmap_match_pf_list1": [ | |
893 | { | |
894 | "set": { | |
895 | "metric": 50, | |
896 | } | |
897 | } | |
898 | ], | |
899 | } | |
900 | } | |
468b867f KK |
901 | } |
902 | ||
903 | static_routes = [NETWORK[adt][0]] | |
904 | ||
905 | time.sleep(2) | |
787e7624 | 906 | result = verify_bgp_attributes( |
907 | tgen, adt, dut, static_routes, "rmap_match_pf_list1", input_dict | |
908 | ) | |
909 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
910 | tc_name, result | |
911 | ) | |
468b867f KK |
912 | |
913 | dut = "r4" | |
787e7624 | 914 | result = verify_bgp_attributes( |
915 | tgen, adt, dut, static_routes, "rmap_match_pf_list1", input_dict | |
916 | ) | |
917 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
918 | tc_name, result | |
919 | ) | |
468b867f KK |
920 | |
921 | logger.info("Testcase " + tc_name + " :Passed \n") | |
922 | ||
923 | # Uncomment next line for debugging | |
924 | # tgen.mininet_cli() | |
925 | ||
926 | ||
927 | def test_route_map_set_only_no_match_p0(request): | |
928 | """ | |
929 | TC_37: | |
930 | Test add/remove route-maps with multiple set | |
931 | clauses and without any match statement.(Set only) | |
932 | """ | |
933 | ||
934 | tgen = get_topogen() | |
935 | # test case name | |
936 | tc_name = request.node.name | |
937 | write_test_header(tc_name) | |
938 | ||
939 | # Creating configuration from JSON | |
940 | reset_config_on_routers(tgen) | |
941 | ||
942 | for adt in ADDR_TYPES: | |
943 | # Create Static routes | |
944 | input_dict = { | |
945 | "r1": { | |
787e7624 | 946 | "static_routes": [ |
947 | { | |
948 | "network": NETWORK[adt][0], | |
949 | "no_of_ip": 1, | |
950 | "next_hop": NEXT_HOP[adt], | |
951 | } | |
952 | ] | |
468b867f KK |
953 | } |
954 | } | |
955 | result = create_static_routes(tgen, input_dict) | |
956 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 957 | tc_name, result |
958 | ) | |
468b867f KK |
959 | |
960 | # Api call to redistribute static routes | |
961 | input_dict_1 = { | |
962 | "r1": { | |
963 | "bgp": { | |
964 | "address_family": { | |
965 | "ipv4": { | |
966 | "unicast": { | |
967 | "redistribute": [ | |
968 | {"redist_type": "static"}, | |
787e7624 | 969 | {"redist_type": "connected"}, |
468b867f KK |
970 | ] |
971 | } | |
972 | }, | |
973 | "ipv6": { | |
974 | "unicast": { | |
975 | "redistribute": [ | |
976 | {"redist_type": "static"}, | |
787e7624 | 977 | {"redist_type": "connected"}, |
468b867f KK |
978 | ] |
979 | } | |
787e7624 | 980 | }, |
468b867f KK |
981 | } |
982 | } | |
983 | } | |
984 | } | |
985 | result = create_router_bgp(tgen, topo, input_dict_1) | |
986 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 987 | tc_name, result |
988 | ) | |
468b867f KK |
989 | |
990 | # Create route map | |
991 | input_dict_3 = { | |
992 | "r3": { | |
993 | "route_maps": { | |
994 | "rmap_match_pf_1": [ | |
995 | { | |
996 | "action": "permit", | |
787e7624 | 997 | "set": {"metric": 50, "locPrf": 150, "weight": 4000}, |
468b867f KK |
998 | } |
999 | ] | |
1000 | } | |
1001 | } | |
1002 | } | |
1003 | result = create_route_maps(tgen, input_dict_3) | |
1004 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1005 | tc_name, result |
1006 | ) | |
468b867f KK |
1007 | |
1008 | # Configure neighbor for route map | |
1009 | input_dict_4 = { | |
1010 | "r3": { | |
1011 | "bgp": { | |
1012 | "address_family": { | |
1013 | "ipv4": { | |
1014 | "unicast": { | |
1015 | "neighbor": { | |
1016 | "r1": { | |
1017 | "dest_link": { | |
1018 | "r3": { | |
787e7624 | 1019 | "route_maps": [ |
1020 | { | |
1021 | "name": "rmap_match_pf_1", | |
1022 | "direction": "in", | |
1023 | } | |
1024 | ] | |
468b867f KK |
1025 | } |
1026 | } | |
1027 | }, | |
1028 | "r4": { | |
1029 | "dest_link": { | |
1030 | "r3": { | |
787e7624 | 1031 | "route_maps": [ |
1032 | { | |
1033 | "name": "rmap_match_pf_1", | |
1034 | "direction": "out", | |
1035 | } | |
1036 | ] | |
468b867f KK |
1037 | } |
1038 | } | |
787e7624 | 1039 | }, |
468b867f KK |
1040 | } |
1041 | } | |
1042 | }, | |
1043 | "ipv6": { | |
1044 | "unicast": { | |
1045 | "neighbor": { | |
1046 | "r1": { | |
1047 | "dest_link": { | |
1048 | "r3": { | |
787e7624 | 1049 | "route_maps": [ |
1050 | { | |
1051 | "name": "rmap_match_pf_1", | |
1052 | "direction": "in", | |
1053 | } | |
1054 | ] | |
468b867f KK |
1055 | } |
1056 | } | |
1057 | }, | |
1058 | "r4": { | |
1059 | "dest_link": { | |
1060 | "r3": { | |
787e7624 | 1061 | "route_maps": [ |
1062 | { | |
1063 | "name": "rmap_match_pf_1", | |
1064 | "direction": "out", | |
1065 | } | |
1066 | ] | |
468b867f KK |
1067 | } |
1068 | } | |
787e7624 | 1069 | }, |
468b867f KK |
1070 | } |
1071 | } | |
787e7624 | 1072 | }, |
468b867f KK |
1073 | } |
1074 | } | |
1075 | } | |
1076 | } | |
1077 | result = create_router_bgp(tgen, topo, input_dict_4) | |
1078 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1079 | tc_name, result |
1080 | ) | |
468b867f KK |
1081 | |
1082 | time.sleep(2) | |
1083 | for adt in ADDR_TYPES: | |
1084 | input_dict_4 = { | |
1085 | "r3": { | |
1086 | "route_maps": { | |
9fa6ec14 | 1087 | "rmap_match_pf_1": [ |
1088 | { | |
1089 | "action": "permit", | |
1090 | "set": { | |
1091 | "metric": 50, | |
1092 | }, | |
1093 | } | |
1094 | ] | |
468b867f KK |
1095 | } |
1096 | } | |
1097 | } | |
1098 | # Verifying RIB routes | |
1099 | static_routes = [NETWORK[adt][0]] | |
787e7624 | 1100 | result = verify_bgp_attributes( |
1101 | tgen, adt, "r3", static_routes, "rmap_match_pf_1", input_dict_3 | |
1102 | ) | |
1103 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
1104 | tc_name, result | |
1105 | ) | |
1106 | ||
1107 | result = verify_bgp_attributes( | |
1108 | tgen, adt, "r4", static_routes, "rmap_match_pf_1", input_dict_4 | |
1109 | ) | |
1110 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
1111 | tc_name, result | |
1112 | ) | |
468b867f KK |
1113 | |
1114 | logger.info("Testcase " + tc_name + " :Passed \n") | |
1115 | ||
1116 | # Uncomment next line for debugging | |
1117 | # tgen.mininet_cli() | |
1118 | ||
1119 | ||
1120 | def test_route_map_match_only_no_set_p0(request): | |
1121 | """ | |
1122 | TC_38: | |
1123 | Test add/remove route-maps with multiple match | |
1124 | clauses and without any set statement.(Match only) | |
1125 | """ | |
1126 | ||
1127 | tgen = get_topogen() | |
1128 | # test case name | |
1129 | tc_name = request.node.name | |
1130 | write_test_header(tc_name) | |
1131 | ||
1132 | # Creating configuration from JSON | |
1133 | reset_config_on_routers(tgen) | |
1134 | ||
1135 | for adt in ADDR_TYPES: | |
1136 | # Create Static routes | |
1137 | input_dict = { | |
1138 | "r1": { | |
787e7624 | 1139 | "static_routes": [ |
1140 | { | |
1141 | "network": NETWORK[adt][0], | |
1142 | "no_of_ip": 1, | |
1143 | "next_hop": NEXT_HOP[adt], | |
1144 | } | |
1145 | ] | |
468b867f KK |
1146 | } |
1147 | } | |
1148 | result = create_static_routes(tgen, input_dict) | |
1149 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1150 | tc_name, result |
1151 | ) | |
468b867f KK |
1152 | |
1153 | # Api call to redistribute static routes | |
1154 | input_dict_1 = { | |
1155 | "r1": { | |
1156 | "bgp": { | |
1157 | "address_family": { | |
1158 | "ipv4": { | |
1159 | "unicast": { | |
1160 | "redistribute": [ | |
1161 | {"redist_type": "static"}, | |
787e7624 | 1162 | {"redist_type": "connected"}, |
468b867f KK |
1163 | ] |
1164 | } | |
1165 | }, | |
1166 | "ipv6": { | |
1167 | "unicast": { | |
1168 | "redistribute": [ | |
1169 | {"redist_type": "static"}, | |
787e7624 | 1170 | {"redist_type": "connected"}, |
468b867f KK |
1171 | ] |
1172 | } | |
787e7624 | 1173 | }, |
468b867f KK |
1174 | } |
1175 | } | |
1176 | } | |
1177 | } | |
1178 | result = create_router_bgp(tgen, topo, input_dict_1) | |
1179 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1180 | tc_name, result |
1181 | ) | |
468b867f KK |
1182 | |
1183 | # Create ip prefix list | |
1184 | input_dict_2 = { | |
1185 | "r1": { | |
1186 | "prefix_lists": { | |
1187 | "ipv4": { | |
787e7624 | 1188 | "pf_list_1_ipv4": [ |
1189 | {"seqid": 10, "network": "any", "action": "permit"} | |
1190 | ] | |
468b867f KK |
1191 | }, |
1192 | "ipv6": { | |
787e7624 | 1193 | "pf_list_1_ipv6": [ |
1194 | {"seqid": 100, "network": "any", "action": "permit"} | |
1195 | ] | |
1196 | }, | |
468b867f KK |
1197 | } |
1198 | } | |
1199 | } | |
1200 | result = create_prefix_lists(tgen, input_dict_2) | |
1201 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1202 | tc_name, result |
1203 | ) | |
468b867f KK |
1204 | |
1205 | # Create route map | |
1206 | for addr_type in ADDR_TYPES: | |
1207 | input_dict_3 = { | |
1208 | "r1": { | |
1209 | "route_maps": { | |
787e7624 | 1210 | "rmap_match_pf_1_{}".format(addr_type): [ |
9fa6ec14 | 1211 | { |
1212 | "action": "permit", | |
1213 | "set": { | |
1214 | "metric": 50, | |
1215 | "locPrf": 150, | |
1216 | }, | |
1217 | } | |
468b867f KK |
1218 | ] |
1219 | } | |
1220 | } | |
1221 | } | |
1222 | result = create_route_maps(tgen, input_dict_3) | |
1223 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1224 | tc_name, result |
1225 | ) | |
468b867f KK |
1226 | |
1227 | # Configure neighbor for route map | |
1228 | input_dict_4 = { | |
1229 | "r1": { | |
1230 | "bgp": { | |
1231 | "address_family": { | |
1232 | "ipv4": { | |
1233 | "unicast": { | |
1234 | "neighbor": { | |
1235 | "r3": { | |
1236 | "dest_link": { | |
1237 | "r1": { | |
787e7624 | 1238 | "route_maps": [ |
1239 | { | |
1240 | "name": "rmap_match_pf_1_ipv4", | |
1241 | "direction": "out", | |
1242 | } | |
1243 | ] | |
468b867f KK |
1244 | } |
1245 | } | |
1246 | } | |
1247 | } | |
1248 | } | |
1249 | }, | |
1250 | "ipv6": { | |
1251 | "unicast": { | |
1252 | "neighbor": { | |
1253 | "r3": { | |
1254 | "dest_link": { | |
1255 | "r1": { | |
787e7624 | 1256 | "route_maps": [ |
1257 | { | |
1258 | "name": "rmap_match_pf_1_ipv6", | |
1259 | "direction": "out", | |
1260 | } | |
1261 | ] | |
468b867f KK |
1262 | } |
1263 | } | |
1264 | } | |
1265 | } | |
1266 | } | |
787e7624 | 1267 | }, |
468b867f KK |
1268 | } |
1269 | } | |
1270 | } | |
1271 | } | |
1272 | result = create_router_bgp(tgen, topo, input_dict_4) | |
1273 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1274 | tc_name, result |
1275 | ) | |
468b867f KK |
1276 | |
1277 | # Create ip prefix list | |
1278 | input_dict_5 = { | |
1279 | "r3": { | |
1280 | "prefix_lists": { | |
1281 | "ipv4": { | |
787e7624 | 1282 | "pf_list_1_ipv4": [ |
1283 | {"seqid": 10, "network": "any", "action": "permit"} | |
1284 | ] | |
468b867f KK |
1285 | }, |
1286 | "ipv6": { | |
787e7624 | 1287 | "pf_list_1_ipv6": [ |
1288 | {"seqid": 100, "network": "any", "action": "permit"} | |
1289 | ] | |
1290 | }, | |
468b867f KK |
1291 | } |
1292 | } | |
1293 | } | |
1294 | result = create_prefix_lists(tgen, input_dict_5) | |
1295 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1296 | tc_name, result |
1297 | ) | |
468b867f KK |
1298 | |
1299 | # Create route map | |
1300 | for addr_type in ADDR_TYPES: | |
1301 | input_dict_6 = { | |
1302 | "r3": { | |
1303 | "route_maps": { | |
787e7624 | 1304 | "rmap_match_pf_2_{}".format(addr_type): [ |
1305 | { | |
468b867f KK |
1306 | "action": "permit", |
1307 | "match": { | |
1308 | addr_type: { | |
787e7624 | 1309 | "prefix_lists": "pf_list_1_{}".format(addr_type) |
468b867f | 1310 | } |
787e7624 | 1311 | }, |
468b867f KK |
1312 | } |
1313 | ] | |
1314 | } | |
1315 | } | |
1316 | } | |
1317 | result = create_route_maps(tgen, input_dict_6) | |
1318 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1319 | tc_name, result |
1320 | ) | |
468b867f KK |
1321 | |
1322 | # Configure neighbor for route map | |
1323 | input_dict_7 = { | |
1324 | "r3": { | |
1325 | "bgp": { | |
1326 | "address_family": { | |
1327 | "ipv4": { | |
1328 | "unicast": { | |
1329 | "neighbor": { | |
1330 | "r1": { | |
1331 | "dest_link": { | |
1332 | "r3": { | |
787e7624 | 1333 | "route_maps": [ |
1334 | { | |
1335 | "name": "rmap_match_pf_2_ipv4", | |
1336 | "direction": "in", | |
1337 | } | |
1338 | ] | |
468b867f KK |
1339 | } |
1340 | } | |
1341 | }, | |
1342 | "r4": { | |
1343 | "dest_link": { | |
1344 | "r3": { | |
787e7624 | 1345 | "route_maps": [ |
1346 | { | |
1347 | "name": "rmap_match_pf_2_ipv4", | |
1348 | "direction": "out", | |
1349 | } | |
1350 | ] | |
468b867f KK |
1351 | } |
1352 | } | |
787e7624 | 1353 | }, |
468b867f KK |
1354 | } |
1355 | } | |
1356 | }, | |
1357 | "ipv6": { | |
1358 | "unicast": { | |
1359 | "neighbor": { | |
1360 | "r1": { | |
1361 | "dest_link": { | |
1362 | "r3": { | |
787e7624 | 1363 | "route_maps": [ |
1364 | { | |
1365 | "name": "rmap_match_pf_2_ipv6", | |
1366 | "direction": "in", | |
1367 | } | |
1368 | ] | |
468b867f KK |
1369 | } |
1370 | } | |
1371 | }, | |
1372 | "r4": { | |
1373 | "dest_link": { | |
1374 | "r3": { | |
787e7624 | 1375 | "route_maps": [ |
1376 | { | |
1377 | "name": "rmap_match_pf_2_ipv6", | |
1378 | "direction": "out", | |
1379 | } | |
1380 | ] | |
468b867f KK |
1381 | } |
1382 | } | |
787e7624 | 1383 | }, |
468b867f KK |
1384 | } |
1385 | } | |
787e7624 | 1386 | }, |
468b867f KK |
1387 | } |
1388 | } | |
1389 | } | |
1390 | } | |
1391 | result = create_router_bgp(tgen, topo, input_dict_7) | |
1392 | assert result is True, "Testcase {} : Failed \n Error: {}".format( | |
787e7624 | 1393 | tc_name, result |
1394 | ) | |
468b867f KK |
1395 | |
1396 | for adt in ADDR_TYPES: | |
1397 | # Verifying RIB routes | |
1398 | static_routes = [NETWORK[adt][0]] | |
787e7624 | 1399 | result = verify_bgp_attributes( |
1400 | tgen, adt, "r3", static_routes, "rmap_match_pf_1", input_dict_3 | |
1401 | ) | |
1402 | assert result is True, "Test case {} : Failed \n Error: {}".format( | |
1403 | tc_name, result | |
1404 | ) | |
468b867f KK |
1405 | |
1406 | ||
1407 | if __name__ == "__main__": | |
1408 | args = ["-s"] + sys.argv[1:] | |
1409 | sys.exit(pytest.main(args)) |