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