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