]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/multicast_pim_static_rp_topo1/test_multicast_pim_static_rp.py
Merge pull request #10940 from opensourcerouting/pim-5549-clarify
[mirror_frr.git] / tests / topotests / multicast_pim_static_rp_topo1 / test_multicast_pim_static_rp.py
1 #!/usr/bin/env python
2
3 #
4 # Copyright (c) 2019 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 """
24 Following tests are covered to test Multicast basic functionality:
25
26 Topology:
27
28 _______r2_____
29 | |
30 iperf | | iperf
31 r0-----r1-------------r3-----r5
32 | |
33 |_____________|
34 r4
35
36 Test steps
37 - Create topology (setup module)
38 - Bring up topology
39
40 TC_1 : Verify upstream interfaces(IIF) and join state are updated properly
41 after adding and deleting the static RP
42 TC_2 : Verify IIF and OIL in "show ip pim state" updated properly after
43 adding and deleting the static RP
44 TC_3: (*, G) Mroute entry are cleared when static RP gets deleted
45 TC_4: Verify (*,G) prune is send towards the RP after deleting the static RP
46 TC_5: Verify OIF entry for RP is cleared when RP becomes unreachable
47 TC_6: Verify IIF and OIL in "show ip pim state" updated properly when RP
48 becomes unreachable
49 TC_7 : Verify upstream interfaces(IIF) and join state are updated properly
50 after adding and deleting the static RP
51 TC_8: Verify (*,G) prune is send towards the RP when RP becomes unreachable
52 TC_9 : Verify RP configured after IGMP join received, PIM join towards RP is
53 sent immediately
54 TC_10 : Verify RP becomes reachable after IGMP join received, PIM join
55 towards RP is sent immediately
56 TC_11 : Verify PIM join send towards the higher preferred RP
57 TC_12 : Verify PIM prune send towards the lower preferred RP
58 TC_13 : Verify RPF interface is updated in mroute (kernel) when higher
59 preferred overlapping RP configured
60 TC_14 : Verify IIF and OIL in "show ip pim state" updated properly when higher
61 preferred overlapping RP configured
62 TC_15 : Verify upstream interfaces(IIF) and join state are updated when higher
63 preferred overlapping RP is configured
64 TC_16 : Verify join is send to lower preferred RP, when higher preferred RP
65 gets deleted
66 TC_17 : Verify prune is send to higher preferred RP when higher preferred RP
67 gets deleted
68 TC_18 : Verify RPF interface updated in mroute when higher preferred RP gets
69 deleted
70 TC_19 : Verify IIF and OIL in "show ip pim state" updated when higher
71 preferred overlapping RP is deleted
72 TC_20 : Verfiy PIM upstream IIF updated when higher preferred overlapping RP
73 deleted
74 TC_21_1 : Verify OIF and RFP for (*,G) and (S,G) when static RP configure in
75 LHR router
76 TC_21_2 : Verify OIF and RFP for (*,G) and (S,G) when static RP configure in
77 LHR router
78 TC_22_1 : Verify OIF and RPF for (*,G) and (S,G) when static RP configure in
79 FHR router
80 TC_22_2 : Verify OIF and RPF for (*,G) and (S,G) when static RP configure in
81 FHR router
82 TC_23 : Verify (*,G) and (S,G) populated correctly when RPT and SPT path are
83 different
84 TC_24 : Verify (*,G) and (S,G) populated correctly when SPT and RPT share the
85 same path
86 TC_25 : Verify (*,G) and (S,G) populated correctly after clearing the PIM ,
87 IGMP and mroutes joins
88 TC_26 : Restart the PIMd process and verify PIM joins , and mroutes entries
89 TC_27 : Configure multiple groups (10 grps) with same RP address
90 TC_28 : Configure multiple groups (10 grps) with different RP address
91 TC_29 : Verify IIF and OIL in updated in mroute when upstream interface
92 configure as RP
93 TC_30 : Verify IIF and OIL change to other path after shut the primary path
94 TC_31 : Verify RP info and (*,G) mroute after deleting the RP and shut / no
95 shut the RPF interface.
96 TC_32 : Verify RP info and (*,G) mroute after deleting the RP and shut / no
97 shut the RPF inteface
98 """
99
100 import os
101 import sys
102 import time
103 from time import sleep
104 import datetime
105 import pytest
106
107 # Save the Current Working Directory to find configuration files.
108 CWD = os.path.dirname(os.path.realpath(__file__))
109 sys.path.append(os.path.join(CWD, "../"))
110 sys.path.append(os.path.join(CWD, "../lib/"))
111
112 # Required to instantiate the topology builder class.
113
114 # pylint: disable=C0413
115 # Import topogen and topotest helpers
116
117 from lib.topogen import Topogen, get_topogen
118 from lib.topolog import logger
119 from lib.topojson import build_topo_from_json, build_config_from_json
120
121 from lib.common_config import (
122 start_topology,
123 write_test_header,
124 write_test_footer,
125 reset_config_on_routers,
126 step,
127 shutdown_bringup_interface,
128 kill_router_daemons,
129 start_router_daemons,
130 create_static_routes,
131 topo_daemons,
132 )
133 from lib.pim import (
134 create_pim_config,
135 verify_igmp_groups,
136 verify_upstream_iif,
137 verify_join_state_and_timer,
138 verify_ip_mroutes,
139 verify_pim_neighbors,
140 get_pim_interface_traffic,
141 verify_pim_rp_info,
142 verify_pim_state,
143 clear_ip_pim_interface_traffic,
144 clear_ip_igmp_interfaces,
145 clear_ip_pim_interfaces,
146 clear_ip_mroute,
147 clear_ip_mroute_verify,
148 McastTesterHelper,
149 )
150
151 pytestmark = [pytest.mark.pimd, pytest.mark.staticd]
152
153
154 # Global variables
155 GROUP_RANGE_ALL = "224.0.0.0/4"
156 GROUP_RANGE = "225.1.1.1/32"
157 GROUP_RANGE_LIST_1 = [
158 "225.1.1.1/32",
159 "225.1.1.2/32",
160 "225.1.1.3/32",
161 "225.1.1.4/32",
162 "225.1.1.5/32",
163 ]
164 GROUP_RANGE_LIST_2 = [
165 "225.1.1.6/32",
166 "225.1.1.7/32",
167 "225.1.1.8/32",
168 "225.1.1.9/32",
169 "225.1.1.10/32",
170 ]
171 GROUP_ADDRESS = "225.1.1.1"
172 GROUP_ADDRESS_LIST_1 = ["225.1.1.1", "225.1.1.2", "225.1.1.3", "225.1.1.4", "225.1.1.5"]
173 GROUP_ADDRESS_LIST_2 = [
174 "225.1.1.6",
175 "225.1.1.7",
176 "225.1.1.8",
177 "225.1.1.9",
178 "225.1.1.10",
179 ]
180 STAR = "*"
181 SOURCE_ADDRESS = "10.0.6.2"
182 SOURCE = "Static"
183
184
185 def build_topo(tgen):
186 """Build function"""
187
188 # Building topology from json file
189 build_topo_from_json(tgen, TOPO)
190
191
192 def setup_module(mod):
193 """
194 Sets up the pytest environment
195
196 * `mod`: module name
197 """
198
199 testsuite_run_time = time.asctime(time.localtime(time.time()))
200 logger.info("Testsuite start time: %s", testsuite_run_time)
201 logger.info("=" * 40)
202
203 topology = """
204
205 _______r2_____
206 | |
207 iperf | | iperf
208 r0-----r1-------------r3-----r5
209 | |
210 |_____________|
211 r4
212
213 """
214 logger.info("Master Topology: \n %s", topology)
215
216 logger.info("Running setup_module to create topology")
217
218 # This function initiates the topology build with Topogen...
219 json_file = "{}/multicast_pim_static_rp.json".format(CWD)
220 tgen = Topogen(json_file, mod.__name__)
221 global TOPO
222 TOPO = tgen.json_topo
223
224 # ... and here it calls Mininet initialization functions.
225
226 # get list of daemons needs to be started for this suite.
227 daemons = topo_daemons(tgen, TOPO)
228
229 # Starting topology, create tmp files which are loaded to routers
230 # to start daemons and then start routers
231 start_topology(tgen, daemons)
232
233 # Don"t run this test if we have any failure.
234 if tgen.routers_have_failure():
235 pytest.skip(tgen.errors)
236
237 # Creating configuration from JSON
238 build_config_from_json(tgen, TOPO)
239
240 # Verify PIM neighbors
241 result = verify_pim_neighbors(tgen, TOPO)
242 assert result is True, "setup_module :Failed \n Error:" " {}".format(result)
243
244 # XXX Replace this using "with McastTesterHelper()... " in each test if possible.
245 global app_helper
246 app_helper = McastTesterHelper(tgen)
247
248 logger.info("Running setup_module() done")
249
250
251 def teardown_module():
252 """Teardown the pytest environment"""
253
254 logger.info("Running teardown_module to delete topology")
255
256 tgen = get_topogen()
257
258 app_helper.cleanup()
259
260 # Stop toplogy and Remove tmp files
261 tgen.stop_topology()
262
263 logger.info("Testsuite end time: %s", time.asctime(time.localtime(time.time())))
264 logger.info("=" * 40)
265
266
267 #####################################################
268 #
269 # Testcases
270 #
271 #####################################################
272
273
274 def verify_mroute_repopulated(uptime_before, uptime_after):
275 """
276 API to compare uptime for mroutes
277
278 Parameters
279 ----------
280 * `uptime_before` : Uptime dictionary for any particular instance
281 * `uptime_after` : Uptime dictionary for any particular instance
282 """
283
284 for group in uptime_before.keys():
285 for source in uptime_before[group].keys():
286 if set(uptime_before[group]) != set(uptime_after[group]):
287 errormsg = (
288 "mroute (%s, %s) has not come"
289 " up after mroute clear [FAILED!!]" % (source, group)
290 )
291 return errormsg
292
293 d_1 = datetime.datetime.strptime(uptime_before[group][source], "%H:%M:%S")
294 d_2 = datetime.datetime.strptime(uptime_after[group][source], "%H:%M:%S")
295 if d_2 >= d_1:
296 errormsg = "mroute (%s, %s) is not " "repopulated [FAILED!!]" % (
297 source,
298 group,
299 )
300 return errormsg
301
302 logger.info("mroute (%s, %s) is " "repopulated [PASSED!!]", source, group)
303
304 return True
305
306
307 def verify_state_incremented(state_before, state_after):
308 """
309 API to compare interface traffic state incrementing
310
311 Parameters
312 ----------
313 * `state_before` : State dictionary for any particular instance
314 * `state_after` : State dictionary for any particular instance
315 """
316
317 for router, state_data in state_before.items():
318 for state, _ in state_data.items():
319 if state_before[router][state] >= state_after[router][state]:
320 errormsg = (
321 "[DUT: %s]: state %s value has not"
322 " incremented, Initial value: %s, "
323 "Current value: %s [FAILED!!]"
324 % (
325 router,
326 state,
327 state_before[router][state],
328 state_after[router][state],
329 )
330 )
331 return errormsg
332
333 logger.info(
334 "[DUT: %s]: State %s value is "
335 "incremented, Initial value: %s, Current value: %s"
336 " [PASSED!!]",
337 router,
338 state,
339 state_before[router][state],
340 state_after[router][state],
341 )
342
343 return True
344
345
346 def test_add_delete_static_RP_p0(request):
347 """
348 TC_1_P0 : Verify upstream interfaces(IIF) and join state are updated
349 properly after adding and deleting the static RP
350 TC_2_P0 : Verify IIF and OIL in "show ip pim state" updated properly
351 after adding and deleting the static RP
352 TC_3_P0: (*, G) Mroute entry are cleared when static RP gets deleted
353 TC_4_P0: Verify (*,G) prune is send towards the RP after deleting the
354 static RP
355
356 Topology used:
357 r0------r1-----r2
358 iperf DUT RP
359 """
360
361 tgen = get_topogen()
362 tc_name = request.node.name
363 write_test_header(tc_name)
364
365 # Don"t run this test if we have any failure.
366 if tgen.routers_have_failure():
367 pytest.skip(tgen.errors)
368
369 step("pre-configuration to send IGMP join and multicast traffic")
370
371 step("Enable IGMP on r1 interface and send IGMP " "join (225.1.1.1) to r1")
372 step("Configure r2 loopback interface as RP")
373 step("Enable PIM between r1 and r3")
374
375 step("r1: Verify show ip igmp group without any IGMP join")
376 dut = "r1"
377 interface = "r1-r0-eth0"
378 result = verify_igmp_groups(tgen, dut, interface, GROUP_ADDRESS, expected=False)
379 assert result is not True, (
380 "Testcase {} : Failed \n "
381 "r1: igmp group present without any IGMP join \n Error: {}".format(
382 tc_name, result
383 )
384 )
385
386 step("r1: Verify show ip pim interface traffic without any IGMP join")
387 state_dict = {"r1": {"r1-r2-eth1": ["pruneTx"]}}
388
389 state_before = get_pim_interface_traffic(tgen, state_dict)
390 assert isinstance(
391 state_before, dict
392 ), "Testcase {} : Failed \n state_before is not dictionary\n Error: {}".format(
393 tc_name, result
394 )
395
396 step("r0 : Send IGMP join")
397 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
398 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
399
400 step("r1: Verify IGMP groups")
401 oif = "r1-r0-eth0"
402 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
403 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
404
405 step("r1: Verify RP info")
406 dut = "r1"
407 iif = "r1-r2-eth1"
408 rp_address = "1.0.2.17"
409 result = verify_pim_rp_info(
410 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
411 )
412 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
413
414 step("r1: Verify upstream IIF interface")
415 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
416 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
417
418 step("r1: Verify upstream join state and join timer")
419 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
420 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
421 step("r1: Verify ip mroutes")
422 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
423 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
424
425 step("r1: Verify ip pim join")
426 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
427 step("r1: Delete RP configuration")
428
429 # Delete RP configuration
430 input_dict = {
431 "r1": {
432 "pim": {
433 "rp": [
434 {
435 "rp_addr": "1.0.2.17",
436 "group_addr_range": GROUP_RANGE_ALL,
437 "delete": True,
438 }
439 ]
440 }
441 }
442 }
443
444 result = create_pim_config(tgen, TOPO, input_dict)
445 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
446
447 step("r1: Verify RP info")
448 result = verify_pim_rp_info(
449 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE, expected=False
450 )
451 assert (
452 result is not True
453 ), "Testcase {} : Failed \n " "r1: RP info present \n Error: {}".format(
454 tc_name, result
455 )
456
457 step("r1: Verify upstream IIF interface")
458 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False)
459 assert result is not True, (
460 "Testcase {} : Failed \n "
461 "r1: upstream IIF interface present \n Error: {}".format(tc_name, result)
462 )
463
464 step("r1: Verify upstream join state and join timer")
465 result = verify_join_state_and_timer(
466 tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False
467 )
468 assert result is not True, (
469 "Testcase {} : Failed \n "
470 "r1: upstream join state is up and join timer is running \n Error: {}".format(
471 tc_name, result
472 )
473 )
474
475 # 20
476 step("r1: Verify PIM state")
477 result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False)
478 assert result is not True, "Testcase {} :Failed \n Error: {}".format(
479 tc_name, result
480 )
481
482 step("r1: Verify ip mroutes")
483 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
484 assert (
485 result is not True
486 ), "Testcase {} : Failed \n " "r1: mroutes are still present \n Error: {}".format(
487 tc_name, result
488 )
489
490 step("r1: Verify show ip pim interface traffic without any IGMP join")
491 state_after = get_pim_interface_traffic(tgen, state_dict)
492 assert isinstance(
493 state_after, dict
494 ), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format(
495 tc_name, result
496 )
497
498 result = verify_state_incremented(state_before, state_after)
499 assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result)
500
501 # Uncomment next line for debugging
502 # tgen.mininet_cli()
503
504 write_test_footer(tc_name)
505
506
507 def test_SPT_RPT_path_same_p1(request):
508 """
509 TC_24_P1 : Verify (*,G) and (S,G) populated correctly when SPT and RPT
510 share the same path
511
512 Topology used:
513 ________r2_____
514 | |
515 iperf | | iperf
516 r0-----r1 r3-----r5
517
518 r1 : LHR
519 r2 : RP
520 r3 : FHR
521 """
522
523 tgen = get_topogen()
524 tc_name = request.node.name
525 write_test_header(tc_name)
526
527 # Don"t run this test if we have any failure.
528 if tgen.routers_have_failure():
529 pytest.skip(tgen.errors)
530
531 step("Creating configuration from JSON")
532 reset_config_on_routers(tgen)
533 app_helper.stop_all_hosts()
534 clear_ip_mroute(tgen)
535 clear_ip_pim_interface_traffic(tgen, TOPO)
536
537 dut = "r1"
538 intf = "r1-r3-eth2"
539 shutdown_bringup_interface(tgen, dut, intf, False)
540 intf = "r1-r4-eth3"
541 shutdown_bringup_interface(tgen, dut, intf, False)
542
543 dut = "r3"
544 intf = "r3-r1-eth0"
545 shutdown_bringup_interface(tgen, dut, intf, False)
546 intf = "r3-r4-eth2"
547 shutdown_bringup_interface(tgen, dut, intf, False)
548
549 step("Enable IGMP on r1 interface and send IGMP join (225.1.1.1) to R1")
550 step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4")
551 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
552 step("Send multicast traffic from R3")
553
554 step("r2: Verify RP info")
555 dut = "r2"
556 rp_address = "1.0.2.17"
557 iif = "lo"
558 result = verify_pim_rp_info(
559 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
560 )
561 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
562
563 step("r0: Send IGMP join")
564 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
565 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
566
567 step("r1: Verify IGMP groups")
568 dut = "r1"
569 oif = "r1-r0-eth0"
570 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
571 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
572
573 step("r5: Send multicast traffic for group 225.1.1.1")
574 result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
575 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
576
577 step("r1: Verify (*, G) upstream IIF interface")
578 dut = "r1"
579 iif = "r1-r2-eth1"
580 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
581 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
582
583 step("r1: Verify (*, G) upstream join state and join timer")
584 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
585 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
586
587 step("r1: Verify (*, G) ip mroutes")
588 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
589 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
590
591 step("r1: Verify (S, G) upstream IIF interface")
592 iif = "r1-r2-eth1"
593 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
594 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
595
596 step("r1: Verify (S, G) upstream join state and join timer")
597 result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
598 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
599
600 step("r1: Verify (S, G) ip mroutes")
601 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
602 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
603
604 step("r2: Verify (*, G) upstream IIF interface")
605 dut = "r2"
606 iif = "lo"
607 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
608 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
609
610 step("r2: Verify (*, G) upstream join state and join timer")
611 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
612 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
613
614 step("r2: Verify (*, G) ip mroutes")
615 oif = "r2-r1-eth0"
616 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
617 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
618
619 step("r2: Verify (S, G) upstream IIF interface")
620 iif = "r2-r3-eth1"
621 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
622 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
623
624 step("r2: Verify (S, G) upstream join state and join timer")
625 result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
626 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
627
628 step("r2: Verify (S, G) ip mroutes")
629 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
630 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
631
632 step("r3: Verify (S, G) upstream IIF interface")
633 dut = "r3"
634 iif = "r3-r5-eth3"
635 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
636 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
637
638 step("r3: Verify (S, G) upstream join state and join timer")
639 result = verify_join_state_and_timer(
640 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False
641 )
642 assert result is not True, (
643 "Testcase {} : Failed \n "
644 "r3: (S, G) upstream join state is up and join timer is running\n Error: {}".format(
645 tc_name, result
646 )
647 )
648
649 step("r3: Verify (S, G) ip mroutes")
650 oif = "r3-r2-eth1"
651 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
652 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
653
654 # Uncomment next line for debugging
655 # tgen.mininet_cli()
656
657 write_test_footer(tc_name)
658
659
660 def test_not_reachable_static_RP_p0(request):
661 """
662 TC_5_P0: Verify OIF entry for RP is cleared when RP becomes unreachable
663 TC_6_P0: Verify IIF and OIL in "show ip pim state" updated properly when
664 RP becomes unreachable
665 TC_7_P0 : Verify upstream interfaces(IIF) and join state are updated
666 properly after adding and deleting the static RP
667 TC_8_P0: Verify (*,G) prune is send towards the RP when RP becomes
668 unreachable
669
670 Topology used:
671 r0------r1-----r2
672 iperf DUT RP
673 """
674
675 tgen = get_topogen()
676 tc_name = request.node.name
677 write_test_header(tc_name)
678
679 # Don"t run this test if we have any failure.
680 if tgen.routers_have_failure():
681 pytest.skip(tgen.errors)
682
683 step("Creating configuration from JSON")
684 reset_config_on_routers(tgen)
685 app_helper.stop_all_hosts()
686 clear_ip_mroute(tgen)
687 clear_ip_pim_interface_traffic(tgen, TOPO)
688
689 dut = "r1"
690 intf = "r1-r3-eth2"
691 shutdown_bringup_interface(tgen, dut, intf, False)
692
693 dut = "r1"
694 intf = "r1-r4-eth3"
695 shutdown_bringup_interface(tgen, dut, intf, False)
696
697 step(
698 "r1: (*,G) prune is not sent towards the RP interface, verify using"
699 "show ip pim interface traffic"
700 )
701 state_dict = {"r1": {"r1-r2-eth1": ["pruneTx"]}}
702 state_before = get_pim_interface_traffic(tgen, state_dict)
703 assert isinstance(
704 state_before, dict
705 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
706 tc_name, state_before
707 )
708
709 step("Enable IGMP on r1 interface and send IGMP " "join (225.1.1.1) to r1")
710 step("Configure r2 loopback interface as RP")
711 step("Enable PIM between r1 and r2")
712
713 step("r0 : Send IGMP join")
714 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
715 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
716
717 step("r1 : Verify rp info")
718 dut = "r1"
719 iif = "r1-r2-eth1"
720 rp_address = "1.0.2.17"
721 result = verify_pim_rp_info(
722 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
723 )
724 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
725
726 step("r1: Verify IGMP groups")
727 oif = "r1-r0-eth0"
728 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
729 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
730
731 step("r1: Verify PIM state")
732 result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS)
733 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
734
735 step("r1: Verify upstream IIF interface")
736 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
737 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
738
739 step("r1: Verify upstream join state and join timer")
740 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
741 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
742
743 step("r1 :Verify ip mroutes")
744 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
745 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
746
747 step("r1: Make RP un-reachable")
748 dut = "r1"
749 input_dict = {
750 dut: {
751 "static_routes": [
752 {"network": "1.0.2.17/32", "next_hop": "10.0.1.2", "delete": True}
753 ]
754 }
755 }
756
757 result = create_static_routes(tgen, input_dict)
758 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
759
760 step("r1: Check RP detail using show ip pim rp-info OIF should be unknown")
761 result = verify_pim_rp_info(
762 tgen, TOPO, dut, GROUP_RANGE_ALL, "Unknown", rp_address, SOURCE
763 )
764 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
765
766 step(
767 "r1 : OIL should be same and IIF should be cleared on R1 verify"
768 "using show ip pim state"
769 )
770 result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False)
771 assert result is not True, (
772 "Testcase {} : Failed \n "
773 "OIL is not same and IIF is not cleared on R1 \n Error: {}".format(
774 tc_name, result
775 )
776 )
777
778 step("r1: upstream IIF should be unknown , verify using show ip pim" "upstream")
779 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False)
780 assert result is not True, (
781 "Testcase {} : Failed \n "
782 "r1: upstream IIF is not unknown \n Error: {}".format(tc_name, result)
783 )
784
785 step(
786 "r1: join state should not be joined and join timer should stop,"
787 "verify using show ip pim upstream"
788 )
789 result = verify_join_state_and_timer(
790 tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False
791 )
792 assert result is not True, (
793 "Testcase {} : Failed \n "
794 "r1: join state is joined and timer is not stopped \n Error: {}".format(
795 tc_name, result
796 )
797 )
798
799 step(
800 "r1: (*,G) prune is sent towards the RP interface, verify using"
801 "show ip pim interface traffic"
802 )
803 state_after = get_pim_interface_traffic(tgen, state_dict)
804 assert isinstance(
805 state_after, dict
806 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
807 tc_name, result
808 )
809
810 result = verify_state_incremented(state_before, state_after)
811 assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result)
812
813 step("r1: (*, G) cleared from mroute table using show ip mroute")
814 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
815 assert result is not True, (
816 "Testcase {} : Failed \n "
817 "r1: (*, G) are not cleared from mroute table \n Error: {}".format(
818 tc_name, result
819 )
820 )
821 logger.info("Expected behavior: %s", result)
822
823 # Uncomment next line for debugging
824 # tgen.mininet_cli()
825
826 write_test_footer(tc_name)
827
828
829 def test_add_RP_after_join_received_p1(request):
830 """
831 TC_9_P1 : Verify RP configured after IGMP join received, PIM join towards
832 RP is sent immediately
833
834 Topology used:
835 r0------r1-----r2
836 iperf DUT RP
837 """
838
839 tgen = get_topogen()
840 tc_name = request.node.name
841 write_test_header(tc_name)
842
843 # Don"t run this test if we have any failure.
844 if tgen.routers_have_failure():
845 pytest.skip(tgen.errors)
846
847 step("Creating configuration from JSON")
848 reset_config_on_routers(tgen)
849 app_helper.stop_all_hosts()
850 clear_ip_mroute(tgen)
851 clear_ip_pim_interface_traffic(tgen, TOPO)
852
853 step("Enable IGMP on R1 interface")
854 step("Configure r2 loopback interface as RP")
855 step("Enable PIM between r1 and r2")
856 step("Delete RP configuration from r1")
857
858 step("r1: Delete RP configuration")
859 input_dict = {
860 "r1": {
861 "pim": {
862 "rp": [
863 {
864 "rp_addr": "1.0.2.17",
865 "group_addr_range": GROUP_RANGE_ALL,
866 "delete": True,
867 }
868 ]
869 }
870 }
871 }
872
873 result = create_pim_config(tgen, TOPO, input_dict)
874 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
875
876 step("r1: Verify rp-info")
877 dut = "r1"
878 rp_address = "1.0.2.17"
879 iif = "r1-r2-eth1"
880 result = verify_pim_rp_info(
881 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE, expected=False
882 )
883 assert (
884 result is not True
885 ), "Testcase {} : Failed \n " "r1: rp-info is present \n Error: {}".format(
886 tc_name, result
887 )
888
889 step("joinTx value before join sent")
890 state_dict = {"r1": {"r1-r2-eth1": ["joinTx"]}}
891 state_before = get_pim_interface_traffic(tgen, state_dict)
892 assert isinstance(
893 state_before, dict
894 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
895 tc_name, result
896 )
897
898 step("r0 : Send IGMP join (225.1.1.1) to r1, when rp is not configured" "in r1")
899 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
900 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
901
902 step("r1: IGMP group is received on R1 verify using show ip igmp groups")
903 oif = "r1-r0-eth0"
904 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
905 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
906
907 step("r1: Verify upstream IIF interface")
908 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False)
909 assert result is not True, (
910 "Testcase {} : Failed \n "
911 "r1: upstream IFF interface is present \n Error: {}".format(tc_name, result)
912 )
913
914 step("r1: Verify upstream join state and join timer")
915
916 result = verify_join_state_and_timer(
917 tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False
918 )
919 assert result is not True, (
920 "Testcase {} : Failed \n "
921 "r1: upstream join state is joined and timer is running \n Error: {}".format(
922 tc_name, result
923 )
924 )
925
926 step("r1: Verify PIM state")
927 result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False)
928 assert (
929 result is not True
930 ), "Testcase {} : Failed \n " "r1: PIM state is up\n Error: {}".format(
931 tc_name, result
932 )
933
934 step("r1: Verify ip mroutes")
935 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
936 assert (
937 result is not True
938 ), "Testcase {} : Failed \n " "r1: mroutes are still present\n Error: {}".format(
939 tc_name, result
940 )
941
942 step("r1: Configure static RP")
943 input_dict = {
944 "r1": {
945 "pim": {
946 "rp": [
947 {
948 "rp_addr": "1.0.2.17",
949 "group_addr_range": GROUP_RANGE_ALL,
950 }
951 ]
952 }
953 }
954 }
955
956 result = create_pim_config(tgen, TOPO, input_dict)
957 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
958
959 step("r1: Verify rp-info")
960 result = verify_pim_rp_info(
961 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
962 )
963 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
964
965 step("r1: Verify upstream IIF interface")
966 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
967 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
968
969 step("r1 : Verify upstream join state and join timer")
970 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
971 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
972
973 step("r1: Verify PIM state")
974 result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS)
975 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
976
977 step("r1 : Verify ip mroutes")
978 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
979 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
980 logger.info("Expected behavior: %s", result)
981
982 state_after = get_pim_interface_traffic(tgen, state_dict)
983 assert isinstance(
984 state_after, dict
985 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
986 tc_name, result
987 )
988
989 result = verify_state_incremented(state_before, state_after)
990 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
991
992 # Uncomment next line for debugging
993 # tgen.mininet_cli()
994
995 write_test_footer(tc_name)
996
997
998 def test_reachable_static_RP_after_join_p0(request):
999 """
1000 TC_10_P0 : Verify RP becomes reachable after IGMP join received, PIM join
1001 towards RP is sent immediately
1002
1003 Topology used:
1004 r0------r1-----r3
1005 iperf DUT RP
1006 """
1007 tgen = get_topogen()
1008 tc_name = request.node.name
1009 write_test_header(tc_name)
1010
1011 # Don"t run this test if we have any failure.
1012 if tgen.routers_have_failure():
1013 pytest.skip(tgen.errors)
1014
1015 step("Creating configuration from JSON")
1016 reset_config_on_routers(tgen)
1017 app_helper.stop_all_hosts()
1018 clear_ip_mroute(tgen)
1019 clear_ip_pim_interface_traffic(tgen, TOPO)
1020
1021 step("Enable IGMP on r1 interface and send IGMP " "join (225.1.1.1) to r1")
1022 step("Configure r2 loopback interface as RP")
1023 step("Enable PIM between r1 and r2")
1024
1025 step("r1 : Verify pim interface traffic")
1026 state_dict = {"r1": {"r1-r2-eth1": ["joinTx"]}}
1027 state_before = get_pim_interface_traffic(tgen, state_dict)
1028 assert isinstance(
1029 state_before, dict
1030 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
1031 tc_name, state_before
1032 )
1033
1034 step("r1: Make RP un-reachable")
1035 dut = "r1"
1036 intf = "r1-r2-eth1"
1037 shutdown_bringup_interface(tgen, dut, intf, False)
1038 intf = "r1-r3-eth2"
1039 shutdown_bringup_interface(tgen, dut, intf, False)
1040 intf = "r1-r4-eth3"
1041 shutdown_bringup_interface(tgen, dut, intf, False)
1042
1043 step("r1: Verify rp-info")
1044 rp_address = "1.0.2.17"
1045 result = verify_pim_rp_info(
1046 tgen, TOPO, dut, GROUP_ADDRESS, "Unknown", rp_address, SOURCE
1047 )
1048 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1049
1050 step("r1 : Send IGMP join for 225.1.1.1")
1051 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
1052 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1053
1054 step("r1 : Verify IGMP groups")
1055 oif = "r1-r0-eth0"
1056 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
1057 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1058
1059 step("r1 : Verify upstream IIF interface")
1060 iif = "r1-r2-eth1"
1061 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False)
1062 assert result is not True, (
1063 "Testcase {} : Failed \n "
1064 "r1: upstream IIF interface is present\n Error: {}".format(tc_name, result)
1065 )
1066
1067 step("r1 : Verify upstream join state and join timer")
1068 result = verify_join_state_and_timer(
1069 tgen, dut, iif, STAR, GROUP_ADDRESS, expected=False
1070 )
1071 assert result is not True, (
1072 "Testcase {} : Failed \n "
1073 "r1: upstream join state is joined and timer is running\n Error: {}".format(
1074 tc_name, result
1075 )
1076 )
1077
1078 step("r1 : Verify PIM state")
1079 result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS, expected=False)
1080 assert (
1081 result is not True
1082 ), "Testcase {} : Failed \n " "r1: PIM state is up\n Error: {}".format(
1083 tc_name, result
1084 )
1085
1086 step("r1 : Verify ip mroutes")
1087 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
1088 assert (
1089 result is not True
1090 ), "Testcase {} : Failed \n " "r1: mroutes are still present\n Error: {}".format(
1091 tc_name, result
1092 )
1093
1094 step("r1: Make RP reachable")
1095 intf = "r1-r2-eth1"
1096 shutdown_bringup_interface(tgen, dut, intf, True)
1097 intf = "r1-r3-eth2"
1098 shutdown_bringup_interface(tgen, dut, intf, True)
1099 intf = "r1-r4-eth3"
1100 shutdown_bringup_interface(tgen, dut, intf, True)
1101
1102 step("r1 : Verify rp-info")
1103 result = verify_pim_rp_info(
1104 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
1105 )
1106 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1107
1108 step("r1: Verify upstream IIF interface")
1109 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
1110 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1111
1112 step("r1 : Verify upstream join state and join timer")
1113 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
1114 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1115
1116 step("r1 : Verify PIM state")
1117 result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS)
1118 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1119
1120 step("r1 : Verify ip mroutes")
1121 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
1122 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1123 logger.info("Expected behavior: %s", result)
1124
1125 step("r1 : Verify pim interface traffic")
1126 state_after = get_pim_interface_traffic(tgen, state_dict)
1127 assert isinstance(
1128 state_after, dict
1129 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
1130 tc_name, result
1131 )
1132
1133 result = verify_state_incremented(state_before, state_after)
1134 assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result)
1135
1136 # Uncomment next line for debugging
1137 # tgen.mininet_cli()
1138
1139 write_test_footer(tc_name)
1140
1141
1142 def test_send_join_on_higher_preffered_rp_p1(request):
1143 """
1144 TC_11_P1 : Verify PIM join send towards the higher preferred RP
1145 TC_12_P1 : Verify PIM prune send towards the lower preferred RP
1146 TC_13_P1 : Verify RPF interface is updated in mroute (kernel) when higher
1147 preferred overlapping RP configured
1148 TC_14_P1 : Verify IIF and OIL in "show ip pim state" updated properly when
1149 higher preferred overlapping RP configured
1150 TC_15_P1 : Verify upstream interfaces(IIF) and join state are updated when
1151 higher preferred overlapping RP is configured
1152 TC_16_P1 : Verify join is send to lower preferred RP, when higher
1153 preferred RP gets deleted
1154 TC_17_P1 : Verify prune is send to higher preferred RP when higher
1155 preferred RP gets deleted
1156 TC_18_P1 : Verify RPF interface updated in mroute when higher preferred RP
1157 gets deleted
1158 TC_19_P1 : Verify IIF and OIL in "show ip pim state" updated when higher
1159 preferred overlapping RP is deleted
1160 TC_20_P1 : Verfiy PIM upstream IIF updated when higher preferred
1161 overlapping RP deleted
1162
1163 Topology used:
1164 _______r2
1165 |
1166 iperf |
1167 r0-----r1
1168 |
1169 |_______r4
1170 """
1171
1172 tgen = get_topogen()
1173 tc_name = request.node.name
1174 write_test_header(tc_name)
1175
1176 # Don"t run this test if we have any failure.
1177 if tgen.routers_have_failure():
1178 pytest.skip(tgen.errors)
1179
1180 step("Creating configuration from JSON")
1181 reset_config_on_routers(tgen)
1182 app_helper.stop_all_hosts()
1183 clear_ip_mroute(tgen)
1184 clear_ip_pim_interface_traffic(tgen, TOPO)
1185
1186 step("Enable IGMP on r1 interface")
1187 step("Configure RP on r2 (loopback interface) for the group range " "224.0.0.0/4")
1188 step("Configure RP on r4 (loopback interface) for the group range " "225.1.1.1/32")
1189
1190 step("r3 : Make all interface not reachable")
1191 dut = "r3"
1192 intf = "r3-r1-eth0"
1193 shutdown_bringup_interface(tgen, dut, intf, False)
1194 intf = "r3-r2-eth1"
1195 shutdown_bringup_interface(tgen, dut, intf, False)
1196 intf = "r3-r4-eth2"
1197 shutdown_bringup_interface(tgen, dut, intf, False)
1198
1199 dut = "r2"
1200 intf = "r2-r3-eth1"
1201 shutdown_bringup_interface(tgen, dut, intf, False)
1202
1203 dut = "r4"
1204 intf = "r4-r3-eth1"
1205 shutdown_bringup_interface(tgen, dut, intf, False)
1206
1207 dut = "r1"
1208 intf = "r1-r3-eth2"
1209 shutdown_bringup_interface(tgen, dut, intf, False)
1210
1211 step("r1 : Verify joinTx count before sending join")
1212 state_dict = {"r1": {"r1-r4-eth3": ["joinTx"], "r1-r2-eth1": ["pruneTx"]}}
1213
1214 state_before = get_pim_interface_traffic(tgen, state_dict)
1215 assert isinstance(
1216 state_before, dict
1217 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
1218 tc_name, state_before
1219 )
1220
1221 step("r0 : Send IGMP join for 225.1.1.1")
1222 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
1223 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1224
1225 step("r1 : Verify IGMP groups")
1226 dut = "r1"
1227 oif = "r1-r0-eth0"
1228 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
1229 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1230
1231 step("Configure static RP for group 225.1.1.1/32")
1232 input_dict = {
1233 "r4": {
1234 "pim": {
1235 "rp": [
1236 {
1237 "rp_addr": "1.0.4.17",
1238 "group_addr_range": ["225.1.1.1/32"],
1239 }
1240 ]
1241 }
1242 }
1243 }
1244
1245 result = create_pim_config(tgen, TOPO, input_dict)
1246 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1247
1248 step("r1 : Verify RP info for group 224.0.0.0/4")
1249 rp_address_1 = "1.0.2.17"
1250 iif = "r1-r2-eth1"
1251 result = verify_pim_rp_info(
1252 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE
1253 )
1254 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1255
1256 step("r1 : Verify RP info for group 225.1.1.1")
1257 rp_address_2 = "1.0.4.17"
1258 iif = "r1-r4-eth3"
1259 result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_RANGE, iif, rp_address_2, SOURCE)
1260 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1261
1262 step("r1 : Verify join is sent to higher preferred RP")
1263 step("r1 : Verify prune is sent to lower preferred RP")
1264 state_after = get_pim_interface_traffic(tgen, state_dict)
1265 assert isinstance(
1266 state_after, dict
1267 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
1268 tc_name, result
1269 )
1270
1271 result = verify_state_incremented(state_before, state_after)
1272 assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result)
1273
1274 step("r1 : Verify ip mroutes")
1275 iif = "r1-r4-eth3"
1276 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
1277 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1278
1279 step("r1 : Verify PIM state")
1280 result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS)
1281 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1282
1283 step("r1 : Verify upstream IIF interface")
1284 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
1285 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1286
1287 step("r1 : Verify upstream join state and join timer")
1288 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
1289 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1290
1291 clear_ip_pim_interface_traffic(tgen, TOPO)
1292
1293 step("r1 : Verify joinTx, pruneTx count before RP gets deleted")
1294 state_dict = {"r1": {"r1-r2-eth1": ["joinTx"], "r1-r4-eth3": ["pruneTx"]}}
1295
1296 state_before = get_pim_interface_traffic(tgen, state_dict)
1297 assert isinstance(
1298 state_before, dict
1299 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
1300 tc_name, result
1301 )
1302
1303 step("r1 : Delete RP configuration for 225.1.1.1")
1304 input_dict = {
1305 "r1": {
1306 "pim": {
1307 "rp": [
1308 {
1309 "rp_addr": "1.0.4.17",
1310 "group_addr_range": ["225.1.1.1/32"],
1311 "delete": True,
1312 }
1313 ]
1314 }
1315 }
1316 }
1317
1318 result = create_pim_config(tgen, TOPO, input_dict)
1319 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1320
1321 step("r1 : Verify rp-info for group 224.0.0.0/4")
1322 iif = "r1-r2-eth1"
1323 result = verify_pim_rp_info(
1324 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address_1, SOURCE
1325 )
1326 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1327
1328 step("r1 : Verify rp-info for group 225.1.1.1")
1329 iif = "r1-r4-eth3"
1330 result = verify_pim_rp_info(
1331 tgen, TOPO, dut, GROUP_RANGE, oif, rp_address_2, SOURCE, expected=False
1332 )
1333 assert result is not True, (
1334 "Testcase {} : Failed \n "
1335 "r1: rp-info is present for group 225.1.1.1 \n Error: {}".format(
1336 tc_name, result
1337 )
1338 )
1339
1340 step(
1341 "r1 : Verify RPF interface updated in mroute when higher preferred"
1342 "RP gets deleted"
1343 )
1344 iif = "r1-r2-eth1"
1345 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
1346 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1347 logger.info("Expected behavior: %s", result)
1348
1349 step(
1350 "r1 : Verify IIF and OIL in show ip pim state updated when higher"
1351 "preferred overlapping RP is deleted"
1352 )
1353 result = verify_pim_state(tgen, dut, iif, oif, GROUP_ADDRESS)
1354 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1355
1356 step(
1357 "r1 : Verfiy upstream IIF updated when higher preferred overlapping"
1358 "RP deleted"
1359 )
1360 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
1361 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1362
1363 step(
1364 "r1 : Verify upstream join state and join timer updated when higher"
1365 "preferred overlapping RP deleted"
1366 )
1367 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
1368 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1369
1370 step(
1371 "r1 : Verify join is sent to lower preferred RP, when higher"
1372 "preferred RP gets deleted"
1373 )
1374 step(
1375 "r1 : Verify prune is sent to higher preferred RP when higher"
1376 " preferred RP gets deleted"
1377 )
1378 state_after = get_pim_interface_traffic(tgen, state_dict)
1379 assert isinstance(
1380 state_after, dict
1381 ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
1382 tc_name, result
1383 )
1384
1385 result = verify_state_incremented(state_before, state_after)
1386 assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result)
1387
1388 # Uncomment next line for debugging
1389 # tgen.mininet_cli()
1390
1391 write_test_footer(tc_name)
1392
1393
1394 def test_RP_configured_as_LHR_1_p1(request):
1395 """
1396 TC_21_1_P1: Verify OIF and RPF for (*,G) and (S,G) when static RP configure
1397 in LHR router
1398
1399 Topology used:
1400 ________r2_____
1401 | |
1402 iperf | | iperf
1403 r0-----r1-------------r3-----r5
1404
1405 r1 : LHR/RP
1406 r3 : FHR
1407 """
1408
1409 tgen = get_topogen()
1410 tc_name = request.node.name
1411 write_test_header(tc_name)
1412
1413 # Don"t run this test if we have any failure.
1414 if tgen.routers_have_failure():
1415 pytest.skip(tgen.errors)
1416
1417 step("Creating configuration from JSON")
1418 reset_config_on_routers(tgen)
1419 app_helper.stop_all_hosts()
1420 clear_ip_mroute(tgen)
1421 clear_ip_pim_interface_traffic(tgen, TOPO)
1422
1423 step("Enable IGMP on r1 interface")
1424 step("Configure RP on r1 (loopback interface) for the group range" " 224.0.0.0/4")
1425 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
1426 step("Send the IGMP join from r0")
1427 step("Send multicast traffic from r5")
1428
1429 step("r1 , r2, r3, r4: Delete existing RP configuration" "configure r1(LHR) as RP")
1430 input_dict = {
1431 "r1": {
1432 "pim": {
1433 "rp": [
1434 {
1435 "rp_addr": "1.0.2.17",
1436 "group_addr_range": GROUP_RANGE_ALL,
1437 "delete": True,
1438 }
1439 ]
1440 }
1441 },
1442 "r2": {
1443 "pim": {
1444 "rp": [
1445 {
1446 "rp_addr": "1.0.2.17",
1447 "group_addr_range": GROUP_RANGE_ALL,
1448 "delete": True,
1449 }
1450 ]
1451 }
1452 },
1453 "r3": {
1454 "pim": {
1455 "rp": [
1456 {
1457 "rp_addr": "1.0.2.17",
1458 "group_addr_range": GROUP_RANGE_ALL,
1459 "delete": True,
1460 }
1461 ]
1462 }
1463 },
1464 "r4": {
1465 "pim": {
1466 "rp": [
1467 {
1468 "rp_addr": "1.0.2.17",
1469 "group_addr_range": GROUP_RANGE_ALL,
1470 "delete": True,
1471 }
1472 ]
1473 }
1474 },
1475 }
1476
1477 result = create_pim_config(tgen, TOPO, input_dict)
1478 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1479
1480 step("r1: Configure r1(LHR) as RP")
1481 input_dict = {
1482 "r1": {
1483 "pim": {
1484 "rp": [
1485 {
1486 "rp_addr": "1.0.1.17",
1487 "group_addr_range": GROUP_RANGE_ALL,
1488 }
1489 ]
1490 }
1491 },
1492 "r2": {
1493 "pim": {
1494 "rp": [
1495 {
1496 "rp_addr": "1.0.1.17",
1497 "group_addr_range": GROUP_RANGE_ALL,
1498 }
1499 ]
1500 }
1501 },
1502 "r3": {
1503 "pim": {
1504 "rp": [
1505 {
1506 "rp_addr": "1.0.1.17",
1507 "group_addr_range": GROUP_RANGE_ALL,
1508 }
1509 ]
1510 }
1511 },
1512 "r4": {
1513 "pim": {
1514 "rp": [
1515 {
1516 "rp_addr": "1.0.1.17",
1517 "group_addr_range": GROUP_RANGE_ALL,
1518 }
1519 ]
1520 }
1521 },
1522 }
1523
1524 result = create_pim_config(tgen, TOPO, input_dict)
1525 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1526
1527 shutdown_bringup_interface(tgen, "r1", "lo", False)
1528 sleep(5)
1529 shutdown_bringup_interface(tgen, "r1", "lo", True)
1530 sleep(5)
1531
1532 step("r1: Verify RP info")
1533 dut = "r1"
1534 rp_address = "1.0.1.17"
1535 iif = "lo"
1536 result = verify_pim_rp_info(
1537 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
1538 )
1539 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1540
1541 step("r0: Send IGMP join")
1542 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
1543 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1544
1545 step("r1: Verify IGMP groups")
1546 oif = "r1-r0-eth0"
1547 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
1548 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1549
1550 step("r5: Send multicast traffic for group 225.1.1.1")
1551 result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
1552 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1553
1554 step("r1: Verify (*, G) upstream IIF interface")
1555 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
1556 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1557
1558 step("r1: Verify (*, G) upstream join state and join timer")
1559 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
1560 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1561
1562 step("r1: Verify (*, G) ip mroutes")
1563 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
1564 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1565
1566 step("r1: Verify (S, G) upstream IIF interface")
1567 iif = "r1-r3-eth2"
1568 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
1569 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1570
1571 step("r1: Verify (S, G) upstream join state and join timer")
1572 result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
1573 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1574
1575 step("r1: Verify (S, G) ip mroutes")
1576 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
1577 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1578
1579 step("r3: Verify (S, G) upstream IIF interface")
1580 dut = "r3"
1581 iif = "r3-r5-eth3"
1582 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
1583 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1584
1585 step("r3: Verify (S, G) upstream join state and join timer")
1586 result = verify_join_state_and_timer(
1587 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False
1588 )
1589 assert result is not True, (
1590 "Testcase {} : Failed \n "
1591 "r3: (S, G) upstream join state is joined and join"
1592 " timer is running \n Error: {}".format(tc_name, result)
1593 )
1594
1595 step("r3: Verify (S, G) ip mroutes")
1596 oif = "r3-r1-eth0"
1597 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
1598 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1599
1600 # Uncomment next line for debugging
1601 # tgen.mininet_cli()
1602
1603 write_test_footer(tc_name)
1604
1605
1606 def test_RP_configured_as_LHR_2_p1(request):
1607 """
1608 TC_21_2_P1: Verify OIF and RPF for (*,G) and (S,G) when static RP configure
1609 in LHR router
1610
1611 Topology used:
1612 ________r2_____
1613 | |
1614 iperf | | iperf
1615 r0-----r1-------------r3-----r5
1616
1617 r1 : LHR/RP
1618 r3 : FHR
1619
1620 """
1621 tgen = get_topogen()
1622 tc_name = request.node.name
1623 write_test_header(tc_name)
1624
1625 # Don"t run this test if we have any failure.
1626 if tgen.routers_have_failure():
1627 pytest.skip(tgen.errors)
1628
1629 step("Creating configuration from JSON")
1630 reset_config_on_routers(tgen)
1631 app_helper.stop_all_hosts()
1632 clear_ip_mroute(tgen)
1633 clear_ip_pim_interface_traffic(tgen, TOPO)
1634
1635 step("Enable IGMP on r1 interface")
1636 step("Configure RP on r1 (loopback interface) for the group range" " 224.0.0.0/4")
1637 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
1638 step("Send multicast traffic from r5")
1639 step("Send the IGMP join from r0")
1640
1641 step("r1, r2, r3, r4: Delete existing RP configuration," "configure r1(LHR) as RP")
1642 input_dict = {
1643 "r1": {
1644 "pim": {
1645 "rp": [
1646 {
1647 "rp_addr": "1.0.2.17",
1648 "group_addr_range": GROUP_RANGE_ALL,
1649 "delete": True,
1650 }
1651 ]
1652 }
1653 },
1654 "r2": {
1655 "pim": {
1656 "rp": [
1657 {
1658 "rp_addr": "1.0.2.17",
1659 "group_addr_range": GROUP_RANGE_ALL,
1660 "delete": True,
1661 }
1662 ]
1663 }
1664 },
1665 "r3": {
1666 "pim": {
1667 "rp": [
1668 {
1669 "rp_addr": "1.0.2.17",
1670 "group_addr_range": GROUP_RANGE_ALL,
1671 "delete": True,
1672 }
1673 ]
1674 }
1675 },
1676 "r4": {
1677 "pim": {
1678 "rp": [
1679 {
1680 "rp_addr": "1.0.2.17",
1681 "group_addr_range": GROUP_RANGE_ALL,
1682 "delete": True,
1683 }
1684 ]
1685 }
1686 },
1687 }
1688
1689 result = create_pim_config(tgen, TOPO, input_dict)
1690 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1691
1692 step("r1, r2, r3, r4: Configure r1(LHR) as RP")
1693 input_dict = {
1694 "r1": {
1695 "pim": {
1696 "rp": [
1697 {
1698 "rp_addr": "1.0.1.17",
1699 "group_addr_range": GROUP_RANGE_ALL,
1700 }
1701 ]
1702 }
1703 },
1704 "r2": {
1705 "pim": {
1706 "rp": [
1707 {
1708 "rp_addr": "1.0.1.17",
1709 "group_addr_range": GROUP_RANGE_ALL,
1710 }
1711 ]
1712 }
1713 },
1714 "r3": {
1715 "pim": {
1716 "rp": [
1717 {
1718 "rp_addr": "1.0.1.17",
1719 "group_addr_range": GROUP_RANGE_ALL,
1720 }
1721 ]
1722 }
1723 },
1724 "r4": {
1725 "pim": {
1726 "rp": [
1727 {
1728 "rp_addr": "1.0.1.17",
1729 "group_addr_range": GROUP_RANGE_ALL,
1730 }
1731 ]
1732 }
1733 },
1734 }
1735
1736 result = create_pim_config(tgen, TOPO, input_dict)
1737 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1738
1739 step("r1: Verify RP info")
1740 dut = "r1"
1741 rp_address = "1.0.1.17"
1742 iif = "lo"
1743 result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_ADDRESS, iif, rp_address, SOURCE)
1744 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1745
1746 step("r5: Send multicast traffic for group 225.1.1.1")
1747 result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
1748 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1749
1750 step("r0: Send IGMP join")
1751 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
1752 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1753
1754 step("r1: Verify IGMP groups")
1755 oif = "r1-r0-eth0"
1756 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
1757 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1758
1759 step("r1: Verify (*, G) upstream IIF interface")
1760 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
1761 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1762
1763 step("r1: Verify (*, G) upstream join state and join timer")
1764 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
1765 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1766
1767 step("r1: Verify (*, G) ip mroutes")
1768 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
1769 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1770
1771 step("r1: Verify (S, G) upstream IIF interface")
1772 iif = "r1-r3-eth2"
1773 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
1774 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1775
1776 step("r1: Verify (S, G) upstream join state and join timer")
1777 result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
1778 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1779
1780 step("r1: Verify (S, G) ip mroutes")
1781 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
1782 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1783
1784 step("r3: Verify (S, G) upstream IIF interface")
1785 dut = "r3"
1786 iif = "r3-r5-eth3"
1787 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
1788 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1789
1790 step("r3: Verify (S, G) upstream join state and join timer")
1791 result = verify_join_state_and_timer(
1792 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False
1793 )
1794 assert result is not True, (
1795 "Testcase {} : Failed \n "
1796 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
1797 tc_name, result
1798 )
1799 )
1800
1801 step("r3: Verify (S, G) ip mroutes")
1802 oif = "r3-r1-eth0"
1803 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
1804 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1805
1806 # Uncomment next line for debugging
1807 # tgen.mininet_cli()
1808
1809 write_test_footer(tc_name)
1810
1811
1812 def test_RP_configured_as_FHR_1_p1(request):
1813 """
1814 TC_22_1_P1: Verify OIF and RFP for (*,G) and (S,G) when static RP configure
1815 in FHR router
1816
1817 Topology used:
1818 ________r2_____
1819 | |
1820 iperf | | iperf
1821 r0-----r1-------------r3-----r5
1822
1823 r1 : LHR
1824 r3 : FHR/RP
1825 """
1826
1827 tgen = get_topogen()
1828 tc_name = request.node.name
1829 write_test_header(tc_name)
1830
1831 # Don"t run this test if we have any failure.
1832 if tgen.routers_have_failure():
1833 pytest.skip(tgen.errors)
1834
1835 step("Creating configuration from JSON")
1836 reset_config_on_routers(tgen)
1837 app_helper.stop_all_hosts()
1838 clear_ip_mroute(tgen)
1839 clear_ip_pim_interface_traffic(tgen, TOPO)
1840
1841 step("Enable IGMP on r1 interface")
1842 step("Configure RP on r2 (loopback interface) for the group range" " 225.1.1.0/24")
1843 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
1844 step("Send the IGMP join from r0")
1845 step("Send multicast traffic from r5")
1846
1847 step("r1, r2, r3, r4: Delete existing RP configuration" "configure r3(FHR) as RP")
1848 input_dict = {
1849 "r1": {
1850 "pim": {
1851 "rp": [
1852 {
1853 "rp_addr": "1.0.2.17",
1854 "group_addr_range": GROUP_RANGE_ALL,
1855 "delete": True,
1856 }
1857 ]
1858 }
1859 },
1860 "r2": {
1861 "pim": {
1862 "rp": [
1863 {
1864 "rp_addr": "1.0.2.17",
1865 "group_addr_range": GROUP_RANGE_ALL,
1866 "delete": True,
1867 }
1868 ]
1869 }
1870 },
1871 "r3": {
1872 "pim": {
1873 "rp": [
1874 {
1875 "rp_addr": "1.0.2.17",
1876 "group_addr_range": GROUP_RANGE_ALL,
1877 "delete": True,
1878 }
1879 ]
1880 }
1881 },
1882 "r4": {
1883 "pim": {
1884 "rp": [
1885 {
1886 "rp_addr": "1.0.2.17",
1887 "group_addr_range": GROUP_RANGE_ALL,
1888 "delete": True,
1889 }
1890 ]
1891 }
1892 },
1893 }
1894 result = create_pim_config(tgen, TOPO, input_dict)
1895 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1896
1897 step("r1, r2, r3, r4: Configure r3(FHR) as RP")
1898 input_dict = {
1899 "r1": {
1900 "pim": {
1901 "rp": [
1902 {
1903 "rp_addr": "1.0.3.17",
1904 "group_addr_range": GROUP_RANGE_ALL,
1905 }
1906 ]
1907 }
1908 },
1909 "r2": {
1910 "pim": {
1911 "rp": [
1912 {
1913 "rp_addr": "1.0.3.17",
1914 "group_addr_range": GROUP_RANGE_ALL,
1915 }
1916 ]
1917 }
1918 },
1919 "r3": {
1920 "pim": {
1921 "rp": [
1922 {
1923 "rp_addr": "1.0.3.17",
1924 "group_addr_range": GROUP_RANGE_ALL,
1925 }
1926 ]
1927 }
1928 },
1929 "r4": {
1930 "pim": {
1931 "rp": [
1932 {
1933 "rp_addr": "1.0.3.17",
1934 "group_addr_range": GROUP_RANGE_ALL,
1935 }
1936 ]
1937 }
1938 },
1939 }
1940
1941 result = create_pim_config(tgen, TOPO, input_dict)
1942 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1943
1944 step("r1: Verify RP info")
1945 dut = "r1"
1946 rp_address = "1.0.3.17"
1947 iif = "r1-r3-eth2"
1948 result = verify_pim_rp_info(
1949 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
1950 )
1951 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1952
1953 step("r0: Send IGMP join")
1954 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
1955 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1956
1957 step("r0: Verify IGMP groups")
1958 oif = "r1-r0-eth0"
1959 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
1960 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1961
1962 step("r5: Send multicast traffic for group 225.1.1.1")
1963 result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
1964 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1965
1966 step("r1: Verify (*, G) upstream IIF interface")
1967 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
1968 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1969
1970 step("r1: Verify (*, G) upstream join state and join timer")
1971 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
1972 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1973
1974 step("r1: Verify (*, G) ip mroutes")
1975 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
1976 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1977
1978 step("r1: Verify (S, G) upstream IIF interface")
1979 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
1980 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1981
1982 step("r1: Verify (S, G) upstream join state and join timer")
1983 result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
1984 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1985
1986 step("r1: Verify (S, G) ip mroutes")
1987 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
1988 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1989
1990 step("r3: Verify (S, G) upstream IIF interface")
1991 dut = "r3"
1992 iif = "r3-r5-eth3"
1993 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
1994 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1995
1996 step("r3: Verify (S, G) upstream join state and join timer")
1997 result = verify_join_state_and_timer(
1998 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False
1999 )
2000 assert result is not True, (
2001 "Testcase {} : Failed \n "
2002 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
2003 tc_name, result
2004 )
2005 )
2006
2007 step("r3: Verify (S, G) ip mroutes")
2008 oif = "r3-r1-eth0"
2009 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
2010 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2011
2012 # Uncomment next line for debugging
2013 # tgen.mininet_cli()
2014
2015 write_test_footer(tc_name)
2016
2017
2018 def test_RP_configured_as_FHR_2_p2(request):
2019 """
2020 TC_22_2_P2: Verify OIF and RFP for (*,G) and (S,G) when static RP configure
2021 in FHR router
2022
2023 Topology used:
2024 ________r2_____
2025 | |
2026 iperf | | iperf
2027 r0-----r1-------------r3-----r5
2028
2029 r1 : LHR
2030 r3 : FHR/RP
2031 """
2032 tgen = get_topogen()
2033 tc_name = request.node.name
2034 write_test_header(tc_name)
2035
2036 # Don"t run this test if we have any failure.
2037 if tgen.routers_have_failure():
2038 pytest.skip(tgen.errors)
2039
2040 step("Creating configuration from JSON")
2041 reset_config_on_routers(tgen)
2042 app_helper.stop_all_hosts()
2043 clear_ip_mroute(tgen)
2044 clear_ip_pim_interface_traffic(tgen, TOPO)
2045
2046 step("Enable IGMP on r1 interface")
2047 step("Configure RP on r2 (loopback interface) for the group range" " 225.1.1.0/24")
2048 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
2049 step("Send multicast traffic from r5")
2050 step("Send the IGMP join from r0")
2051
2052 step("r1, r2, r3, r4: Delete existing RP configuration" "configure r3(FHR) as RP")
2053 input_dict = {
2054 "r1": {
2055 "pim": {
2056 "rp": [
2057 {
2058 "rp_addr": "1.0.2.17",
2059 "group_addr_range": GROUP_RANGE_ALL,
2060 "delete": True,
2061 }
2062 ]
2063 }
2064 },
2065 "r2": {
2066 "pim": {
2067 "rp": [
2068 {
2069 "rp_addr": "1.0.2.17",
2070 "group_addr_range": GROUP_RANGE_ALL,
2071 "delete": True,
2072 }
2073 ]
2074 }
2075 },
2076 "r3": {
2077 "pim": {
2078 "rp": [
2079 {
2080 "rp_addr": "1.0.2.17",
2081 "group_addr_range": GROUP_RANGE_ALL,
2082 "delete": True,
2083 }
2084 ]
2085 }
2086 },
2087 "r4": {
2088 "pim": {
2089 "rp": [
2090 {
2091 "rp_addr": "1.0.2.17",
2092 "group_addr_range": GROUP_RANGE_ALL,
2093 "delete": True,
2094 }
2095 ]
2096 }
2097 },
2098 }
2099
2100 result = create_pim_config(tgen, TOPO, input_dict)
2101 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2102
2103 step("r1, r2, r3, r4: Configure r3(FHR) as RP")
2104 input_dict = {
2105 "r1": {
2106 "pim": {
2107 "rp": [
2108 {
2109 "rp_addr": "1.0.3.17",
2110 "group_addr_range": GROUP_RANGE_ALL,
2111 }
2112 ]
2113 }
2114 },
2115 "r2": {
2116 "pim": {
2117 "rp": [
2118 {
2119 "rp_addr": "1.0.3.17",
2120 "group_addr_range": GROUP_RANGE_ALL,
2121 }
2122 ]
2123 }
2124 },
2125 "r3": {
2126 "pim": {
2127 "rp": [
2128 {
2129 "rp_addr": "1.0.3.17",
2130 "group_addr_range": GROUP_RANGE_ALL,
2131 }
2132 ]
2133 }
2134 },
2135 "r4": {
2136 "pim": {
2137 "rp": [
2138 {
2139 "rp_addr": "1.0.3.17",
2140 "group_addr_range": GROUP_RANGE_ALL,
2141 }
2142 ]
2143 }
2144 },
2145 }
2146
2147 result = create_pim_config(tgen, TOPO, input_dict)
2148 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2149
2150 step("r1: Verify RP info")
2151 dut = "r1"
2152 rp_address = "1.0.3.17"
2153 iif = "r1-r3-eth2"
2154 result = verify_pim_rp_info(
2155 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
2156 )
2157 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2158
2159 step("r5: Send multicast traffic for group 225.1.1.1")
2160 result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
2161 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2162
2163 step("r0: Send IGMP join")
2164 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
2165 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2166
2167 step("r0: Verify IGMP groups")
2168 oif = "r1-r0-eth0"
2169 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
2170 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2171
2172 step("r1: Verify (*, G) upstream IIF interface")
2173 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
2174 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2175
2176 step("r1: Verify (*, G) upstream join state and join timer")
2177 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
2178 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2179
2180 step("r1: Verify (*, G) ip mroutes")
2181 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
2182 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2183
2184 step("r1: Verify (S, G) upstream IIF interface")
2185 iif = "r1-r3-eth2"
2186 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
2187 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2188
2189 step("r1: Verify (S, G) upstream join state and join timer")
2190 result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
2191 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2192
2193 step("r1: Verify (S, G) ip mroutes")
2194 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
2195 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2196
2197 step("r3: Verify (S, G) upstream IIF interface")
2198 dut = "r3"
2199 iif = "r3-r5-eth3"
2200 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
2201 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2202
2203 step("r3: Verify (S, G) upstream join state and join timer")
2204 result = verify_join_state_and_timer(
2205 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False
2206 )
2207 assert result is not True, (
2208 "Testcase {} : Failed \n "
2209 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
2210 tc_name, result
2211 )
2212 )
2213
2214 step("r3: Verify (S, G) ip mroutes")
2215 oif = "r3-r1-eth0"
2216 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
2217 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2218
2219 # Uncomment next line for debugging
2220 # tgen.mininet_cli()
2221
2222 write_test_footer(tc_name)
2223
2224
2225 def test_SPT_RPT_path_different_p1(request):
2226 """
2227 TC_23_P1: Verify (*,G) and (S,G) populated correctly when RPT and SPT path
2228 are different
2229
2230 Topology used:
2231 ________r2_____
2232 | |
2233 iperf | | iperf
2234 r0-----r1-------------r3-----r5
2235
2236 r1: LHR
2237 r2: RP
2238 r3: FHR
2239 """
2240
2241 tgen = get_topogen()
2242 tc_name = request.node.name
2243 write_test_header(tc_name)
2244
2245 # Don"t run this test if we have any failure.
2246 if tgen.routers_have_failure():
2247 pytest.skip(tgen.errors)
2248
2249 step("Creating configuration from JSON")
2250 reset_config_on_routers(tgen)
2251 app_helper.stop_all_hosts()
2252 clear_ip_mroute(tgen)
2253 clear_ip_pim_interface_traffic(tgen, TOPO)
2254
2255 step("Enable IGMP on r1 interface and send IGMP join (225.1.1.1) to r1")
2256 step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4")
2257 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
2258 step("Send multicast traffic from r3")
2259
2260 step("r2: Verify RP info")
2261 dut = "r2"
2262 rp_address = "1.0.2.17"
2263 iif = "lo"
2264 result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_ADDRESS, iif, rp_address, SOURCE)
2265 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2266
2267 step("r0: Send IGMP join")
2268 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
2269 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2270
2271 step("r1: Verify IGMP groups")
2272 dut = "r1"
2273 oif = "r1-r0-eth0"
2274 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
2275 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2276
2277 step("r5: Send multicast traffic for group 225.1.1.1")
2278 result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
2279 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2280
2281 step("r1: Verify (*, G) upstream IIF interface")
2282 iif = "r1-r2-eth1"
2283 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
2284 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2285
2286 step("r1: Verify (*, G) upstream join state and join timer")
2287 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
2288 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2289
2290 step("r1: Verify (*, G) ip mroutes")
2291 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
2292 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2293
2294 step("r1: Verify (S, G) upstream IIF interface")
2295 iif = "r1-r3-eth2"
2296 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
2297 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2298
2299 step("r1: Verify (S, G) upstream join state and join timer")
2300 result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
2301 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2302
2303 step("r1: Verify (S, G) ip mroutes")
2304 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
2305 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2306
2307 step("r2: Verify (*, G) upstream IIF interface")
2308 dut = "r2"
2309 iif = "lo"
2310 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
2311 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2312
2313 step("r2: Verify (*, G) upstream join state and join timer")
2314 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
2315 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2316
2317 step("r2: Verify (*, G) ip mroutes")
2318 oif = "r2-r1-eth0"
2319 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
2320 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2321
2322 step("r3: Verify (S, G) upstream IIF interface")
2323 dut = "r3"
2324 iif = "r3-r5-eth3"
2325 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
2326 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2327
2328 step("r3: Verify (S, G) upstream join state and join timer")
2329 result = verify_join_state_and_timer(
2330 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False
2331 )
2332 assert result is not True, (
2333 "Testcase {} : Failed \n "
2334 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
2335 tc_name, result
2336 )
2337 )
2338
2339 step("r3: Verify (S, G) ip mroutes")
2340 oif = "r3-r1-eth0"
2341 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
2342 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2343
2344 step("r2: Verify (S, G) upstream IIF interface")
2345 dut = "r2"
2346 iif = "r2-r3-eth1"
2347 result = verify_upstream_iif(
2348 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, joinState="NotJoined"
2349 )
2350 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2351
2352 step("r2: Verify (S, G) upstream join state and join timer")
2353 result = verify_join_state_and_timer(
2354 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False
2355 )
2356 assert result is not True, (
2357 "Testcase {} : Failed \n "
2358 "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
2359 tc_name, result
2360 )
2361 )
2362
2363 step("r2: Verify (S, G) ip mroutes")
2364 oif = "none"
2365 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
2366 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2367
2368 # Uncomment next line for debugging
2369 # tgen.mininet_cli()
2370
2371 write_test_footer(tc_name)
2372
2373
2374 def test_clear_pim_configuration_p1(request):
2375 """
2376 TC_25_P1: Verify (*,G) and (S,G) populated correctly after clearing the
2377 PIM,IGMP and mroutes joins
2378
2379 Topology used:
2380 ________r2_____
2381 | |
2382 iperf | | iperf
2383 r0-----r1-------------r3-----r5
2384 | |
2385 |_____________|
2386 r4
2387 r1 : LHR
2388 r2 : RP
2389 r3 : FHR
2390 """
2391
2392 tgen = get_topogen()
2393 tc_name = request.node.name
2394 write_test_header(tc_name)
2395
2396 # Don"t run this test if we have any failure.
2397 if tgen.routers_have_failure():
2398 pytest.skip(tgen.errors)
2399
2400 step("Creating configuration from JSON")
2401 reset_config_on_routers(tgen)
2402 app_helper.stop_all_hosts()
2403 clear_ip_mroute(tgen)
2404 clear_ip_pim_interface_traffic(tgen, TOPO)
2405
2406 step("Enable IGMP on r1 interface")
2407 step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4")
2408 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
2409 step("Send the IGMP join from r0")
2410 step("Send multicast traffic from r5")
2411
2412 step("r2: Verify RP info")
2413 dut = "r2"
2414 rp_address = "1.0.2.17"
2415 oif = "lo"
2416 result = verify_pim_rp_info(
2417 tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE
2418 )
2419 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2420
2421 step("r0: Send IGMP join")
2422 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
2423 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2424
2425 step("r1: Verify IGMP groups")
2426 dut = "r1"
2427 iif = "r1-r0-eth0"
2428 result = verify_igmp_groups(tgen, dut, iif, GROUP_ADDRESS)
2429 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2430
2431 step("r5: Send multicast traffic for group 225.1.1.1")
2432 result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
2433 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2434
2435 step("r1: Verify (*, G) upstream IIF interface")
2436 dut = "r1"
2437 iif = "r1-r2-eth1"
2438 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
2439 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2440
2441 step("r1: Verify (*, G) upstream join state and join timer")
2442 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
2443 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2444
2445 step("r1: Verify (*, G) ip mroutes")
2446 oif = "r1-r0-eth0"
2447 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
2448 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2449
2450 step("r1: Verify IGMP groups timer restarted")
2451 result = clear_ip_igmp_interfaces(tgen, dut)
2452 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2453
2454 step("r1: Verify PIM neighbor timer restarted")
2455 result = clear_ip_pim_interfaces(tgen, dut)
2456 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2457
2458 step("r1: Verify PIM mroute timer restarted")
2459 result = clear_ip_mroute_verify(tgen, dut)
2460 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2461
2462 # Uncomment next line for debugging
2463 # tgen.mininet_cli()
2464
2465 write_test_footer(tc_name)
2466
2467
2468 def test_restart_pimd_process_p2(request):
2469 """
2470 TC_26_P2: Restart the PIMd process and verify PIM upstream and mroutes
2471 entries
2472 Topology used:
2473 ________r2_____
2474 | |
2475 iperf | | iperf
2476 r0-----r1-------------r3-----r5
2477 | |
2478 |_____________|
2479 r4
2480 r1 : LHR
2481 r2 : RP
2482 r3 : FHR
2483 """
2484
2485 tgen = get_topogen()
2486 tc_name = request.node.name
2487 write_test_header(tc_name)
2488
2489 # Don"t run this test if we have any failure.
2490 if tgen.routers_have_failure():
2491 pytest.skip(tgen.errors)
2492
2493 step("Creating configuration from JSON")
2494 reset_config_on_routers(tgen)
2495 app_helper.stop_all_hosts()
2496 clear_ip_mroute(tgen)
2497 clear_ip_pim_interface_traffic(tgen, TOPO)
2498
2499 step("Enable IGMP on r1 interface and send IGMP join (225.1.1.1) to R1")
2500 step("Configure RP on r3 (loopback interface) for the group range" " 224.0.0.0/4")
2501 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
2502 step("Send multicast traffic from R3")
2503 step("Restart the PIMd process")
2504
2505 step("r2: Verify RP info")
2506 dut = "r2"
2507 rp_address = "1.0.2.17"
2508 oif = "lo"
2509 result = verify_pim_rp_info(
2510 tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE
2511 )
2512 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2513
2514 step("r0: Send IGMP join")
2515 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
2516 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2517
2518 step("r1: Verify IGMP groups")
2519 dut = "r1"
2520 oif = "r1-r0-eth0"
2521 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
2522 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2523
2524 step("r5: Send multicast traffic for group 225.1.1.1")
2525 result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
2526 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2527
2528 step("r1: Verify (*, G) upstream IIF interface")
2529 iif = "r1-r2-eth1"
2530 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
2531 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2532
2533 step("r1: Verify (*, G) upstream join state and join timer")
2534 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
2535 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2536
2537 step("r1: Verify (*, G) ip mroutes")
2538 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
2539 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2540
2541 step("r1: Verify (S, G) upstream IIF interface")
2542 iif = "r1-r3-eth2"
2543 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
2544 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2545
2546 step("r1: Verify (S, G) upstream join state and join timer")
2547 result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
2548 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2549
2550 step("r1: Verify (S, G) ip mroutes")
2551 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
2552 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2553
2554 step("r2: Verify (*, G) upstream IIF interface")
2555 dut = "r2"
2556 iif = "lo"
2557 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
2558 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2559
2560 step("r2: Verify (*, G) upstream join state and join timer")
2561 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
2562 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2563
2564 step("r2: Verify (*, G) ip mroutes")
2565 oif = "r2-r1-eth0"
2566 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
2567 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2568
2569 step("r3: Verify (S, G) upstream IIF interface")
2570 dut = "r3"
2571 iif = "r3-r5-eth3"
2572 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
2573 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2574
2575 step("r3: Verify (S, G) upstream join state and join timer")
2576 result = verify_join_state_and_timer(
2577 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False
2578 )
2579 assert result is not True, (
2580 "Testcase {} : Failed \n "
2581 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
2582 tc_name, result
2583 )
2584 )
2585
2586 step("r3: Verify (S, G) ip mroutes")
2587 oif = "r3-r1-eth0"
2588 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
2589 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2590
2591 dut = "r1"
2592 iif = "r1-r2-eth1"
2593 oil = "r1-r0-eth0"
2594 logger.info("waiting for 10 sec to make sure old mroute time is higher")
2595 sleep(10)
2596 # Why do we then wait 60 seconds below before checking the routes?
2597 uptime_before = verify_ip_mroutes(
2598 tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, mwait=60
2599 )
2600 assert isinstance(uptime_before, dict), "Testcase{} : Failed Error: {}".format(
2601 tc_name, result
2602 )
2603
2604 step("r1: Kill pimd process")
2605 kill_router_daemons(tgen, "r1", ["pimd"])
2606
2607 step("r1 : Start pimd process")
2608 start_router_daemons(tgen, "r1", ["pimd"])
2609
2610 logger.info("Waiting for 5sec to get PIMd restarted and mroute" " re-learned..")
2611 sleep(5)
2612
2613 # Why do we then wait 10 seconds below before checking the routes?
2614 uptime_after = verify_ip_mroutes(
2615 tgen, dut, STAR, GROUP_ADDRESS, iif, oil, return_uptime=True, mwait=10
2616 )
2617 assert isinstance(uptime_after, dict), "Testcase{} : Failed Error: {}".format(
2618 tc_name, result
2619 )
2620
2621 result = verify_mroute_repopulated(uptime_before, uptime_after)
2622 assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result)
2623
2624 write_test_footer(tc_name)
2625
2626
2627 def test_multiple_groups_same_RP_address_p2(request):
2628 """
2629 TC_27_P2: Configure multiple groups (10 grps) with same RP address
2630
2631 Topology used:
2632 ________r2_____
2633 | |
2634 iperf | | iperf
2635 r0-----r1-------------r3-----r5
2636
2637 r1 : LHR
2638 r2 : RP
2639 r3 : FHR
2640 """
2641
2642 tgen = get_topogen()
2643 tc_name = request.node.name
2644 write_test_header(tc_name)
2645
2646 # Don"t run this test if we have any failure.
2647 if tgen.routers_have_failure():
2648 pytest.skip(tgen.errors)
2649
2650 step("Creating configuration from JSON")
2651 reset_config_on_routers(tgen)
2652 app_helper.stop_all_hosts()
2653 clear_ip_mroute(tgen)
2654 clear_ip_pim_interface_traffic(tgen, TOPO)
2655
2656 step("Enable IGMP on r1 interface and send IGMP join (225.1.1.1) to r1")
2657 step("Configure RP on r2 (loopback interface) for the group range" "225.1.1.0/24")
2658 step("Enable the PIM on all the interfaces of r1-r2-r3")
2659 step("Send multicast traffic from r5 to all the groups")
2660 step("r1 : Remove the groups to RP mapping one by one")
2661 step("r1: Shut the upstream interfaces")
2662 step("r1: No shut the upstream interfaces")
2663 step("r1: Configure the RP again")
2664 step("r1: Shut the receiver interfaces")
2665 step("r1: No Shut the receiver interfaces")
2666 step("r2: Verify RP info")
2667
2668 step("r2: verify rp-info")
2669 dut = "r2"
2670 rp_address = "1.0.2.17"
2671 oif = "lo"
2672 result = verify_pim_rp_info(
2673 tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE
2674 )
2675 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2676
2677 group_address_list = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2
2678 step("r0: Send IGMP join for 10 groups")
2679 result = app_helper.run_join("r0", group_address_list, "r1")
2680 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2681
2682 step("r1: Verify IGMP groups")
2683 dut = "r1"
2684 oif = "r1-r0-eth0"
2685 result = verify_igmp_groups(tgen, dut, oif, group_address_list)
2686 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2687
2688 step("r5: Send multicast traffic for group 225.1.1.1")
2689 result = app_helper.run_traffic("r5", group_address_list, "r3")
2690 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2691
2692 step("r1: Verify (*, G) upstream IIF interface")
2693 dut = "r1"
2694 iif = "r1-r2-eth1"
2695 result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list)
2696 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2697
2698 step("r1: Verify (*, G) upstream join state and join timer")
2699 result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list)
2700 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2701
2702 step("r1: Verify (*, G) ip mroutes")
2703 oif = "r1-r0-eth0"
2704 result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif)
2705 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2706
2707 step("r1: Verify (S, G) upstream IIF interface")
2708 iif = "r1-r3-eth2"
2709 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list)
2710 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2711
2712 step("r1: Verify (S, G) upstream join state and join timer")
2713 result = verify_join_state_and_timer(
2714 tgen, dut, iif, SOURCE_ADDRESS, group_address_list
2715 )
2716 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2717
2718 step("r1: Verify (S, G) ip mroutes")
2719 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
2720 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2721
2722 step("r2: Verify (*, G) upstream IIF interface")
2723 dut = "r2"
2724 iif = "lo"
2725 result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list)
2726 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2727
2728 step("r2: Verify (*, G) upstream join state and join timer")
2729 result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list)
2730 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2731
2732 step("r2: Verify (*, G) ip mroutes")
2733 oif = "r2-r1-eth0"
2734 result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif)
2735 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2736
2737 step("r3: Verify (S, G) upstream IIF interface")
2738 dut = "r3"
2739 iif = "r3-r5-eth3"
2740 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list)
2741 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2742
2743 step("r3: Verify (S, G) upstream join state and join timer")
2744 result = verify_join_state_and_timer(
2745 tgen, dut, iif, SOURCE_ADDRESS, group_address_list, expected=False
2746 )
2747 assert result is not True, (
2748 "Testcase {} : Failed \n "
2749 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
2750 tc_name, result
2751 )
2752 )
2753
2754 step("r3: Verify (S, G) ip mroutes")
2755 oif = "r3-r1-eth0"
2756 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
2757 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2758
2759 step("r2: Verify (S, G) upstream IIF interface")
2760 dut = "r2"
2761 iif = "r2-r3-eth1"
2762 result = verify_upstream_iif(
2763 tgen, dut, iif, SOURCE_ADDRESS, group_address_list, joinState="NotJoined"
2764 )
2765 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2766
2767 step("r2: Verify (S, G) upstream join state and join timer")
2768 result = verify_join_state_and_timer(
2769 tgen, dut, iif, SOURCE_ADDRESS, group_address_list, expected=False
2770 )
2771 assert result is not True, (
2772 "Testcase {} : Failed \n "
2773 "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
2774 tc_name, result
2775 )
2776 )
2777
2778 step("r2: Verify (S, G) ip mroutes")
2779 oif = "none"
2780 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
2781 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2782
2783 step("r1: Delete RP configuration")
2784 input_dict = {
2785 "r1": {
2786 "pim": {
2787 "rp": [
2788 {
2789 "rp_addr": "1.0.2.17",
2790 "group_addr_range": GROUP_RANGE_ALL,
2791 "delete": True,
2792 }
2793 ]
2794 }
2795 }
2796 }
2797
2798 result = create_pim_config(tgen, TOPO, input_dict)
2799 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2800
2801 step("r1: Shut the interface r1-r2-eth1 from R1 to R2")
2802 dut = "r1"
2803 intf = "r1-r2-eth1"
2804 shutdown_bringup_interface(tgen, dut, intf, False)
2805
2806 step("r1: No Shut the interface r1-r2-eth1 from R1 to R2")
2807 intf = "r1-r2-eth1"
2808 shutdown_bringup_interface(tgen, dut, intf, True)
2809
2810 step("r1: Configure RP")
2811 input_dict = {
2812 "r1": {
2813 "pim": {
2814 "rp": [
2815 {
2816 "rp_addr": "1.0.2.17",
2817 "group_addr_range": GROUP_RANGE_ALL,
2818 }
2819 ]
2820 }
2821 }
2822 }
2823
2824 result = create_pim_config(tgen, TOPO, input_dict)
2825 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2826
2827 step("r1: Shut the interface r1-r0-eth0 from R1 to R2")
2828 intf = "r1-r0-eth0"
2829 shutdown_bringup_interface(tgen, dut, intf, False)
2830
2831 step("r1: No Shut the interface r1-r0-eth0 from R1 to R2")
2832 intf = "r1-r0-eth0"
2833 shutdown_bringup_interface(tgen, dut, intf, True)
2834
2835 step("r1: Verify (*, G) upstream IIF interface")
2836 dut = "r1"
2837 iif = "r1-r2-eth1"
2838 result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list)
2839 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2840
2841 step("r1: Verify (*, G) upstream join state and join timer")
2842 result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list)
2843 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2844
2845 step("r1: Verify (*, G) ip mroutes")
2846 oif = "r1-r0-eth0"
2847 result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif)
2848 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2849
2850 step("r1: Verify (S, G) upstream IIF interface")
2851 iif = "r1-r3-eth2"
2852 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list)
2853 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2854
2855 step("r1: Verify (S, G) upstream join state and join timer")
2856 result = verify_join_state_and_timer(
2857 tgen, dut, iif, SOURCE_ADDRESS, group_address_list
2858 )
2859 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2860
2861 step("r1: Verify (S, G) ip mroutes")
2862 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
2863 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2864
2865 step("r2: Verify (*, G) upstream IIF interface")
2866 dut = "r2"
2867 iif = "lo"
2868 result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list)
2869 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2870
2871 step("r2: Verify (*, G) upstream join state and join timer")
2872 result = verify_join_state_and_timer(tgen, dut, iif, STAR, group_address_list)
2873 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2874
2875 step("r2: Verify (*, G) ip mroutes")
2876 oif = "r2-r1-eth0"
2877 result = verify_ip_mroutes(tgen, dut, STAR, group_address_list, iif, oif)
2878 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2879
2880 step("r2: Verify (S, G) upstream IIF interface")
2881 dut = "r2"
2882 iif = "r2-r3-eth1"
2883 result = verify_upstream_iif(
2884 tgen, dut, iif, SOURCE_ADDRESS, group_address_list, joinState="NotJoined"
2885 )
2886 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2887
2888 step("r2: Verify (S, G) upstream join state and join timer")
2889 result = verify_join_state_and_timer(
2890 tgen, dut, iif, SOURCE_ADDRESS, group_address_list, expected=False
2891 )
2892 assert result is not True, (
2893 "Testcase {} : Failed \n "
2894 "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
2895 tc_name, result
2896 )
2897 )
2898
2899 step("r2: Verify (S, G) ip mroutes")
2900 oif = "none"
2901 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
2902 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2903
2904 step("r3: Verify (S, G) upstream IIF interface")
2905 dut = "r3"
2906 iif = "r3-r5-eth3"
2907 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list)
2908 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2909
2910 step("r3: Verify (S, G) upstream join state and join timer")
2911 result = verify_join_state_and_timer(
2912 tgen, dut, iif, SOURCE_ADDRESS, group_address_list, expected=False
2913 )
2914 assert result is not True, (
2915 "Testcase {} : Failed \n "
2916 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
2917 tc_name, result
2918 )
2919 )
2920
2921 step("r3: Verify (S, G) ip mroutes")
2922 oif = "r3-r1-eth0"
2923 result = verify_ip_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
2924 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2925
2926 write_test_footer(tc_name)
2927
2928
2929 def test_multiple_groups_different_RP_address_p2(request):
2930 """
2931 TC_28_P2: Verify IIF and OIL in updated in mroute when upstream interface
2932 configure as RP
2933
2934 Topology used:
2935 ________r2_____
2936 | |
2937 iperf | | iperf
2938 r0-----r1-------------r3-----r5
2939 | |
2940 |_____________|
2941 r4
2942 r1 : LHR
2943 r2 & r4 : RP
2944 r3 : FHR
2945 """
2946
2947 tgen = get_topogen()
2948 tc_name = request.node.name
2949 write_test_header(tc_name)
2950
2951 # Don"t run this test if we have any failure.
2952 if tgen.routers_have_failure():
2953 pytest.skip(tgen.errors)
2954
2955 step("Creating configuration from JSON")
2956 reset_config_on_routers(tgen)
2957 app_helper.stop_all_hosts()
2958 clear_ip_mroute(tgen)
2959 clear_ip_pim_interface_traffic(tgen, TOPO)
2960
2961 step("Delete existing RP configuration")
2962 input_dict = {
2963 "r2": {
2964 "pim": {
2965 "rp": [
2966 {
2967 "rp_addr": "1.0.2.17",
2968 "group_addr_range": GROUP_RANGE_ALL,
2969 "delete": True,
2970 }
2971 ]
2972 }
2973 }
2974 }
2975 result = create_pim_config(tgen, TOPO, input_dict)
2976 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
2977
2978 input_dict = {
2979 "r2": {
2980 "pim": {
2981 "rp": [
2982 {
2983 "rp_addr": "1.0.2.17",
2984 "group_addr_range": GROUP_RANGE_LIST_1,
2985 }
2986 ]
2987 }
2988 },
2989 "r4": {
2990 "pim": {
2991 "rp": [
2992 {
2993 "rp_addr": "1.0.4.17",
2994 "group_addr_range": GROUP_RANGE_LIST_2,
2995 }
2996 ]
2997 }
2998 },
2999 }
3000 result = create_pim_config(tgen, TOPO, input_dict)
3001 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3002
3003 step("r2: Verify RP info")
3004 dut = "r2"
3005 rp_address = "1.0.2.17"
3006 oif = "lo"
3007 result = verify_pim_rp_info(
3008 tgen, TOPO, dut, GROUP_RANGE_LIST_1, oif, rp_address, SOURCE
3009 )
3010 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3011
3012 step("r4: Verify RP info")
3013 dut = "r4"
3014 rp_address = "1.0.4.17"
3015 result = verify_pim_rp_info(
3016 tgen, TOPO, dut, GROUP_RANGE_LIST_2, oif, rp_address, SOURCE
3017 )
3018 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3019
3020 group_address_list = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2
3021 step("r0: Send IGMP join")
3022 result = app_helper.run_join("r0", group_address_list, "r1")
3023 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3024
3025 step("r1: Verify IGMP groups")
3026 dut = "r1"
3027 oif = "r1-r0-eth0"
3028 result = verify_igmp_groups(tgen, dut, oif, group_address_list)
3029 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3030
3031 step("r5: Send multicast traffic for group 225.1.1.1")
3032 result = app_helper.run_traffic("r5", group_address_list, "r3")
3033 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3034
3035 step("r1: Verify (*, G) upstream IIF interface")
3036 dut = "r1"
3037 iif = "r1-r2-eth1"
3038 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
3039 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3040
3041 step("r1: Verify (*, G) upstream join state and join timer")
3042 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
3043 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3044
3045 step("r1: Verify (*, G) ip mroutes")
3046 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_1, iif, oif)
3047 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3048
3049 step("r1: Verify (S, G) upstream IIF interface")
3050 iif = "r1-r3-eth2"
3051 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1)
3052 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3053
3054 step("r1: Verify (S, G) upstream join state and join timer")
3055 result = verify_join_state_and_timer(
3056 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1
3057 )
3058 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3059
3060 step("r1: Verify (S, G) ip mroutes")
3061 result = verify_ip_mroutes(
3062 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif
3063 )
3064 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3065
3066 step("r2: Verify (*, G) upstream IIF interface")
3067 dut = "r2"
3068 iif = "lo"
3069 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
3070 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3071
3072 step("r2: Verify (*, G) upstream join state and join timer")
3073 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
3074 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3075
3076 step("r2: Verify (*, G) ip mroutes")
3077 oif = "r2-r1-eth0"
3078 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_1, iif, oif)
3079 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3080
3081 step("r2: Verify (S, G) upstream IIF interface")
3082 iif = "r2-r3-eth1"
3083 result = verify_upstream_iif(
3084 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, joinState="NotJoined"
3085 )
3086 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3087
3088 step("r2: Verify (S, G) upstream join state and join timer")
3089 result = verify_join_state_and_timer(
3090 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False
3091 )
3092 assert result is not True, (
3093 "Testcase {} : Failed \n "
3094 "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
3095 tc_name, result
3096 )
3097 )
3098
3099 step("r2: Verify (S, G) ip mroutes")
3100 oif = "none"
3101 result = verify_ip_mroutes(
3102 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif
3103 )
3104 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3105
3106 step("r3: Verify (S, G) upstream IIF interface")
3107 dut = "r3"
3108 iif = "r3-r5-eth3"
3109 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1)
3110 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3111
3112 step("r3: Verify (S, G) upstream join state and join timer")
3113 result = verify_join_state_and_timer(
3114 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False
3115 )
3116 assert result is not True, (
3117 "Testcase {} : Failed \n "
3118 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
3119 tc_name, result
3120 )
3121 )
3122
3123 step("r3: Verify (S, G) ip mroutes")
3124 oif = "r3-r1-eth0"
3125 result = verify_ip_mroutes(
3126 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif
3127 )
3128 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3129
3130 step("r1: Verify (*, G) upstream IIF interface")
3131 dut = "r1"
3132 iif = "r1-r4-eth3"
3133 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
3134 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3135
3136 step("r1: Verify (*, G) upstream join state and join timer")
3137 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
3138 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3139
3140 step("r1: Verify (*, G) ip mroutes")
3141 oif = "r1-r0-eth0"
3142 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_2, iif, oif)
3143 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3144
3145 step("r1: Verify (S, G) upstream IIF interface")
3146 iif = "r1-r3-eth2"
3147 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2)
3148 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3149
3150 step("r1: Verify (S, G) upstream join state and join timer")
3151 result = verify_join_state_and_timer(
3152 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2
3153 )
3154 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3155
3156 step("r1: Verify (S, G) ip mroutes")
3157 result = verify_ip_mroutes(
3158 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif
3159 )
3160 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3161
3162 step("r4: Verify (*, G) upstream IIF interface")
3163 dut = "r4"
3164 iif = "lo"
3165 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
3166 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3167
3168 step("r4: Verify (*, G) upstream join state and join timer")
3169 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
3170 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3171
3172 step("r4: Verify (*, G) ip mroutes")
3173 oif = "r4-r1-eth0"
3174 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_2, iif, oif)
3175 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3176
3177 step("r4: Verify (S, G) upstream IIF interface")
3178 iif = "r4-r3-eth1"
3179 result = verify_upstream_iif(
3180 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, joinState="NotJoined"
3181 )
3182 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3183
3184 step("r4: Verify (S, G) upstream join state and join timer")
3185 result = verify_join_state_and_timer(
3186 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False
3187 )
3188 assert result is not True, (
3189 "Testcase {} : Failed \n "
3190 "r4: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
3191 tc_name, result
3192 )
3193 )
3194
3195 step("r4: Verify (S, G) ip mroutes")
3196 oif = "none"
3197 result = verify_ip_mroutes(
3198 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif
3199 )
3200 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3201
3202 step("r3: Verify (S, G) upstream IIF interface")
3203 dut = "r3"
3204 iif = "r3-r5-eth3"
3205 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2)
3206 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3207
3208 step("r3: Verify (S, G) upstream join state and join timer")
3209 result = verify_join_state_and_timer(
3210 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False
3211 )
3212 assert result is not True, "Testcase {} :Failed \n Error: {}".format(
3213 tc_name, result
3214 )
3215
3216 step("r3: Verify (S, G) ip mroutes")
3217 oif = "r3-r1-eth0"
3218 result = verify_ip_mroutes(
3219 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif
3220 )
3221 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3222
3223 step("Delete RP configuration")
3224 input_dict = {
3225 "r2": {
3226 "pim": {
3227 "rp": [
3228 {
3229 "rp_addr": "1.0.2.17",
3230 "group_addr_range": GROUP_RANGE_LIST_1,
3231 "delete": True,
3232 }
3233 ]
3234 }
3235 },
3236 "r4": {
3237 "pim": {
3238 "rp": [
3239 {
3240 "rp_addr": "1.0.4.17",
3241 "group_addr_range": GROUP_RANGE_LIST_2,
3242 "delete": True,
3243 }
3244 ]
3245 }
3246 },
3247 }
3248 result = create_pim_config(tgen, TOPO, input_dict)
3249 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3250
3251 step("r1, r2, r3, r4: Re-configure RP")
3252 input_dict = {
3253 "r2": {
3254 "pim": {
3255 "rp": [
3256 {
3257 "rp_addr": "1.0.2.17",
3258 "group_addr_range": GROUP_RANGE_LIST_1,
3259 }
3260 ]
3261 }
3262 },
3263 "r4": {
3264 "pim": {
3265 "rp": [
3266 {
3267 "rp_addr": "1.0.4.17",
3268 "group_addr_range": GROUP_RANGE_LIST_2,
3269 }
3270 ]
3271 }
3272 },
3273 }
3274 result = create_pim_config(tgen, TOPO, input_dict)
3275 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3276
3277 step("r1: Shut the interface r1-r2-eth1 from R1 to R2")
3278 dut = "r1"
3279 intf = "r1-r2-eth1"
3280 shutdown_bringup_interface(tgen, dut, intf, False)
3281
3282 step("r1: No shut the interface r1-r2-eth1 from R1 to R2")
3283 dut = "r1"
3284 intf = "r1-r2-eth1"
3285 shutdown_bringup_interface(tgen, dut, intf, True)
3286
3287 step("r1: Shut the interface r1-r2-eth1 from R1 to R4")
3288 dut = "r1"
3289 intf = "r1-r4-eth3"
3290 shutdown_bringup_interface(tgen, dut, intf, False)
3291
3292 step("r1: No shut the interface r1-r2-eth1 from R1 to r4")
3293 dut = "r1"
3294 intf = "r1-r4-eth3"
3295 shutdown_bringup_interface(tgen, dut, intf, True)
3296
3297 step("r1: Shut the interface r1-r0-eth0 from R1 to R0")
3298 dut = "r1"
3299 intf = "r1-r0-eth0"
3300 shutdown_bringup_interface(tgen, dut, intf, False)
3301
3302 step("r1: No Shut the interface r1-r0-eth0 from R1 to R0")
3303 dut = "r1"
3304 intf = "r1-r0-eth0"
3305 shutdown_bringup_interface(tgen, dut, intf, True)
3306
3307 step("r1: Verify (*, G) upstream IIF interface")
3308 dut = "r1"
3309 iif = "r1-r2-eth1"
3310 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
3311 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3312
3313 step("r1: Verify (*, G) upstream join state and join timer")
3314 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
3315 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3316
3317 step("r1: Verify (*, G) ip mroutes")
3318 oif = "r1-r0-eth0"
3319 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_1, iif, oif)
3320 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3321
3322 step("r1: Verify (S, G) upstream IIF interface")
3323 iif = "r1-r3-eth2"
3324 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1)
3325 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3326
3327 step("r1: Verify (S, G) upstream join state and join timer")
3328 result = verify_join_state_and_timer(
3329 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1
3330 )
3331 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3332
3333 step("r1: Verify (S, G) ip mroutes")
3334 result = verify_ip_mroutes(
3335 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif
3336 )
3337 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3338
3339 step("r2: Verify (*, G) upstream IIF interface")
3340 dut = "r2"
3341 iif = "lo"
3342 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
3343 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3344
3345 step("r2: Verify (*, G) upstream join state and join timer")
3346 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
3347 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3348
3349 step("r2: Verify (*, G) ip mroutes")
3350 oif = "r2-r1-eth0"
3351 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_1, iif, oif)
3352 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3353
3354 step("r2: Verify (S, G) upstream IIF interface")
3355 iif = "r2-r3-eth1"
3356 result = verify_upstream_iif(
3357 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, joinState="NotJoined"
3358 )
3359 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3360
3361 step("r2: Verify (S, G) upstream join state and join timer")
3362 result = verify_join_state_and_timer(
3363 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False
3364 )
3365 assert result is not True, (
3366 "Testcase {} : Failed \n "
3367 "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
3368 tc_name, result
3369 )
3370 )
3371
3372 step("r2: Verify (S, G) ip mroutes")
3373 oif = "none"
3374 result = verify_ip_mroutes(
3375 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif
3376 )
3377 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3378
3379 step("r3: Verify (S, G) upstream IIF interface")
3380 dut = "r3"
3381 iif = "r3-r5-eth3"
3382 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1)
3383 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3384
3385 step("r3: Verify (S, G) upstream join state and join timer")
3386 result = verify_join_state_and_timer(
3387 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, expected=False
3388 )
3389 assert result is not True, (
3390 "Testcase {} : Failed \n "
3391 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
3392 tc_name, result
3393 )
3394 )
3395
3396 step("r3: Verify (S, G) ip mroutes")
3397 oif = "r3-r1-eth0"
3398 result = verify_ip_mroutes(
3399 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif
3400 )
3401 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3402
3403 step("r1: Verify (*, G) upstream IIF interface")
3404 dut = "r1"
3405 iif = "r1-r4-eth3"
3406 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
3407 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3408
3409 step("r1: Verify (*, G) upstream join state and join timer")
3410 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
3411 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3412
3413 step("r1: Verify (*, G) ip mroutes")
3414 oif = "r1-r0-eth0"
3415 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_2, iif, oif)
3416 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3417
3418 step("r1: Verify (S, G) upstream IIF interface")
3419 iif = "r1-r3-eth2"
3420 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2)
3421 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3422
3423 step("r1: Verify (S, G) upstream join state and join timer")
3424 result = verify_join_state_and_timer(
3425 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2
3426 )
3427 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3428
3429 step("r1: Verify (S, G) ip mroutes")
3430 result = verify_ip_mroutes(
3431 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif
3432 )
3433 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3434
3435 step("r4: Verify (*, G) upstream IIF interface")
3436 dut = "r4"
3437 iif = "lo"
3438 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
3439 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3440
3441 step("r4: Verify (*, G) upstream join state and join timer")
3442 result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
3443 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3444
3445 step("r4: Verify (*, G) ip mroutes")
3446 oif = "r4-r1-eth0"
3447 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_2, iif, oif)
3448 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3449
3450 step("r4: Verify (S, G) upstream IIF interface")
3451 iif = "r4-r3-eth1"
3452 result = verify_upstream_iif(
3453 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, joinState="NotJoined"
3454 )
3455 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3456
3457 step("r4: Verify (S, G) upstream join state and join timer")
3458 result = verify_join_state_and_timer(
3459 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False
3460 )
3461 assert result is not True, (
3462 "Testcase {} : Failed \n "
3463 "r4: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
3464 tc_name, result
3465 )
3466 )
3467
3468 step("r4: Verify (S, G) ip mroutes")
3469 oif = "none"
3470 result = verify_ip_mroutes(
3471 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif
3472 )
3473 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3474
3475 step("r3: Verify (S, G) upstream IIF interface")
3476 dut = "r3"
3477 iif = "r3-r5-eth3"
3478 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2)
3479 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3480
3481 step("r3: Verify (S, G) upstream join state and join timer")
3482 result = verify_join_state_and_timer(
3483 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, expected=False
3484 )
3485 assert result is not True, (
3486 "Testcase {} : Failed \n "
3487 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
3488 tc_name, result
3489 )
3490 )
3491
3492 step("r3: Verify (S, G) ip mroutes")
3493 oif = "r3-r1-eth0"
3494 result = verify_ip_mroutes(
3495 tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif
3496 )
3497 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3498
3499 write_test_footer(tc_name)
3500
3501
3502 def test_shutdown_primary_path_p1(request):
3503 """
3504 TC_30_P1: Verify IIF and OIL change to other path after shut the primary
3505 path
3506
3507 Topology used:
3508 ________r2_____
3509 | |
3510 iperf | |
3511 r0-----r1-------------r3
3512 """
3513
3514 tgen = get_topogen()
3515 tc_name = request.node.name
3516 write_test_header(tc_name)
3517
3518 # Don"t run this test if we have any failure.
3519 if tgen.routers_have_failure():
3520 pytest.skip(tgen.errors)
3521
3522 step("Creating configuration from JSON")
3523 reset_config_on_routers(tgen)
3524 app_helper.stop_all_hosts()
3525 clear_ip_mroute(tgen)
3526 clear_ip_pim_interface_traffic(tgen, TOPO)
3527
3528 # Steps to execute
3529 step("Enable IGMP on r1 interface")
3530 step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4")
3531 step("r1: Shut the link from r1 to r2")
3532 step("r3: Shut the link from r1 to r3")
3533 step("r1: No shut the link from r1 to r2")
3534 step("r3: No shut the link from r1 to r3")
3535
3536 step("r1: Verify RP info")
3537 dut = "r1"
3538 rp_address = "1.0.2.17"
3539 iif = "r1-r2-eth1"
3540 result = verify_pim_rp_info(
3541 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
3542 )
3543 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3544
3545 step("r0: Send IGMP join")
3546 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
3547 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3548
3549 step("r1: Verify IGMP groups")
3550 oif = "r1-r0-eth0"
3551 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
3552 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3553
3554 step("r1: Verify (*, G) ip mroutes")
3555 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3556 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3557
3558 step("r2: Verify (*, G) ip mroutes")
3559 dut = "r2"
3560 iif = "lo"
3561 oif = "r2-r1-eth0"
3562 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3563 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3564
3565 step("r1: Shut the interface r1-r2-eth1 from R1 to R2")
3566 dut = "r1"
3567 intf = "r1-r2-eth1"
3568 shutdown_bringup_interface(tgen, dut, intf, False)
3569
3570 step(
3571 "Verify after shut the R1 to R2 link , verify join is reaching to RP"
3572 "via other path"
3573 )
3574
3575 logger.info("Waiting for 110 sec only if test run with crucible")
3576
3577 step("r1: Verify (*, G) ip mroutes")
3578 dut = "r1"
3579 iif = "r1-r3-eth2"
3580 oif = "r1-r0-eth0"
3581 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3582 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3583
3584 step("r2: Verify (*, G) ip mroutes")
3585 dut = "r2"
3586 iif = "lo"
3587 oif = "r2-r3-eth1"
3588 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3589 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3590
3591 step("r3: Verify (*, G) ip mroutes")
3592 dut = "r3"
3593 iif = "r3-r2-eth1"
3594 oif = "r3-r1-eth0"
3595 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3596 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3597
3598 step("r3: Shut the link from R1 to R3 from R3 node")
3599 dut = "r3"
3600 intf = "r3-r1-eth0"
3601 shutdown_bringup_interface(tgen, dut, intf, False)
3602
3603 step(
3604 "Verify after shut of R1 to R3 link , verify (*,G) entries got"
3605 " cleared from all the node R1, R2, R3"
3606 )
3607
3608 step("r1: Verify (*, G) ip mroutes")
3609 dut = "r1"
3610 iif = "r1-r3-eth2"
3611 oif = "r1-r0-eth0"
3612 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
3613 assert result is not True, (
3614 "Testcase {} : Failed \n "
3615 "r1: (*,G) mroutes are not cleared after shut of R1 to R3 link\n Error: {}".format(
3616 tc_name, result
3617 )
3618 )
3619
3620 step("r2: Verify (*, G) ip mroutes")
3621 dut = "r2"
3622 iif = "lo"
3623 oif = "r2-r3-eth1"
3624 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
3625 assert result is not True, (
3626 "Testcase {} : Failed \n "
3627 "r2: (*,G) mroutes are not cleared after shut of R1 to R3 link\n Error: {}".format(
3628 tc_name, result
3629 )
3630 )
3631
3632 step("r3: Verify (*, G) ip mroutes")
3633 dut = "r3"
3634 iif = "r3-r2-eth1"
3635 oif = "r3-r1-eth0"
3636 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
3637 assert result is not True, (
3638 "Testcase {} : Failed \n "
3639 "r3: (*,G) mroutes are not cleared after shut of R1 to R3 link\n Error: {}".format(
3640 tc_name, result
3641 )
3642 )
3643
3644 step("r3: No shutdown the link from R1 to R3 from R3 node")
3645 dut = "r3"
3646 intf = "r3-r1-eth0"
3647 shutdown_bringup_interface(tgen, dut, intf, True)
3648
3649 step("r1: Verify (*, G) ip mroutes")
3650 dut = "r1"
3651 iif = "r1-r3-eth2"
3652 oif = "r1-r0-eth0"
3653 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3654 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3655
3656 step("r2: Verify (*, G) ip mroutes")
3657 dut = "r2"
3658 iif = "lo"
3659 oif = "r2-r3-eth1"
3660 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3661 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3662
3663 step("r3: Verify (*, G) ip mroutes")
3664 dut = "r3"
3665 iif = "r3-r2-eth1"
3666 oif = "r3-r1-eth0"
3667 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3668 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3669
3670 step("r1: No shutdown the link from R1 to R2 from R1 node")
3671 dut = "r1"
3672 intf = "r1-r2-eth1"
3673 shutdown_bringup_interface(tgen, dut, intf, True)
3674
3675 step("r1: Verify (*, G) ip mroutes")
3676 dut = "r1"
3677 iif = "r1-r2-eth1"
3678 oif = "r1-r0-eth0"
3679 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3680 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3681
3682 step("r2: Verify (*, G) ip mroutes")
3683 dut = "r2"
3684 iif = "lo"
3685 oif = "r2-r1-eth0"
3686 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3687 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3688
3689 write_test_footer(tc_name)
3690
3691
3692 def test_delete_RP_shut_noshut_upstream_interface_p1(request):
3693 """
3694 TC_31_P1: Verify RP info and (*,G) mroute after deleting the RP and shut /
3695 no shut the RPF interface.
3696 Topology used:
3697 ________r2_____
3698 | |
3699 iperf | |
3700 r0-----r1-------------r3
3701 """
3702
3703 tgen = get_topogen()
3704 tc_name = request.node.name
3705 write_test_header(tc_name)
3706
3707 # Don"t run this test if we have any failure.
3708 if tgen.routers_have_failure():
3709 pytest.skip(tgen.errors)
3710
3711 step("Creating configuration from JSON")
3712 reset_config_on_routers(tgen)
3713 app_helper.stop_all_hosts()
3714 clear_ip_mroute(tgen)
3715 clear_ip_pim_interface_traffic(tgen, TOPO)
3716
3717 step("Enable IGMP on r1 interface")
3718 step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4")
3719 step("r1: Delete the RP config")
3720 step("r1: Shut and no shut the upstream interface (R1-R2) connected link")
3721 step("r1: Shut and no shut the OIL interface")
3722
3723 step("r1: Verify RP info")
3724 dut = "r1"
3725 rp_address = "1.0.2.17"
3726 iif = "r1-r2-eth1"
3727 result = verify_pim_rp_info(
3728 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
3729 )
3730 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3731
3732 step("r0: Send IGMP join")
3733 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
3734 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3735
3736 step("r1: Verify IGMP groups")
3737 dut = "r1"
3738 oif = "r1-r0-eth0"
3739 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
3740 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3741
3742 step("r1: Verify (*, G) ip mroutes created")
3743 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3744 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3745
3746 step("r2: Verify (*, G) ip mroutes created")
3747 dut = "r2"
3748 iif = "lo"
3749 oif = "r2-r1-eth0"
3750 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3751 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3752
3753 step("r1: Delete RP configuration")
3754
3755 # Delete RP configuration
3756 input_dict = {
3757 "r1": {
3758 "pim": {
3759 "rp": [
3760 {
3761 "rp_addr": "1.0.2.17",
3762 "group_addr_range": GROUP_RANGE_ALL,
3763 "delete": True,
3764 }
3765 ]
3766 }
3767 }
3768 }
3769
3770 result = create_pim_config(tgen, TOPO, input_dict)
3771 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3772
3773 step("r1: Shut the interface r1-r2-eth1 from R1 to R2")
3774 dut = "r1"
3775 intf = "r1-r2-eth1"
3776 shutdown_bringup_interface(tgen, dut, intf, False)
3777
3778 step("r1: No shutdown the interface r1-r2-eth1 from R1 to R2")
3779 dut = "r1"
3780 intf = "r1-r2-eth1"
3781 shutdown_bringup_interface(tgen, dut, intf, True)
3782
3783 step("r1: Shutdown the OIL interface r1-r0-eth0 from R1 to R0 ")
3784 dut = "r1"
3785 intf = "r1-r0-eth0"
3786 shutdown_bringup_interface(tgen, dut, intf, False)
3787
3788 step("r1: No shutdown the OIL interface r1-r0-eth0 from R1 to R0")
3789 dut = "r1"
3790 intf = "r1-r0-eth0"
3791 shutdown_bringup_interface(tgen, dut, intf, True)
3792
3793 step("r1: Verify (*, G) ip mroutes cleared")
3794 dut = "r1"
3795 iif = "r1-r2-eth1"
3796 oif = "r1-r0-eth0"
3797 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
3798 assert result is not True, (
3799 "Testcase {} : Failed \n "
3800 "r1: (*,G) mroutes are not cleared after shut of R1 to R0 link\n Error: {}".format(
3801 tc_name, result
3802 )
3803 )
3804
3805 step("r2: Verify (*, G) ip mroutes cleared")
3806 dut = "r2"
3807 iif = "lo"
3808 oif = "r2-r1-eth0"
3809 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
3810 assert result is not True, (
3811 "Testcase {} : Failed \n "
3812 "r2: (*,G) mroutes are not cleared after shut of R1 to R0 link\n Error: {}".format(
3813 tc_name, result
3814 )
3815 )
3816
3817 write_test_footer(tc_name)
3818
3819
3820 def test_delete_RP_shut_noshut_RP_interface_p1(request):
3821 """
3822 TC_32_P1: Verify RP info and (*,G) mroute after deleting the RP and shut/
3823 no shut the RPF inteface
3824
3825 Topology used:
3826 ________r2_____
3827 | |
3828 iperf | |
3829 r0-----r1-------------r3
3830 """
3831
3832 tgen = get_topogen()
3833 tc_name = request.node.name
3834 write_test_header(tc_name)
3835
3836 # Don"t run this test if we have any failure.
3837 if tgen.routers_have_failure():
3838 pytest.skip(tgen.errors)
3839
3840 step("Creating configuration from JSON")
3841 reset_config_on_routers(tgen)
3842 app_helper.stop_all_hosts()
3843 clear_ip_mroute(tgen)
3844 clear_ip_pim_interface_traffic(tgen, TOPO)
3845
3846 step("Enable IGMP on r1 interface")
3847 step("Configure RP on r2 (lo) for the group range" " 224.0.0.0/4")
3848 step("r2: Delete the RP configuration")
3849 step("r2: Shut the RP interface (lo)")
3850 step("r1: Shut the interface(r1-r2-eth1, r1-r3-eth2) towards rp")
3851
3852 step("r1: Verify RP info")
3853 dut = "r1"
3854 rp_address = "1.0.2.17"
3855 iif = "r1-r2-eth1"
3856 result = verify_pim_rp_info(
3857 tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE
3858 )
3859 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3860
3861 step("r0: Send IGMP join")
3862 result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
3863 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3864
3865 step("r1: Verify IGMP groups")
3866 oif = "r1-r0-eth0"
3867 result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
3868 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3869
3870 step("r1: Verify (*, G) ip mroutes created")
3871 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3872 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3873
3874 step("r2: Verify (*, G) ip mroutes created")
3875 dut = "r2"
3876 iif = "lo"
3877 oif = "r2-r1-eth0"
3878 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
3879 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3880
3881 step("r2: Delete RP configuration")
3882
3883 # Delete RP configuration
3884 input_dict = {
3885 "r2": {
3886 "pim": {
3887 "rp": [
3888 {
3889 "rp_addr": "1.0.2.17",
3890 "group_addr_range": GROUP_RANGE_ALL,
3891 "delete": True,
3892 }
3893 ]
3894 }
3895 }
3896 }
3897
3898 result = create_pim_config(tgen, TOPO, input_dict)
3899 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
3900
3901 step("r2: Shut the RP interface lo")
3902 dut = "r2"
3903 intf = "lo"
3904 shutdown_bringup_interface(tgen, dut, intf, False)
3905
3906 step("r1: Shut the interface r1-r2-eth1 towards RP")
3907 dut = "r1"
3908 intf = "r1-r2-eth1"
3909 shutdown_bringup_interface(tgen, dut, intf, False)
3910
3911 step("r1: Shut the interface r1-r3-eth2 towards RP")
3912 dut = "r1"
3913 intf = "r1-r3-eth2"
3914 shutdown_bringup_interface(tgen, dut, intf, False)
3915
3916 step("r1: Verify (*, G) ip mroutes cleared")
3917 dut = "r1"
3918 iif = "r1-r2-eth1"
3919 oif = "r1-r0-eth0"
3920 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
3921 assert result is not True, (
3922 "Testcase {} : Failed \n "
3923 "r1: (*,G) mroutes are not cleared after shut of R1 to R2 and R3 link\n Error: {}".format(
3924 tc_name, result
3925 )
3926 )
3927
3928 step("r2: Verify (*, G) ip mroutes cleared")
3929 dut = "r2"
3930 iif = "lo"
3931 oif = "r2-r1-eth0"
3932 result = verify_ip_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif, expected=False)
3933 assert result is not True, (
3934 "Testcase {} : Failed \n "
3935 "r2: (*,G) mroutes are not cleared after shut of R1 to R2 and R3 link\n Error: {}".format(
3936 tc_name, result
3937 )
3938 )
3939
3940 write_test_footer(tc_name)
3941
3942
3943 if __name__ == "__main__":
3944 ARGS = ["-s"] + sys.argv[1:]
3945 sys.exit(pytest.main(ARGS))