]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py
Merge pull request #12780 from opensourcerouting/spdx-license-id
[mirror_frr.git] / tests / topotests / ospfv3_basic_functionality / test_ospfv3_asbr_summary_topo1.py
1 #!/usr/bin/python
2 # SPDX-License-Identifier: ISC
3
4 #
5 # Copyright (c) 2021 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
7 # ("NetDEF") in this file.
8 #
9
10
11 """OSPF Summarisation Functionality Automation."""
12 import os
13 import sys
14 import time
15 import pytest
16
17 # Save the Current Working Directory to find configuration files.
18 CWD = os.path.dirname(os.path.realpath(__file__))
19 sys.path.append(os.path.join(CWD, "../"))
20 sys.path.append(os.path.join(CWD, "../lib/"))
21
22 # pylint: disable=C0413
23 # Import topogen and topotest helpers
24 from lib.topogen import Topogen, get_topogen
25 import ipaddress
26 from time import sleep
27
28 # Import topoJson from lib, to create topology and initial configuration
29 from lib.common_config import (
30 start_topology,
31 write_test_header,
32 kill_router_daemons,
33 write_test_footer,
34 reset_config_on_routers,
35 stop_router,
36 start_router,
37 verify_rib,
38 create_static_routes,
39 step,
40 start_router_daemons,
41 create_route_maps,
42 shutdown_bringup_interface,
43 create_prefix_lists,
44 create_route_maps,
45 create_interfaces_cfg,
46 )
47 from lib.topolog import logger
48 from lib.topojson import build_config_from_json
49 from lib.ospf import (
50 verify_ospf6_neighbor,
51 clear_ospf,
52 verify_ospf6_rib,
53 create_router_ospf,
54 verify_ospf_summary,
55 )
56
57 pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
58
59 # Global variables
60 topo = None
61
62 NETWORK = {
63 "ipv4": [
64 "11.0.20.1/32",
65 "11.0.20.2/32",
66 "11.0.20.3/32",
67 "11.0.20.4/32",
68 "11.0.20.5/32",
69 ],
70 "ipv6": [
71 "2011:0:20::1/128",
72 "2011:0:20::2/128",
73 "2011:0:20::3/128",
74 "2011:0:20::4/128",
75 "2011:0:20::5/128",
76 ],
77 }
78 NETWORK_11 = {
79 "ipv4": ["11.0.20.6/32", "11.0.20.7/32"],
80 "ipv6": ["2011:0:20::6/128", "2011:0:20::7/128"],
81 }
82
83 NETWORK2 = {
84 "ipv4": [
85 "12.0.20.1/32",
86 "12.0.20.2/32",
87 "12.0.20.3/32",
88 "12.0.20.4/32",
89 "12.0.20.5/32",
90 ],
91 "ipv6": [
92 "2012:0:20::1/128",
93 "2012:0:20::2/128",
94 "2012:0:20::3/128",
95 "2012:0:20::4/128",
96 "2012:0:20::5/128",
97 ],
98 }
99 SUMMARY = {
100 "ipv4": ["11.0.0.0/8", "12.0.0.0/8", "11.0.0.0/24"],
101 "ipv6": ["2011::/32", "2012::/32", "2011::/64", "2011::/24"],
102 }
103 """
104 TOPOOLOGY =
105 Please view in a fixed-width font such as Courier.
106 +---+ A0 +---+
107 +R1 +------------+R2 |
108 +-+-+- +--++
109 | -- -- |
110 | -- A0 -- |
111 A0| ---- |
112 | ---- | A0
113 | -- -- |
114 | -- -- |
115 +-+-+- +-+-+
116 +R0 +-------------+R3 |
117 +---+ A0 +---+
118
119 TESTCASES =
120 1. OSPF summarisation functionality.
121 2. OSPF summarisation with advertise and no advertise option
122 3. OSPF summarisation with route map modification of metric type.
123 4. OSPF CLI Show verify ospf ASBR summary config and show commands behaviours.
124 5. OSPF summarisation Chaos.
125 """
126
127
128 def setup_module(mod):
129 """
130 Sets up the pytest environment
131
132 * `mod`: module name
133 """
134 testsuite_run_time = time.asctime(time.localtime(time.time()))
135 logger.info("Testsuite start time: {}".format(testsuite_run_time))
136 logger.info("=" * 40)
137
138 logger.info("Running setup_module to create topology")
139
140 # This function initiates the topology build with Topogen...
141 json_file = "{}/ospfv3_asbr_summary_topo1.json".format(CWD)
142 tgen = Topogen(json_file, mod.__name__)
143 global topo
144 topo = tgen.json_topo
145 # ... and here it calls Mininet initialization functions.
146
147 # Starting topology, create tmp files which are loaded to routers
148 # to start daemons and then start routers
149 start_topology(tgen)
150
151 # Creating configuration from JSON
152 build_config_from_json(tgen, topo)
153
154 # Don't run this test if we have any failure.
155 if tgen.routers_have_failure():
156 pytest.skip(tgen.errors)
157 # Api call verify whether OSPF is converged
158 ospf_covergence = verify_ospf6_neighbor(tgen, topo)
159 assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
160 ospf_covergence
161 )
162
163 logger.info("Running setup_module() done")
164
165
166 def teardown_module(mod):
167 """
168 Teardown the pytest environment.
169
170 * `mod`: module name
171 """
172
173 logger.info("Running teardown_module to delete topology")
174
175 tgen = get_topogen()
176
177 # Stop toplogy and Remove tmp files
178 tgen.stop_topology()
179
180 logger.info(
181 "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
182 )
183 logger.info("=" * 40)
184
185
186 def red_static(dut, config=True):
187 """
188 Local 'def' for Redstribute static routes inside ospf.
189
190 Parameters
191 ----------
192 * `dut` : DUT on which configs have to be made.
193 * `config` : True or False, True by default for configure, set False for
194 unconfiguration.
195 """
196 global topo
197 tgen = get_topogen()
198 if config:
199 ospf_red = {dut: {"ospf6": {"redistribute": [{"redist_type": "static"}]}}}
200 else:
201 ospf_red = {
202 dut: {
203 "ospf6": {"redistribute": [{"redist_type": "static", "delete": True}]}
204 }
205 }
206 result = create_router_ospf(tgen, topo, ospf_red)
207 assert result is True, "Testcase : Failed \n Error: {}".format(result)
208
209
210 def red_connected(dut, config=True):
211 """
212 Local 'def' for Redstribute connected routes inside ospf
213
214 Parameters
215 ----------
216 * `dut` : DUT on which configs have to be made.
217 * `config` : True or False, True by default for configure, set False for
218 unconfiguration.
219 """
220 global topo
221 tgen = get_topogen()
222 if config:
223 ospf_red = {dut: {"ospf6": {"redistribute": [{"redist_type": "connected"}]}}}
224 else:
225 ospf_red = {
226 dut: {
227 "ospf6": {
228 "redistribute": [{"redist_type": "connected", "delete": True}]
229 }
230 }
231 }
232 result = create_router_ospf(tgen, topo, ospf_red)
233 assert result is True, "Testcase: Failed \n Error: {}".format(result)
234
235
236 # ##################################
237 # Test cases start here.
238 # ##################################
239
240
241 def test_ospfv3_type5_summary_tc42_p0(request):
242 """OSPF summarisation functionality."""
243 tc_name = request.node.name
244 write_test_header(tc_name)
245 tgen = get_topogen()
246
247 # Don't run this test if we have any failure.
248 if tgen.routers_have_failure():
249 pytest.skip(tgen.errors)
250
251 global topo
252 step("Bring up the base config as per the topology")
253 reset_config_on_routers(tgen)
254
255 protocol = "ospf"
256
257 step(
258 "Configure 5 static routes from the same network on R0"
259 "5 static routes from different networks and redistribute in R0"
260 )
261 input_dict_static_rtes = {
262 "r0": {
263 "static_routes": [
264 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
265 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
266 ]
267 }
268 }
269 result = create_static_routes(tgen, input_dict_static_rtes)
270 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
271
272 dut = "r0"
273 red_static(dut)
274
275 step("Verify that routes are learnt on R1.")
276 dut = "r1"
277
278 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
279 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
280 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
281 assert (
282 result is True
283 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
284
285 step(
286 "Configure External Route summary in R0 to summarise 5"
287 " routes to one route. with aggregate timer as 6 sec"
288 )
289
290 ospf_summ_r1 = {
291 "r0": {
292 "ospf6": {
293 "summary-address": [
294 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
295 ],
296 "aggr_timer": 6,
297 }
298 }
299 }
300 result = create_router_ospf(tgen, topo, ospf_summ_r1)
301 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
302
303 step(
304 "Verify that external routes are summarised to configured summary "
305 "address on R0 after 5 secs of delay timer expiry and only one "
306 "route is sent to R1."
307 )
308 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
309 dut = "r1"
310
311 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
312 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
313
314 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
315 assert (
316 result is True
317 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
318
319 step("Verify that show ip ospf summary should show the summaries.")
320 input_dict = {
321 SUMMARY["ipv6"][0]: {
322 "summaryAddress": SUMMARY["ipv6"][0],
323 "metricType": "E2",
324 "Metric": 20,
325 "Tag": 0,
326 "externalRouteCount": 5,
327 }
328 }
329 dut = "r0"
330 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
331 assert (
332 result is True
333 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
334
335 step("Verify that originally advertised routes are withdraw from there" " peer.")
336 input_dict = {
337 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
338 }
339 dut = "r1"
340 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
341 assert (
342 result is not True
343 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
344 tc_name, result
345 )
346
347 result = verify_rib(
348 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
349 )
350 assert (
351 result is not True
352 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
353
354 step("Delete the configured summary")
355 ospf_summ_r1 = {
356 "r0": {
357 "ospf6": {
358 "summary-address": [
359 {
360 "prefix": SUMMARY["ipv6"][0].split("/")[0],
361 "mask": "32",
362 "del_aggr_timer": True,
363 "delete": True,
364 }
365 ]
366 }
367 }
368 }
369 result = create_router_ospf(tgen, topo, ospf_summ_r1)
370 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
371
372 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
373 dut = "r1"
374 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
375 assert (
376 result is not True
377 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
378 tc_name, result
379 )
380
381 result = verify_rib(
382 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
383 )
384 assert (
385 result is not True
386 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
387 tc_name
388 )
389
390 step("show ip ospf summary should not have any summary address.")
391 input_dict = {
392 SUMMARY["ipv6"][0]: {
393 "summaryAddress": SUMMARY["ipv6"][0],
394 "metricType": "E2",
395 "Metric": 20,
396 "Tag": 0,
397 "externalRouteCount": 5,
398 }
399 }
400 dut = "r0"
401 result = verify_ospf_summary(
402 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
403 )
404 assert (
405 result is not True
406 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name)
407
408 dut = "r1"
409 step("All 5 routes are advertised after deletion of configured summary.")
410
411 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
412 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
413
414 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
415 assert (
416 result is True
417 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
418
419 step("configure the summary again and delete static routes .")
420 ospf_summ_r1 = {
421 "r0": {
422 "ospf6": {
423 "summary-address": [
424 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
425 ]
426 }
427 }
428 }
429 result = create_router_ospf(tgen, topo, ospf_summ_r1)
430 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
431
432 input_dict = {
433 SUMMARY["ipv6"][0]: {
434 "summaryAddress": SUMMARY["ipv6"][0],
435 "metricType": "E2",
436 "Metric": 20,
437 "Tag": 0,
438 "externalRouteCount": 5,
439 }
440 }
441 dut = "r0"
442 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
443 assert (
444 result is True
445 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
446
447 input_dict = {
448 "r0": {
449 "static_routes": [
450 {"network": NETWORK["ipv6"], "next_hop": "blackhole", "delete": True}
451 ]
452 }
453 }
454 result = create_static_routes(tgen, input_dict)
455 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
456
457 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
458 step("Verify that summary route is withdrawn from R1.")
459
460 dut = "r1"
461 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
462 assert (
463 result is not True
464 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
465 tc_name, result
466 )
467
468 result = verify_rib(
469 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
470 )
471 assert (
472 result is not True
473 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
474
475 step("Add back static routes.")
476 input_dict_static_rtes = {
477 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
478 }
479 result = create_static_routes(tgen, input_dict_static_rtes)
480 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
481
482 step(
483 "Verify that external routes are summarised to configured summary"
484 " address on R0 and only one route is sent to R1."
485 )
486 dut = "r1"
487
488 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes, expected=False)
489 assert (
490 result is not True
491 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
492 tc_name, result
493 )
494
495 result = verify_rib(
496 tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol, expected=False
497 )
498 assert (
499 result is not True
500 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
501
502 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
503 dut = "r1"
504
505 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
506 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
507
508 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
509 assert (
510 result is True
511 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
512
513 step("Verify that show ip ospf summary should show configure summaries.")
514
515 input_dict = {
516 SUMMARY["ipv6"][0]: {
517 "summaryAddress": SUMMARY["ipv6"][0],
518 "metricType": "E2",
519 "Metric": 20,
520 "Tag": 0,
521 "externalRouteCount": 5,
522 }
523 }
524 dut = "r0"
525 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
526 assert (
527 result is True
528 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
529
530 step("Configure new static route which is matching configured summary.")
531 input_dict_static_rtes = {
532 "r0": {
533 "static_routes": [{"network": NETWORK_11["ipv6"], "next_hop": "blackhole"}]
534 }
535 }
536 result = create_static_routes(tgen, input_dict_static_rtes)
537 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
538
539 # step("verify that summary lsa is not refreshed.")
540 # show ip ospf database command is not working, waiting for DEV fix.
541
542 step("Delete one of the static route.")
543 input_dict_static_rtes = {
544 "r0": {
545 "static_routes": [
546 {"network": NETWORK_11["ipv6"], "next_hop": "blackhole", "delete": True}
547 ]
548 }
549 }
550 result = create_static_routes(tgen, input_dict_static_rtes)
551 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
552
553 # step("verify that summary lsa is not refreshed.")
554 # show ip ospf database command is not working, waiting for DEV fix.
555
556 # step("Verify that deleted static route is removed from ospf LSDB.")
557 # show ip ospf database command is not working, waiting for DEV fix.
558
559 step(
560 "Configure redistribute connected and configure ospf external"
561 " summary address to summarise the connected routes."
562 )
563
564 dut = "r0"
565 red_connected(dut)
566 clear_ospf(tgen, dut, ospf="ospf6")
567
568 ip = topo["routers"]["r0"]["links"]["r3"]["ipv6"]
569
570 ip_net = str(ipaddress.ip_interface(u"{}".format(ip)).network)
571 ospf_summ_r1 = {
572 "r0": {
573 "ospf6": {
574 "summary-address": [{"prefix": ip_net.split("/")[0], "mask": "8"}]
575 }
576 }
577 }
578 result = create_router_ospf(tgen, topo, ospf_summ_r1)
579 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
580
581 step(
582 "Verify that external routes are summarised to configured "
583 "summary address on R0 and only one route is sent to R1."
584 )
585
586 input_dict_summary = {"r0": {"static_routes": [{"network": "fd00::/64"}]}}
587 dut = "r1"
588 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
589 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
590
591 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
592 assert (
593 result is True
594 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
595
596 step("Shut one of the interface")
597 intf = topo["routers"]["r0"]["links"]["r3-link0"]["interface"]
598 shutdown_bringup_interface(tgen, dut, intf, False)
599
600 # step("verify that summary lsa is not refreshed.")
601 # show ip ospf database command is not working, waiting for DEV fix.
602
603 # step("Verify that deleted connected route is removed from ospf LSDB.")
604 # show ip ospf database command is not working, waiting for DEV fix.
605
606 step("Un do shut the interface")
607 shutdown_bringup_interface(tgen, dut, intf, True)
608
609 # step("verify that summary lsa is not refreshed.")
610 # show ip ospf database command is not working, waiting for DEV fix.
611
612 # step("Verify that deleted connected route is removed from ospf LSDB.")
613 # show ip ospf database command is not working, waiting for DEV fix.
614
615 step("Delete OSPF process.")
616 ospf_del = {"r0": {"ospf6": {"delete": True}}}
617 result = create_router_ospf(tgen, topo, ospf_del)
618 assert result is True, "Testcase : Failed \n Error: {}".format(result)
619
620 step("Reconfigure ospf process with summary")
621 reset_config_on_routers(tgen)
622
623 input_dict_static_rtes = {
624 "r0": {
625 "static_routes": [
626 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
627 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
628 ]
629 }
630 }
631 result = create_static_routes(tgen, input_dict_static_rtes)
632 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
633
634 dut = "r0"
635 red_static(dut)
636 red_connected(dut)
637 ospf_summ_r1 = {
638 "r0": {
639 "ospf6": {
640 "summary-address": [
641 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
642 ]
643 }
644 }
645 }
646 result = create_router_ospf(tgen, topo, ospf_summ_r1)
647 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
648 step(
649 "Verify that external routes are summarised to configured summary "
650 "address on R0 and only one route is sent to R1."
651 )
652
653 input_dict = {
654 SUMMARY["ipv6"][0]: {
655 "summaryAddress": SUMMARY["ipv6"][0],
656 "metricType": "E2",
657 "Metric": 20,
658 "Tag": 0,
659 "externalRouteCount": 5,
660 }
661 }
662 dut = "r0"
663 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
664 assert (
665 result is True
666 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
667
668 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
669
670 dut = "r1"
671 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
672 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
673
674 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
675 assert (
676 result is True
677 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
678
679 ospf_summ_r1 = {
680 "r0": {
681 "ospf6": {
682 "summary-address": [
683 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
684 ]
685 }
686 }
687 }
688 result = create_router_ospf(tgen, topo, ospf_summ_r1)
689 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
690
691 # step("verify that summary lsa is not refreshed.")
692 # show ip ospf database command is not working, waiting for DEV fix.
693
694 step("Delete the redistribute command in ospf.")
695 dut = "r0"
696 red_connected(dut, config=False)
697 red_static(dut, config=False)
698
699 step("Verify that summary route is withdrawn from the peer.")
700
701 dut = "r1"
702 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
703 assert (
704 result is not True
705 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
706 tc_name, result
707 )
708
709 result = verify_rib(
710 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
711 )
712 assert (
713 result is not True
714 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
715
716 ospf_summ_r1 = {
717 "r0": {
718 "ospf6": {
719 "summary-address": [
720 {
721 "prefix": SUMMARY["ipv6"][0].split("/")[0],
722 "mask": "32",
723 "metric": "1234",
724 }
725 ]
726 }
727 }
728 }
729 result = create_router_ospf(tgen, topo, ospf_summ_r1)
730 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
731
732 write_test_footer(tc_name)
733
734
735 def test_ospfv3_type5_summary_tc43_p0(request):
736 """OSPF summarisation with metric type 2."""
737 tc_name = request.node.name
738 write_test_header(tc_name)
739 tgen = get_topogen()
740
741 # Don't run this test if we have any failure.
742 if tgen.routers_have_failure():
743 pytest.skip(tgen.errors)
744
745 global topo
746 step("Bring up the base config as per the topology")
747 reset_config_on_routers(tgen)
748
749 protocol = "ospf"
750
751 step(
752 "Configure 5 static routes from the same network on R0"
753 "5 static routes from different networks and redistribute in R0"
754 )
755 input_dict_static_rtes = {
756 "r0": {
757 "static_routes": [
758 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
759 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
760 ]
761 }
762 }
763 result = create_static_routes(tgen, input_dict_static_rtes)
764 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
765
766 dut = "r0"
767 red_static(dut)
768
769 step("Verify that routes are learnt on R1.")
770 dut = "r1"
771
772 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
773 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
774 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
775 assert (
776 result is True
777 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
778
779 step(
780 "Configure External Route summary in R0 to summarise 5" " routes to one route."
781 )
782 ospf_summ_r1 = {
783 "r0": {
784 "ospf6": {
785 "summary-address": [
786 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
787 ]
788 }
789 }
790 }
791 result = create_router_ospf(tgen, topo, ospf_summ_r1)
792 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
793 step(
794 "Verify that external routes are summarised to configured summary "
795 "address on R0 after 5 secs of delay timer expiry and only one "
796 "route is sent to R1."
797 )
798 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
799 dut = "r1"
800
801 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
802 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
803
804 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
805 assert (
806 result is True
807 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
808
809 step("Verify that show ip ospf summary should show the summaries.")
810 input_dict = {
811 SUMMARY["ipv6"][0]: {
812 "summaryAddress": SUMMARY["ipv6"][0],
813 "metricType": "E2",
814 "Metric": 20,
815 "Tag": 0,
816 "externalRouteCount": 5,
817 }
818 }
819 dut = "r0"
820 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
821 assert (
822 result is True
823 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
824
825 step("Change the summary address mask to lower match (ex - 16 to 8)")
826 ospf_summ_r1 = {
827 "r0": {
828 "ospf6": {
829 "summary-address": [
830 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "16"},
831 {
832 "prefix": SUMMARY["ipv6"][0].split("/")[0],
833 "mask": "32",
834 "delete": True,
835 },
836 ]
837 }
838 }
839 }
840 result = create_router_ospf(tgen, topo, ospf_summ_r1)
841 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
842
843 sleep(5)
844
845 input_dict = {
846 "2011::/16": {
847 "summaryAddress": "2011::/16",
848 "metricType": "E2",
849 "Metric": 20,
850 "Tag": 0,
851 "externalRouteCount": 5,
852 }
853 }
854 dut = "r0"
855 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
856 assert (
857 result is True
858 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
859
860 step(
861 "Verify that external routes(static / connected) are summarised"
862 " to configured summary address with newly configured mask."
863 )
864
865 input_dict_summary = {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
866 dut = "r1"
867
868 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
869 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
870
871 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
872 assert (
873 result is True
874 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
875
876 step("Change the summary address mask to higher match (ex - 8 to 24)")
877 ospf_summ_r1 = {
878 "r0": {
879 "ospf6": {
880 "summary-address": [
881 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
882 ]
883 }
884 }
885 }
886 result = create_router_ospf(tgen, topo, ospf_summ_r1)
887 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
888
889 input_dict = {
890 "2011::/32": {
891 "summaryAddress": "2011::/32",
892 "metricType": "E2",
893 "Metric": 20,
894 "Tag": 0,
895 "externalRouteCount": 0,
896 }
897 }
898 dut = "r0"
899 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
900 assert (
901 result is True
902 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
903
904 step(
905 "Verify that external routes(static / connected) are summarised"
906 " to configured summary address with newly configured mask."
907 )
908 step("Configure 2 summary address with different mask of same network.")
909 step(
910 "Verify that external routes(static / connected) are summarised "
911 "to configured summary address with highest match."
912 )
913
914 input_dict_summary = {"r0": {"static_routes": [{"network": "2011::0/32"}]}}
915 dut = "r1"
916
917 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
918 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
919
920 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
921 assert (
922 result is True
923 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
924
925 step(" Un configure one of the summary address.")
926 ospf_summ_r1 = {
927 "r0": {
928 "ospf6": {
929 "summary-address": [
930 {
931 "prefix": SUMMARY["ipv6"][0].split("/")[0],
932 "mask": "32",
933 "delete": True,
934 }
935 ]
936 }
937 }
938 }
939 result = create_router_ospf(tgen, topo, ospf_summ_r1)
940 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
941
942 sleep(5)
943
944 step(
945 "Verify that external routes(static / connected) are summarised"
946 " to configured summary address with newly configured mask."
947 )
948
949 input_dict_summary = {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
950 dut = "r1"
951
952 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
953 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
954
955 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
956 assert (
957 result is True
958 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
959
960 ospf_summ_r1 = {
961 "r0": {
962 "ospf6": {
963 "summary-address": [
964 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "16"}
965 ]
966 }
967 }
968 }
969 result = create_router_ospf(tgen, topo, ospf_summ_r1)
970 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
971
972 step(
973 "Verify that external routes(static / connected) are summarised "
974 "to configured summary address with highest match."
975 )
976 input_dict_summary = {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
977 dut = "r1"
978
979 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
980 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
981
982 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
983 assert (
984 result is True
985 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
986
987 write_test_footer(tc_name)
988
989
990 def ospfv3_type5_summary_tc45_p0(request):
991 """OSPF summarisation with Tag option"""
992 tc_name = request.node.name
993 write_test_header(tc_name)
994 tgen = get_topogen()
995
996 # Don't run this test if we have any failure.
997 if tgen.routers_have_failure():
998 pytest.skip(tgen.errors)
999
1000 global topo
1001 step("Bring up the base config as per the topology")
1002 step("Configure OSPF on all the routers of the topology.")
1003 reset_config_on_routers(tgen)
1004
1005 protocol = "ospf"
1006
1007 step(
1008 "Configure 5 static routes from the same network on R0"
1009 "5 static routes from different networks and redistribute in R0"
1010 )
1011 input_dict_static_rtes = {
1012 "r0": {
1013 "static_routes": [
1014 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1015 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1016 ]
1017 }
1018 }
1019 result = create_static_routes(tgen, input_dict_static_rtes)
1020 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1021
1022 dut = "r0"
1023 red_static(dut)
1024
1025 step("Verify that routes are learnt on R1.")
1026 dut = "r1"
1027
1028 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1029 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1030 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1031 assert (
1032 result is True
1033 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1034
1035 step(
1036 "Configure External Route summary in R0 to summarise 5" " routes to one route."
1037 )
1038 ospf_summ_r1 = {
1039 "r0": {
1040 "ospf6": {
1041 "summary-address": [
1042 {
1043 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1044 "mask": "32",
1045 "tag": "1234",
1046 }
1047 ]
1048 }
1049 }
1050 }
1051 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1052 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1053
1054 step(
1055 "Verify that external routes are summarised to configured summary"
1056 " address on R0 and only one route is sent to R1 with configured tag."
1057 )
1058 input_dict_summary = {
1059 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "1234"}]}
1060 }
1061 dut = "r1"
1062
1063 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1064 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1065
1066 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1067 assert (
1068 result is True
1069 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1070
1071 step("Verify that show ip ospf summary should show the summaries with tag.")
1072 input_dict = {
1073 SUMMARY["ipv6"][0]: {
1074 "summaryAddress": SUMMARY["ipv6"][0],
1075 "metricType": "E2",
1076 "Metric": 20,
1077 "Tag": 1234,
1078 "externalRouteCount": 5,
1079 }
1080 }
1081 dut = "r0"
1082 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1083 assert (
1084 result is True
1085 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
1086
1087 step("Delete the configured summary")
1088 ospf_summ_r1 = {
1089 "r0": {
1090 "ospf6": {
1091 "summary-address": [
1092 {
1093 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1094 "mask": "32",
1095 "tag": "1234",
1096 "delete": True,
1097 }
1098 ]
1099 }
1100 }
1101 }
1102 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1103 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1104
1105 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1106 dut = "r1"
1107 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
1108 assert (
1109 result is not True
1110 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1111 tc_name, result
1112 )
1113
1114 result = verify_rib(
1115 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1116 )
1117 assert (
1118 result is not True
1119 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
1120 tc_name
1121 )
1122
1123 step("show ip ospf summary should not have any summary address.")
1124 input_dict = {
1125 SUMMARY["ipv6"][0]: {
1126 "summaryAddress": SUMMARY["ipv6"][0],
1127 "metricType": "E2",
1128 "Metric": 20,
1129 "Tag": 1234,
1130 "externalRouteCount": 5,
1131 }
1132 }
1133 dut = "r0"
1134 result = verify_ospf_summary(
1135 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1136 )
1137 assert (
1138 result is not True
1139 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name)
1140
1141 step("Configure Min tag value")
1142 ospf_summ_r1 = {
1143 "r0": {
1144 "ospf6": {
1145 "summary-address": [
1146 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32", "tag": 1}
1147 ]
1148 }
1149 }
1150 }
1151 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1152 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1153 input_dict_summary = {
1154 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "1"}]}
1155 }
1156 dut = "r1"
1157
1158 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1159 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1160
1161 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1162 assert (
1163 result is True
1164 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1165
1166 step("Verify that show ip ospf summary should show the summaries with tag.")
1167 input_dict = {
1168 SUMMARY["ipv6"][0]: {
1169 "summaryAddress": SUMMARY["ipv6"][0],
1170 "metricType": "E2",
1171 "Metric": 20,
1172 "Tag": 1,
1173 "externalRouteCount": 5,
1174 }
1175 }
1176 dut = "r0"
1177 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1178 assert (
1179 result is True
1180 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
1181
1182 step("Configure Max Tag Value")
1183 ospf_summ_r1 = {
1184 "r0": {
1185 "ospf6": {
1186 "summary-address": [
1187 {
1188 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1189 "mask": "32",
1190 "tag": 4294967295,
1191 }
1192 ]
1193 }
1194 }
1195 }
1196 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1197 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1198
1199 input_dict_summary = {
1200 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "4294967295"}]}
1201 }
1202 dut = "r1"
1203
1204 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1205 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1206
1207 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1208 assert (
1209 result is True
1210 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1211
1212 step(
1213 "Verify that boundary values tags are used for summary route"
1214 " using show ip ospf route command."
1215 )
1216 input_dict = {
1217 SUMMARY["ipv6"][0]: {
1218 "summaryAddress": SUMMARY["ipv6"][0],
1219 "metricType": "E2",
1220 "Metric": 20,
1221 "Tag": 4294967295,
1222 "externalRouteCount": 5,
1223 }
1224 }
1225 dut = "r0"
1226 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1227 assert (
1228 result is True
1229 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
1230
1231 step("configure new static route with different tag.")
1232 input_dict_static_rtes_11 = {
1233 "r0": {
1234 "static_routes": [
1235 {"network": NETWORK_11["ipv6"], "next_hop": "blackhole", "tag": "88888"}
1236 ]
1237 }
1238 }
1239 result = create_static_routes(tgen, input_dict_static_rtes_11)
1240 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1241
1242 step("New tag has not been used by summary address.")
1243
1244 input_dict_summary = {
1245 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "88888"}]}
1246 }
1247 dut = "r1"
1248
1249 result = verify_ospf6_rib(
1250 tgen, dut, input_dict_summary, tag="88888", expected=False
1251 )
1252 assert (
1253 result is not True
1254 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1255 tc_name, result
1256 )
1257
1258 result = verify_rib(
1259 tgen,
1260 "ipv6",
1261 dut,
1262 input_dict_summary,
1263 protocol=protocol,
1264 tag="88888",
1265 expected=False,
1266 )
1267 assert (
1268 result is not True
1269 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
1270
1271 step(
1272 "Verify that boundary values tags are used for summary route"
1273 " using show ip ospf route command."
1274 )
1275 input_dict = {
1276 SUMMARY["ipv6"][0]: {
1277 "summaryAddress": SUMMARY["ipv6"][0],
1278 "metricType": "E2",
1279 "Metric": 20,
1280 "Tag": 88888,
1281 "externalRouteCount": 5,
1282 }
1283 }
1284 dut = "r0"
1285 result = verify_ospf_summary(
1286 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1287 )
1288 assert (
1289 result is not True
1290 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
1291
1292 step("Delete the configured summary address")
1293 ospf_summ_r1 = {
1294 "r0": {
1295 "ospf6": {
1296 "summary-address": [
1297 {
1298 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1299 "mask": "32",
1300 "tag": 4294967295,
1301 "delete": True,
1302 }
1303 ]
1304 }
1305 }
1306 }
1307 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1308 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1309
1310 step(
1311 "Verify that 6 routes are advertised to neighbour with 5 routes"
1312 " without any tag, 1 route with tag."
1313 )
1314
1315 dut = "r1"
1316 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1317 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1318 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1319 assert (
1320 result is True
1321 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1322
1323 step("Verify that summary address is flushed from neighbor.")
1324
1325 dut = "r1"
1326 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
1327 assert (
1328 result is not True
1329 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1330 tc_name, result
1331 )
1332
1333 result = verify_rib(
1334 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1335 )
1336 assert (
1337 result is not True
1338 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
1339
1340 step("Configure summary first & then configure matching static route.")
1341
1342 input_dict_static_rtes = {
1343 "r0": {
1344 "static_routes": [
1345 {"network": NETWORK["ipv6"], "next_hop": "blackhole", "delete": True},
1346 {"network": NETWORK2["ipv6"], "next_hop": "blackhole", "delete": True},
1347 ]
1348 }
1349 }
1350 result = create_static_routes(tgen, input_dict_static_rtes)
1351 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1352
1353 ospf_summ_r1 = {
1354 "r0": {
1355 "ospf6": {
1356 "summary-address": [
1357 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
1358 ]
1359 }
1360 }
1361 }
1362 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1363 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1364
1365 input_dict_static_rtes = {
1366 "r0": {
1367 "static_routes": [
1368 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1369 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1370 ]
1371 }
1372 }
1373 result = create_static_routes(tgen, input_dict_static_rtes)
1374 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1375
1376 step("Repeat steps 1 to 10 of summarisation in non Back bone area.")
1377 reset_config_on_routers(tgen)
1378
1379 step("Change the area id on the interface on R0")
1380 input_dict = {
1381 "r0": {
1382 "links": {
1383 "r1": {
1384 "interface": topo["routers"]["r0"]["links"]["r1"]["interface"],
1385 "ospf6": {"area": "0.0.0.0"},
1386 "delete": True,
1387 }
1388 }
1389 }
1390 }
1391
1392 result = create_interfaces_cfg(tgen, input_dict)
1393 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1394
1395 input_dict = {
1396 "r0": {
1397 "links": {
1398 "r1": {
1399 "interface": topo["routers"]["r0"]["links"]["r1"]["interface"],
1400 "ospf6": {"area": "0.0.0.1"},
1401 }
1402 }
1403 }
1404 }
1405
1406 result = create_interfaces_cfg(tgen, input_dict)
1407 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1408
1409 step("Change the area id on the interface ")
1410 input_dict = {
1411 "r1": {
1412 "links": {
1413 "r0": {
1414 "interface": topo["routers"]["r1"]["links"]["r0"]["interface"],
1415 "ospf6": {"area": "0.0.0.0"},
1416 "delete": True,
1417 }
1418 }
1419 }
1420 }
1421
1422 result = create_interfaces_cfg(tgen, input_dict)
1423 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1424
1425 input_dict = {
1426 "r1": {
1427 "links": {
1428 "r0": {
1429 "interface": topo["routers"]["r1"]["links"]["r0"]["interface"],
1430 "ospf6": {"area": "0.0.0.1"},
1431 }
1432 }
1433 }
1434 }
1435
1436 result = create_interfaces_cfg(tgen, input_dict)
1437 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1438
1439 ospf_covergence = verify_ospf6_neighbor(tgen, topo)
1440 assert ospf_covergence is True, "Testcase {} :Failed \n Error: {}".format(
1441 tc_name, ospf_covergence
1442 )
1443
1444 step(
1445 "Configure 5 static routes from the same network on R0"
1446 "5 static routes from different networks and redistribute in R0"
1447 )
1448 input_dict_static_rtes = {
1449 "r0": {
1450 "static_routes": [
1451 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1452 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1453 ]
1454 }
1455 }
1456 result = create_static_routes(tgen, input_dict_static_rtes)
1457 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1458
1459 dut = "r0"
1460 red_static(dut)
1461
1462 step("Verify that routes are learnt on R1.")
1463 dut = "r1"
1464
1465 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1466 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1467 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1468 assert (
1469 result is True
1470 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1471
1472 step(
1473 "Configure External Route summary in R0 to summarise 5" " routes to one route."
1474 )
1475 ospf_summ_r1 = {
1476 "r0": {
1477 "ospf6": {
1478 "summary-address": [
1479 {
1480 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1481 "mask": "32",
1482 "tag": "1234",
1483 }
1484 ]
1485 }
1486 }
1487 }
1488 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1489 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1490
1491 step(
1492 "Verify that external routes are summarised to configured summary"
1493 " address on R0 and only one route is sent to R1 with configured tag."
1494 )
1495 input_dict_summary = {
1496 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "1234"}]}
1497 }
1498 dut = "r1"
1499
1500 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1501 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1502
1503 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1504 assert (
1505 result is True
1506 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1507
1508 step("Verify that show ip ospf summary should show the summaries with tag.")
1509 input_dict = {
1510 SUMMARY["ipv6"][0]: {
1511 "summaryAddress": SUMMARY["ipv6"][0],
1512 "metricType": "E2",
1513 "Metric": 20,
1514 "Tag": 1234,
1515 "externalRouteCount": 5,
1516 }
1517 }
1518 dut = "r0"
1519 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1520 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1521
1522 step("Delete the configured summary")
1523 ospf_summ_r1 = {
1524 "r0": {
1525 "ospf6": {
1526 "summary-address": [
1527 {
1528 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1529 "mask": "32",
1530 "delete": True,
1531 }
1532 ]
1533 }
1534 }
1535 }
1536 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1537 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1538
1539 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1540 dut = "r1"
1541 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
1542 assert (
1543 result is not True
1544 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1545 tc_name, result
1546 )
1547
1548 result = verify_rib(
1549 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1550 )
1551 assert (
1552 result is not True
1553 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
1554 tc_name
1555 )
1556
1557 step("show ip ospf summary should not have any summary address.")
1558 input_dict = {
1559 SUMMARY["ipv6"][0]: {
1560 "summaryAddress": SUMMARY["ipv6"][0],
1561 "metricType": "E2",
1562 "Metric": 20,
1563 "Tag": 1234,
1564 "externalRouteCount": 5,
1565 }
1566 }
1567 dut = "r0"
1568 result = verify_ospf_summary(
1569 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1570 )
1571 assert (
1572 result is not True
1573 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name)
1574
1575 step("Configure Min tag value")
1576 ospf_summ_r1 = {
1577 "r0": {
1578 "ospf6": {
1579 "summary-address": [
1580 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32", "tag": 1}
1581 ]
1582 }
1583 }
1584 }
1585 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1586 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1587 input_dict_summary = {
1588 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "1"}]}
1589 }
1590 dut = "r1"
1591
1592 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1593 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1594
1595 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1596 assert (
1597 result is True
1598 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1599
1600 step("Verify that show ip ospf summary should show the summaries with tag.")
1601 input_dict = {
1602 SUMMARY["ipv6"][0]: {
1603 "summaryAddress": SUMMARY["ipv6"][0],
1604 "metricType": "E2",
1605 "Metric": 20,
1606 "Tag": 1,
1607 "externalRouteCount": 5,
1608 }
1609 }
1610 dut = "r0"
1611 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1612 assert (
1613 result is True
1614 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
1615
1616 step("Configure Max Tag Value")
1617 ospf_summ_r1 = {
1618 "r0": {
1619 "ospf6": {
1620 "summary-address": [
1621 {
1622 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1623 "mask": "32",
1624 "tag": 4294967295,
1625 }
1626 ]
1627 }
1628 }
1629 }
1630 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1631 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1632
1633 input_dict_summary = {
1634 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "4294967295"}]}
1635 }
1636 dut = "r1"
1637
1638 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1639 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1640
1641 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1642 assert (
1643 result is True
1644 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1645
1646 step(
1647 "Verify that boundary values tags are used for summary route"
1648 " using show ip ospf route command."
1649 )
1650 input_dict = {
1651 SUMMARY["ipv6"][0]: {
1652 "summaryAddress": SUMMARY["ipv6"][0],
1653 "metricType": "E2",
1654 "Metric": 20,
1655 "Tag": 4294967295,
1656 "externalRouteCount": 5,
1657 }
1658 }
1659 dut = "r0"
1660 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1661 assert (
1662 result is True
1663 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
1664
1665 step("configure new static route with different tag.")
1666 input_dict_static_rtes_11 = {
1667 "r0": {
1668 "static_routes": [
1669 {"network": NETWORK_11["ipv6"], "next_hop": "blackhole", "tag": "88888"}
1670 ]
1671 }
1672 }
1673 result = create_static_routes(tgen, input_dict_static_rtes_11)
1674 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1675
1676 step("New tag has not been used by summary address.")
1677
1678 input_dict_summary = {
1679 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "88888"}]}
1680 }
1681 dut = "r1"
1682
1683 result = verify_ospf6_rib(
1684 tgen, dut, input_dict_summary, tag="88888", expected=False
1685 )
1686 assert (
1687 result is not True
1688 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1689 tc_name, result
1690 )
1691
1692 result = verify_rib(
1693 tgen,
1694 "ipv6",
1695 dut,
1696 input_dict_summary,
1697 protocol=protocol,
1698 tag="88888",
1699 expected=False,
1700 )
1701 assert (
1702 result is not True
1703 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
1704
1705 step(
1706 "Verify that boundary values tags are used for summary route"
1707 " using show ip ospf route command."
1708 )
1709 input_dict = {
1710 SUMMARY["ipv6"][0]: {
1711 "summaryAddress": SUMMARY["ipv6"][0],
1712 "metricType": "E2",
1713 "Metric": 20,
1714 "Tag": 88888,
1715 "externalRouteCount": 5,
1716 }
1717 }
1718 dut = "r0"
1719 result = verify_ospf_summary(
1720 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1721 )
1722 assert (
1723 result is not True
1724 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
1725
1726 step("Delete the configured summary address")
1727 ospf_summ_r1 = {
1728 "r0": {
1729 "ospf6": {
1730 "summary-address": [
1731 {
1732 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1733 "mask": "32",
1734 "tag": 4294967295,
1735 "delete": True,
1736 }
1737 ]
1738 }
1739 }
1740 }
1741 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1742 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1743
1744 step(
1745 "Verify that 6 routes are advertised to neighbour with 5 routes"
1746 " without any tag, 1 route with tag."
1747 )
1748
1749 dut = "r1"
1750 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1751 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1752 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1753 assert (
1754 result is True
1755 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1756
1757 step("Verify that summary address is flushed from neighbor.")
1758
1759 dut = "r1"
1760 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
1761 assert (
1762 result is not True
1763 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1764 tc_name, result
1765 )
1766
1767 result = verify_rib(
1768 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1769 )
1770 assert (
1771 result is not True
1772 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
1773
1774 step("Configure summary first & then configure matching static route.")
1775
1776 input_dict_static_rtes = {
1777 "r0": {
1778 "static_routes": [
1779 {"network": NETWORK["ipv6"], "next_hop": "blackhole", "delete": True},
1780 {"network": NETWORK2["ipv6"], "next_hop": "blackhole", "delete": True},
1781 ]
1782 }
1783 }
1784 result = create_static_routes(tgen, input_dict_static_rtes)
1785 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1786
1787 ospf_summ_r1 = {
1788 "r0": {
1789 "ospf6": {
1790 "summary-address": [
1791 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
1792 ]
1793 }
1794 }
1795 }
1796 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1797 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1798
1799 input_dict_static_rtes = {
1800 "r0": {
1801 "static_routes": [
1802 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1803 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1804 ]
1805 }
1806 }
1807 result = create_static_routes(tgen, input_dict_static_rtes)
1808 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1809
1810 write_test_footer(tc_name)
1811
1812
1813 def test_ospfv3_type5_summary_tc46_p0(request):
1814 """OSPF summarisation with advertise and no advertise option"""
1815 tc_name = request.node.name
1816 write_test_header(tc_name)
1817 tgen = get_topogen()
1818
1819 # Don't run this test if we have any failure.
1820 if tgen.routers_have_failure():
1821 pytest.skip(tgen.errors)
1822
1823 global topo
1824 step("Bring up the base config as per the topology")
1825 step("Configure OSPF on all the routers of the topology.")
1826 reset_config_on_routers(tgen)
1827
1828 protocol = "ospf"
1829
1830 step(
1831 "Configure 5 static routes from the same network on R0"
1832 "5 static routes from different networks and redistribute in R0"
1833 )
1834 input_dict_static_rtes = {
1835 "r0": {
1836 "static_routes": [
1837 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1838 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1839 ]
1840 }
1841 }
1842 result = create_static_routes(tgen, input_dict_static_rtes)
1843 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1844
1845 dut = "r0"
1846 red_static(dut)
1847
1848 step("Verify that routes are learnt on R1.")
1849 dut = "r1"
1850
1851 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1852 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1853 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1854 assert (
1855 result is True
1856 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
1857
1858 step(
1859 "Configure External Route summary in R0 to summarise 5"
1860 " routes to one route with no advertise option."
1861 )
1862 ospf_summ_r1 = {
1863 "r0": {
1864 "ospf6": {
1865 "summary-address": [
1866 {
1867 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1868 "mask": "32",
1869 "advertise": False,
1870 }
1871 ]
1872 }
1873 }
1874 }
1875 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1876 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1877
1878 step(
1879 "Verify that external routes are summarised to configured summary"
1880 " address on R0 and summary route is not advertised to neighbor as"
1881 " no advertise is configured.."
1882 )
1883
1884 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
1885 dut = "r1"
1886
1887 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
1888 assert (
1889 result is not True
1890 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1891 tc_name, result
1892 )
1893
1894 result = verify_rib(
1895 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1896 )
1897 assert (
1898 result is not True
1899 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
1900
1901 step("Verify that show ip ospf summary should show the " "configured summaries.")
1902 input_dict = {
1903 SUMMARY["ipv6"][0]: {
1904 "summaryAddress": SUMMARY["ipv6"][0],
1905 "externalRouteCount": 5,
1906 }
1907 }
1908 dut = "r0"
1909 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1910 assert (
1911 result is True
1912 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
1913
1914 step("Delete the configured summary")
1915 ospf_summ_r1 = {
1916 "r0": {
1917 "ospf6": {
1918 "summary-address": [
1919 {
1920 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1921 "mask": "32",
1922 "delete": True,
1923 }
1924 ]
1925 }
1926 }
1927 }
1928 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1929 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1930
1931 step("Summary has 5 sec delay timer, sleep 5 secs...")
1932 sleep(5)
1933
1934 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1935 dut = "r1"
1936 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
1937 assert (
1938 result is not True
1939 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1940 tc_name, result
1941 )
1942
1943 result = verify_rib(
1944 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1945 )
1946 assert (
1947 result is not True
1948 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
1949 tc_name
1950 )
1951
1952 step("show ip ospf summary should not have any summary address.")
1953 input_dict = {
1954 SUMMARY["ipv6"][0]: {
1955 "summaryAddress": SUMMARY["ipv6"][0],
1956 "metricType": "E2",
1957 "Metric": 20,
1958 "Tag": 1234,
1959 "externalRouteCount": 5,
1960 }
1961 }
1962 dut = "r0"
1963 result = verify_ospf_summary(
1964 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1965 )
1966 assert (
1967 result is not True
1968 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name)
1969
1970 step("Reconfigure summary with no advertise.")
1971 ospf_summ_r1 = {
1972 "r0": {
1973 "ospf6": {
1974 "summary-address": [
1975 {
1976 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1977 "mask": "32",
1978 "advertise": False,
1979 }
1980 ]
1981 }
1982 }
1983 }
1984 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1985 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1986
1987 step(
1988 "Verify that external routes are summarised to configured summary"
1989 " address on R0 and summary route is not advertised to neighbor as"
1990 " no advertise is configured.."
1991 )
1992
1993 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
1994 dut = "r1"
1995
1996 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
1997 assert (
1998 result is not True
1999 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2000 tc_name, result
2001 )
2002
2003 result = verify_rib(
2004 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
2005 )
2006 assert (
2007 result is not True
2008 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
2009
2010 step("Verify that show ip ospf summary should show the " "configured summaries.")
2011 input_dict = {
2012 SUMMARY["ipv6"][0]: {
2013 "summaryAddress": SUMMARY["ipv6"][0],
2014 "externalRouteCount": 5,
2015 }
2016 }
2017 dut = "r0"
2018 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2019 assert (
2020 result is True
2021 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
2022
2023 step(
2024 "Change summary address from no advertise to advertise "
2025 "(summary-address 10.0.0.0 255.255.0.0)"
2026 )
2027
2028 ospf_summ_r1 = {
2029 "r0": {
2030 "ospf6": {
2031 "summary-address": [
2032 {
2033 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2034 "mask": "32",
2035 "advertise": False,
2036 }
2037 ]
2038 }
2039 }
2040 }
2041 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2042 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2043
2044 ospf_summ_r1 = {
2045 "r0": {
2046 "ospf6": {
2047 "summary-address": [
2048 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
2049 ]
2050 }
2051 }
2052 }
2053 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2054 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2055
2056 step(
2057 "Verify that external routes are summarised to configured summary "
2058 "address on R0 after 5 secs of delay timer expiry and only one "
2059 "route is sent to R1."
2060 )
2061 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2062 dut = "r1"
2063
2064 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2065 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2066
2067 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2068 assert (
2069 result is True
2070 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
2071
2072 step("Verify that show ip ospf summary should show the summaries.")
2073 input_dict = {
2074 SUMMARY["ipv6"][0]: {
2075 "summaryAddress": SUMMARY["ipv6"][0],
2076 "metricType": "E2",
2077 "Metric": 20,
2078 "Tag": 0,
2079 "externalRouteCount": 5,
2080 }
2081 }
2082 dut = "r0"
2083 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2084 assert (
2085 result is True
2086 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
2087
2088 step("Verify that originally advertised routes are withdraw from there" " peer.")
2089 output = tgen.gears["r0"].vtysh_cmd(
2090 "show ipv6 ospf6 database as-external json", isjson=True
2091 )
2092
2093 output = tgen.gears["r1"].vtysh_cmd(
2094 "show ipv6 ospf6 database as-external json", isjson=True
2095 )
2096
2097 input_dict = {
2098 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
2099 }
2100 dut = "r1"
2101 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
2102 assert (
2103 result is not True
2104 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2105 tc_name, result
2106 )
2107
2108 result = verify_rib(
2109 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
2110 )
2111 assert (
2112 result is not True
2113 ), "Testcase {} : Failed" "Error: Routes is present in RIB".format(tc_name)
2114
2115 write_test_footer(tc_name)
2116
2117
2118 def test_ospfv3_type5_summary_tc48_p0(request):
2119 """OSPF summarisation with route map modification of metric type."""
2120 tc_name = request.node.name
2121 write_test_header(tc_name)
2122 tgen = get_topogen()
2123
2124 # Don't run this test if we have any failure.
2125 if tgen.routers_have_failure():
2126 pytest.skip(tgen.errors)
2127
2128 global topo
2129 step("Bring up the base config as per the topology")
2130 reset_config_on_routers(tgen)
2131
2132 protocol = "ospf"
2133
2134 step(
2135 "Configure 5 static routes from the same network on R0"
2136 "5 static routes from different networks and redistribute in R0"
2137 )
2138 input_dict_static_rtes = {
2139 "r0": {
2140 "static_routes": [
2141 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
2142 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
2143 ]
2144 }
2145 }
2146 result = create_static_routes(tgen, input_dict_static_rtes)
2147 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2148
2149 dut = "r0"
2150 red_static(dut)
2151
2152 step("Verify that routes are learnt on R1.")
2153 dut = "r1"
2154
2155 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
2156 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2157 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
2158 assert (
2159 result is True
2160 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
2161
2162 step(
2163 "Configure External Route summary in R0 to summarise 5" " routes to one route."
2164 )
2165
2166 ospf_summ_r1 = {
2167 "r0": {
2168 "ospf6": {
2169 "summary-address": [
2170 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
2171 ]
2172 }
2173 }
2174 }
2175 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2176 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2177
2178 step(
2179 "Verify that external routes are summarised to configured summary "
2180 "address on R0 after 5 secs of delay timer expiry and only one "
2181 "route is sent to R1."
2182 )
2183 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2184 dut = "r1"
2185
2186 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2187 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2188
2189 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2190 assert (
2191 result is True
2192 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
2193
2194 step("Verify that show ip ospf summary should show the summaries.")
2195 input_dict = {
2196 SUMMARY["ipv6"][0]: {
2197 "summaryAddress": SUMMARY["ipv6"][0],
2198 "metricType": "E2",
2199 "Metric": 20,
2200 "Tag": 0,
2201 "externalRouteCount": 5,
2202 }
2203 }
2204 dut = "r0"
2205 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2206 assert (
2207 result is True
2208 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
2209
2210 step("Verify that originally advertised routes are withdraw from there" " peer.")
2211 input_dict = {
2212 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
2213 }
2214 dut = "r1"
2215 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
2216 assert (
2217 result is not True
2218 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2219 tc_name, result
2220 )
2221
2222 result = verify_rib(
2223 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
2224 )
2225 assert (
2226 result is not True
2227 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
2228
2229 step(
2230 "Configure route map and & rule to permit configured summary address,"
2231 " redistribute static & connected routes with the route map."
2232 )
2233 step("Configure prefixlist to permit the static routes, add to route map.")
2234 # Create ip prefix list
2235 pfx_list = {
2236 "r0": {
2237 "prefix_lists": {
2238 "ipv6": {
2239 "pf_list_1_ipv6": [
2240 {"seqid": 10, "network": "any", "action": "permit"}
2241 ]
2242 }
2243 }
2244 }
2245 }
2246 result = create_prefix_lists(tgen, pfx_list)
2247 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2248
2249 routemaps = {
2250 "r0": {
2251 "route_maps": {
2252 "rmap_ipv6": [
2253 {
2254 "action": "permit",
2255 "seq_id": "1",
2256 "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
2257 }
2258 ]
2259 }
2260 }
2261 }
2262 result = create_route_maps(tgen, routemaps)
2263 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2264
2265 ospf_red_r1 = {
2266 "r0": {
2267 "ospf6": {
2268 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
2269 }
2270 }
2271 }
2272 result = create_router_ospf(tgen, topo, ospf_red_r1)
2273 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2274
2275 step(
2276 "Verify that external routes are summarised to configured"
2277 "summary address on R0 and only one route is sent to R1. Verify that "
2278 "show ip ospf summary should show the configure summaries."
2279 )
2280
2281 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2282 dut = "r1"
2283
2284 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2285 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2286
2287 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2288 assert (
2289 result is True
2290 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
2291
2292 input_dict = {
2293 SUMMARY["ipv6"][0]: {
2294 "summaryAddress": SUMMARY["ipv6"][0],
2295 "metricType": "E2",
2296 "Metric": 20,
2297 "Tag": 0,
2298 "externalRouteCount": 5,
2299 }
2300 }
2301 dut = "r0"
2302 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2303 assert (
2304 result is True
2305 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
2306
2307 step("Configure metric type as 1 in route map.")
2308
2309 routemaps = {
2310 "r0": {
2311 "route_maps": {
2312 "rmap_ipv6": [
2313 {
2314 "seq_id": "1",
2315 "action": "permit",
2316 "set": {"metric-type": "type-1"},
2317 }
2318 ]
2319 }
2320 }
2321 }
2322 result = create_route_maps(tgen, routemaps)
2323 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2324
2325 step(
2326 "Verify that external routes(static / connected) are summarised"
2327 " to configured summary address with metric type 2."
2328 )
2329 input_dict = {
2330 SUMMARY["ipv6"][0]: {
2331 "summaryAddress": SUMMARY["ipv6"][0],
2332 "metricType": "E2",
2333 "Metric": 20,
2334 "Tag": 0,
2335 "externalRouteCount": 5,
2336 }
2337 }
2338 dut = "r0"
2339 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2340 assert (
2341 result is True
2342 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
2343
2344 step("Un configure metric type from route map.")
2345
2346 routemaps = {
2347 "r0": {
2348 "route_maps": {
2349 "rmap_ipv6": [
2350 {
2351 "action": "permit",
2352 "seq_id": "1",
2353 "set": {"metric-type": "type-1", "delete": True},
2354 }
2355 ]
2356 }
2357 }
2358 }
2359 result = create_route_maps(tgen, routemaps)
2360 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2361
2362 step(
2363 "Verify that external routes(static / connected) are summarised"
2364 " to configured summary address with metric type 2."
2365 )
2366 input_dict = {
2367 SUMMARY["ipv6"][0]: {
2368 "summaryAddress": SUMMARY["ipv6"][0],
2369 "metricType": "E2",
2370 "Metric": 20,
2371 "Tag": 0,
2372 "externalRouteCount": 5,
2373 }
2374 }
2375 dut = "r0"
2376 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2377 assert (
2378 result is True
2379 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
2380
2381 step("Change rule from permit to deny in prefix list.")
2382 pfx_list = {
2383 "r0": {
2384 "prefix_lists": {
2385 "ipv6": {
2386 "pf_list_1_ipv6": [
2387 {"seqid": 10, "network": "any", "action": "deny"}
2388 ]
2389 }
2390 }
2391 }
2392 }
2393 result = create_prefix_lists(tgen, pfx_list)
2394 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2395
2396 step(
2397 "Verify that previously originated summary lsa "
2398 "is withdrawn from the neighbor."
2399 )
2400 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2401 dut = "r1"
2402
2403 step("summary route has delay of 5 secs, wait for 5 secs")
2404
2405 sleep(5)
2406
2407 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
2408 assert (
2409 result is not True
2410 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2411 tc_name, result
2412 )
2413
2414 result = verify_rib(
2415 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
2416 )
2417 assert (
2418 result is not True
2419 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
2420
2421 write_test_footer(tc_name)
2422
2423
2424 def test_ospfv3_type5_summary_tc51_p2(request):
2425 """OSPF CLI Show.
2426
2427 verify ospf ASBR summary config and show commands behaviours.
2428 """
2429 tc_name = request.node.name
2430 write_test_header(tc_name)
2431 tgen = get_topogen()
2432
2433 # Don't run this test if we have any failure.
2434 if tgen.routers_have_failure():
2435 pytest.skip(tgen.errors)
2436
2437 global topo
2438 step("Bring up the base config as per the topology")
2439 reset_config_on_routers(tgen)
2440
2441 step("Configure all the supported OSPF ASBR summary commands on DUT.")
2442 ospf_summ_r1 = {
2443 "r0": {
2444 "ospf6": {
2445 "summary-address": [
2446 {
2447 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2448 "mask": "32",
2449 "tag": 4294967295,
2450 },
2451 {
2452 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2453 "mask": "16",
2454 "advertise": True,
2455 },
2456 {
2457 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2458 "mask": "24",
2459 "advertise": False,
2460 },
2461 {
2462 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2463 "mask": "24",
2464 "advertise": False,
2465 },
2466 ]
2467 }
2468 }
2469 }
2470 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2471 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2472
2473 step("Configure and re configure all the commands 10 times in a loop.")
2474
2475 for itrate in range(0, 10):
2476 ospf_summ_r1 = {
2477 "r0": {
2478 "ospf6": {
2479 "summary-address": [
2480 {
2481 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2482 "mask": "8",
2483 "tag": 4294967295,
2484 },
2485 {
2486 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2487 "mask": "16",
2488 "advertise": True,
2489 },
2490 {
2491 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2492 "mask": "24",
2493 "advertise": False,
2494 },
2495 {
2496 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2497 "mask": "24",
2498 "advertise": False,
2499 },
2500 ]
2501 }
2502 }
2503 }
2504 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2505 assert result is True, "Testcase {} : Failed \n Error: {}".format(
2506 tc_name, result
2507 )
2508
2509 ospf_summ_r1 = {
2510 "r0": {
2511 "ospf6": {
2512 "summary-address": [
2513 {
2514 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2515 "mask": "8",
2516 "tag": 4294967295,
2517 "delete": True,
2518 },
2519 {
2520 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2521 "mask": "16",
2522 "advertise": True,
2523 "delete": True,
2524 },
2525 {
2526 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2527 "mask": "24",
2528 "advertise": False,
2529 "delete": True,
2530 },
2531 {
2532 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2533 "mask": "24",
2534 "advertise": False,
2535 "delete": True,
2536 },
2537 ]
2538 }
2539 }
2540 }
2541 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2542 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2543
2544 step("Verify the show commands")
2545
2546 input_dict = {
2547 SUMMARY["ipv6"][3]: {
2548 "summaryAddress": SUMMARY["ipv6"][3],
2549 "metricType": "E2",
2550 "Metric": 20,
2551 "Tag": 0,
2552 "externalRouteCount": 0,
2553 }
2554 }
2555 dut = "r0"
2556 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2557 assert (
2558 result is True
2559 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
2560
2561 write_test_footer(tc_name)
2562
2563
2564 def test_ospfv3_type5_summary_tc49_p2(request):
2565 """OSPF summarisation Chaos."""
2566 tc_name = request.node.name
2567 write_test_header(tc_name)
2568 tgen = get_topogen()
2569
2570 # Don't run this test if we have any failure.
2571 if tgen.routers_have_failure():
2572 pytest.skip(tgen.errors)
2573
2574 global topo
2575 step("Bring up the base config as per the topology")
2576 reset_config_on_routers(tgen)
2577
2578 protocol = "ospf"
2579
2580 step(
2581 "Configure 5 static routes from the same network on R0"
2582 "5 static routes from different networks and redistribute in R0"
2583 )
2584 input_dict_static_rtes = {
2585 "r0": {
2586 "static_routes": [
2587 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
2588 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
2589 ]
2590 }
2591 }
2592 result = create_static_routes(tgen, input_dict_static_rtes)
2593 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2594
2595 dut = "r0"
2596 red_static(dut)
2597
2598 step("Verify that routes are learnt on R1.")
2599 dut = "r1"
2600
2601 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
2602 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2603 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
2604 assert (
2605 result is True
2606 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
2607
2608 step(
2609 "Configure External Route summary in R0 to summarise 5" " routes to one route."
2610 )
2611
2612 ospf_summ_r1 = {
2613 "r0": {
2614 "ospf6": {
2615 "summary-address": [
2616 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
2617 ]
2618 }
2619 }
2620 }
2621 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2622 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2623
2624 step(
2625 "Verify that external routes are summarised to configured summary "
2626 "address on R0 after 5 secs of delay timer expiry and only one "
2627 "route is sent to R1."
2628 )
2629 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2630 dut = "r1"
2631
2632 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2633 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2634
2635 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2636 assert (
2637 result is True
2638 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
2639
2640 step("Verify that show ip ospf summary should show the summaries.")
2641 input_dict = {
2642 SUMMARY["ipv6"][0]: {
2643 "summaryAddress": SUMMARY["ipv6"][0],
2644 "metricType": "E2",
2645 "Metric": 20,
2646 "Tag": 0,
2647 "externalRouteCount": 5,
2648 }
2649 }
2650 dut = "r0"
2651 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2652 assert (
2653 result is True
2654 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
2655
2656 step("Verify that originally advertised routes are withdraw from there" " peer.")
2657 input_dict = {
2658 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
2659 }
2660 dut = "r1"
2661 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
2662 assert (
2663 result is not True
2664 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2665 tc_name, result
2666 )
2667
2668 result = verify_rib(
2669 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
2670 )
2671 assert (
2672 result is not True
2673 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
2674
2675 step("Reload the FRR router")
2676 # stop/start -> restart FRR router and verify
2677 stop_router(tgen, "r0")
2678 start_router(tgen, "r0")
2679
2680 step(
2681 "Verify that external routes are summarised to configured summary "
2682 "address on R0 after 5 secs of delay timer expiry and only one "
2683 "route is sent to R1."
2684 )
2685 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2686 dut = "r1"
2687
2688 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2689 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2690
2691 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2692 assert (
2693 result is True
2694 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name)
2695
2696 step("Verify that show ip ospf summary should show the summaries.")
2697 input_dict = {
2698 SUMMARY["ipv6"][0]: {
2699 "summaryAddress": SUMMARY["ipv6"][0],
2700 "metricType": "E2",
2701 "Metric": 20,
2702 "Tag": 0,
2703 "externalRouteCount": 5,
2704 }
2705 }
2706 dut = "r0"
2707 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2708 assert (
2709 result is True
2710 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name)
2711
2712 step("Verify that originally advertised routes are withdraw from there" " peer.")
2713 input_dict = {
2714 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
2715 }
2716 dut = "r1"
2717 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
2718 assert (
2719 result is not True
2720 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2721 tc_name, result
2722 )
2723
2724 result = verify_rib(
2725 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
2726 )
2727 assert (
2728 result is not True
2729 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name)
2730
2731 write_test_footer(tc_name)
2732
2733
2734 if __name__ == "__main__":
2735 args = ["-s"] + sys.argv[1:]
2736 sys.exit(pytest.main(args))