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