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