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