]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/multicast_pim_sm_topo3/test_multicast_pim_sm_topo3.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / multicast_pim_sm_topo3 / test_multicast_pim_sm_topo3.py
1 #!/usr/bin/env python
2 # SPDX-License-Identifier: ISC
3
4 #
5 # Copyright (c) 2020 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation,
7 # Inc. ("NetDEF") in this file.
8 #
9
10 """
11 Following tests are covered to test multicast pim sm:
12
13 Test steps
14 - Create topology (setup module)
15 - Bring up topology
16
17 Following tests are covered:
18
19 1. verify oil when join prune sent scenario_1 p0
20 2. verify oil when join prune sent scenario_2 p0
21 3. shut noshut source interface when upstream cleared from LHR p0(
22 4. shut noshut receiver interface when upstream cleared from LHR p0(
23 5. verify igmp clis p0
24 6. verify igmp cli generate query once p0
25 7. verify remove add igmp config to receiver interface p0
26 8. verify remove add igmp commands when pim configured p0
27 9. verify remove add pim commands when igmp configured p0
28 10. pim dr priority p0
29 11. pim hello timer p0
30 12. Verify mroute after removing RP sending IGMP prune p2
31 13. Verify prune is sent to LHR and FHR when PIM nbr went down
32 14. Verify mroute flag in LHR and FHR node
33 15. Verify IGMP prune processed correctly when same join received from IGMP and PIM
34 16. Verify multicast traffic flowing fine, when LHR connected to RP
35 17. Verify multicast traffic is flowing fine when FHR is connected to RP
36 """
37
38 import os
39 import re
40 import sys
41 import time
42 import datetime
43 import pytest
44 from time import sleep
45
46 pytestmark = pytest.mark.pimd
47
48 # Save the Current Working Directory to find configuration files.
49 CWD = os.path.dirname(os.path.realpath(__file__))
50 sys.path.append(os.path.join(CWD, "../"))
51 sys.path.append(os.path.join(CWD, "../lib/"))
52
53 # Required to instantiate the topology builder class.
54
55 # pylint: disable=C0413
56 # Import topogen and topotest helpers
57 from lib.topogen import Topogen, get_topogen
58
59 from lib.common_config import (
60 start_topology,
61 write_test_header,
62 write_test_footer,
63 step,
64 reset_config_on_routers,
65 shutdown_bringup_interface,
66 apply_raw_config,
67 check_router_status,
68 required_linux_kernel_version,
69 topo_daemons,
70 )
71 from lib.pim import (
72 create_pim_config,
73 create_igmp_config,
74 verify_igmp_groups,
75 verify_mroutes,
76 clear_mroute,
77 clear_pim_interface_traffic,
78 verify_igmp_config,
79 verify_pim_config,
80 verify_pim_interface,
81 verify_upstream_iif,
82 verify_multicast_traffic,
83 verify_pim_rp_info,
84 verify_multicast_flag_state,
85 McastTesterHelper,
86 verify_pim_interface_traffic,
87 )
88 from lib.topolog import logger
89 from lib.topojson import build_config_from_json
90
91 CWD = os.path.dirname(os.path.realpath(__file__))
92 pytestmark = pytest.mark.pimd
93
94 TOPOLOGY = """
95
96 i4-----c1-------------c2---i5
97 | |
98 | |
99 i1-----l1------r2-----f1---i2
100 | | | |
101 | | | |
102 i7 i6 i3 i8
103
104 Description:
105 i1, i2, i3. i4, i5, i6, i7, i8 - FRR running iperf to send IGMP
106 join and traffic
107 l1 - LHR
108 f1 - FHR
109 r2 - FRR router
110 c1 - FRR router
111 c2 - FRR router
112 """
113
114 # Global variables
115 VLAN_1 = 2501
116 GROUP_RANGE = "225.0.0.0/8"
117 IGMP_GROUP = "225.1.1.1/32"
118 IGMP_JOIN = "225.1.1.1"
119 VLAN_INTF_ADRESS_1 = "10.0.8.3/24"
120 GROUP_RANGE_1 = [
121 "225.1.1.1/32",
122 "225.1.1.2/32",
123 "225.1.1.3/32",
124 "225.1.1.4/32",
125 "225.1.1.5/32",
126 ]
127 IGMP_JOIN_RANGE_1 = ["225.1.1.1", "225.1.1.2", "225.1.1.3", "225.1.1.4", "225.1.1.5"]
128 GROUP_RANGE_2 = [
129 "226.1.1.1/32",
130 "226.1.1.2/32",
131 "226.1.1.3/32",
132 "226.1.1.4/32",
133 "226.1.1.5/32",
134 ]
135 IGMP_JOIN_RANGE_2 = ["226.1.1.1", "226.1.1.2", "226.1.1.3", "226.1.1.4", "226.1.1.5"]
136 GROUP_RANGE_3 = [
137 "227.1.1.1/32",
138 "227.1.1.2/32",
139 "227.1.1.3/32",
140 "227.1.1.4/32",
141 "227.1.1.5/32",
142 ]
143 IGMP_JOIN_RANGE_3 = ["227.1.1.1", "227.1.1.2", "227.1.1.3", "227.1.1.4", "227.1.1.5"]
144
145 SAME_VLAN_IP_1 = {"ip": "10.1.1.1", "subnet": "255.255.255.0", "cidr": "24"}
146 SAME_VLAN_IP_2 = {"ip": "10.1.1.2", "subnet": "255.255.255.0", "cidr": "24"}
147 SAME_VLAN_IP_3 = {"ip": "10.1.1.3", "subnet": "255.255.255.0", "cidr": "24"}
148 SAME_VLAN_IP_4 = {"ip": "10.1.1.4", "subnet": "255.255.255.0", "cidr": "24"}
149
150
151 def setup_module(mod):
152 """
153 Sets up the pytest environment
154
155 * `mod`: module name
156 """
157
158 # Required linux kernel version for this suite to run.
159 result = required_linux_kernel_version("4.19")
160 if result is not True:
161 pytest.skip("Kernel version should be >= 4.19")
162
163 testsuite_run_time = time.asctime(time.localtime(time.time()))
164 logger.info("Testsuite start time: {}".format(testsuite_run_time))
165 logger.info("=" * 40)
166 logger.info("Master Topology: \n {}".format(TOPOLOGY))
167
168 logger.info("Running setup_module to create topology")
169
170 json_file = "{}/multicast_pim_sm_topo3.json".format(CWD)
171 tgen = Topogen(json_file, mod.__name__)
172 global topo
173 topo = tgen.json_topo
174 # ... and here it calls Mininet initialization functions.
175
176 # Starting topology, create tmp files which are loaded to routers
177 # to start daemons and then start routers
178 start_topology(tgen)
179
180 # Don"t run this test if we have any failure.
181 if tgen.routers_have_failure():
182 pytest.skip(tgen.errors)
183
184 # Creating configuration from JSON
185 build_config_from_json(tgen, topo)
186
187 # XXX Replace this using "with McastTesterHelper()... " in each test if possible.
188 global app_helper
189 app_helper = McastTesterHelper(tgen)
190
191 logger.info("Running setup_module() done")
192
193
194 def teardown_module():
195 """Teardown the pytest environment"""
196
197 logger.info("Running teardown_module to delete topology")
198
199 tgen = get_topogen()
200
201 app_helper.cleanup()
202
203 # Stop toplogy and Remove tmp files
204 tgen.stop_topology()
205
206 logger.info(
207 "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
208 )
209 logger.info("=" * 40)
210
211
212 #####################################################
213 #
214 # Testcases
215 #
216 #####################################################
217
218
219 def verify_mroute_repopulated(uptime_before, uptime_after):
220 """
221 API to compare uptime for mroutes
222
223 Parameters
224 ----------
225 * `uptime_before` : Uptime dictionary for any particular instance
226 * `uptime_after` : Uptime dictionary for any particular instance
227 """
228
229 for group in uptime_before.keys():
230 for source in uptime_before[group].keys():
231 if set(uptime_before[group]) != set(uptime_after[group]):
232 errormsg = (
233 "mroute (%s, %s) has not come"
234 " up after mroute clear [FAILED!!]" % (source, group)
235 )
236 return errormsg
237
238 d1 = datetime.datetime.strptime(uptime_before[group][source], "%H:%M:%S")
239 d2 = datetime.datetime.strptime(uptime_after[group][source], "%H:%M:%S")
240 if d2 >= d1:
241 errormsg = "mroute (%s, %s) is not " "repopulated [FAILED!!]" % (
242 source,
243 group,
244 )
245 return errormsg
246
247 logger.info("mroute (%s, %s) is " "repopulated [PASSED!!]", source, group)
248
249 return True
250
251
252 def verify_state_incremented(state_before, state_after):
253 """
254 API to compare interface traffic state incrementing
255
256 Parameters
257 ----------
258 * `state_before` : State dictionary for any particular instance
259 * `state_after` : State dictionary for any particular instance
260 """
261
262 for ttype, v1 in state_before.items():
263 for intf, v2 in v1.items():
264 for state, value in v2.items():
265 if value >= state_after[ttype][intf][state]:
266 errormsg = "[DUT: %s]: state %s value has not incremented, Initial value: %s, Current value: %s [FAILED!!]" % (
267 intf,
268 state,
269 value,
270 state_after[ttype][intf][state],
271 )
272 return errormsg
273
274 logger.info(
275 "[DUT: %s]: State %s value is incremented, Initial value: %s, Current value: %s [PASSED!!]",
276 intf,
277 state,
278 value,
279 state_after[ttype][intf][state],
280 )
281
282 return True
283
284
285 def find_v2_query_msg_in_tcpdump(tgen, router, message, count, cap_file):
286 """
287 Find v2 query messages in tcpdump file
288
289 Parameters
290 ----------
291 * `tgen` : Topology handler
292 * `router` : Device under test
293 * `cap_file` : tcp dump file name
294
295 """
296
297 filepath = os.path.join(tgen.logdir, router, cap_file)
298 with open(filepath) as f:
299 if len(re.findall("{}".format(message), f.read())) < count:
300 errormsg = "[DUT: %s]: Verify Message: %s in tcpdump" " [FAILED!!]" % (
301 router,
302 message,
303 )
304 return errormsg
305
306 logger.info(
307 "[DUT: %s]: Found message: %s in tcpdump " " count: %s [PASSED!!]",
308 router,
309 message,
310 count,
311 )
312 return True
313
314
315 def find_tos_in_tcpdump(tgen, router, message, cap_file):
316 """
317 Find v2 query messages in tcpdump file
318
319 Parameters
320 ----------
321 * `tgen` : Topology handler
322 * `router` : Device under test
323 * `cap_file` : tcp dump file name
324
325 """
326
327 filepath = os.path.join(tgen.logdir, router, cap_file)
328 with open(filepath) as f:
329
330 if len(re.findall(message, f.read())) < 1:
331 errormsg = "[DUT: %s]: Verify Message: %s in tcpdump" " [FAILED!!]" % (
332 router,
333 message,
334 )
335 return errormsg
336
337 logger.info(
338 "[DUT: %s]: Found message: %s in tcpdump " "[PASSED!!]", router, message
339 )
340 return True
341
342
343 def verify_pim_stats_increament(stats_before, stats_after):
344 """
345 API to compare pim interface control plane traffic
346
347 Parameters
348 ----------
349 * `stats_before` : Stats dictionary for any particular instance
350 * `stats_after` : Stats dictionary for any particular instance
351 """
352
353 for router, stats_data in stats_before.items():
354 for stats, value in stats_data.items():
355 if stats_before[router][stats] >= stats_after[router][stats]:
356 errormsg = (
357 "[DUT: %s]: state %s value has not"
358 " incremented, Initial value: %s, "
359 "Current value: %s [FAILED!!]"
360 % (
361 router,
362 stats,
363 stats_before[router][stats],
364 stats_after[router][stats],
365 )
366 )
367 return errormsg
368
369 logger.info(
370 "[DUT: %s]: State %s value is "
371 "incremented, Initial value: %s, Current value: %s"
372 " [PASSED!!]",
373 router,
374 stats,
375 stats_before[router][stats],
376 stats_after[router][stats],
377 )
378
379 return True
380
381
382 def test_verify_oil_when_join_prune_sent_scenario_1_p1(request):
383 """
384 TC_21_1:
385 Verify OIL detail updated in (S,G) and (*,G) mroute when IGMP
386 join/prune is sent
387 """
388
389 tgen = get_topogen()
390 tc_name = request.node.name
391 write_test_header(tc_name)
392
393 # Don"t run this test if we have any failure.
394 if tgen.routers_have_failure():
395 pytest.skip(tgen.errors)
396
397 # Creating configuration from JSON
398 app_helper.stop_all_hosts()
399 clear_mroute(tgen)
400 reset_config_on_routers(tgen)
401 clear_pim_interface_traffic(tgen, topo)
402 check_router_status(tgen)
403
404 step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3")
405 step(
406 "Enable IGMP of FRR1 interface and send IGMP joins "
407 " from FRR1 node for group range (226.1.1.1-5)"
408 )
409 step(
410 "Enable IGMP of FRR3 interface and send IGMP joins "
411 " from FRR3 node for group range (226.1.1.1-5)"
412 )
413
414 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
415 input_dict = {
416 "f1": {
417 "igmp": {
418 "interfaces": {
419 intf_f1_i8: {
420 "igmp": {"version": "2", "query": {"query-interval": 15}}
421 }
422 }
423 }
424 }
425 }
426 result = create_igmp_config(tgen, topo, input_dict)
427 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
428
429 input_join = {
430 "i1": topo["routers"]["i1"]["links"]["l1"]["interface"],
431 "i8": topo["routers"]["i8"]["links"]["f1"]["interface"],
432 }
433
434 for recvr, recvr_intf in input_join.items():
435 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
436 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
437
438 step("Configure static RP for (226.1.1.1-5) in R2")
439
440 input_dict = {
441 "r2": {
442 "pim": {
443 "rp": [
444 {
445 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
446 "/"
447 )[0],
448 "group_addr_range": GROUP_RANGE,
449 }
450 ]
451 }
452 }
453 }
454
455 result = create_pim_config(tgen, topo, input_dict)
456 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
457
458 step(
459 "Configure one source on FRR3 for all the groups and send" " multicast traffic"
460 )
461
462 input_src = {"i2": topo["routers"]["i2"]["links"]["f1"]["interface"]}
463
464 for src, src_intf in input_src.items():
465 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
466 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
467
468 source_i2 = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
469 input_dict_all = [
470 {
471 "dut": "l1",
472 "src_address": "*",
473 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
474 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
475 },
476 {
477 "dut": "l1",
478 "src_address": source_i2,
479 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
480 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
481 },
482 {
483 "dut": "r2",
484 "src_address": "*",
485 "iif": "lo",
486 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
487 },
488 {
489 "dut": "r2",
490 "src_address": source_i2,
491 "iif": topo["routers"]["r2"]["links"]["f1"]["interface"],
492 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
493 },
494 {
495 "dut": "f1",
496 "src_address": "*",
497 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
498 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
499 },
500 {
501 "dut": "f1",
502 "src_address": source_i2,
503 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
504 "oil": topo["routers"]["f1"]["links"]["r2"]["interface"],
505 },
506 ]
507
508 step("Verify mroutes and iff upstream")
509
510 for data in input_dict_all:
511 result = verify_mroutes(
512 tgen,
513 data["dut"],
514 data["src_address"],
515 IGMP_JOIN_RANGE_1,
516 data["iif"],
517 data["oil"],
518 )
519 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
520
521 for data in input_dict_all:
522 result = verify_upstream_iif(
523 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
524 )
525 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
526
527 step("Send the IGMP prune from ixia to (226.1.1.1-5) receiver on " "FRR1 node")
528
529 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
530 shutdown_bringup_interface(tgen, "l1", intf_l1_i1, False)
531
532 step(
533 "After receiving the IGMP prune from FRR1 , verify traffic "
534 "immediately stopped for this receiver 'show ip multicast'"
535 )
536
537 input_traffic = {"l1": {"traffic_sent": [intf_l1_i1]}}
538 result = verify_multicast_traffic(tgen, input_traffic, expected=False)
539 assert result is not True, (
540 "Testcase {} : Failed \n "
541 "Expected: [{}]: Multicast traffic should be stopped \n "
542 "Found: {}".format(tc_name, "l1", result)
543 )
544
545 step(
546 "IGMP groups are remove from FRR1 node 'show ip igmp groups'"
547 " FRR3 IGMP still present"
548 )
549
550 dut = "l1"
551 result = verify_igmp_groups(
552 tgen, dut, intf_l1_i1, IGMP_JOIN_RANGE_1, expected=False
553 )
554 assert result is not True, (
555 "Testcase {} : Failed \n "
556 "Expected: [{}]: IGMP groups should be deleted \n "
557 "Found: {}".format(tc_name, dut, result)
558 )
559
560 dut = "f1"
561 result = verify_igmp_groups(tgen, dut, intf_f1_i8, IGMP_JOIN_RANGE_1)
562 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
563
564 step(
565 "(*,G) and (S,G) OIL got removed immediately after receiving"
566 " prune 'show ip pim state' and 'show ip mroute' on FRR1 node,"
567 " no impact on FRR3 receiver"
568 )
569
570 input_dict_l1 = [
571 {
572 "dut": "l1",
573 "src_address": "*",
574 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
575 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
576 },
577 {
578 "dut": "l1",
579 "src_address": source_i2,
580 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
581 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
582 },
583 ]
584
585 step("Verify mroutes and iff upstream")
586
587 for data in input_dict_l1:
588 result = verify_mroutes(
589 tgen,
590 data["dut"],
591 data["src_address"],
592 IGMP_JOIN_RANGE_1,
593 data["iif"],
594 data["oil"],
595 expected=False,
596 )
597 assert result is not True, (
598 "Testcase {} : Failed \n "
599 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
600 "Found: {}".format(tc_name, data["dut"], result)
601 )
602
603 for data in input_dict_l1:
604 result = verify_upstream_iif(
605 tgen,
606 data["dut"],
607 data["iif"],
608 data["src_address"],
609 IGMP_JOIN_RANGE_1,
610 expected=False,
611 )
612 assert result is not True, (
613 "Testcase {} : Failed \n "
614 "Expected: [{}]: Upstream IIF {} should not be present \n "
615 "Found: {}".format(tc_name, data["dut"], data["iif"], result)
616 )
617
618 input_dict_f1 = [
619 {
620 "dut": "f1",
621 "src_address": "*",
622 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
623 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
624 },
625 {
626 "dut": "f1",
627 "src_address": source_i2,
628 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
629 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
630 },
631 ]
632
633 step("Verify mroutes and iff upstream")
634
635 for data in input_dict_f1:
636 result = verify_mroutes(
637 tgen,
638 data["dut"],
639 data["src_address"],
640 IGMP_JOIN_RANGE_1,
641 data["iif"],
642 data["oil"],
643 )
644 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
645
646 for data in input_dict_f1:
647 result = verify_upstream_iif(
648 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
649 )
650 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
651
652 step("Send the IGMP prune from ixia to (226.1.1.1-5) receiver on " " FRR3 node")
653
654 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
655 shutdown_bringup_interface(tgen, "f1", intf_f1_i8, False)
656
657 step(
658 "After receiving the IGMP prune from FRR3s , verify traffic "
659 "immediately stopped for this receiver 'show ip multicast'"
660 )
661
662 input_traffic = {"f1": {"traffic_sent": [intf_f1_i8]}}
663 result = verify_multicast_traffic(tgen, input_traffic, expected=False)
664 assert result is not True, (
665 "Testcase {} : Failed \n "
666 "Expected: [{}]: Multicast traffic should be stopped \n "
667 "Found: {}".format(tc_name, "f1", result)
668 )
669
670 step(
671 "IGMP groups are remove from FRR1 node 'show ip igmp groups'"
672 " FRR3 IGMP still present"
673 )
674
675 dut = "f1"
676 result = verify_igmp_groups(
677 tgen, dut, intf_f1_i8, IGMP_JOIN_RANGE_1, expected=False
678 )
679 assert result is not True, (
680 "Testcase {} : Failed \n "
681 "Expected: [{}]: IGMP groups should be deleted \n "
682 "Found: {}".format(tc_name, dut, result)
683 )
684
685 step(
686 "(*,G) and (S,G) OIL got prune state (none) from all the nodes"
687 "FRR1, FRR3 verify using 'show ip mroute'"
688 )
689
690 input_dict_l1 = [
691 {
692 "dut": "l1",
693 "src_address": "*",
694 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
695 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
696 },
697 {
698 "dut": "l1",
699 "src_address": source_i2,
700 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
701 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
702 },
703 ]
704
705 step("Verify mroutes and iff upstream")
706
707 for data in input_dict_l1:
708 result = verify_mroutes(
709 tgen,
710 data["dut"],
711 data["src_address"],
712 IGMP_JOIN_RANGE_1,
713 data["iif"],
714 data["oil"],
715 expected=False,
716 )
717 assert result is not True, (
718 "Testcase {} : Failed \n "
719 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
720 "Found: {}".format(tc_name, data["dut"], result)
721 )
722
723 for data in input_dict_l1:
724 result = verify_upstream_iif(
725 tgen,
726 data["dut"],
727 data["iif"],
728 data["src_address"],
729 IGMP_JOIN_RANGE_1,
730 expected=False,
731 )
732 assert result is not True, (
733 "Testcase {} : Failed \n "
734 "Expected: [{}]: Upstream IIF {} should not be present \n "
735 "Found: {}".format(tc_name, data["dut"], data["iif"], result)
736 )
737
738 shutdown_bringup_interface(tgen, "f1", intf_f1_i8, True)
739 shutdown_bringup_interface(tgen, "l1", intf_l1_i1, True)
740
741 for data in input_dict_l1:
742 result = verify_upstream_iif(
743 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
744 )
745 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
746
747 write_test_footer(tc_name)
748
749
750 def test_verify_oil_when_join_prune_sent_scenario_2_p1(request):
751 """
752 TC_21_2: Verify OIL detail updated in (S,G) and (*,G) mroute when IGMP
753 join/prune is sent
754 """
755
756 tgen = get_topogen()
757 tc_name = request.node.name
758 write_test_header(tc_name)
759
760 # Don"t run this test if we have any failure.
761 if tgen.routers_have_failure():
762 pytest.skip(tgen.errors)
763
764 # Creating configuration from JSON
765 app_helper.stop_all_hosts()
766 clear_mroute(tgen)
767 reset_config_on_routers(tgen)
768 clear_pim_interface_traffic(tgen, topo)
769 check_router_status(tgen)
770
771 step("Removing FRR3 to simulate topo " "FHR(FRR1)---LHR(FRR2)")
772
773 intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["interface"]
774 intf_f1_c2 = topo["routers"]["f1"]["links"]["c2"]["interface"]
775 intf_f1_r2 = topo["routers"]["f1"]["links"]["r2"]["interface"]
776 shutdown_bringup_interface(tgen, "l1", intf_l1_c1, False)
777 shutdown_bringup_interface(tgen, "f1", intf_f1_c2, False)
778 shutdown_bringup_interface(tgen, "f1", intf_f1_r2, False)
779
780 step("Enable the PIM on all the interfaces of FRR1, FRR2")
781 step(
782 "Enable IGMP of FRR1 interface and send IGMP joins "
783 " from FRR1 node for group range (226.1.1.1-5)"
784 )
785 step(
786 "Enable IGMP of FRR3 interface and send IGMP joins "
787 " from FRR3 node for group range (226.1.1.1-5)"
788 )
789
790 intf_r2_i3 = topo["routers"]["r2"]["links"]["i3"]["interface"]
791 input_dict = {
792 "r2": {
793 "igmp": {
794 "interfaces": {
795 intf_r2_i3: {
796 "igmp": {"version": "2", "query": {"query-interval": 15}}
797 }
798 }
799 }
800 }
801 }
802 result = create_igmp_config(tgen, topo, input_dict)
803 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
804
805 input_join = {
806 "i1": topo["routers"]["i1"]["links"]["l1"]["interface"],
807 "i3": topo["routers"]["i3"]["links"]["r2"]["interface"],
808 }
809
810 for recvr, recvr_intf in input_join.items():
811 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
812 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
813
814 step("Configure static RP for (226.1.1.1-5) in R2")
815
816 input_dict = {
817 "r2": {
818 "pim": {
819 "rp": [
820 {
821 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
822 "/"
823 )[0],
824 "group_addr_range": GROUP_RANGE,
825 }
826 ]
827 }
828 }
829 }
830
831 result = create_pim_config(tgen, topo, input_dict)
832 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
833 input_dict_all = [
834 {
835 "dut": "l1",
836 "src_address": "*",
837 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
838 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
839 },
840 {
841 "dut": "r2",
842 "src_address": "*",
843 "iif": "lo",
844 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
845 },
846 {
847 "dut": "r2",
848 "src_address": "*",
849 "iif": "lo",
850 "oil": topo["routers"]["r2"]["links"]["i3"]["interface"],
851 },
852 ]
853
854 step("Verify mroutes and iff upstream")
855
856 for data in input_dict_all:
857 result = verify_mroutes(
858 tgen,
859 data["dut"],
860 data["src_address"],
861 IGMP_JOIN_RANGE_1,
862 data["iif"],
863 data["oil"],
864 )
865 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
866
867 for data in input_dict_all:
868 result = verify_upstream_iif(
869 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
870 )
871 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
872
873 step("Send the IGMP prune from ixia to (226.1.1.1-5) receiver on " "FRR3(r2) node")
874
875 intf_r2_i3 = topo["routers"]["r2"]["links"]["i3"]["interface"]
876 shutdown_bringup_interface(tgen, "r2", intf_r2_i3, False)
877
878 step(
879 "After sending IGMP prune from FRR3(r2) node verify (*,G) OIL "
880 "immediately removed for local receiver mroute should have "
881 " PIM protocol , IGMP should be removed verify using "
882 "'show ip mroute' no impact seen on FRR1(l1) (*,G)"
883 )
884
885 input_dict_r2 = [
886 {
887 "dut": "r2",
888 "src_address": "*",
889 "iif": "lo",
890 "oil": topo["routers"]["r2"]["links"]["i3"]["interface"],
891 }
892 ]
893
894 for data in input_dict_r2:
895 result = verify_mroutes(
896 tgen,
897 data["dut"],
898 data["src_address"],
899 IGMP_JOIN_RANGE_1,
900 data["iif"],
901 data["oil"],
902 expected=False,
903 )
904 assert result is not True, (
905 "Testcase {} : Failed \n "
906 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
907 "Found: {}".format(tc_name, data["dut"], result)
908 )
909
910 input_dict_l1_r2 = [
911 {
912 "dut": "l1",
913 "src_address": "*",
914 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
915 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
916 },
917 {
918 "dut": "r2",
919 "src_address": "*",
920 "iif": "lo",
921 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
922 },
923 ]
924
925 step("Verify mroutes and iff upstream")
926
927 for data in input_dict_l1_r2:
928 result = verify_mroutes(
929 tgen,
930 data["dut"],
931 data["src_address"],
932 IGMP_JOIN_RANGE_1,
933 data["iif"],
934 data["oil"],
935 )
936 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
937
938 step("Send the IGMP prune from ixia to (226.1.1.1-5) receiver on " "FRR1(l1) node")
939
940 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
941 shutdown_bringup_interface(tgen, "l1", intf_l1_i1, False)
942
943 step(
944 "After sending IGMP prune from FRR1 node verify (*,G) OIL"
945 "got removed immediately from FRR1 node"
946 )
947
948 input_dict_l1 = [
949 {
950 "dut": "l1",
951 "src_address": "*",
952 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
953 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
954 }
955 ]
956
957 for data in input_dict_l1:
958 result = verify_mroutes(
959 tgen,
960 data["dut"],
961 data["src_address"],
962 IGMP_JOIN_RANGE_1,
963 data["iif"],
964 data["oil"],
965 expected=False,
966 )
967 assert result is not True, (
968 "Testcase {} : Failed \n "
969 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
970 "Found: {}".format(tc_name, data["dut"], result)
971 )
972
973 step("After prune is sent verify upstream got removed in FRR1 node")
974
975 for data in input_dict_l1:
976 result = verify_upstream_iif(
977 tgen,
978 data["dut"],
979 data["iif"],
980 data["src_address"],
981 IGMP_JOIN_RANGE_1,
982 expected=False,
983 )
984 assert result is not True, (
985 "Testcase {} : Failed \n "
986 "Expected: [{}]: Upstream IIF {} should not be present \n "
987 "Found: {}".format(tc_name, data["dut"], data["iif"], result)
988 )
989
990 write_test_footer(tc_name)
991
992
993 def test_shut_noshut_source_interface_when_upstream_cleared_from_LHR_p1(request):
994 """
995 TC_26: Verify shut/no shut of source interface after upstream got cleared
996 from LHR
997 """
998
999 tgen = get_topogen()
1000 tc_name = request.node.name
1001 write_test_header(tc_name)
1002
1003 # Don"t run this test if we have any failure.
1004 if tgen.routers_have_failure():
1005 pytest.skip(tgen.errors)
1006
1007 # Creating configuration from JSON
1008 app_helper.stop_all_hosts()
1009 clear_mroute(tgen)
1010 reset_config_on_routers(tgen)
1011 clear_pim_interface_traffic(tgen, topo)
1012 check_router_status(tgen)
1013
1014 step("Enable the PIM on all the interfaces of FRR1, R2 and FRR3" " routers")
1015 step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)")
1016
1017 input_join = {"i1": topo["routers"]["i1"]["links"]["l1"]["interface"]}
1018
1019 for recvr, recvr_intf in input_join.items():
1020 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
1021 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1022
1023 step("Configure RP on R2 (loopback interface) for " "the group range 225.0.0.0/8")
1024
1025 input_dict = {
1026 "r2": {
1027 "pim": {
1028 "rp": [
1029 {
1030 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
1031 "/"
1032 )[0],
1033 "group_addr_range": GROUP_RANGE_1,
1034 }
1035 ]
1036 }
1037 }
1038 }
1039
1040 result = create_pim_config(tgen, topo, input_dict)
1041 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1042
1043 step("Send multicast traffic from FRR3 to 225.1.1.1-225.1.1.10" " receiver")
1044
1045 input_src = {"i2": topo["routers"]["i2"]["links"]["f1"]["interface"]}
1046
1047 for src, src_intf in input_src.items():
1048 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
1049 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1050
1051 step(
1052 "'show ip mroute' showing correct RPF and OIF interface for (*,G)"
1053 " and (S,G) entries on all the nodes"
1054 )
1055
1056 source_i2 = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
1057 input_dict_all = [
1058 {
1059 "dut": "l1",
1060 "src_address": "*",
1061 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1062 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1063 },
1064 {
1065 "dut": "l1",
1066 "src_address": source_i2,
1067 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1068 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1069 },
1070 {
1071 "dut": "r2",
1072 "src_address": "*",
1073 "iif": "lo",
1074 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
1075 },
1076 {
1077 "dut": "r2",
1078 "src_address": source_i2,
1079 "iif": topo["routers"]["r2"]["links"]["f1"]["interface"],
1080 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
1081 },
1082 {
1083 "dut": "f1",
1084 "src_address": source_i2,
1085 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
1086 "oil": topo["routers"]["f1"]["links"]["r2"]["interface"],
1087 },
1088 ]
1089
1090 step(
1091 "'show ip pim upstream' and 'show ip pim upstream-rpf' showing"
1092 " correct OIL and IIF on all the nodes"
1093 )
1094
1095 for data in input_dict_all:
1096 result = verify_mroutes(
1097 tgen,
1098 data["dut"],
1099 data["src_address"],
1100 IGMP_JOIN_RANGE_1,
1101 data["iif"],
1102 data["oil"],
1103 )
1104 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1105
1106 for data in input_dict_all:
1107 result = verify_upstream_iif(
1108 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1109 )
1110 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1111
1112 step("Shut the source interface from FRR3")
1113 intf_f1_i2 = topo["routers"]["f1"]["links"]["i2"]["interface"]
1114 shutdown_bringup_interface(tgen, "f1", intf_f1_i2, False)
1115
1116 step(
1117 "After shut of source interface verify (S,G) mroutes are cleared"
1118 " from all the nodes"
1119 )
1120
1121 intf_f1_r2 = topo["routers"]["f1"]["links"]["r2"]["interface"]
1122 result = verify_mroutes(
1123 tgen, "f1", source_i2, IGMP_JOIN_RANGE_1, intf_f1_i2, intf_f1_r2, expected=False
1124 )
1125 assert result is not True, (
1126 "Testcase {} : Failed \n "
1127 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
1128 "Found: {}".format(tc_name, "f1", result)
1129 )
1130
1131 step(
1132 "After waiting for (S,G) timeout from FRR1 for same"
1133 " source verify that (S,G) is flushed from FRR1 node"
1134 " 'show ip pim upstream' 'show ip mroute' "
1135 )
1136
1137 result = verify_upstream_iif(
1138 tgen, "l1", "Unknown", source_i2, IGMP_JOIN_RANGE_1, expected=False
1139 )
1140 assert result is not True, (
1141 "Testcase {} : Failed \n "
1142 "Expected: [{}]: Upstream IIF should be Unknown \n "
1143 "Found: {}".format(tc_name, "l1", result)
1144 )
1145
1146 step("No shut the Source interface just after the upstream is expired" " from FRR1")
1147 shutdown_bringup_interface(tgen, "f1", intf_f1_i2, True)
1148
1149 step(
1150 "After no shut of source interface , verify all the (S,G) is "
1151 " populated again on 'show ip mroute' 'show ip pim upstream' "
1152 " with proper OIL and IIF detail"
1153 )
1154
1155 for data in input_dict_all:
1156 result = verify_mroutes(
1157 tgen,
1158 data["dut"],
1159 data["src_address"],
1160 IGMP_JOIN_RANGE_1,
1161 data["iif"],
1162 data["oil"],
1163 )
1164 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1165
1166 for data in input_dict_all:
1167 result = verify_upstream_iif(
1168 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1169 )
1170 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1171
1172 step("shut and no shut the source interface immediately")
1173 shutdown_bringup_interface(tgen, "f1", intf_f1_i2, False)
1174 shutdown_bringup_interface(tgen, "f1", intf_f1_i2, True)
1175
1176 step(
1177 "All the mroutes got updated with proper OIL after no shut of"
1178 "interface verify using 'show ip mroute'"
1179 )
1180
1181 for data in input_dict_all:
1182 result = verify_mroutes(
1183 tgen,
1184 data["dut"],
1185 data["src_address"],
1186 IGMP_JOIN_RANGE_1,
1187 data["iif"],
1188 data["oil"],
1189 )
1190 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1191
1192 for data in input_dict_all:
1193 result = verify_upstream_iif(
1194 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1195 )
1196 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1197
1198 write_test_footer(tc_name)
1199
1200
1201 def test_shut_noshut_receiver_interface_when_upstream_cleared_from_LHR_p1(request):
1202 """
1203 TC_27: Verify shut/no shut of receiver interface after upstream got
1204 cleared from LHR
1205 """
1206
1207 tgen = get_topogen()
1208 tc_name = request.node.name
1209 write_test_header(tc_name)
1210
1211 # Don"t run this test if we have any failure.
1212 if tgen.routers_have_failure():
1213 pytest.skip(tgen.errors)
1214
1215 # Creating configuration from JSON
1216 app_helper.stop_all_hosts()
1217 clear_mroute(tgen)
1218 reset_config_on_routers(tgen)
1219 clear_pim_interface_traffic(tgen, topo)
1220 check_router_status(tgen)
1221
1222 step("Enable the PIM on all the interfaces of FRR1, R2 and FRR3" " routers")
1223 step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)")
1224
1225 input_join = {"i1": topo["routers"]["i1"]["links"]["l1"]["interface"]}
1226
1227 for recvr, recvr_intf in input_join.items():
1228 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
1229 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1230
1231 step("Configure RP on R2 (loopback interface) for " "the group range 225.0.0.0/8")
1232
1233 input_dict = {
1234 "r2": {
1235 "pim": {
1236 "rp": [
1237 {
1238 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
1239 "/"
1240 )[0],
1241 "group_addr_range": GROUP_RANGE_1,
1242 }
1243 ]
1244 }
1245 }
1246 }
1247
1248 result = create_pim_config(tgen, topo, input_dict)
1249 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1250
1251 step("Send multicast traffic from FRR3 to 225.1.1.1-225.1.1.10" " receiver")
1252
1253 input_src = {"i2": topo["routers"]["i2"]["links"]["f1"]["interface"]}
1254
1255 for src, src_intf in input_src.items():
1256 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
1257 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1258
1259 step(
1260 "'show ip mroute' showing correct RPF and OIF interface for (*,G)"
1261 " and (S,G) entries on all the nodes"
1262 )
1263
1264 source_i2 = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
1265 input_dict_all = [
1266 {
1267 "dut": "l1",
1268 "src_address": "*",
1269 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1270 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1271 },
1272 {
1273 "dut": "l1",
1274 "src_address": source_i2,
1275 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1276 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1277 },
1278 {
1279 "dut": "r2",
1280 "src_address": "*",
1281 "iif": "lo",
1282 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
1283 },
1284 {
1285 "dut": "r2",
1286 "src_address": source_i2,
1287 "iif": topo["routers"]["r2"]["links"]["f1"]["interface"],
1288 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
1289 },
1290 {
1291 "dut": "f1",
1292 "src_address": source_i2,
1293 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
1294 "oil": topo["routers"]["f1"]["links"]["r2"]["interface"],
1295 },
1296 ]
1297
1298 for data in input_dict_all:
1299 result = verify_mroutes(
1300 tgen,
1301 data["dut"],
1302 data["src_address"],
1303 IGMP_JOIN_RANGE_1,
1304 data["iif"],
1305 data["oil"],
1306 )
1307 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1308
1309 step(
1310 "'show ip pim upstream' and 'show ip pim upstream-rpf' showing"
1311 " correct OIL and IIF on all the nodes"
1312 )
1313
1314 for data in input_dict_all:
1315 result = verify_upstream_iif(
1316 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1317 )
1318 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1319
1320 step("Shut the source interface FRR1")
1321 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
1322 intf_f1_i2 = topo["routers"]["f1"]["links"]["i2"]["interface"]
1323 intf_f1_r2 = topo["routers"]["f1"]["links"]["r2"]["interface"]
1324 shutdown_bringup_interface(tgen, "l1", intf_l1_i1, False)
1325
1326 step(
1327 "After waiting for (S,G) timeout from FRR1 for same"
1328 " source verify that (S,G) is flushed from FRR1 node"
1329 " 'show ip pim upstream' 'show ip mroute' "
1330 )
1331
1332 result = verify_upstream_iif(
1333 tgen, "l1", "Unknown", source_i2, IGMP_JOIN_RANGE_1, expected=False
1334 )
1335 assert result is not True, (
1336 "Testcase {} : Failed \n "
1337 "Expected: [{}]: Upstream IIF should be Unknown \n "
1338 "Found: {}".format(tc_name, "l1", result)
1339 )
1340
1341 step("No shut the Source interface just after the upstream is expired" " from FRR1")
1342 shutdown_bringup_interface(tgen, "l1", intf_l1_i1, True)
1343
1344 step(
1345 "After no shut of source interface , verify all the (S,G) is "
1346 " populated again on 'show ip mroute' 'show ip pim upstream' "
1347 " with proper OIL and IIF detail"
1348 )
1349
1350 for data in input_dict_all:
1351 result = verify_mroutes(
1352 tgen,
1353 data["dut"],
1354 data["src_address"],
1355 IGMP_JOIN_RANGE_1,
1356 data["iif"],
1357 data["oil"],
1358 )
1359 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1360
1361 for data in input_dict_all:
1362 result = verify_upstream_iif(
1363 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1364 )
1365 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1366
1367 step("shut and no shut the source interface immediately")
1368 shutdown_bringup_interface(tgen, "f1", intf_f1_i2, False)
1369 shutdown_bringup_interface(tgen, "f1", intf_f1_i2, True)
1370
1371 step(
1372 "After no shut of receiver interface , verify all the (S,G) is "
1373 "populated again on 'show ip mroute' 'show ip pim upstream' "
1374 "with proper OIL and IIF detail"
1375 )
1376
1377 for data in input_dict_all:
1378 result = verify_mroutes(
1379 tgen,
1380 data["dut"],
1381 data["src_address"],
1382 IGMP_JOIN_RANGE_1,
1383 data["iif"],
1384 data["oil"],
1385 )
1386 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1387
1388 for data in input_dict_all:
1389 result = verify_upstream_iif(
1390 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1391 )
1392 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1393
1394 write_test_footer(tc_name)
1395
1396
1397 def test_verify_remove_add_igmp_config_to_receiver_interface_p0(request):
1398 """
1399 TC_33: Verify removing and adding IGMP config from the receiver interface
1400 """
1401 tgen = get_topogen()
1402 tc_name = request.node.name
1403 write_test_header(tc_name)
1404
1405 # Don"t run this test if we have any failure.
1406 if tgen.routers_have_failure():
1407 pytest.skip(tgen.errors)
1408
1409 # Creating configuration from JSON
1410 app_helper.stop_all_hosts()
1411 clear_mroute(tgen)
1412 reset_config_on_routers(tgen)
1413 clear_pim_interface_traffic(tgen, topo)
1414 check_router_status(tgen)
1415
1416 step("Enable PIM on all routers")
1417 step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)")
1418
1419 input_join = {"i1": topo["routers"]["i1"]["links"]["l1"]["interface"]}
1420
1421 for recvr, recvr_intf in input_join.items():
1422 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
1423 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1424
1425 step("Configure RP for (226.1.1.1-5) and (232.1.1.1-5) in cisco-1(f1)")
1426
1427 input_dict = {
1428 "r2": {
1429 "pim": {
1430 "rp": [
1431 {
1432 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
1433 "/"
1434 )[0],
1435 "group_addr_range": GROUP_RANGE,
1436 }
1437 ]
1438 }
1439 }
1440 }
1441
1442 result = create_pim_config(tgen, topo, input_dict)
1443 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1444
1445 step("Configure source on FRR3 and start the traffic for" " (225.1.1.1-225.1.1.10)")
1446
1447 input_src = {"i2": topo["routers"]["i2"]["links"]["f1"]["interface"]}
1448
1449 for src, src_intf in input_src.items():
1450 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
1451 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1452
1453 step("Configure source on FRR1 and start the traffic for" " (225.1.1.1-225.1.1.10)")
1454
1455 input_src = {"i6": topo["routers"]["i6"]["links"]["l1"]["interface"]}
1456
1457 for src, src_intf in input_src.items():
1458 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
1459 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1460
1461 source_i6 = topo["routers"]["i6"]["links"]["l1"]["ipv4"].split("/")[0]
1462 source_i2 = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
1463 input_dict_all = [
1464 {
1465 "dut": "l1",
1466 "src_address": "*",
1467 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1468 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1469 },
1470 {
1471 "dut": "l1",
1472 "src_address": source_i6,
1473 "iif": topo["routers"]["l1"]["links"]["i6"]["interface"],
1474 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1475 },
1476 {
1477 "dut": "l1",
1478 "src_address": source_i2,
1479 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1480 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1481 },
1482 {
1483 "dut": "r2",
1484 "src_address": "*",
1485 "iif": "lo",
1486 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
1487 },
1488 {
1489 "dut": "f1",
1490 "src_address": source_i2,
1491 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
1492 "oil": topo["routers"]["f1"]["links"]["r2"]["interface"],
1493 },
1494 ]
1495
1496 for data in input_dict_all:
1497 result = verify_mroutes(
1498 tgen,
1499 data["dut"],
1500 data["src_address"],
1501 IGMP_JOIN_RANGE_1,
1502 data["iif"],
1503 data["oil"],
1504 )
1505 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1506
1507 for data in input_dict_all:
1508 result = verify_upstream_iif(
1509 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1510 )
1511 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1512
1513 step(
1514 "Remove igmp 'no ip igmp' and 'no ip igmp version 2' from"
1515 " receiver interface of FRR1"
1516 )
1517
1518 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
1519 input_dict_2 = {
1520 "l1": {
1521 "igmp": {
1522 "interfaces": {
1523 intf_l1_i1: {
1524 "igmp": {
1525 "version": "2",
1526 "delete": True,
1527 }
1528 }
1529 }
1530 }
1531 }
1532 }
1533 result = create_igmp_config(tgen, topo, input_dict_2)
1534 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1535
1536 step("IGMP join removed from FRR1 , verify using " "'show ip igmp groups json'")
1537
1538 dut = "l1"
1539 interface = topo["routers"]["l1"]["links"]["i1"]["interface"]
1540 result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN_RANGE_1, expected=False)
1541 assert result is not True, (
1542 "Testcase {} : Failed \n "
1543 "Expected: [{}]: IGMP groups should not be present \n "
1544 "Found: {}".format(tc_name, dut, result)
1545 )
1546
1547 intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
1548 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
1549 intf_f1_r2 = topo["routers"]["f1"]["links"]["r2"]["interface"]
1550 intf_f1_i2 = topo["routers"]["f1"]["links"]["i2"]["interface"]
1551 input_traffic = {
1552 "l1": {"traffic_received": [intf_l1_r2], "traffic_sent": [intf_l1_i1]},
1553 "f1": {"traffic_sent": [intf_f1_r2], "traffic_received": [intf_f1_i2]},
1554 }
1555 result = verify_multicast_traffic(tgen, input_traffic)
1556 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1557
1558 step(
1559 "Configure igmp 'ip igmp' and 'ip igmp version 2' from "
1560 "receiver interface of FRR1"
1561 )
1562
1563 input_dict_2 = {
1564 "l1": {
1565 "igmp": {
1566 "interfaces": {
1567 intf_l1_i1: {
1568 "igmp": {"version": "2", "query": {"query-interval": 15}}
1569 }
1570 }
1571 }
1572 }
1573 }
1574 result = create_igmp_config(tgen, topo, input_dict_2)
1575 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1576
1577 step(
1578 "After adding IGMP on receiver interface verify (S,G) and (*,G)"
1579 " entries got populated and traffic is resumed on FRR1 and FRR3 node"
1580 )
1581
1582 step(
1583 "Verify OIL/IIF and drJoinDesired using 'show ip mroute , and traffic"
1584 " using show ip pim upstream and show ip multicast'"
1585 )
1586
1587 for data in input_dict_all:
1588 result = verify_mroutes(
1589 tgen,
1590 data["dut"],
1591 data["src_address"],
1592 IGMP_JOIN_RANGE_1,
1593 data["iif"],
1594 data["oil"],
1595 )
1596 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1597
1598 for data in input_dict_all:
1599 result = verify_upstream_iif(
1600 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1601 )
1602 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1603
1604 result = verify_multicast_traffic(tgen, input_traffic)
1605 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1606
1607 step("Verify that no core is observed")
1608 if tgen.routers_have_failure():
1609 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
1610
1611 step(
1612 "Remove igmp 'no ip igmp' and 'no ip igmp version 2' from"
1613 " receiver interface of FRR1"
1614 )
1615
1616 input_dict_2 = {
1617 "l1": {
1618 "igmp": {
1619 "interfaces": {
1620 intf_l1_i1: {
1621 "igmp": {
1622 "version": "2",
1623 "delete": True,
1624 }
1625 }
1626 }
1627 }
1628 }
1629 }
1630
1631 result = create_igmp_config(tgen, topo, input_dict_2)
1632 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1633
1634 step("IGMP join removed from FRR1 , verify using " "'show ip igmp groups json'")
1635
1636 dut = "l1"
1637 interface = topo["routers"]["l1"]["links"]["i1"]["interface"]
1638 result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN_RANGE_1, expected=False)
1639 assert result is not True, (
1640 "Testcase {} : Failed \n "
1641 "Expected: [{}]: IGMP groups should not be present \n "
1642 "Found: {}".format(tc_name, dut, result)
1643 )
1644
1645 result = verify_multicast_traffic(tgen, input_traffic)
1646 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1647
1648 step(
1649 "Configure igmp 'ip igmp' and 'ip igmp version 2' from "
1650 "receiver interface of FRR1"
1651 )
1652
1653 input_dict_2 = {
1654 "l1": {
1655 "igmp": {
1656 "interfaces": {
1657 intf_l1_i1: {
1658 "igmp": {"version": "2", "query": {"query-interval": 15}}
1659 }
1660 }
1661 }
1662 }
1663 }
1664 result = create_igmp_config(tgen, topo, input_dict_2)
1665 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1666
1667 step(
1668 "After adding IGMP on receiver interface verify (S,G) and (*,G)"
1669 " entries got populated and traffic is resumed on FRR1 and FRR3 node"
1670 )
1671
1672 step(
1673 "Verify OIL/IIF and drJoinDesired using 'show ip mroute , and traffic"
1674 " using show ip pim upstream and show ip multicast'"
1675 )
1676
1677 input_dict_l1_f1 = [
1678 {
1679 "dut": "l1",
1680 "src_address": "*",
1681 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1682 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1683 },
1684 {
1685 "dut": "l1",
1686 "src_address": source_i6,
1687 "iif": topo["routers"]["l1"]["links"]["i6"]["interface"],
1688 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1689 },
1690 {
1691 "dut": "l1",
1692 "src_address": source_i2,
1693 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1694 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1695 },
1696 {
1697 "dut": "f1",
1698 "src_address": source_i2,
1699 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
1700 "oil": topo["routers"]["f1"]["links"]["r2"]["interface"],
1701 },
1702 ]
1703
1704 for data in input_dict_l1_f1:
1705 result = verify_mroutes(
1706 tgen,
1707 data["dut"],
1708 data["src_address"],
1709 IGMP_JOIN_RANGE_1,
1710 data["iif"],
1711 data["oil"],
1712 )
1713 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1714
1715 for data in input_dict_l1_f1:
1716 result = verify_upstream_iif(
1717 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1718 )
1719 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1720
1721 result = verify_multicast_traffic(tgen, input_traffic)
1722 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1723
1724 step("Verify that no core is observed")
1725 if tgen.routers_have_failure():
1726 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
1727
1728 step("Remove ip igmp and send igmp prune from FRR1 interface")
1729
1730 input_dict_2 = {
1731 "l1": {
1732 "igmp": {
1733 "interfaces": {
1734 intf_l1_i1: {
1735 "igmp": {
1736 "version": "2",
1737 "delete": True,
1738 }
1739 }
1740 }
1741 }
1742 }
1743 }
1744 result = create_igmp_config(tgen, topo, input_dict_2)
1745 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1746 step(
1747 "Verification: After removing igmp 'no ip igmp' and "
1748 " sending prune verify mroute and upstream got removed"
1749 " from FRR1 verify using 'show ip mroute' and "
1750 "'show ip pim upstream'"
1751 )
1752
1753 dut = "l1"
1754 iif = topo["routers"]["l1"]["links"]["i6"]["interface"]
1755 oil = topo["routers"]["l1"]["links"]["i1"]["interface"]
1756 source = source_i6
1757 result = verify_mroutes(
1758 tgen, dut, source, IGMP_JOIN_RANGE_1, iif, oil, expected=False
1759 )
1760 assert result is not True, (
1761 "Testcase {} : Failed \n "
1762 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
1763 "Found: {}".format(tc_name, dut, result)
1764 )
1765
1766 write_test_footer(tc_name)
1767
1768
1769 def test_verify_remove_add_igmp_commands_when_pim_configured_p0(request):
1770 """
1771 TC_34: Verify removing and adding IGMP commands when PIM is already
1772 configured
1773 """
1774
1775 tgen = get_topogen()
1776 tc_name = request.node.name
1777 write_test_header(tc_name)
1778
1779 # Don"t run this test if we have any failure.
1780 if tgen.routers_have_failure():
1781 pytest.skip(tgen.errors)
1782
1783 # Creating configuration from JSON
1784 app_helper.stop_all_hosts()
1785 clear_mroute(tgen)
1786 reset_config_on_routers(tgen)
1787 clear_pim_interface_traffic(tgen, topo)
1788 check_router_status(tgen)
1789
1790 step("Enable PIM on all routers")
1791 step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)")
1792
1793 input_join = {"i1": topo["routers"]["i1"]["links"]["l1"]["interface"]}
1794
1795 for recvr, recvr_intf in input_join.items():
1796 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
1797 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1798
1799 step("Configure RP for (226.1.1.1-5) and (232.1.1.1-5) in cisco-1(f1)")
1800
1801 input_dict = {
1802 "r2": {
1803 "pim": {
1804 "rp": [
1805 {
1806 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
1807 "/"
1808 )[0],
1809 "group_addr_range": GROUP_RANGE,
1810 }
1811 ]
1812 }
1813 }
1814 }
1815
1816 result = create_pim_config(tgen, topo, input_dict)
1817 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1818
1819 step("Configure source on FRR3 and start the traffic for" " (225.1.1.1-225.1.1.10)")
1820
1821 input_src = {"i2": topo["routers"]["i2"]["links"]["f1"]["interface"]}
1822
1823 for src, src_intf in input_src.items():
1824 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
1825 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1826
1827 step("Configure source on FRR1 and start the traffic for" " (225.1.1.1-225.1.1.10)")
1828
1829 input_src = {"i6": topo["routers"]["i6"]["links"]["l1"]["interface"]}
1830
1831 for src, src_intf in input_src.items():
1832 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
1833 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1834
1835 source_i6 = topo["routers"]["i6"]["links"]["l1"]["ipv4"].split("/")[0]
1836 source_i2 = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
1837 input_dict_all = [
1838 {
1839 "dut": "l1",
1840 "src_address": "*",
1841 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1842 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1843 },
1844 {
1845 "dut": "l1",
1846 "src_address": source_i6,
1847 "iif": topo["routers"]["l1"]["links"]["i6"]["interface"],
1848 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1849 },
1850 {
1851 "dut": "l1",
1852 "src_address": source_i2,
1853 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
1854 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
1855 },
1856 {
1857 "dut": "r2",
1858 "src_address": "*",
1859 "iif": "lo",
1860 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
1861 },
1862 {
1863 "dut": "f1",
1864 "src_address": source_i2,
1865 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
1866 "oil": topo["routers"]["f1"]["links"]["r2"]["interface"],
1867 },
1868 ]
1869
1870 for data in input_dict_all:
1871 result = verify_mroutes(
1872 tgen,
1873 data["dut"],
1874 data["src_address"],
1875 IGMP_JOIN_RANGE_1,
1876 data["iif"],
1877 data["oil"],
1878 )
1879 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1880
1881 for data in input_dict_all:
1882 result = verify_upstream_iif(
1883 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
1884 )
1885 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1886
1887 step(
1888 "Verification: After configuring IGMP related config , "
1889 "verify config is present in the interface "
1890 "'show ip igmp interface ensxx json'"
1891 )
1892
1893 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
1894 input_dict_1 = {
1895 "l1": {
1896 "igmp": {
1897 "interfaces": {
1898 intf_l1_i1: {
1899 "igmp": {
1900 "version": "2",
1901 "query": {
1902 "query-max-response-time": 40,
1903 "query-interval": 5,
1904 },
1905 }
1906 }
1907 }
1908 }
1909 }
1910 }
1911
1912 result = verify_igmp_config(tgen, input_dict_1)
1913 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1914
1915 step(
1916 "Remove igmp 'no ip igmp' and 'no ip igmp version 2' from"
1917 " receiver interface of FRR1"
1918 )
1919
1920 input_dict_2 = {
1921 "l1": {
1922 "igmp": {
1923 "interfaces": {
1924 intf_l1_i1: {
1925 "igmp": {
1926 "version": "2",
1927 "delete": True,
1928 }
1929 }
1930 }
1931 }
1932 }
1933 }
1934
1935 result = create_igmp_config(tgen, topo, input_dict_2)
1936 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1937
1938 step(
1939 "Verification: After removing the config CLI got removed "
1940 "'show ip igmp interface ensxx json'"
1941 )
1942
1943 result = verify_igmp_config(tgen, input_dict_1, expected=False)
1944 assert result is not True, (
1945 "Testcase {} : Failed \n "
1946 "Expected: [{}]: IGMP interface should be removed \n "
1947 "Found: {}".format(tc_name, data["dut"], result)
1948 )
1949
1950 step("Verify that no core is observed")
1951 if tgen.routers_have_failure():
1952 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
1953
1954 step("Configure 'ip igmp last-member-query-count 10' on FRR1" " receiver interface")
1955
1956 input_dict_3 = {
1957 "l1": {
1958 "igmp": {
1959 "interfaces": {
1960 "l1-i1-eth1": {"igmp": {"query": {"last-member-query-count": 5}}}
1961 }
1962 }
1963 }
1964 }
1965 result = create_igmp_config(tgen, topo, input_dict_3)
1966 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1967
1968 result = verify_igmp_config(tgen, input_dict_3)
1969 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1970
1971 step("Remove 'ip igmp last-member-query-count 10' on FRR1" " receiver interface")
1972
1973 input_dict_3 = {
1974 "l1": {
1975 "igmp": {
1976 "interfaces": {
1977 "l1-i1-eth1": {
1978 "igmp": {
1979 "query": {"last-member-query-count": "", "delete": True}
1980 }
1981 }
1982 }
1983 }
1984 }
1985 }
1986 result = create_igmp_config(tgen, topo, input_dict_3)
1987 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1988
1989 input_dict_3 = {
1990 "l1": {
1991 "igmp": {
1992 "interfaces": {
1993 "l1-i1-eth1": {"igmp": {"query": {"last-member-query-count": 2}}}
1994 }
1995 }
1996 }
1997 }
1998 result = verify_igmp_config(tgen, input_dict_3)
1999 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2000
2001 step("Verify that no core is observed")
2002 if tgen.routers_have_failure():
2003 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
2004
2005 step(
2006 "Configure 'ip igmp last-member-query-interval 20' on FRR1"
2007 " receiver interface"
2008 )
2009
2010 input_dict_3 = {
2011 "l1": {
2012 "igmp": {
2013 "interfaces": {
2014 "l1-i1-eth1": {
2015 "igmp": {"query": {"last-member-query-interval": 20}}
2016 }
2017 }
2018 }
2019 }
2020 }
2021 result = create_igmp_config(tgen, topo, input_dict_3)
2022 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2023
2024 result = verify_igmp_config(tgen, input_dict_3)
2025 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2026
2027 step("Remove 'ip igmp last-member-query-count 10' on FRR1" " receiver interface")
2028
2029 input_dict_3 = {
2030 "l1": {
2031 "igmp": {
2032 "interfaces": {
2033 "l1-i1-eth1": {
2034 "igmp": {
2035 "query": {"last-member-query-interval": "", "delete": True}
2036 }
2037 }
2038 }
2039 }
2040 }
2041 }
2042 result = create_igmp_config(tgen, topo, input_dict_3)
2043 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2044
2045 input_dict_3 = {
2046 "l1": {
2047 "igmp": {
2048 "interfaces": {
2049 "l1-i1-eth1": {
2050 "igmp": {"query": {"last-member-query-interval": 10}}
2051 }
2052 }
2053 }
2054 }
2055 }
2056 result = verify_igmp_config(tgen, input_dict_3)
2057 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2058
2059 step("Verify that no core is observed")
2060 if tgen.routers_have_failure():
2061 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
2062
2063 write_test_footer(tc_name)
2064
2065
2066 def test_verify_remove_add_pim_commands_when_igmp_configured_p1(request):
2067 """
2068 TC_35: Verify removing and adding PIM commands when IGMP is already
2069 configured
2070 """
2071
2072 tgen = get_topogen()
2073 tc_name = request.node.name
2074 write_test_header(tc_name)
2075
2076 # Don"t run this test if we have any failure.
2077 if tgen.routers_have_failure():
2078 pytest.skip(tgen.errors)
2079
2080 # Creating configuration from JSON
2081 app_helper.stop_all_hosts()
2082 clear_mroute(tgen)
2083 reset_config_on_routers(tgen)
2084 clear_pim_interface_traffic(tgen, topo)
2085 check_router_status(tgen)
2086
2087 step("Configure 'ip pim' on receiver interface on FRR1")
2088 step("Enable PIM on all routers")
2089 step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)")
2090
2091 input_join = {"i1": topo["routers"]["i1"]["links"]["l1"]["interface"]}
2092
2093 for recvr, recvr_intf in input_join.items():
2094 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
2095 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2096
2097 step("Configure RP for (226.1.1.1-5) and (232.1.1.1-5) in cisco-1(f1)")
2098
2099 input_dict = {
2100 "r2": {
2101 "pim": {
2102 "rp": [
2103 {
2104 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
2105 "/"
2106 )[0],
2107 "group_addr_range": GROUP_RANGE,
2108 }
2109 ]
2110 }
2111 }
2112 }
2113
2114 result = create_pim_config(tgen, topo, input_dict)
2115 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2116
2117 step("Remove 'no ip pim' on receiver interface on FRR1")
2118
2119 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
2120 raw_config = {
2121 "l1": {"raw_config": ["interface {}".format(intf_l1_i1), "no ip pim"]}
2122 }
2123 result = apply_raw_config(tgen, raw_config)
2124 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2125
2126 step("Verify that no core is observed")
2127 if tgen.routers_have_failure():
2128 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
2129
2130 step("Configure 'ip pim bsm' on receiver interface on FRR1")
2131
2132 raw_config = {
2133 "l1": {"raw_config": ["interface {}".format(intf_l1_i1), "ip pim bsm"]}
2134 }
2135 result = apply_raw_config(tgen, raw_config)
2136 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2137
2138 step("Remove 'no ip pim bsm' on receiver interface on FRR1")
2139
2140 raw_config = {
2141 "l1": {"raw_config": ["interface {}".format(intf_l1_i1), "no ip pim bsm"]}
2142 }
2143 result = apply_raw_config(tgen, raw_config)
2144 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2145
2146 step("Verify that no core is observed")
2147 if tgen.routers_have_failure():
2148 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
2149
2150 step("Configure 'ip pim drpriority' on receiver interface on FRR1")
2151
2152 raw_config = {
2153 "l1": {
2154 "raw_config": ["interface {}".format(intf_l1_i1), "ip pim drpriority 10"]
2155 }
2156 }
2157 result = apply_raw_config(tgen, raw_config)
2158 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2159
2160 step(
2161 "Verification: After configuring PIM related config, "
2162 "verify config is present in the interface "
2163 "'show ip pim interface ensxx json'"
2164 )
2165
2166 input_dict_dr = {"l1": {"pim": {"interfaces": {intf_l1_i1: {"drPriority": 10}}}}}
2167 result = verify_pim_config(tgen, input_dict_dr)
2168 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2169
2170 step("Remove 'no ip pim drpriority' on receiver interface on FRR1")
2171
2172 raw_config = {
2173 "l1": {
2174 "raw_config": ["interface {}".format(intf_l1_i1), "no ip pim drpriority 10"]
2175 }
2176 }
2177 result = apply_raw_config(tgen, raw_config)
2178 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2179
2180 step(
2181 "Verification: After removing the config CLI got removed "
2182 "'show ip pim interface ensxx json'"
2183 )
2184
2185 input_dict_dr = {"l1": {"pim": {"interfaces": {intf_l1_i1: {"drPriority": 1}}}}}
2186 result = verify_pim_config(tgen, input_dict_dr)
2187 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2188
2189 step("Verify that no core is observed")
2190 if tgen.routers_have_failure():
2191 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
2192
2193 step("Configure 'ip pim hello' on receiver interface on FRR1")
2194
2195 raw_config = {
2196 "l1": {"raw_config": ["interface {}".format(intf_l1_i1), "ip pim hello 50"]}
2197 }
2198 result = apply_raw_config(tgen, raw_config)
2199 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2200
2201 step(
2202 "Verification: After configuring PIM related config, "
2203 "verify config is present in the interface "
2204 "'show ip pim interface ensxx json'"
2205 )
2206
2207 input_dict_dr = {"l1": {"pim": {"interfaces": {intf_l1_i1: {"helloPeriod": 50}}}}}
2208 result = verify_pim_config(tgen, input_dict_dr)
2209 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2210
2211 step("Remove 'no ip pim hello' on receiver interface on FRR1")
2212
2213 raw_config = {
2214 "l1": {"raw_config": ["interface {}".format(intf_l1_i1), "no ip pim hello"]}
2215 }
2216 result = apply_raw_config(tgen, raw_config)
2217 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2218
2219 step(
2220 "Verification: After removing the config CLI got removed "
2221 "'show ip pim interface ensxx json'"
2222 )
2223
2224 input_dict_dr = {"l1": {"pim": {"interfaces": {intf_l1_i1: {"helloPeriod": 30}}}}}
2225 result = verify_pim_config(tgen, input_dict_dr)
2226 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2227
2228 step("Verify that no core is observed")
2229 if tgen.routers_have_failure():
2230 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
2231
2232 step("Configure 'ip pim unicast-bsm' on receiver interface on FRR1")
2233
2234 raw_config = {
2235 "l1": {"raw_config": ["interface {}".format(intf_l1_i1), "ip pim unicast-bsm"]}
2236 }
2237 result = apply_raw_config(tgen, raw_config)
2238 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2239
2240 step("Remove 'no ip pim hello' on receiver interface on FRR1")
2241
2242 raw_config = {
2243 "l1": {
2244 "raw_config": ["interface {}".format(intf_l1_i1), "no ip pim unicast-bsm"]
2245 }
2246 }
2247 result = apply_raw_config(tgen, raw_config)
2248 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2249
2250 step("Verify that no core is observed")
2251 if tgen.routers_have_failure():
2252 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
2253
2254 write_test_footer(tc_name)
2255
2256
2257 def test_pim_dr_priority_p0(request):
2258 """
2259 TC_36: Verify highest DR priority become the PIM DR
2260 """
2261
2262 tgen = get_topogen()
2263 tc_name = request.node.name
2264 write_test_header(tc_name)
2265
2266 # Don"t run this test if we have any failure.
2267 if tgen.routers_have_failure():
2268 pytest.skip(tgen.errors)
2269
2270 # Creating configuration from JSON
2271 app_helper.stop_all_hosts()
2272 clear_mroute(tgen)
2273 reset_config_on_routers(tgen)
2274 clear_pim_interface_traffic(tgen, topo)
2275 check_router_status(tgen)
2276
2277 step("Configure 'ip pim' on receiver interface on FRR1")
2278 step("Enable PIM on all routers")
2279 step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)")
2280
2281 input_join = {"i1": topo["routers"]["i1"]["links"]["l1"]["interface"]}
2282
2283 for recvr, recvr_intf in input_join.items():
2284 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
2285 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2286
2287 step("Configure RP for (226.1.1.1-5) and (232.1.1.1-5) in cisco-1(f1)")
2288
2289 input_dict = {
2290 "r2": {
2291 "pim": {
2292 "rp": [
2293 {
2294 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
2295 "/"
2296 )[0],
2297 "group_addr_range": GROUP_RANGE,
2298 }
2299 ]
2300 }
2301 }
2302 }
2303
2304 result = create_pim_config(tgen, topo, input_dict)
2305 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2306
2307 input_src = {"i2": topo["routers"]["i2"]["links"]["f1"]["interface"]}
2308
2309 for src, src_intf in input_src.items():
2310 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
2311 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2312
2313 source_i2 = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
2314 input_dict_all = [
2315 {
2316 "dut": "l1",
2317 "src_address": "*",
2318 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
2319 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
2320 },
2321 {
2322 "dut": "l1",
2323 "src_address": source_i2,
2324 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
2325 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
2326 },
2327 {
2328 "dut": "r2",
2329 "src_address": "*",
2330 "iif": "lo",
2331 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
2332 },
2333 {
2334 "dut": "f1",
2335 "src_address": source_i2,
2336 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
2337 "oil": topo["routers"]["f1"]["links"]["r2"]["interface"],
2338 },
2339 ]
2340
2341 for data in input_dict_all:
2342 result = verify_mroutes(
2343 tgen,
2344 data["dut"],
2345 data["src_address"],
2346 IGMP_JOIN_RANGE_1,
2347 data["iif"],
2348 data["oil"],
2349 )
2350 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2351
2352 for data in input_dict_all:
2353 result = verify_upstream_iif(
2354 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
2355 )
2356 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2357
2358 step("Configure 'ip pim drpriority 10' on receiver interface on FRR1(LHR)")
2359
2360 intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
2361 raw_config = {
2362 "l1": {
2363 "raw_config": ["interface {}".format(intf_l1_r2), "ip pim drpriority 10"]
2364 }
2365 }
2366 result = apply_raw_config(tgen, raw_config)
2367 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2368
2369 step(
2370 "DR config is successful on FRR1 node , verify using "
2371 " 'show ip pim interface json'"
2372 )
2373
2374 input_dict_dr = {"l1": {"pim": {"interfaces": {intf_l1_r2: {"drPriority": 10}}}}}
2375 result = verify_pim_config(tgen, input_dict_dr)
2376 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2377
2378 for data in input_dict_all:
2379 result = verify_mroutes(
2380 tgen,
2381 data["dut"],
2382 data["src_address"],
2383 IGMP_JOIN_RANGE_1,
2384 data["iif"],
2385 data["oil"],
2386 )
2387 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2388
2389 for data in input_dict_all:
2390 result = verify_upstream_iif(
2391 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
2392 )
2393 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2394
2395 step("Configure 'ip pim drpriority 20' on receiver interface on FRR3(FHR)")
2396
2397 intf_f1_r2 = topo["routers"]["f1"]["links"]["r2"]["interface"]
2398 raw_config = {
2399 "f1": {
2400 "raw_config": ["interface {}".format(intf_f1_r2), "ip pim drpriority 20"]
2401 }
2402 }
2403 result = apply_raw_config(tgen, raw_config)
2404 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2405
2406 step(
2407 "DR config is successful on FRR3 node , verify using "
2408 " 'show ip pim interface json'"
2409 )
2410
2411 input_dict_dr = {"f1": {"pim": {"interfaces": {intf_f1_r2: {"drPriority": 20}}}}}
2412 result = verify_pim_config(tgen, input_dict_dr)
2413 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2414
2415 for data in input_dict_all:
2416 result = verify_mroutes(
2417 tgen,
2418 data["dut"],
2419 data["src_address"],
2420 IGMP_JOIN_RANGE_1,
2421 data["iif"],
2422 data["oil"],
2423 )
2424 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2425
2426 for data in input_dict_all:
2427 result = verify_upstream_iif(
2428 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
2429 )
2430 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2431
2432 step(
2433 "PIM is enable on FRR1, FRR2 interface and neighbor is up, "
2434 " verify using 'show ip pim interface'"
2435 )
2436
2437 result = verify_pim_interface(tgen, topo, "l1")
2438 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2439
2440 result = verify_pim_interface(tgen, topo, "f1")
2441 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2442
2443 step(
2444 "Highet IP become PIM DR , verify using "
2445 "'show ip pim interface json' and 'show ip pim neighbor'"
2446 )
2447 step("Highest priority become PIM DR")
2448
2449 dr_address = topo["routers"]["l1"]["links"]["r2"]["ipv4"].split("/")[0]
2450 input_dict_dr = {
2451 "l1": {"pim": {"interfaces": {intf_l1_r2: {"drAddress": dr_address}}}}
2452 }
2453 result = verify_pim_config(tgen, input_dict_dr)
2454 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2455
2456 dr_address = topo["routers"]["f1"]["links"]["r2"]["ipv4"].split("/")[0]
2457 input_dict_dr = {
2458 "f1": {"pim": {"interfaces": {intf_f1_r2: {"drAddress": dr_address}}}}
2459 }
2460 result = verify_pim_config(tgen, input_dict_dr)
2461 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2462
2463 step("Remove 'no ip pim drpriority' on receiver interface on FRR1")
2464
2465 raw_config = {
2466 "l1": {
2467 "raw_config": ["interface {}".format(intf_l1_r2), "no ip pim drpriority 10"]
2468 }
2469 }
2470 result = apply_raw_config(tgen, raw_config)
2471 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2472
2473 step("Remove 'no ip pim drpriority' on receiver interface on FRR3")
2474
2475 raw_config = {
2476 "f1": {
2477 "raw_config": ["interface {}".format(intf_f1_r2), "no ip pim drpriority 20"]
2478 }
2479 }
2480 result = apply_raw_config(tgen, raw_config)
2481 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2482
2483 step(
2484 "After removing drpriority , config got removed from both the "
2485 "nodes and highest IP become PIM DR"
2486 )
2487
2488 input_dict_dr = {"l1": {"pim": {"interfaces": {intf_l1_r2: {"drPriority": 1}}}}}
2489 result = verify_pim_config(tgen, input_dict_dr)
2490 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2491
2492 input_dict_dr = {"f1": {"pim": {"interfaces": {intf_f1_r2: {"drPriority": 1}}}}}
2493 result = verify_pim_config(tgen, input_dict_dr)
2494 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2495
2496 dr_address = topo["routers"]["r2"]["links"]["l1"]["ipv4"].split("/")[0]
2497 input_dict_dr = {
2498 "l1": {"pim": {"interfaces": {intf_l1_r2: {"drAddress": dr_address}}}}
2499 }
2500 result = verify_pim_config(tgen, input_dict_dr)
2501 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2502
2503 dr_address = topo["routers"]["r2"]["links"]["f1"]["ipv4"].split("/")[0]
2504 input_dict_dr = {
2505 "f1": {"pim": {"interfaces": {intf_f1_r2: {"drAddress": dr_address}}}}
2506 }
2507 result = verify_pim_config(tgen, input_dict_dr)
2508 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2509
2510 for data in input_dict_all:
2511 result = verify_mroutes(
2512 tgen,
2513 data["dut"],
2514 data["src_address"],
2515 IGMP_JOIN_RANGE_1,
2516 data["iif"],
2517 data["oil"],
2518 )
2519 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2520
2521 for data in input_dict_all:
2522 result = verify_upstream_iif(
2523 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
2524 )
2525 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2526
2527 write_test_footer(tc_name)
2528
2529
2530 def test_pim_hello_timer_p1(request):
2531 """
2532 TC_37: Verify PIM hello is sent on configured timer
2533 """
2534
2535 tgen = get_topogen()
2536 tc_name = request.node.name
2537 write_test_header(tc_name)
2538
2539 # Don"t run this test if we have any failure.
2540 if tgen.routers_have_failure():
2541 pytest.skip(tgen.errors)
2542
2543 # Creating configuration from JSON
2544 app_helper.stop_all_hosts()
2545 clear_mroute(tgen)
2546 reset_config_on_routers(tgen)
2547 clear_pim_interface_traffic(tgen, topo)
2548 check_router_status(tgen)
2549
2550 step("Configure 'ip pim' on receiver interface on FRR1")
2551 step("Enable PIM on all routers")
2552 step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-225.1.1.10)")
2553
2554 input_join = {"i1": topo["routers"]["i1"]["links"]["l1"]["interface"]}
2555
2556 for recvr, recvr_intf in input_join.items():
2557 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
2558 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2559
2560 step("Configure RP for (226.1.1.1-5) and (232.1.1.1-5) in cisco-1(f1)")
2561
2562 input_dict = {
2563 "r2": {
2564 "pim": {
2565 "rp": [
2566 {
2567 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
2568 "/"
2569 )[0],
2570 "group_addr_range": GROUP_RANGE,
2571 }
2572 ]
2573 }
2574 }
2575 }
2576
2577 result = create_pim_config(tgen, topo, input_dict)
2578 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2579
2580 step("Configure PIM hello interval timer 100 on FRR1 node (FRR1-FRR2 link)")
2581
2582 intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
2583 raw_config = {
2584 "l1": {"raw_config": ["interface {}".format(intf_l1_r2), "ip pim hello 100"]}
2585 }
2586 result = apply_raw_config(tgen, raw_config)
2587 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2588
2589 step(
2590 "PIM hello interval is configured on interface verify using "
2591 "'show ip pim interface'"
2592 )
2593
2594 input_dict_hello = {
2595 "l1": {"pim": {"interfaces": {intf_l1_r2: {"helloPeriod": 100}}}}
2596 }
2597 result = verify_pim_config(tgen, input_dict_hello)
2598 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2599
2600 step("Modify hello timer to 180 and then 50sec")
2601
2602 intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
2603 raw_config = {
2604 "l1": {"raw_config": ["interface {}".format(intf_l1_r2), "ip pim hello 180"]}
2605 }
2606 result = apply_raw_config(tgen, raw_config)
2607 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2608
2609 step(
2610 "PIM hello interval is configured on interface verify using "
2611 "'show ip pim interface'"
2612 )
2613
2614 input_dict_hello = {
2615 "l1": {"pim": {"interfaces": {intf_l1_r2: {"helloPeriod": 180}}}}
2616 }
2617 result = verify_pim_config(tgen, input_dict_hello)
2618 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2619
2620 intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
2621 raw_config = {
2622 "l1": {"raw_config": ["interface {}".format(intf_l1_r2), "ip pim hello 50"]}
2623 }
2624 result = apply_raw_config(tgen, raw_config)
2625 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2626
2627 step(
2628 "PIM hello interval is configured on interface verify using "
2629 "'show ip pim interface'"
2630 )
2631
2632 input_dict_hello = {
2633 "l1": {"pim": {"interfaces": {intf_l1_r2: {"helloPeriod": 50}}}}
2634 }
2635 result = verify_pim_config(tgen, input_dict_hello)
2636 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2637
2638 step("Verify that no core is observed")
2639 if tgen.routers_have_failure():
2640 assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
2641
2642 write_test_footer(tc_name)
2643
2644
2645 def test_mroute_after_removing_RP_sending_IGMP_prune_p2(request):
2646 """
2647 TC_39 Verify mroute after removing the RP and sending IGMP prune
2648 """
2649
2650 tgen = get_topogen()
2651 tc_name = request.node.name
2652 write_test_header(tc_name)
2653
2654 # Don"t run this test if we have any failure.
2655 if tgen.routers_have_failure():
2656 pytest.skip(tgen.errors)
2657
2658 # Creating configuration from JSON
2659 app_helper.stop_all_hosts()
2660 clear_mroute(tgen)
2661 reset_config_on_routers(tgen)
2662 clear_pim_interface_traffic(tgen, topo)
2663 check_router_status(tgen)
2664
2665 step(
2666 "Remove cisco connected link to simulate topo "
2667 "LHR(FRR1(f1))----RP(cisco(f1)---FHR(FRR3(l1))"
2668 )
2669
2670 intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["interface"]
2671 intf_f1_c2 = topo["routers"]["f1"]["links"]["c2"]["interface"]
2672 shutdown_bringup_interface(tgen, "l1", intf_l1_c1, False)
2673 shutdown_bringup_interface(tgen, "f1", intf_f1_c2, False)
2674
2675 step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3")
2676 step(
2677 "Enable IGMP of FRR1 interface and send IGMP joins "
2678 " from FRR1 node for group range (225.1.1.1-5)"
2679 )
2680
2681 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
2682 input_dict = {
2683 "f1": {
2684 "igmp": {
2685 "interfaces": {
2686 intf_f1_i8: {
2687 "igmp": {"version": "2", "query": {"query-interval": 15}}
2688 }
2689 }
2690 }
2691 }
2692 }
2693 result = create_igmp_config(tgen, topo, input_dict)
2694 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2695
2696 input_join = {"i8": topo["routers"]["i8"]["links"]["f1"]["interface"]}
2697
2698 for recvr, recvr_intf in input_join.items():
2699 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
2700 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2701
2702 step("Configure static RP for (225.1.1.1-5) as R2")
2703
2704 input_dict = {
2705 "r2": {
2706 "pim": {
2707 "rp": [
2708 {
2709 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
2710 "/"
2711 )[0],
2712 "group_addr_range": GROUP_RANGE,
2713 }
2714 ]
2715 }
2716 }
2717 }
2718
2719 result = create_pim_config(tgen, topo, input_dict)
2720 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2721
2722 step(
2723 "Send traffic from FHR to all the groups ( 225.1.1.1 to 225.1.1.5) and send"
2724 " multicast traffic"
2725 )
2726
2727 input_src = {"i6": topo["routers"]["i6"]["links"]["l1"]["interface"]}
2728
2729 for src, src_intf in input_src.items():
2730 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
2731 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2732
2733 source_i2 = topo["routers"]["i6"]["links"]["l1"]["ipv4"].split("/")[0]
2734
2735 input_dict_all = [
2736 {
2737 "dut": "l1",
2738 "src_address": source_i2,
2739 "iif": topo["routers"]["l1"]["links"]["i6"]["interface"],
2740 "oil": topo["routers"]["l1"]["links"]["r2"]["interface"],
2741 },
2742 {
2743 "dut": "f1",
2744 "src_address": "*",
2745 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
2746 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
2747 },
2748 {
2749 "dut": "f1",
2750 "src_address": source_i2,
2751 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
2752 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
2753 },
2754 ]
2755
2756 step("Verify mroutes and iff upstream")
2757
2758 for data in input_dict_all:
2759 result = verify_mroutes(
2760 tgen,
2761 data["dut"],
2762 data["src_address"],
2763 IGMP_JOIN_RANGE_1,
2764 data["iif"],
2765 data["oil"],
2766 )
2767 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2768
2769 for data in input_dict_all:
2770 result = verify_upstream_iif(
2771 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
2772 )
2773 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2774
2775 step("Remove the RP config for both the range from all the nodes")
2776
2777 input_dict = {
2778 "r2": {
2779 "pim": {
2780 "rp": [
2781 {
2782 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
2783 "/"
2784 )[0],
2785 "group_addr_range": GROUP_RANGE,
2786 "delete": True,
2787 }
2788 ]
2789 }
2790 }
2791 }
2792
2793 result = create_pim_config(tgen, topo, input_dict)
2794 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2795
2796 input_dict_starg = [
2797 {
2798 "dut": "f1",
2799 "src_address": "*",
2800 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
2801 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
2802 }
2803 ]
2804
2805 input_dict_sg = [
2806 {
2807 "dut": "l1",
2808 "src_address": source_i2,
2809 "iif": topo["routers"]["l1"]["links"]["i6"]["interface"],
2810 "oil": topo["routers"]["l1"]["links"]["r2"]["interface"],
2811 },
2812 {
2813 "dut": "f1",
2814 "src_address": source_i2,
2815 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
2816 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
2817 },
2818 ]
2819
2820 for data in input_dict_starg:
2821 result = verify_mroutes(
2822 tgen,
2823 data["dut"],
2824 data["src_address"],
2825 IGMP_JOIN_RANGE_1,
2826 data["iif"],
2827 data["oil"],
2828 expected=False,
2829 )
2830 assert result is not True, (
2831 "Testcase {} : Failed \n "
2832 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
2833 "Found: {}".format(tc_name, data["dut"], result)
2834 )
2835
2836 for data in input_dict_sg:
2837 result = verify_mroutes(
2838 tgen,
2839 data["dut"],
2840 data["src_address"],
2841 IGMP_JOIN_RANGE_1,
2842 data["iif"],
2843 data["oil"],
2844 )
2845 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2846
2847 step("Send prune from receiver-1 (using ctrl+c) on iperf interface")
2848 app_helper.stop_all_hosts()
2849
2850 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
2851 input_traffic = {"f1": {"traffic_sent": [intf_f1_i8]}}
2852 traffic_before = verify_multicast_traffic(tgen, input_traffic, return_traffic=True)
2853 assert isinstance(traffic_before, dict), (
2854 "Testcase {} : Failed \n traffic_before is not dictionary \n "
2855 "Error: {}".format(tc_name, result)
2856 )
2857
2858 step("IGMP groups are remove from FRR1 node 'show ip igmp groups'")
2859
2860 dut = "f1"
2861 result = verify_igmp_groups(
2862 tgen, dut, intf_f1_i8, IGMP_JOIN_RANGE_1, expected=False
2863 )
2864 assert result is not True, (
2865 "Testcase {} : Failed \n "
2866 "Expected: [{}]: IGMP groups should not present \n "
2867 "Found: {}".format(tc_name, dut, result)
2868 )
2869
2870 step(
2871 "After receiving the IGMP prune from FRR1 , verify traffic "
2872 "immediately stopped for this receiver 'show ip multicast'"
2873 )
2874
2875 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
2876 input_traffic = {"f1": {"traffic_sent": [intf_f1_i8]}}
2877 traffic_after = verify_multicast_traffic(tgen, input_traffic, return_traffic=True)
2878 assert isinstance(traffic_after, dict), (
2879 "Testcase {} : Failed \n traffic_after is not dictionary \n "
2880 "Error: {}".format(tc_name, result)
2881 )
2882
2883 result = verify_state_incremented(traffic_before, traffic_after)
2884 assert result is not True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2885 logger.info("Expected Behaviour: {}".format(result))
2886
2887 step("Configure static RP for (225.1.1.1-5) as R2 loopback interface")
2888
2889 input_dict = {
2890 "r2": {
2891 "pim": {
2892 "rp": [
2893 {
2894 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
2895 "/"
2896 )[0],
2897 "group_addr_range": GROUP_RANGE,
2898 }
2899 ]
2900 }
2901 }
2902 }
2903
2904 result = create_pim_config(tgen, topo, input_dict)
2905 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2906
2907 step("Send IGMP joins again from LHR,check IGMP joins and starg received")
2908
2909 for recvr, recvr_intf in input_join.items():
2910 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
2911 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2912
2913 for data in input_dict_starg:
2914 result = verify_mroutes(
2915 tgen,
2916 data["dut"],
2917 data["src_address"],
2918 IGMP_JOIN_RANGE_1,
2919 data["iif"],
2920 data["oil"],
2921 )
2922 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2923
2924 step("Send traffic from FHR and verify mroute upstream")
2925
2926 for src, src_intf in input_src.items():
2927 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
2928 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2929
2930 source_i2 = topo["routers"]["i6"]["links"]["l1"]["ipv4"].split("/")[0]
2931
2932 for data in input_dict_sg:
2933 result = verify_mroutes(
2934 tgen,
2935 data["dut"],
2936 data["src_address"],
2937 IGMP_JOIN_RANGE_1,
2938 data["iif"],
2939 data["oil"],
2940 )
2941 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
2942
2943 write_test_footer(tc_name)
2944
2945
2946 def test_prune_sent_to_LHR_and_FHR_when_PIMnbr_down_p2(request):
2947 """
2948 TC_38 Verify prune is sent to LHR and FHR when PIM nbr went down
2949 """
2950
2951 tgen = get_topogen()
2952 tc_name = request.node.name
2953 write_test_header(tc_name)
2954
2955 # Don"t run this test if we have any failure.
2956 if tgen.routers_have_failure():
2957 pytest.skip(tgen.errors)
2958
2959 # Creating configuration from JSON
2960 app_helper.stop_all_hosts()
2961 clear_mroute(tgen)
2962 reset_config_on_routers(tgen)
2963 clear_pim_interface_traffic(tgen, topo)
2964 check_router_status(tgen)
2965
2966 step(
2967 "Remove cisco connected link to simulate topo "
2968 "LHR(FRR1(f1))----RP(cisco(f1)---FHR(FRR3(l1))"
2969 )
2970
2971 intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["interface"]
2972 intf_f1_c2 = topo["routers"]["f1"]["links"]["c2"]["interface"]
2973 shutdown_bringup_interface(tgen, "l1", intf_l1_c1, False)
2974 shutdown_bringup_interface(tgen, "f1", intf_f1_c2, False)
2975
2976 step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3")
2977 step(
2978 "Enable IGMP of FRR1 interface and send IGMP joins "
2979 " from FRR1 node for group range (225.1.1.1-5)"
2980 )
2981
2982 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
2983 input_dict = {
2984 "f1": {
2985 "igmp": {
2986 "interfaces": {
2987 intf_f1_i8: {
2988 "igmp": {"version": "2", "query": {"query-interval": 15}}
2989 }
2990 }
2991 }
2992 }
2993 }
2994 result = create_igmp_config(tgen, topo, input_dict)
2995 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
2996
2997 input_join = {"i8": topo["routers"]["i8"]["links"]["f1"]["interface"]}
2998
2999 for recvr, recvr_intf in input_join.items():
3000 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
3001 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
3002
3003 step("Configure static RP for (225.1.1.1-5) as R2")
3004
3005 input_dict = {
3006 "r2": {
3007 "pim": {
3008 "rp": [
3009 {
3010 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
3011 "/"
3012 )[0],
3013 "group_addr_range": GROUP_RANGE,
3014 }
3015 ]
3016 }
3017 }
3018 }
3019
3020 result = create_pim_config(tgen, topo, input_dict)
3021 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3022
3023 step(
3024 "Send traffic from FHR to all the groups ( 225.1.1.1 to 225.1.1.5) and send"
3025 " multicast traffic"
3026 )
3027
3028 input_src = {
3029 "i6": topo["routers"]["i6"]["links"]["l1"]["interface"],
3030 "i2": topo["routers"]["i2"]["links"]["f1"]["interface"],
3031 }
3032
3033 for src, src_intf in input_src.items():
3034 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
3035 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3036
3037 source_i2 = topo["routers"]["i6"]["links"]["l1"]["ipv4"].split("/")[0]
3038 source_i1 = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
3039
3040 input_dict_all = [
3041 {
3042 "dut": "l1",
3043 "src_address": source_i2,
3044 "iif": topo["routers"]["l1"]["links"]["i6"]["interface"],
3045 "oil": topo["routers"]["l1"]["links"]["r2"]["interface"],
3046 },
3047 {
3048 "dut": "f1",
3049 "src_address": "*",
3050 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
3051 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
3052 },
3053 {
3054 "dut": "f1",
3055 "src_address": source_i1,
3056 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
3057 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
3058 },
3059 {
3060 "dut": "f1",
3061 "src_address": source_i2,
3062 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
3063 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
3064 },
3065 ]
3066
3067 step("Verify mroutes and iff upstream")
3068
3069 for data in input_dict_all:
3070 result = verify_mroutes(
3071 tgen,
3072 data["dut"],
3073 data["src_address"],
3074 IGMP_JOIN_RANGE_1,
3075 data["iif"],
3076 data["oil"],
3077 )
3078 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3079
3080 for data in input_dict_all:
3081 result = verify_upstream_iif(
3082 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3083 )
3084 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3085 step("Verify mcast traffic received")
3086 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
3087 input_traffic = {"f1": {"traffic_sent": [intf_f1_i8]}}
3088
3089 result = verify_multicast_traffic(tgen, input_traffic)
3090 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3091
3092 step("Shut the link from LHR to RP from RP node")
3093
3094 intf_r2_f1 = topo["routers"]["r2"]["links"]["f1"]["interface"]
3095 shutdown_bringup_interface(tgen, "r2", intf_r2_f1, False)
3096
3097 step("Verify RP info after Shut the link from LHR to RP from RP node")
3098 dut = "f1"
3099 rp_address = "1.0.5.17"
3100 SOURCE = "Static"
3101 result = verify_pim_rp_info(
3102 tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE
3103 )
3104 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3105
3106 input_dict_starg = [
3107 {
3108 "dut": "f1",
3109 "src_address": "*",
3110 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
3111 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
3112 }
3113 ]
3114
3115 input_dict_sg_i2 = [
3116 {
3117 "dut": "l1",
3118 "src_address": source_i2,
3119 "iif": topo["routers"]["l1"]["links"]["i6"]["interface"],
3120 "oil": topo["routers"]["l1"]["links"]["r2"]["interface"],
3121 },
3122 {
3123 "dut": "f1",
3124 "src_address": source_i2,
3125 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
3126 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
3127 },
3128 ]
3129
3130 input_dict_sg_i1 = [
3131 {
3132 "dut": "f1",
3133 "src_address": source_i1,
3134 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
3135 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
3136 }
3137 ]
3138
3139 input_dict_sg_i2_l1 = [
3140 {
3141 "dut": "l1",
3142 "src_address": source_i2,
3143 "iif": topo["routers"]["l1"]["links"]["i6"]["interface"],
3144 "oil": topo["routers"]["l1"]["links"]["r2"]["interface"],
3145 }
3146 ]
3147
3148 step("Verify mroute after Shut the link from LHR to RP from RP node")
3149
3150 for data in input_dict_starg:
3151 result = verify_mroutes(
3152 tgen,
3153 data["dut"],
3154 data["src_address"],
3155 IGMP_JOIN_RANGE_1,
3156 data["iif"],
3157 data["oil"],
3158 expected=False,
3159 )
3160 assert result is not True, (
3161 "Testcase {} : Failed \n "
3162 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
3163 "Found: {}".format(tc_name, data["dut"], result)
3164 )
3165
3166 for data in input_dict_sg_i1:
3167 result = verify_mroutes(
3168 tgen,
3169 data["dut"],
3170 data["src_address"],
3171 IGMP_JOIN_RANGE_1,
3172 data["iif"],
3173 data["oil"],
3174 )
3175 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3176
3177 step("Verify upstream after Shut the link from LHR to RP from RP node")
3178
3179 for data in input_dict_starg:
3180 result = verify_upstream_iif(
3181 tgen,
3182 data["dut"],
3183 data["iif"],
3184 data["src_address"],
3185 IGMP_JOIN_RANGE_1,
3186 expected=False,
3187 )
3188 assert result is not True, (
3189 "Testcase {} : Failed \n "
3190 "Expected: [{}]: Upstream IIF interface {} should not be present\n"
3191 "Found: {}".format(tc_name, data["dut"], data["iif"], result)
3192 )
3193
3194 for data in input_dict_sg_i1:
3195 result = verify_upstream_iif(
3196 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3197 )
3198 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3199
3200 step("No shut the link from LHR to RP from RP node")
3201
3202 intf_r2_f1 = topo["routers"]["r2"]["links"]["f1"]["interface"]
3203 shutdown_bringup_interface(tgen, "r2", intf_r2_f1, True)
3204
3205 step("Verify RP info after No shut the link from LHR to RP from RP node")
3206 dut = "f1"
3207 rp_address = "1.0.5.17"
3208 SOURCE = "Static"
3209 result = verify_pim_rp_info(
3210 tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False
3211 )
3212 assert result is not True, (
3213 "Testcase {} : Failed \n "
3214 "Expected: [{}]: RP IIF should be updated as Unknown \n "
3215 "Found: {}".format(tc_name, dut, result)
3216 )
3217
3218 step("Verify mroute after No shut the link from LHR to RP from RP node")
3219
3220 for data in input_dict_starg:
3221 result = verify_mroutes(
3222 tgen,
3223 data["dut"],
3224 data["src_address"],
3225 IGMP_JOIN_RANGE_1,
3226 data["iif"],
3227 data["oil"],
3228 )
3229 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3230
3231 for data in input_dict_sg_i2:
3232 result = verify_mroutes(
3233 tgen,
3234 data["dut"],
3235 data["src_address"],
3236 IGMP_JOIN_RANGE_1,
3237 data["iif"],
3238 data["oil"],
3239 )
3240 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3241
3242 for data in input_dict_sg_i1:
3243 result = verify_mroutes(
3244 tgen,
3245 data["dut"],
3246 data["src_address"],
3247 IGMP_JOIN_RANGE_1,
3248 data["iif"],
3249 data["oil"],
3250 )
3251 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3252
3253 step("Verify upstrem after No shut the link from LHR to RP from RP node")
3254
3255 for data in input_dict_starg:
3256 result = verify_upstream_iif(
3257 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3258 )
3259 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3260
3261 for data in input_dict_sg_i1:
3262 result = verify_upstream_iif(
3263 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3264 )
3265 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3266
3267 for data in input_dict_sg_i2:
3268 result = verify_upstream_iif(
3269 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3270 )
3271 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3272
3273 step("Verify mcast traffic received after noshut LHR to RP from RP node")
3274
3275 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
3276 input_traffic = {"f1": {"traffic_sent": [intf_f1_i8]}}
3277 result = verify_multicast_traffic(tgen, input_traffic)
3278 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3279
3280 step("Shut the link from FHR to RP from RP node")
3281
3282 intf_r2_l1 = topo["routers"]["r2"]["links"]["l1"]["interface"]
3283 shutdown_bringup_interface(tgen, "r2", intf_r2_l1, False)
3284
3285 step("Verify RP info after Shut the link from FHR to RP from RP node")
3286 dut = "l1"
3287 rp_address = "1.0.5.17"
3288 SOURCE = "Static"
3289 result = verify_pim_rp_info(
3290 tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE
3291 )
3292 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3293
3294 step("Verify mroute after Shut the link from FHR to RP from RP node")
3295
3296 for data in input_dict_starg:
3297 result = verify_mroutes(
3298 tgen,
3299 data["dut"],
3300 data["src_address"],
3301 IGMP_JOIN_RANGE_1,
3302 data["iif"],
3303 data["oil"],
3304 )
3305 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3306
3307 for data in input_dict_sg_i1:
3308 result = verify_mroutes(
3309 tgen,
3310 data["dut"],
3311 data["src_address"],
3312 IGMP_JOIN_RANGE_1,
3313 data["iif"],
3314 data["oil"],
3315 )
3316 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3317
3318 step("Verify upstream after Shut the link from FHR to RP from RP node")
3319
3320 for data in input_dict_starg:
3321 result = verify_upstream_iif(
3322 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3323 )
3324 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3325
3326 for data in input_dict_sg_i1:
3327 result = verify_upstream_iif(
3328 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3329 )
3330 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3331
3332 for data in input_dict_sg_i2_l1:
3333 result = verify_upstream_iif(
3334 tgen,
3335 data["dut"],
3336 data["iif"],
3337 data["src_address"],
3338 IGMP_JOIN_RANGE_1,
3339 expected=False,
3340 )
3341 assert result is not True, (
3342 "Testcase {} : Failed \n "
3343 "Expected: [{}]: Upstream IIF interface {} should not be present"
3344 " after shutting link from RP to FHR \n"
3345 "Found: {}".format(tc_name, data["dut"], data["iif"], result)
3346 )
3347
3348 step(" No shut the link from FHR to RP from RP node")
3349
3350 intf_r2_l1 = topo["routers"]["r2"]["links"]["l1"]["interface"]
3351 shutdown_bringup_interface(tgen, "r2", intf_r2_l1, True)
3352
3353 step("Verify RP info after Noshut the link from FHR to RP from RP node")
3354
3355 dut = "l1"
3356 rp_address = "1.0.5.17"
3357 SOURCE = "Static"
3358 result = verify_pim_rp_info(
3359 tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False
3360 )
3361 assert result is not True, (
3362 "Testcase {} : Failed \n "
3363 "Expected: [{}]: RP IIF should be updated as Unknown \n"
3364 "Found: {}".format(tc_name, dut, result)
3365 )
3366
3367 step("Verify mroute after Noshut the link from FHR to RP from RP node")
3368
3369 for data in input_dict_starg:
3370 result = verify_mroutes(
3371 tgen,
3372 data["dut"],
3373 data["src_address"],
3374 IGMP_JOIN_RANGE_1,
3375 data["iif"],
3376 data["oil"],
3377 )
3378 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3379
3380 for data in input_dict_sg_i2:
3381 result = verify_mroutes(
3382 tgen,
3383 data["dut"],
3384 data["src_address"],
3385 IGMP_JOIN_RANGE_1,
3386 data["iif"],
3387 data["oil"],
3388 )
3389 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3390
3391 for data in input_dict_sg_i1:
3392 result = verify_mroutes(
3393 tgen,
3394 data["dut"],
3395 data["src_address"],
3396 IGMP_JOIN_RANGE_1,
3397 data["iif"],
3398 data["oil"],
3399 )
3400 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3401
3402 step("Verify mroute after Noshut the link from FHR to RP from RP node")
3403
3404 for data in input_dict_starg:
3405 result = verify_upstream_iif(
3406 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3407 )
3408 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3409
3410 for data in input_dict_sg_i1:
3411 result = verify_upstream_iif(
3412 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3413 )
3414 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3415
3416 for data in input_dict_sg_i2:
3417 result = verify_upstream_iif(
3418 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3419 )
3420 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3421
3422 step("Verify mcast traffic received after noshut FHR to RP from RP node")
3423 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
3424 input_traffic = {"f1": {"traffic_sent": [intf_f1_i8]}}
3425 result = verify_multicast_traffic(tgen, input_traffic)
3426 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3427
3428 step("Shut the link from FHR to RP from FHR node")
3429
3430 intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
3431 shutdown_bringup_interface(tgen, "l1", intf_l1_r2, False)
3432
3433 step("Verify PIM Nbrs after Shut the link from FHR to RP from FHR node")
3434
3435 step("Verify RP info after Shut the link from FHR to RP from FHR node")
3436 dut = "l1"
3437 rp_address = "1.0.5.17"
3438 SOURCE = "Static"
3439 result = verify_pim_rp_info(
3440 tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE
3441 )
3442 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3443
3444 step("Verify mroute after Shut the link from FHR to RP from FHR node")
3445
3446 for data in input_dict_starg:
3447 result = verify_mroutes(
3448 tgen,
3449 data["dut"],
3450 data["src_address"],
3451 IGMP_JOIN_RANGE_1,
3452 data["iif"],
3453 data["oil"],
3454 )
3455 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3456
3457 for data in input_dict_sg_i1:
3458 result = verify_mroutes(
3459 tgen,
3460 data["dut"],
3461 data["src_address"],
3462 IGMP_JOIN_RANGE_1,
3463 data["iif"],
3464 data["oil"],
3465 )
3466 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3467
3468 step("Verify upstream after Shut the link from FHR to RP from FHR node")
3469 for data in input_dict_starg:
3470 result = verify_upstream_iif(
3471 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3472 )
3473 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3474
3475 for data in input_dict_sg_i1:
3476 result = verify_upstream_iif(
3477 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3478 )
3479 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3480
3481 for data in input_dict_sg_i2_l1:
3482 result = verify_upstream_iif(
3483 tgen,
3484 data["dut"],
3485 data["iif"],
3486 data["src_address"],
3487 IGMP_JOIN_RANGE_1,
3488 expected=False,
3489 )
3490 assert result is not True, (
3491 "Testcase {} : Failed \n "
3492 "Expected: [{}]: Upstream IIF interface {} should not be present"
3493 " after shutting link from FHR to RP \n"
3494 "Found: {}".format(tc_name, data["dut"], data["iif"], result)
3495 )
3496
3497 step(" No shut the link from FHR to RP from FHR node")
3498
3499 intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
3500 shutdown_bringup_interface(tgen, "l1", intf_l1_r2, True)
3501
3502 step("Verify RP info after No Shut the link from FHR to RP from FHR node")
3503 dut = "l1"
3504 rp_address = "1.0.5.17"
3505 SOURCE = "Static"
3506 result = verify_pim_rp_info(
3507 tgen, topo, dut, GROUP_RANGE_1, "Unknown", rp_address, SOURCE, expected=False
3508 )
3509 assert result is not True, (
3510 "Testcase {} : Failed \n "
3511 "Expected: [{}]: RP IIF should be updated as Unknown \n"
3512 "Found: {}".format(tc_name, dut, result)
3513 )
3514
3515 step("Verify mroute after No Shut the link from FHR to RP from FHR node")
3516
3517 for data in input_dict_starg:
3518 result = verify_mroutes(
3519 tgen,
3520 data["dut"],
3521 data["src_address"],
3522 IGMP_JOIN_RANGE_1,
3523 data["iif"],
3524 data["oil"],
3525 )
3526 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3527
3528 for data in input_dict_sg_i2:
3529 result = verify_mroutes(
3530 tgen,
3531 data["dut"],
3532 data["src_address"],
3533 IGMP_JOIN_RANGE_1,
3534 data["iif"],
3535 data["oil"],
3536 )
3537 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3538
3539 for data in input_dict_sg_i1:
3540 result = verify_mroutes(
3541 tgen,
3542 data["dut"],
3543 data["src_address"],
3544 IGMP_JOIN_RANGE_1,
3545 data["iif"],
3546 data["oil"],
3547 )
3548 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3549
3550 step("Verify upstream after No Shut the link from FHR to RP from FHR node")
3551
3552 for data in input_dict_starg:
3553 result = verify_upstream_iif(
3554 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3555 )
3556 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3557
3558 for data in input_dict_sg_i1:
3559 result = verify_upstream_iif(
3560 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3561 )
3562 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3563
3564 for data in input_dict_sg_i2:
3565 result = verify_upstream_iif(
3566 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3567 )
3568 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3569
3570 step("Verify mcast traffic received after noshut FHR to RP from FHR node")
3571 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
3572 input_traffic = {"f1": {"traffic_sent": [intf_f1_i8]}}
3573 result = verify_multicast_traffic(tgen, input_traffic)
3574 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3575
3576 write_test_footer(tc_name)
3577
3578
3579 def test_mroute_flags_p1(request):
3580 """
3581 TC_47 Verify mroute flag in LHR and FHR node
3582 """
3583
3584 tgen = get_topogen()
3585 tc_name = request.node.name
3586 write_test_header(tc_name)
3587
3588 # Don"t run this test if we have any failure.
3589 if tgen.routers_have_failure():
3590 pytest.skip(tgen.errors)
3591
3592 # Creating configuration from JSON
3593 app_helper.stop_all_hosts()
3594 clear_mroute(tgen)
3595 reset_config_on_routers(tgen)
3596 clear_pim_interface_traffic(tgen, topo)
3597 check_router_status(tgen)
3598
3599 step(
3600 "Remove cisco connected link to simulate topo "
3601 "LHR(FRR1(f1))----RP(cisco(f1)---FHR(FRR3(l1))"
3602 )
3603
3604 intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["interface"]
3605 intf_f1_c2 = topo["routers"]["f1"]["links"]["c2"]["interface"]
3606 shutdown_bringup_interface(tgen, "l1", intf_l1_c1, False)
3607 shutdown_bringup_interface(tgen, "f1", intf_f1_c2, False)
3608
3609 step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3")
3610 step(
3611 "Enable IGMP of FRR1 interface and send IGMP joins "
3612 " from FRR1 node for group range (225.1.1.1-5)"
3613 )
3614
3615 intf_f1_i8 = topo["routers"]["f1"]["links"]["i8"]["interface"]
3616 input_dict = {
3617 "f1": {
3618 "igmp": {
3619 "interfaces": {
3620 intf_f1_i8: {
3621 "igmp": {"version": "2", "query": {"query-interval": 15}}
3622 }
3623 }
3624 }
3625 }
3626 }
3627 result = create_igmp_config(tgen, topo, input_dict)
3628 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
3629
3630 input_join = {"i8": topo["routers"]["i8"]["links"]["f1"]["interface"]}
3631
3632 for recvr, recvr_intf in input_join.items():
3633 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
3634 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
3635
3636 step("Configure static RP for (225.1.1.1-5) as R2")
3637
3638 input_dict = {
3639 "r2": {
3640 "pim": {
3641 "rp": [
3642 {
3643 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
3644 "/"
3645 )[0],
3646 "group_addr_range": GROUP_RANGE,
3647 }
3648 ]
3649 }
3650 }
3651 }
3652
3653 result = create_pim_config(tgen, topo, input_dict)
3654 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3655
3656 step(
3657 "Send traffic from FHR to all the groups ( 225.1.1.1 to 225.1.1.5) and send"
3658 " multicast traffic"
3659 )
3660
3661 input_src = {
3662 "i6": topo["routers"]["i6"]["links"]["l1"]["interface"],
3663 "i2": topo["routers"]["i2"]["links"]["f1"]["interface"],
3664 }
3665
3666 for src, src_intf in input_src.items():
3667 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
3668 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3669
3670 source_i2 = topo["routers"]["i6"]["links"]["l1"]["ipv4"].split("/")[0]
3671 source_i1 = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
3672
3673 input_dict_all = [
3674 {
3675 "dut": "l1",
3676 "src_address": source_i2,
3677 "iif": topo["routers"]["l1"]["links"]["i6"]["interface"],
3678 "oil": topo["routers"]["l1"]["links"]["r2"]["interface"],
3679 },
3680 {
3681 "dut": "f1",
3682 "src_address": "*",
3683 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
3684 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
3685 },
3686 {
3687 "dut": "f1",
3688 "src_address": source_i1,
3689 "iif": topo["routers"]["f1"]["links"]["i2"]["interface"],
3690 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
3691 },
3692 {
3693 "dut": "f1",
3694 "src_address": source_i2,
3695 "iif": topo["routers"]["f1"]["links"]["r2"]["interface"],
3696 "oil": topo["routers"]["f1"]["links"]["i8"]["interface"],
3697 },
3698 ]
3699
3700 step("Verify mroutes and iff upstream")
3701
3702 for data in input_dict_all:
3703 result = verify_mroutes(
3704 tgen,
3705 data["dut"],
3706 data["src_address"],
3707 IGMP_JOIN_RANGE_1,
3708 data["iif"],
3709 data["oil"],
3710 )
3711 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3712
3713 result = verify_upstream_iif(
3714 tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
3715 )
3716 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3717
3718 dut = "f1"
3719 step("verify flag for (*,G) on f1")
3720 src_address = "*"
3721 flag = "SC"
3722 result = verify_multicast_flag_state(
3723 tgen, dut, src_address, IGMP_JOIN_RANGE_1, flag
3724 )
3725 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3726
3727 step("verify flag for (S,G) on f1 for Remote spurce ")
3728 src_address = source_i2
3729 flag = "ST"
3730 result = verify_multicast_flag_state(
3731 tgen, dut, src_address, IGMP_JOIN_RANGE_1, flag
3732 )
3733 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3734
3735 write_test_footer(tc_name)
3736
3737
3738 def test_verify_multicast_traffic_when_LHR_connected_to_RP_p1(request):
3739 """
3740 TC_11: Verify multicast traffic flowing fine, when LHR connected to RP
3741 Topology used:
3742 FHR(FRR3(l1))---LHR(FRR1(r2)----RP(FRR2(f1))
3743 """
3744
3745 tgen = get_topogen()
3746 tc_name = request.node.name
3747 write_test_header(tc_name)
3748
3749 # Don"t run this test if we have any failure.
3750 if tgen.routers_have_failure():
3751 pytest.skip(tgen.errors)
3752
3753 # Creating configuration from JSON
3754 app_helper.stop_all_hosts()
3755 clear_mroute(tgen)
3756 reset_config_on_routers(tgen)
3757 clear_pim_interface_traffic(tgen, topo)
3758 check_router_status(tgen)
3759
3760 step(
3761 "Remove FRR3 to cisco connected link to simulate topo "
3762 "FHR(FRR3(l1))---LHR(FRR1(r2)----RP(FRR2(f1))"
3763 )
3764
3765 intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["interface"]
3766 intf_f1_c2 = topo["routers"]["f1"]["links"]["c2"]["interface"]
3767 shutdown_bringup_interface(tgen, "l1", intf_l1_c1, False)
3768 shutdown_bringup_interface(tgen, "f1", intf_f1_c2, False)
3769
3770 step("Disable IGMP config from l1")
3771 input_dict_2 = {
3772 "l1": {
3773 "igmp": {
3774 "interfaces": {
3775 "l1-i1-eth1": {
3776 "igmp": {
3777 "version": "2",
3778 "delete": True,
3779 }
3780 }
3781 }
3782 }
3783 }
3784 }
3785 result = create_igmp_config(tgen, topo, input_dict_2)
3786 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
3787
3788 step("Enable the PIM on all the interfaces of FRR1, R2 and FRR3" " routers")
3789 step(
3790 "Enable IGMP on FRR1(r2) interface and send IGMP join (226.1.1.1-5)"
3791 " and (232.1.1.1-5)"
3792 )
3793
3794 intf_r2_i3 = topo["routers"]["r2"]["links"]["i3"]["interface"]
3795 input_dict = {
3796 "r2": {
3797 "igmp": {
3798 "interfaces": {
3799 intf_r2_i3: {
3800 "igmp": {"version": "2", "query": {"query-interval": 15}}
3801 }
3802 }
3803 }
3804 }
3805 }
3806 result = create_igmp_config(tgen, topo, input_dict)
3807 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
3808
3809 _GROUP_RANGE = GROUP_RANGE_2 + GROUP_RANGE_3
3810 _IGMP_JOIN_RANGE = IGMP_JOIN_RANGE_2 + IGMP_JOIN_RANGE_3
3811
3812 input_join = {"i3": topo["routers"]["i3"]["links"]["r2"]["interface"]}
3813
3814 for recvr, recvr_intf in input_join.items():
3815 result = app_helper.run_join(recvr, _IGMP_JOIN_RANGE, join_intf=recvr_intf)
3816 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
3817
3818 step("Configure RP for (226.1.1.1-5) and (232.1.1.1-5) in (f1)")
3819
3820 input_dict = {
3821 "f1": {
3822 "pim": {
3823 "rp": [
3824 {
3825 "rp_addr": topo["routers"]["f1"]["links"]["lo"]["ipv4"].split(
3826 "/"
3827 )[0],
3828 "group_addr_range": _GROUP_RANGE,
3829 }
3830 ]
3831 }
3832 }
3833 }
3834
3835 result = create_pim_config(tgen, topo, input_dict)
3836 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3837
3838 step("Send multicast traffic from FRR3 to 225.1.1.1-225.1.1.10" " receiver")
3839
3840 input_src = {"i1": topo["routers"]["i1"]["links"]["l1"]["interface"]}
3841
3842 for src, src_intf in input_src.items():
3843 result = app_helper.run_traffic(src, _IGMP_JOIN_RANGE, bind_intf=src_intf)
3844 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3845
3846 step(
3847 "'show ip mroute' showing correct RPF and OIF interface for (*,G)"
3848 " and (S,G) entries on all the nodes"
3849 )
3850
3851 source_i1 = topo["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0]
3852 input_dict_all = [
3853 {
3854 "dut": "l1",
3855 "src_address": source_i1,
3856 "iif": topo["routers"]["l1"]["links"]["i1"]["interface"],
3857 "oil": topo["routers"]["l1"]["links"]["r2"]["interface"],
3858 },
3859 {
3860 "dut": "r2",
3861 "src_address": "*",
3862 "iif": topo["routers"]["r2"]["links"]["f1"]["interface"],
3863 "oil": topo["routers"]["r2"]["links"]["i3"]["interface"],
3864 },
3865 {
3866 "dut": "r2",
3867 "src_address": source_i1,
3868 "iif": topo["routers"]["r2"]["links"]["l1"]["interface"],
3869 "oil": topo["routers"]["r2"]["links"]["i3"]["interface"],
3870 },
3871 ]
3872
3873 for data in input_dict_all:
3874 result = verify_mroutes(
3875 tgen,
3876 data["dut"],
3877 data["src_address"],
3878 _IGMP_JOIN_RANGE,
3879 data["iif"],
3880 data["oil"],
3881 )
3882 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3883
3884 for data in input_dict_all:
3885 result = verify_upstream_iif(
3886 tgen, data["dut"], data["iif"], data["src_address"], _IGMP_JOIN_RANGE
3887 )
3888 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3889
3890 step(
3891 "Multicast traffic is flowing for all the groups verify"
3892 "using 'show ip multicast'"
3893 )
3894
3895 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
3896 intf_r2_l1 = topo["routers"]["r2"]["links"]["l1"]["interface"]
3897 intf_r2_f1 = topo["routers"]["r2"]["links"]["f1"]["interface"]
3898 intf_r2_i3 = topo["routers"]["r2"]["links"]["i3"]["interface"]
3899 intf_f1_r2 = topo["routers"]["f1"]["links"]["r2"]["interface"]
3900 input_traffic = {
3901 "l1": {"traffic_received": [intf_l1_i1]},
3902 "r2": {"traffic_received": [intf_r2_l1], "traffic_sent": [intf_r2_i3]},
3903 }
3904 result = verify_multicast_traffic(tgen, input_traffic)
3905 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3906
3907 step("Shut and No shut the receiver port")
3908
3909 intf_r2_i3 = topo["routers"]["r2"]["links"]["i3"]["interface"]
3910 shutdown_bringup_interface(tgen, "r2", intf_r2_i3, False)
3911
3912 step(
3913 "Verification: After Shut of receiver port, Verify (*,G) and "
3914 "(S,G) got removed from LHR node (FRR1) using 'show ip mroute'"
3915 )
3916
3917 input_dict_r2 = [
3918 {
3919 "dut": "r2",
3920 "src_address": "*",
3921 "iif": topo["routers"]["r2"]["links"]["f1"]["interface"],
3922 "oil": topo["routers"]["r2"]["links"]["i3"]["interface"],
3923 },
3924 {
3925 "dut": "r2",
3926 "src_address": source_i1,
3927 "iif": topo["routers"]["r2"]["links"]["l1"]["interface"],
3928 "oil": topo["routers"]["r2"]["links"]["i3"]["interface"],
3929 },
3930 ]
3931
3932 for data in input_dict_r2:
3933 result = verify_mroutes(
3934 tgen,
3935 data["dut"],
3936 data["src_address"],
3937 _IGMP_JOIN_RANGE,
3938 data["iif"],
3939 data["oil"],
3940 expected=False,
3941 )
3942 assert result is not True, (
3943 "Testcase {} : Failed \n "
3944 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
3945 "Found: {}".format(tc_name, data["dut"], result)
3946 )
3947
3948 shutdown_bringup_interface(tgen, "r2", intf_r2_i3, True)
3949
3950 step(
3951 "Verification: After No shut of receiver port , Verify (*,G)"
3952 " and (S,G) got populated on LHR node (FRR1) using "
3953 "'show ip mroute' 'show ip pim upstream'"
3954 )
3955
3956 for data in input_dict_r2:
3957 result = verify_mroutes(
3958 tgen,
3959 data["dut"],
3960 data["src_address"],
3961 _IGMP_JOIN_RANGE,
3962 data["iif"],
3963 data["oil"],
3964 )
3965 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3966
3967 for data in input_dict_r2:
3968 result = verify_upstream_iif(
3969 tgen, data["dut"], data["iif"], data["src_address"], _IGMP_JOIN_RANGE
3970 )
3971 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3972
3973 step(
3974 "Multicast traffic is resumed for all the groups verify "
3975 "using 'show ip multicast'"
3976 )
3977
3978 result = verify_multicast_traffic(tgen, input_traffic)
3979 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
3980
3981 step("Shut and No shut the source port")
3982
3983 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
3984 shutdown_bringup_interface(tgen, "l1", intf_l1_i1, False)
3985
3986 step(
3987 "Verification: After Shut of source port, Verify (*,G) and "
3988 "(S,G) got removed from LHR node (FRR1) using 'show ip mroute'"
3989 )
3990
3991 input_dict_l1 = [
3992 {
3993 "dut": "l1",
3994 "src_address": source_i1,
3995 "iif": topo["routers"]["l1"]["links"]["i1"]["interface"],
3996 "oil": topo["routers"]["l1"]["links"]["r2"]["interface"],
3997 }
3998 ]
3999
4000 for data in input_dict_l1:
4001 result = verify_mroutes(
4002 tgen,
4003 data["dut"],
4004 data["src_address"],
4005 _IGMP_JOIN_RANGE,
4006 data["iif"],
4007 data["oil"],
4008 expected=False,
4009 )
4010 assert result is not True, (
4011 "Testcase {} : Failed \n "
4012 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
4013 "Found: {}".format(tc_name, data["dut"], result)
4014 )
4015
4016 shutdown_bringup_interface(tgen, "l1", intf_l1_i1, True)
4017
4018 step(
4019 "Verification: After No shut of source port , Verify (*,G)"
4020 " and (S,G) got populated on LHR node (FRR1) using "
4021 "'show ip mroute' 'show ip pim upstream'"
4022 )
4023
4024 for data in input_dict_l1:
4025 result = verify_mroutes(
4026 tgen,
4027 data["dut"],
4028 data["src_address"],
4029 _IGMP_JOIN_RANGE,
4030 data["iif"],
4031 data["oil"],
4032 )
4033 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4034
4035 for data in input_dict_l1:
4036 result = verify_upstream_iif(
4037 tgen, data["dut"], data["iif"], data["src_address"], _IGMP_JOIN_RANGE
4038 )
4039 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4040
4041 step(
4042 "Multicast traffic is resumed for all the groups verify "
4043 "using 'show ip multicast'"
4044 )
4045
4046 result = verify_multicast_traffic(tgen, input_traffic)
4047 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4048
4049 step("Shut and No shut of LHR to cisco port from LHR side")
4050
4051 intf_r2_f1 = topo["routers"]["r2"]["links"]["f1"]["interface"]
4052 shutdown_bringup_interface(tgen, "r2", intf_r2_f1, False)
4053
4054 step(
4055 "Verification: After Shut of source port, Verify (S,G) got "
4056 "removed from LHR and FHR using 'show ip mroute'"
4057 )
4058
4059 input_dict_r2_f1 = [
4060 {
4061 "dut": "r2",
4062 "src_address": "*",
4063 "iif": topo["routers"]["r2"]["links"]["f1"]["interface"],
4064 "oil": topo["routers"]["r2"]["links"]["i3"]["interface"],
4065 },
4066 {
4067 "dut": "f1",
4068 "src_address": "*",
4069 "iif": "lo",
4070 "oil": topo["routers"]["f1"]["links"]["r2"]["interface"],
4071 },
4072 ]
4073
4074 for data in input_dict_r2_f1:
4075 result = verify_mroutes(
4076 tgen,
4077 data["dut"],
4078 data["src_address"],
4079 _IGMP_JOIN_RANGE,
4080 data["iif"],
4081 data["oil"],
4082 expected=False,
4083 )
4084 assert result is not True, (
4085 "Testcase {} : Failed \n "
4086 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
4087 "Found: {}".format(tc_name, data["dut"], result)
4088 )
4089
4090 shutdown_bringup_interface(tgen, "r2", intf_r2_f1, True)
4091
4092 step(
4093 "Verification: After No shut of source port , Verify (*,G)"
4094 " and (S,G) got populated on LHR node (FRR1) using "
4095 "'show ip mroute' 'show ip pim upstream'"
4096 )
4097
4098 for data in input_dict_all:
4099 result = verify_mroutes(
4100 tgen,
4101 data["dut"],
4102 data["src_address"],
4103 _IGMP_JOIN_RANGE,
4104 data["iif"],
4105 data["oil"],
4106 )
4107 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4108
4109 for data in input_dict_all:
4110 result = verify_upstream_iif(
4111 tgen, data["dut"], data["iif"], data["src_address"], _IGMP_JOIN_RANGE
4112 )
4113 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4114
4115 step(
4116 "Multicast traffic is resumed for all the groups verify "
4117 "using 'show ip multicast'"
4118 )
4119
4120 input_traffic_r2 = {
4121 "r2": {"traffic_received": [intf_r2_l1], "traffic_sent": [intf_r2_i3]}
4122 }
4123 result = verify_multicast_traffic(tgen, input_traffic_r2)
4124 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4125
4126 step("Shut and no shut of FHR to LHR port from FHR side")
4127
4128 intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
4129 shutdown_bringup_interface(tgen, "l1", intf_l1_r2, False)
4130
4131 step(
4132 "Verification: After Shut of LHR to FHR port, Verify (S,G)"
4133 "got removed from LHR 'show ip mroute'"
4134 )
4135
4136 dut = "r2"
4137 src_address = "*"
4138 iif = topo["routers"]["r2"]["links"]["f1"]["interface"]
4139 oil = topo["routers"]["r2"]["links"]["i3"]["interface"]
4140
4141 result = verify_mroutes(tgen, dut, src_address, _IGMP_JOIN_RANGE, iif, oil)
4142 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4143
4144 src_address = source_i1
4145 iif = topo["routers"]["r2"]["links"]["l1"]["interface"]
4146 oil = topo["routers"]["r2"]["links"]["i3"]["interface"]
4147
4148 result = verify_mroutes(
4149 tgen, dut, src_address, _IGMP_JOIN_RANGE, iif, oil, expected=False
4150 )
4151 assert result is not True, (
4152 "Testcase {} : Failed \n "
4153 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
4154 "Found: {}".format(tc_name, dut, result)
4155 )
4156
4157 shutdown_bringup_interface(tgen, "l1", intf_l1_r2, True)
4158
4159 step(
4160 "Verification: After No shut of source port , Verify (*,G)"
4161 " and (S,G) got populated on LHR node (FRR1) using "
4162 "'show ip mroute' 'show ip pim upstream'"
4163 )
4164
4165 for data in input_dict_all:
4166 result = verify_mroutes(
4167 tgen,
4168 data["dut"],
4169 data["src_address"],
4170 _IGMP_JOIN_RANGE,
4171 data["iif"],
4172 data["oil"],
4173 )
4174 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4175
4176 for data in input_dict_all:
4177 result = verify_upstream_iif(
4178 tgen, data["dut"], data["iif"], data["src_address"], _IGMP_JOIN_RANGE
4179 )
4180 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4181
4182 step(
4183 "Multicast traffic is resumed for all the groups verify "
4184 "using 'show ip multicast'"
4185 )
4186
4187 result = verify_multicast_traffic(tgen, input_traffic_r2)
4188 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4189
4190 write_test_footer(tc_name)
4191
4192
4193 def test_verify_multicast_traffic_when_FHR_connected_to_RP_p1(request):
4194 """
4195 TC_12: Verify multicast traffic is flowing fine when FHR is connected to RP
4196 Topology used:
4197 LHR(FRR1)---FHR(FRR3)----RP(FRR2)
4198 """
4199
4200 tgen = get_topogen()
4201 tc_name = request.node.name
4202 write_test_header(tc_name)
4203
4204 # Don"t run this test if we have any failure.
4205 if tgen.routers_have_failure():
4206 pytest.skip(tgen.errors)
4207
4208 # Creating configuration from JSON
4209 app_helper.stop_all_hosts()
4210 clear_mroute(tgen)
4211 reset_config_on_routers(tgen)
4212 clear_pim_interface_traffic(tgen, topo)
4213 check_router_status(tgen)
4214
4215 step(
4216 "Remove FRR3 to FRR2 connected link to simulate topo "
4217 "FHR(FRR3)---LHR(FRR1)----RP(FFR2)"
4218 )
4219
4220 intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["interface"]
4221 intf_f1_c2 = topo["routers"]["f1"]["links"]["c2"]["interface"]
4222 shutdown_bringup_interface(tgen, "l1", intf_l1_c1, False)
4223 shutdown_bringup_interface(tgen, "f1", intf_f1_c2, False)
4224
4225 step("Enable the PIM on all the interfaces of FRR1, R2 and FRR3" " routers")
4226 step("Enable IGMP on FRR1(l1) interface and send IGMP join " " and (225.1.1.1-5)")
4227
4228 _GROUP_RANGE = GROUP_RANGE_2 + GROUP_RANGE_3
4229 _IGMP_JOIN_RANGE = IGMP_JOIN_RANGE_2 + IGMP_JOIN_RANGE_3
4230
4231 input_join = {"i1": topo["routers"]["i1"]["links"]["l1"]["interface"]}
4232
4233 for recvr, recvr_intf in input_join.items():
4234 result = app_helper.run_join(recvr, _IGMP_JOIN_RANGE, join_intf=recvr_intf)
4235 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
4236
4237 step("Configure RP for (225.1.1.1-5) in (f1)")
4238
4239 input_dict = {
4240 "f1": {
4241 "pim": {
4242 "rp": [
4243 {
4244 "rp_addr": topo["routers"]["f1"]["links"]["lo"]["ipv4"].split(
4245 "/"
4246 )[0],
4247 "group_addr_range": _GROUP_RANGE,
4248 }
4249 ]
4250 }
4251 }
4252 }
4253
4254 result = create_pim_config(tgen, topo, input_dict)
4255 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4256
4257 step("Send multicast traffic from FRR3(r2) to 225.1.1.1-225.1.1.10" " receiver")
4258
4259 input_src = {"i3": topo["routers"]["i3"]["links"]["r2"]["interface"]}
4260
4261 for src, src_intf in input_src.items():
4262 result = app_helper.run_traffic(src, _IGMP_JOIN_RANGE, bind_intf=src_intf)
4263 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4264
4265 step(
4266 "'show ip mroute' showing correct RPF and OIF interface for (*,G)"
4267 " and (S,G) entries on all the nodes"
4268 )
4269
4270 source_i3 = topo["routers"]["i3"]["links"]["r2"]["ipv4"].split("/")[0]
4271 input_dict_all = [
4272 {
4273 "dut": "l1",
4274 "src_address": "*",
4275 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
4276 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
4277 },
4278 {
4279 "dut": "l1",
4280 "src_address": source_i3,
4281 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
4282 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
4283 },
4284 {
4285 "dut": "r2",
4286 "src_address": "*",
4287 "iif": topo["routers"]["r2"]["links"]["f1"]["interface"],
4288 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
4289 },
4290 {
4291 "dut": "r2",
4292 "src_address": source_i3,
4293 "iif": topo["routers"]["r2"]["links"]["i3"]["interface"],
4294 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
4295 },
4296 ]
4297
4298 for data in input_dict_all:
4299 result = verify_mroutes(
4300 tgen,
4301 data["dut"],
4302 data["src_address"],
4303 _IGMP_JOIN_RANGE,
4304 data["iif"],
4305 data["oil"],
4306 )
4307 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4308
4309 for data in input_dict_all:
4310 result = verify_upstream_iif(
4311 tgen, data["dut"], data["iif"], data["src_address"], _IGMP_JOIN_RANGE
4312 )
4313 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4314
4315 intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
4316 intf_f1_r2 = topo["routers"]["f1"]["links"]["r2"]["interface"]
4317 intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
4318 input_traffic = {
4319 "l1": {"traffic_received": [intf_l1_r2], "traffic_sent": [intf_l1_i1]}
4320 }
4321 result = verify_multicast_traffic(tgen, input_traffic)
4322 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4323
4324 step("Shut the receiver(l1) port in 1 min interval")
4325
4326 shutdown_bringup_interface(tgen, "l1", intf_l1_i1, False)
4327
4328 step(
4329 "Verification: After Shut of receiver port, Verify (*,G) and "
4330 "(S,G) got removed from LHR node (FRR1) using 'show ip mroute'"
4331 )
4332
4333 input_dict_l1 = [
4334 {
4335 "dut": "l1",
4336 "src_address": source_i3,
4337 "iif": topo["routers"]["l1"]["links"]["r2"]["interface"],
4338 "oil": topo["routers"]["l1"]["links"]["i1"]["interface"],
4339 }
4340 ]
4341
4342 for data in input_dict_l1:
4343 result = verify_mroutes(
4344 tgen,
4345 data["dut"],
4346 data["src_address"],
4347 _IGMP_JOIN_RANGE,
4348 data["iif"],
4349 data["oil"],
4350 expected=False,
4351 )
4352 assert result is not True, (
4353 "Testcase {} : Failed \n "
4354 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
4355 "Found: {}".format(tc_name, data["dut"], result)
4356 )
4357
4358 step("No shut the receiver(l1) port in 1 min interval")
4359
4360 shutdown_bringup_interface(tgen, "l1", intf_l1_i1, True)
4361
4362 step(
4363 "Verification: After No shut of receiver port , Verify (*,G)"
4364 " and (S,G) got populated on LHR node (FRR1) using "
4365 "'show ip mroute' 'show ip pim upstream'"
4366 )
4367
4368 for data in input_dict_l1:
4369 result = verify_mroutes(
4370 tgen,
4371 data["dut"],
4372 data["src_address"],
4373 _IGMP_JOIN_RANGE,
4374 data["iif"],
4375 data["oil"],
4376 )
4377 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4378
4379 for data in input_dict_l1:
4380 result = verify_upstream_iif(
4381 tgen, data["dut"], data["iif"], data["src_address"], _IGMP_JOIN_RANGE
4382 )
4383 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4384
4385 result = verify_multicast_traffic(tgen, input_traffic)
4386 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4387
4388 step("Shut the source(r2) port in 1 min interval")
4389
4390 intf_r2_i3 = topo["routers"]["r2"]["links"]["i3"]["interface"]
4391 shutdown_bringup_interface(tgen, "r2", intf_r2_i3, False)
4392
4393 step(
4394 "Verification: After Shut of source port, Verify (S,G) got "
4395 "removed from FHR using 'show ip mroute'"
4396 )
4397
4398 input_dict_r2 = [
4399 {
4400 "dut": "r2",
4401 "src_address": source_i3,
4402 "iif": topo["routers"]["r2"]["links"]["i3"]["interface"],
4403 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
4404 }
4405 ]
4406
4407 for data in input_dict_r2:
4408 result = verify_mroutes(
4409 tgen,
4410 data["dut"],
4411 data["src_address"],
4412 _IGMP_JOIN_RANGE,
4413 data["iif"],
4414 data["oil"],
4415 expected=False,
4416 )
4417 assert result is not True, (
4418 "Testcase {} : Failed \n "
4419 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
4420 "Found: {}".format(tc_name, data["dut"], result)
4421 )
4422
4423 step("No shut the source(r2) port in 1 min interval")
4424
4425 shutdown_bringup_interface(tgen, "r2", intf_r2_i3, True)
4426
4427 step(
4428 "Verification: After No shut of source port , Verify (*,G)"
4429 " and (S,G) got populated on LHR and FHR using "
4430 "'show ip mroute' 'show ip pim upstream'"
4431 )
4432
4433 for data in input_dict_r2:
4434 result = verify_mroutes(
4435 tgen,
4436 data["dut"],
4437 data["src_address"],
4438 _IGMP_JOIN_RANGE,
4439 data["iif"],
4440 data["oil"],
4441 )
4442 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4443
4444 for data in input_dict_r2:
4445 result = verify_upstream_iif(
4446 tgen, data["dut"], data["iif"], data["src_address"], _IGMP_JOIN_RANGE
4447 )
4448 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4449
4450 result = verify_multicast_traffic(tgen, input_traffic)
4451 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4452
4453 step("Shut FHR to RP port from FHR side")
4454
4455 intf_r2_f1 = topo["routers"]["r2"]["links"]["f1"]["interface"]
4456 shutdown_bringup_interface(tgen, "r2", intf_r2_f1, False)
4457
4458 step(
4459 "Verification: After Shut of FHR to cisco port, Verify (*,G) "
4460 "got removed from FHR and cisco node using 'show ip mroute'"
4461 )
4462
4463 input_dict_all_star = [
4464 {
4465 "dut": "r2",
4466 "src_address": "*",
4467 "iif": topo["routers"]["r2"]["links"]["f1"]["interface"],
4468 "oil": topo["routers"]["r2"]["links"]["l1"]["interface"],
4469 },
4470 {
4471 "dut": "f1",
4472 "src_address": "*",
4473 "iif": "lo",
4474 "oil": topo["routers"]["f1"]["links"]["r2"]["interface"],
4475 },
4476 ]
4477
4478 for data in input_dict_all_star:
4479 result = verify_mroutes(
4480 tgen,
4481 data["dut"],
4482 data["src_address"],
4483 _IGMP_JOIN_RANGE,
4484 data["iif"],
4485 data["oil"],
4486 expected=False,
4487 )
4488 assert result is not True, (
4489 "Testcase {} : Failed \n "
4490 "Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
4491 "Found: {}".format(tc_name, data["dut"], result)
4492 )
4493
4494 write_test_footer(tc_name)
4495
4496
4497 def test_PIM_passive_p1(request):
4498 """
4499 TC Verify PIM passive functionality"
4500 """
4501
4502 tgen = get_topogen()
4503 tc_name = request.node.name
4504 write_test_header(tc_name)
4505 app_helper.stop_all_hosts()
4506 # Creating configuration from JSON
4507 clear_mroute(tgen)
4508 if tgen.routers_have_failure():
4509 check_router_status(tgen)
4510 reset_config_on_routers(tgen)
4511 clear_pim_interface_traffic(tgen, topo)
4512
4513 step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3")
4514 step(
4515 "Enable IGMP of FRR1 interface and send IGMP joins "
4516 " from FRR1 node for group range (225.1.1.1-5)"
4517 )
4518
4519 intf_c1_i4 = topo["routers"]["c1"]["links"]["i4"]["interface"]
4520
4521 step(
4522 "configure PIM passive on receiver interface to verify no impact on IGMP join"
4523 "and multicast traffic on pim passive interface"
4524 )
4525
4526 raw_config = {
4527 "c1": {"raw_config": ["interface {}".format(intf_c1_i4), "ip pim passive"]}
4528 }
4529 result = apply_raw_config(tgen, raw_config)
4530 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4531
4532 step("configure IGMPv2 and send IGMP joinon on PIM passive interface")
4533 input_dict = {
4534 "c1": {"igmp": {"interfaces": {intf_c1_i4: {"igmp": {"version": "2"}}}}}
4535 }
4536 result = create_igmp_config(tgen, topo, input_dict)
4537 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
4538
4539 input_join = {"i4": topo["routers"]["i4"]["links"]["c1"]["interface"]}
4540 for recvr, recvr_intf in input_join.items():
4541 result = app_helper.run_join(recvr, IGMP_JOIN_RANGE_1, join_intf=recvr_intf)
4542 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
4543
4544 step("Configure static RP for (225.1.1.1-5) as R2")
4545
4546 input_dict = {
4547 "r2": {
4548 "pim": {
4549 "rp": [
4550 {
4551 "rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
4552 "/"
4553 )[0],
4554 "group_addr_range": GROUP_RANGE_1,
4555 }
4556 ]
4557 }
4558 }
4559 }
4560
4561 result = create_pim_config(tgen, topo, input_dict)
4562 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4563
4564 step("Send Mcast traffic from C2 to all the groups ( 225.1.1.1 to 225.1.1.5)")
4565
4566 input_src = {"i5": topo["routers"]["i5"]["links"]["c2"]["interface"]}
4567 for src, src_intf in input_src.items():
4568 result = app_helper.run_traffic(src, IGMP_JOIN_RANGE_1, bind_intf=src_intf)
4569 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4570
4571 source_i5 = topo["routers"]["i5"]["links"]["c2"]["ipv4"].split("/")[0]
4572
4573 input_dict_starg = [
4574 {
4575 "dut": "c1",
4576 "src_address": "*",
4577 "iif": topo["routers"]["c1"]["links"]["l1"]["interface"],
4578 "oil": topo["routers"]["c1"]["links"]["i4"]["interface"],
4579 }
4580 ]
4581
4582 input_dict_sg = [
4583 {
4584 "dut": "c1",
4585 "src_address": source_i5,
4586 "iif": topo["routers"]["c1"]["links"]["c2"]["interface"],
4587 "oil": topo["routers"]["c1"]["links"]["i4"]["interface"],
4588 }
4589 ]
4590
4591 step("(*,G) and (S,G) created on f1 and node verify using 'show ip mroute'")
4592
4593 for data in input_dict_sg:
4594 result = verify_mroutes(
4595 tgen,
4596 data["dut"],
4597 data["src_address"],
4598 IGMP_JOIN_RANGE_1,
4599 data["iif"],
4600 data["oil"],
4601 )
4602 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4603
4604 for data in input_dict_sg:
4605 result = verify_mroutes(
4606 tgen,
4607 data["dut"],
4608 data["src_address"],
4609 IGMP_JOIN_RANGE_1,
4610 data["iif"],
4611 data["oil"],
4612 )
4613 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4614
4615 for data in input_dict_starg:
4616 result = verify_mroutes(
4617 tgen,
4618 data["dut"],
4619 data["src_address"],
4620 IGMP_JOIN_RANGE_1,
4621 data["iif"],
4622 data["oil"],
4623 )
4624 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4625
4626 intf_c1_c2 = topo["routers"]["c1"]["links"]["c2"]["interface"]
4627 intf_c2_c1 = topo["routers"]["c2"]["links"]["c1"]["interface"]
4628
4629 step(
4630 "configure PIM passive on upstream interface to verify"
4631 "hello tx/rx counts are not incremented"
4632 )
4633
4634 # Changing hello timer to 3sec for checking more number of packets
4635
4636 raw_config = {
4637 "c1": {
4638 "raw_config": [
4639 "interface {}".format(intf_c1_c2),
4640 "ip pim passive",
4641 "ip pim hello 3",
4642 ]
4643 },
4644 "c2": {"raw_config": ["interface {}".format(intf_c2_c1), "ip pim hello 3"]},
4645 }
4646 result = apply_raw_config(tgen, raw_config)
4647 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4648
4649 step("verify PIM hello tx/rx stats on C1")
4650 state_dict = {
4651 "c1": {
4652 intf_c1_c2: ["helloTx", "helloRx"],
4653 }
4654 }
4655
4656 logger.info("waiting for 5 sec config to get apply and hello count update")
4657 sleep(5)
4658
4659 c1_state_before = verify_pim_interface_traffic(tgen, state_dict)
4660 assert isinstance(
4661 c1_state_before, dict
4662 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
4663 tc_name, result
4664 )
4665
4666 logger.info(
4667 "sleeping for 30 sec hello interval timer to verify count are not increamented"
4668 )
4669 sleep(35)
4670
4671 c1_state_after = verify_pim_interface_traffic(tgen, state_dict)
4672 assert isinstance(
4673 c1_state_after, dict
4674 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
4675 tc_name, result
4676 )
4677
4678 step("verify stats not increamented on c1")
4679 result = verify_pim_stats_increament(c1_state_before, c1_state_after)
4680 assert (
4681 result is not True
4682 ), "Testcase{} : Failed Error: {}" "stats incremented".format(tc_name, result)
4683
4684 step("No impact observed on mroutes")
4685 for data in input_dict_sg:
4686 result = verify_mroutes(
4687 tgen,
4688 data["dut"],
4689 data["src_address"],
4690 IGMP_JOIN_RANGE_1,
4691 data["iif"],
4692 data["oil"],
4693 )
4694 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4695
4696 for data in input_dict_sg:
4697 result = verify_mroutes(
4698 tgen,
4699 data["dut"],
4700 data["src_address"],
4701 IGMP_JOIN_RANGE_1,
4702 data["iif"],
4703 data["oil"],
4704 )
4705 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4706
4707 for data in input_dict_starg:
4708 result = verify_mroutes(
4709 tgen,
4710 data["dut"],
4711 data["src_address"],
4712 IGMP_JOIN_RANGE_1,
4713 data["iif"],
4714 data["oil"],
4715 )
4716 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4717
4718 step("remove PIM passive and verify hello tx/rx is increamented")
4719 raw_config = {
4720 "c1": {
4721 "raw_config": [
4722 "interface {}".format(intf_c1_c2),
4723 "no ip pim passive",
4724 "ip pim hello 3",
4725 ]
4726 }
4727 }
4728 result = apply_raw_config(tgen, raw_config)
4729 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
4730
4731 logger.info("waiting for 30 sec for pim hello to receive")
4732 sleep(30)
4733
4734 c1_state_after = verify_pim_interface_traffic(tgen, state_dict)
4735 assert isinstance(
4736 c1_state_after, dict
4737 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
4738 tc_name, result
4739 )
4740
4741 step("verify stats increamented on c1 after removing pim passive")
4742 result = verify_pim_stats_increament(c1_state_before, c1_state_after)
4743 assert result is True, "Testcase{} : Failed Error: {}" "stats incremented".format(
4744 tc_name, result
4745 )
4746
4747 write_test_footer(tc_name)
4748
4749
4750 if __name__ == "__main__":
4751 args = ["-s"] + sys.argv[1:]
4752 sys.exit(pytest.main(args))