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