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