]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/ospfv3_basic_functionality/test_ospfv3_routemaps.py
Merge pull request #9345 from mjstapp/fix_lib_zmq_free
[mirror_frr.git] / tests / topotests / ospfv3_basic_functionality / test_ospfv3_routemaps.py
1 #!/usr/bin/python
2
3 #
4 # Copyright (c) 2021 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
6 # ("NetDEF") in this file.
7 #
8 # Permission to use, copy, modify, and/or distribute this software
9 # for any purpose with or without fee is hereby granted, provided
10 # that the above copyright notice and this permission notice appear
11 # in all copies.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 # OF THIS SOFTWARE.
21 #
22
23
24 """OSPF Basic Functionality Automation."""
25 import os
26 import sys
27 import time
28 import pytest
29
30 # Save the Current Working Directory to find configuration files.
31 CWD = os.path.dirname(os.path.realpath(__file__))
32 sys.path.append(os.path.join(CWD, "../"))
33 sys.path.append(os.path.join(CWD, "../lib/"))
34
35 # pylint: disable=C0413
36 # Import topogen and topotest helpers
37 from lib.topogen import Topogen, get_topogen
38
39 # Import topoJson from lib, to create topology and initial configuration
40 from lib.common_config import (
41 start_topology,
42 write_test_header,
43 write_test_footer,
44 reset_config_on_routers,
45 create_prefix_lists,
46 verify_rib,
47 create_static_routes,
48 step,
49 create_route_maps,
50 verify_prefix_lists,
51 topo_daemons,
52 )
53 from lib.topolog import logger
54 from lib.topojson import build_config_from_json
55
56 from lib.ospf import (
57 verify_ospf6_neighbor,
58 verify_ospf6_rib,
59 create_router_ospf,
60 )
61
62
63 pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
64
65
66 # Global variables
67 topo = None
68
69
70 NETWORK = {
71 "ipv4": [
72 "11.0.20.1/32",
73 "11.0.20.2/32",
74 "11.0.20.3/32",
75 "11.0.20.4/32",
76 "11.0.20.5/32",
77 ],
78 "ipv6": ["2::1/128", "2::2/128", "2::3/128", "2::4/128", "2::5/128"],
79 }
80
81 routerids = ["100.1.1.0", "100.1.1.1", "100.1.1.2", "100.1.1.3"]
82
83 """
84 TOPOOLOGY =
85 Please view in a fixed-width font such as Courier.
86 +---+ A1 +---+
87 +R1 +------------+R2 |
88 +-+-+- +--++
89 | -- -- |
90 | -- A0 -- |
91 A0| ---- |
92 | ---- | A2
93 | -- -- |
94 | -- -- |
95 +-+-+- +-+-+
96 +R0 +-------------+R3 |
97 +---+ A3 +---+
98
99 TESTCASES =
100 2. Verify OSPF route map support functionality when route map is not
101 configured at system level but configured in OSPF
102 4. Verify OSPF route map support functionality
103 when route map actions are toggled.
104 5. Verify OSPF route map support functionality with multiple sequence
105 numbers in a single route-map for different match/set clauses.
106 6. Verify OSPF route map support functionality when we add/remove route-maps
107 with multiple set clauses and without any match statement.(Set only)
108 7. Verify OSPF route map support functionality when we
109 add/remove route-maps with multiple match clauses and without
110 any set statement.(Match only)
111 8. Verify OSPF route map applied to ospf redistribution with ipv6 prefix list
112 """
113
114
115 def setup_module(mod):
116 """
117 Sets up the pytest environment
118
119 * `mod`: module name
120 """
121 testsuite_run_time = time.asctime(time.localtime(time.time()))
122 logger.info("Testsuite start time: {}".format(testsuite_run_time))
123 logger.info("=" * 40)
124
125 logger.info("Running setup_module to create topology")
126
127 # This function initiates the topology build with Topogen...
128 json_file = "{}/ospfv3_routemaps.json".format(CWD)
129 tgen = Topogen(json_file, mod.__name__)
130 global topo
131 topo = tgen.json_topo
132 # ... and here it calls Mininet initialization functions.
133
134 # get list of daemons needs to be started for this suite.
135 daemons = topo_daemons(tgen, topo)
136
137 # Starting topology, create tmp files which are loaded to routers
138 # to start deamons and then start routers
139 start_topology(tgen, daemons)
140
141 # Creating configuration from JSON
142 build_config_from_json(tgen, topo)
143
144 # Don't run this test if we have any failure.
145 if tgen.routers_have_failure():
146 pytest.skip(tgen.errors)
147
148 ospf_covergence = verify_ospf6_neighbor(tgen, topo)
149 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
150 ospf_covergence
151 )
152
153 logger.info("Running setup_module() done")
154
155
156 def teardown_module(mod):
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
170 logger.info(
171 "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
172 )
173 logger.info("=" * 40)
174
175
176 # ##################################
177 # Test cases start here.
178 # ##################################
179
180
181 def test_ospfv3_routemaps_functionality_tc20_p0(request):
182 """
183 OSPF route map support functionality.
184
185 Verify OSPF route map support functionality when route map is not
186 configured at system level but configured in OSPF
187
188 """
189 tc_name = request.node.name
190 write_test_header(tc_name)
191 tgen = get_topogen()
192 global topo
193 step("Bring up the base config as per the topology")
194
195 reset_config_on_routers(tgen)
196
197 step("Create static routes(10.0.20.1/32 and 10.0.20.2/32) in R0")
198 # Create Static routes
199 input_dict = {
200 "r0": {
201 "static_routes": [
202 {
203 "network": NETWORK["ipv6"][0],
204 "no_of_ip": 5,
205 "next_hop": "Null0",
206 }
207 ]
208 }
209 }
210 result = create_static_routes(tgen, input_dict)
211 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
212
213 step("Redistribute to ospf using route map ( non existent route map)")
214 ospf_red_r1 = {
215 "r0": {
216 "ospf6": {
217 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
218 }
219 }
220 }
221 result = create_router_ospf(tgen, topo, ospf_red_r1)
222 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
223
224 step(
225 "Verify that routes are not allowed in OSPF even tough no "
226 "matching routing map is configured."
227 )
228
229 dut = "r1"
230 protocol = "ospf"
231 result = verify_ospf6_rib(tgen, dut, input_dict)
232 assert (
233 result is not True
234 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
235 tc_name, result
236 )
237
238 result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
239 assert (
240 result is not True
241 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
242 tc_name, result
243 )
244
245 step(
246 "configure the route map with the same name that is used "
247 "in the ospf with deny rule."
248 )
249
250 # Create route map
251 routemaps = {"r0": {"route_maps": {"rmap_ipv6": [{"action": "deny"}]}}}
252 result = create_route_maps(tgen, routemaps)
253 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
254
255 step("verify that now route map is activated & routes are denied in OSPF.")
256 dut = "r1"
257 protocol = "ospf"
258 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
259 assert (
260 result is not True
261 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
262 tc_name, result
263 )
264
265 result = verify_rib(
266 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
267 )
268 assert (
269 result is not True
270 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
271 tc_name, result
272 )
273
274 # Create route map
275 routemaps = {"r0": {"route_maps": {"rmap_ipv6": [{"action": "deny"}]}}}
276 result = create_route_maps(tgen, routemaps)
277 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
278
279 step("verify that now route map is activated & routes are denied in OSPF.")
280 dut = "r1"
281 protocol = "ospf"
282 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
283 assert (
284 result is not True
285 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
286 tc_name, result
287 )
288
289 result = verify_rib(
290 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
291 )
292 assert (
293 result is not True
294 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
295 tc_name, result
296 )
297
298 step("Delete the route map.")
299 # Create route map
300 routemaps = {
301 "r0": {"route_maps": {"rmap_ipv6": [{"action": "deny", "delete": True}]}}
302 }
303 result = create_route_maps(tgen, routemaps)
304 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
305
306 step(
307 "Verify that routes are allowed in OSPF even tough "
308 "no matching routing map is configured."
309 )
310 dut = "r1"
311 protocol = "ospf"
312 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
313 assert (
314 result is not True
315 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
316 tc_name, result
317 )
318
319 result = verify_rib(
320 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
321 )
322 assert (
323 result is not True
324 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
325 tc_name, result
326 )
327
328 write_test_footer(tc_name)
329
330
331 def test_ospfv3_routemaps_functionality_tc25_p0(request):
332 """
333 OSPF route map support functionality.
334
335 Verify OSPF route map support functionality
336 when route map actions are toggled.
337
338 """
339 tc_name = request.node.name
340 write_test_header(tc_name)
341 tgen = get_topogen()
342 global topo
343 step("Bring up the base config as per the topology")
344
345 reset_config_on_routers(tgen)
346
347 step(
348 "Create static routes(10.0.20.1/32) in R1 and redistribute "
349 "to OSPF using route map."
350 )
351
352 # Create Static routes
353 input_dict = {
354 "r0": {
355 "static_routes": [
356 {
357 "network": NETWORK["ipv6"][0],
358 "no_of_ip": 5,
359 "next_hop": "Null0",
360 }
361 ]
362 }
363 }
364 result = create_static_routes(tgen, input_dict)
365 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
366
367 ospf_red_r0 = {
368 "r0": {
369 "ospf6": {
370 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
371 }
372 }
373 }
374 result = create_router_ospf(tgen, topo, ospf_red_r0)
375 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
376 step("Configure route map with permit rule")
377 # Create route map
378 routemaps = {"r0": {"route_maps": {"rmap_ipv6": [{"action": "permit"}]}}}
379 result = create_route_maps(tgen, routemaps)
380 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
381
382 step("Verify that route is advertised to R1.")
383 dut = "r1"
384 protocol = "ospf"
385 result = verify_ospf6_rib(tgen, dut, input_dict)
386 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
387
388 result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
389 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
390 step("Configure route map with deny rule")
391 # Create route map
392 routemaps = {
393 "r0": {"route_maps": {"rmap_ipv6": [{"seq_id": 10, "action": "deny"}]}}
394 }
395 result = create_route_maps(tgen, routemaps)
396 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
397
398 # Api call verify whether OSPF is converged
399 ospf_covergence = verify_ospf6_neighbor(tgen, topo)
400 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
401 ospf_covergence
402 )
403
404 step("Verify that route is not advertised to R1.")
405 dut = "r1"
406 protocol = "ospf"
407 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
408 assert (
409 result is not True
410 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
411 tc_name, result
412 )
413
414 result = verify_rib(
415 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
416 )
417 assert (
418 result is not True
419 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
420 tc_name, result
421 )
422
423 write_test_footer(tc_name)
424
425
426 def test_ospfv3_routemaps_functionality_tc22_p0(request):
427 """
428 OSPF Route map - Multiple sequence numbers.
429
430 Verify OSPF route map support functionality with multiple sequence
431 numbers in a single route-map for different match/set clauses.
432
433 """
434 tc_name = request.node.name
435 write_test_header(tc_name)
436 tgen = get_topogen()
437 global topo
438 step("Bring up the base config as per the topology")
439
440 reset_config_on_routers(tgen)
441
442 step(
443 "Configure route map with seq number 10 to with ip prefix"
444 " permitting route 10.0.20.1/32 in R1"
445 )
446 step(
447 "Configure route map with seq number 20 to with ip prefix"
448 " permitting route 10.0.20.2/32 in R1"
449 )
450
451 # Create route map
452 input_dict_3 = {
453 "r0": {
454 "route_maps": {
455 "rmap_ipv6": [
456 {
457 "action": "permit",
458 "seq_id": "10",
459 "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
460 },
461 {
462 "action": "permit",
463 "seq_id": "20",
464 "match": {"ipv6": {"prefix_lists": "pf_list_2_ipv4"}},
465 },
466 ]
467 }
468 }
469 }
470 result = create_route_maps(tgen, input_dict_3)
471 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
472
473 # Create ip prefix list
474 input_dict_2 = {
475 "r0": {
476 "prefix_lists": {
477 "ipv4": {
478 "pf_list_1_ipv6": [
479 {"seqid": 10, "network": NETWORK["ipv6"][0], "action": "permit"}
480 ]
481 }
482 }
483 }
484 }
485 result = create_prefix_lists(tgen, input_dict_2)
486 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
487
488 # Create ip prefix list
489 input_dict_2 = {
490 "r0": {
491 "prefix_lists": {
492 "ipv4": {
493 "pf_list_2_ipv4": [
494 {"seqid": 10, "network": NETWORK["ipv6"][1], "action": "permit"}
495 ]
496 }
497 }
498 }
499 }
500 result = create_prefix_lists(tgen, input_dict_2)
501 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
502
503 step("Configure static routes 10.0.20.1/32 and 10.0.20.2 in R1")
504 # Create Static routes
505 input_dict = {
506 "r0": {
507 "static_routes": [
508 {
509 "network": NETWORK["ipv6"][0],
510 "no_of_ip": 5,
511 "next_hop": "Null0",
512 }
513 ]
514 }
515 }
516 result = create_static_routes(tgen, input_dict)
517 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
518
519 step("Configure redistribute static route with route map.")
520 ospf_red_r0 = {
521 "r0": {
522 "ospf6": {
523 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
524 }
525 }
526 }
527 result = create_router_ospf(tgen, topo, ospf_red_r0)
528 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
529
530 input_dict = {
531 "r0": {
532 "static_routes": [
533 {
534 "network": NETWORK["ipv6"][0],
535 "no_of_ip": 2,
536 "next_hop": "Null0",
537 }
538 ]
539 }
540 }
541 result = create_static_routes(tgen, input_dict)
542 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
543
544 step("Verify that both routes are learned in R1 and R2")
545 dut = "r1"
546 protocol = "ospf"
547 result = verify_ospf6_rib(tgen, dut, input_dict)
548 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
549
550 result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
551 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
552
553 dut = "r2"
554 protocol = "ospf"
555 result = verify_ospf6_rib(tgen, dut, input_dict)
556 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
557
558 result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
559 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
560
561 step("Change route map with seq number 20 to deny.")
562 # Create route map
563 input_dict_3 = {
564 "r0": {
565 "route_maps": {
566 "rmap_ipv6": [
567 {
568 "action": "deny",
569 "seq_id": "20",
570 "match": {"ipv6": {"prefix_lists": "pf_list_2_ipv4"}},
571 }
572 ]
573 }
574 }
575 }
576 result = create_route_maps(tgen, input_dict_3)
577 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
578
579 step(
580 "Verify the route 10.0.20.2/32 is withdrawn and not present "
581 "in the routing table of R0 and R1."
582 )
583
584 input_dict = {
585 "r0": {"static_routes": [{"network": NETWORK["ipv6"][1], "next_hop": "Null0"}]}
586 }
587
588 dut = "r1"
589 protocol = "ospf"
590 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
591 assert (
592 result is not True
593 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
594 tc_name, result
595 )
596
597 result = verify_rib(
598 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
599 )
600 assert (
601 result is not True
602 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
603 tc_name, result
604 )
605
606 dut = "r2"
607 protocol = "ospf"
608 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
609 assert (
610 result is not True
611 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
612 tc_name, result
613 )
614
615 result = verify_rib(
616 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
617 )
618 assert (
619 result is not True
620 ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format(
621 tc_name, result
622 )
623
624 write_test_footer(tc_name)
625
626
627 def test_ospfv3_routemaps_functionality_tc24_p0(request):
628 """
629 OSPF Route map - Multiple set clauses.
630
631 Verify OSPF route map support functionality when we
632 add/remove route-maps with multiple match clauses and without
633 any set statement.(Match only)
634
635 """
636 tc_name = request.node.name
637 write_test_header(tc_name)
638 tgen = get_topogen()
639 global topo
640 step("Bring up the base config as per the topology")
641
642 reset_config_on_routers(tgen)
643
644 step(
645 "Create static routes(10.0.20.1/32) in R1 and redistribute to "
646 "OSPF using route map."
647 )
648 # Create Static routes
649 input_dict = {
650 "r0": {
651 "static_routes": [
652 {
653 "network": NETWORK["ipv6"][0],
654 "no_of_ip": 1,
655 "next_hop": "Null0",
656 }
657 ]
658 }
659 }
660 result = create_static_routes(tgen, input_dict)
661 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
662
663 ospf_red_r0 = {
664 "r0": {
665 "ospf6": {
666 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
667 }
668 }
669 }
670 result = create_router_ospf(tgen, topo, ospf_red_r0)
671 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
672
673 # Create ip prefix list
674 pfx_list = {
675 "r0": {
676 "prefix_lists": {
677 "ipv6": {
678 "pf_list_1_ipv6": [
679 {"seqid": 10, "network": "any", "action": "permit"}
680 ]
681 }
682 }
683 }
684 }
685 result = create_prefix_lists(tgen, pfx_list)
686 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
687
688 step("verify that prefix-list is created in R0.")
689 result = verify_prefix_lists(tgen, pfx_list)
690 assert (
691 result is not True
692 ), "Testcase {} : Failed \n Prefix list not " "present. Error: {}".format(
693 tc_name, result
694 )
695
696 # Create route map
697 routemaps = {
698 "r0": {
699 "route_maps": {
700 "rmap_ipv6": [
701 {
702 "action": "permit",
703 "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
704 }
705 ]
706 }
707 }
708 }
709 result = create_route_maps(tgen, routemaps)
710 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
711
712 step("Verify that metric falls back to original metric for ospf routes.")
713 dut = "r1"
714 protocol = "ospf"
715
716 result = verify_ospf6_rib(tgen, dut, input_dict)
717 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
718
719 result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
720 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
721
722 step(
723 "Create static routes(10.0.20.1/32) in R1 and redistribute to "
724 "OSPF using route map."
725 )
726 # Create Static routes
727 input_dict = {
728 "r0": {
729 "static_routes": [
730 {
731 "network": NETWORK["ipv6"][1],
732 "no_of_ip": 1,
733 "next_hop": "Null0",
734 "tag": 1000,
735 }
736 ]
737 }
738 }
739 result = create_static_routes(tgen, input_dict)
740 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
741
742 # Create ip prefix list
743 pfx_list = {
744 "r0": {
745 "prefix_lists": {
746 "ipv6": {
747 "pf_list_1_ipv6": [
748 {"seqid": 10, "network": "any", "action": "permit"}
749 ]
750 }
751 }
752 }
753 }
754 result = create_prefix_lists(tgen, pfx_list)
755 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
756
757 step("verify that prefix-list is created in R0.")
758 result = verify_prefix_lists(tgen, pfx_list)
759 assert (
760 result is not True
761 ), "Testcase {} : Failed \n Prefix list not " "present. Error: {}".format(
762 tc_name, result
763 )
764
765 # Create route map
766 routemaps = {
767 "r0": {
768 "route_maps": {
769 "rmap_ipv6": [{"action": "permit", "match": {"ipv6": {"tag": "1000"}}}]
770 }
771 }
772 }
773 result = create_route_maps(tgen, routemaps)
774 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
775
776 step("Verify that metric falls back to original metric for ospf routes.")
777 dut = "r1"
778 protocol = "ospf"
779
780 result = verify_ospf6_rib(tgen, dut, input_dict)
781 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
782
783 result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
784 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
785
786 step("Delete the match clause with tag in route map")
787 # Create route map
788 routemaps = {
789 "r0": {
790 "route_maps": {
791 "rmap_ipv6": [
792 {
793 "action": "permit",
794 "match": {"ipv6": {"tag": "1000", "delete": True}},
795 }
796 ]
797 }
798 }
799 }
800 result = create_route_maps(tgen, routemaps)
801 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
802
803 step("Verify that metric falls back to original metric for ospf routes.")
804 dut = "r1"
805 protocol = "ospf"
806
807 result = verify_ospf6_rib(tgen, dut, input_dict)
808 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
809
810 result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
811 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
812
813 step("Delete the match clause with metric in route map.")
814
815 # Create route map
816 routemaps = {
817 "r0": {
818 "route_maps": {
819 "rmap_ipv6": [
820 {
821 "action": "permit",
822 "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
823 }
824 ]
825 }
826 }
827 }
828 result = create_route_maps(tgen, routemaps)
829 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
830
831 result = verify_ospf6_rib(tgen, dut, input_dict)
832 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
833
834 result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol)
835 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
836
837 write_test_footer(tc_name)
838
839
840 if __name__ == "__main__":
841 args = ["-s"] + sys.argv[1:]
842 sys.exit(pytest.main(args))