2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2019 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation,
7 # Inc. ("NetDEF") in this file.
11 Following tests are covered to test Multicast basic functionality:
18 r0-----r1-------------r3-----r5
24 - Create topology (setup module)
27 TC_1 : Verify upstream interfaces(IIF) and join state are updated properly
28 after adding and deleting the static RP
29 TC_2 : Verify IIF and OIL in "show ip pim state" updated properly after
30 adding and deleting the static RP
31 TC_3: (*, G) Mroute entry are cleared when static RP gets deleted
32 TC_4: Verify (*,G) prune is send towards the RP after deleting the static RP
33 TC_5: Verify OIF entry for RP is cleared when RP becomes unreachable
34 TC_6: Verify IIF and OIL in "show ip pim state" updated properly when RP
36 TC_7 : Verify upstream interfaces(IIF) and join state are updated properly
37 after adding and deleting the static RP
38 TC_8: Verify (*,G) prune is send towards the RP when RP becomes unreachable
39 TC_9 : Verify RP configured after IGMP join received, PIM join towards RP is
41 TC_10 : Verify RP becomes reachable after IGMP join received, PIM join
42 towards RP is sent immediately
43 TC_11 : Verify PIM join send towards the higher preferred RP
44 TC_12 : Verify PIM prune send towards the lower preferred RP
45 TC_13 : Verify RPF interface is updated in mroute (kernel) when higher
46 preferred overlapping RP configured
47 TC_14 : Verify IIF and OIL in "show ip pim state" updated properly when higher
48 preferred overlapping RP configured
49 TC_15 : Verify upstream interfaces(IIF) and join state are updated when higher
50 preferred overlapping RP is configured
51 TC_16 : Verify join is send to lower preferred RP, when higher preferred RP
53 TC_17 : Verify prune is send to higher preferred RP when higher preferred RP
55 TC_18 : Verify RPF interface updated in mroute when higher preferred RP gets
57 TC_19 : Verify IIF and OIL in "show ip pim state" updated when higher
58 preferred overlapping RP is deleted
59 TC_20 : Verify PIM upstream IIF updated when higher preferred overlapping RP
61 TC_21_1 : Verify OIF and RFP for (*,G) and (S,G) when static RP configure in
63 TC_21_2 : Verify OIF and RFP for (*,G) and (S,G) when static RP configure in
65 TC_22_1 : Verify OIF and RPF for (*,G) and (S,G) when static RP configure in
67 TC_22_2 : Verify OIF and RPF for (*,G) and (S,G) when static RP configure in
69 TC_23 : Verify (*,G) and (S,G) populated correctly when RPT and SPT path are
71 TC_24 : Verify (*,G) and (S,G) populated correctly when SPT and RPT share the
73 TC_25 : Verify (*,G) and (S,G) populated correctly after clearing the PIM ,
74 IGMP and mroutes joins
75 TC_26 : Restart the PIMd process and verify PIM joins , and mroutes entries
76 TC_27 : Configure multiple groups (10 grps) with same RP address
77 TC_28 : Configure multiple groups (10 grps) with different RP address
78 TC_29 : Verify IIF and OIL in updated in mroute when upstream interface
80 TC_30 : Verify IIF and OIL change to other path after shut the primary path
81 TC_31 : Verify RP info and (*,G) mroute after deleting the RP and shut / no
82 shut the RPF interface.
83 TC_32 : Verify RP info and (*,G) mroute after deleting the RP and shut / no
84 shut the RPF interface
90 from time
import sleep
94 # Save the Current Working Directory to find configuration files.
95 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
96 sys
.path
.append(os
.path
.join(CWD
, "../"))
97 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
99 # Required to instantiate the topology builder class.
101 # pylint: disable=C0413
102 # Import topogen and topotest helpers
104 from lib
.topogen
import Topogen
, get_topogen
105 from lib
.topolog
import logger
106 from lib
.topojson
import build_topo_from_json
, build_config_from_json
108 from lib
.common_config
import (
112 reset_config_on_routers
,
114 shutdown_bringup_interface
,
116 start_router_daemons
,
117 create_static_routes
,
119 from lib
.pim
import (
123 verify_join_state_and_timer
,
125 verify_pim_neighbors
,
126 get_pim_interface_traffic
,
129 clear_pim_interface_traffic
,
130 clear_igmp_interfaces
,
131 clear_pim_interfaces
,
137 pytestmark
= [pytest
.mark
.pimd
, pytest
.mark
.staticd
]
141 GROUP_RANGE_ALL
= "224.0.0.0/4"
142 GROUP_RANGE
= "225.1.1.1/32"
143 GROUP_RANGE_LIST_1
= [
150 GROUP_RANGE_LIST_2
= [
157 GROUP_ADDRESS
= "225.1.1.1"
158 GROUP_ADDRESS_LIST_1
= ["225.1.1.1", "225.1.1.2", "225.1.1.3", "225.1.1.4", "225.1.1.5"]
159 GROUP_ADDRESS_LIST_2
= [
167 SOURCE_ADDRESS
= "10.0.6.2"
171 def build_topo(tgen
):
174 # Building topology from json file
175 build_topo_from_json(tgen
, TOPO
)
178 def setup_module(mod
):
180 Sets up the pytest environment
185 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
186 logger
.info("Testsuite start time: %s", testsuite_run_time
)
187 logger
.info("=" * 40)
194 r0-----r1-------------r3-----r5
200 logger
.info("Master Topology: \n %s", topology
)
202 logger
.info("Running setup_module to create topology")
204 # This function initiates the topology build with Topogen...
205 json_file
= "{}/multicast_pim_static_rp.json".format(CWD
)
206 tgen
= Topogen(json_file
, mod
.__name
__)
208 TOPO
= tgen
.json_topo
210 # ... and here it calls Mininet initialization functions.
212 # Starting topology, create tmp files which are loaded to routers
213 # to start daemons and then start routers
216 # Don"t run this test if we have any failure.
217 if tgen
.routers_have_failure():
218 pytest
.skip(tgen
.errors
)
220 # Creating configuration from JSON
221 build_config_from_json(tgen
, TOPO
)
223 # Verify PIM neighbors
224 result
= verify_pim_neighbors(tgen
, TOPO
)
225 assert result
is True, "setup_module :Failed \n Error:" " {}".format(result
)
227 # XXX Replace this using "with McastTesterHelper()... " in each test if possible.
229 app_helper
= McastTesterHelper(tgen
)
231 logger
.info("Running setup_module() done")
234 def teardown_module():
235 """Teardown the pytest environment"""
237 logger
.info("Running teardown_module to delete topology")
243 # Stop toplogy and Remove tmp files
246 logger
.info("Testsuite end time: %s", time
.asctime(time
.localtime(time
.time())))
247 logger
.info("=" * 40)
250 #####################################################
254 #####################################################
257 def verify_mroute_repopulated(uptime_before
, uptime_after
):
259 API to compare uptime for mroutes
263 * `uptime_before` : Uptime dictionary for any particular instance
264 * `uptime_after` : Uptime dictionary for any particular instance
267 for group
in uptime_before
.keys():
268 for source
in uptime_before
[group
].keys():
269 if set(uptime_before
[group
]) != set(uptime_after
[group
]):
271 "mroute (%s, %s) has not come"
272 " up after mroute clear [FAILED!!]" % (source
, group
)
276 d_1
= datetime
.datetime
.strptime(uptime_before
[group
][source
], "%H:%M:%S")
277 d_2
= datetime
.datetime
.strptime(uptime_after
[group
][source
], "%H:%M:%S")
279 errormsg
= "mroute (%s, %s) is not " "repopulated [FAILED!!]" % (
285 logger
.info("mroute (%s, %s) is " "repopulated [PASSED!!]", source
, group
)
290 def verify_state_incremented(state_before
, state_after
):
292 API to compare interface traffic state incrementing
296 * `state_before` : State dictionary for any particular instance
297 * `state_after` : State dictionary for any particular instance
300 for router
, state_data
in state_before
.items():
301 for state
, _
in state_data
.items():
302 if state_before
[router
][state
] >= state_after
[router
][state
]:
304 "[DUT: %s]: state %s value has not"
305 " incremented, Initial value: %s, "
306 "Current value: %s [FAILED!!]"
310 state_before
[router
][state
],
311 state_after
[router
][state
],
317 "[DUT: %s]: State %s value is "
318 "incremented, Initial value: %s, Current value: %s"
322 state_before
[router
][state
],
323 state_after
[router
][state
],
329 def test_RP_configured_as_LHR_1_p1(request
):
331 TC_21_1_P1: Verify OIF and RPF for (*,G) and (S,G) when static RP configure
338 r0-----r1-------------r3-----r5
345 tc_name
= request
.node
.name
346 write_test_header(tc_name
)
348 # Don"t run this test if we have any failure.
349 if tgen
.routers_have_failure():
350 pytest
.skip(tgen
.errors
)
352 step("Creating configuration from JSON")
353 reset_config_on_routers(tgen
)
354 app_helper
.stop_all_hosts()
356 clear_pim_interface_traffic(tgen
, TOPO
)
358 step("Enable IGMP on r1 interface")
359 step("Configure RP on r1 (loopback interface) for the group range" " 224.0.0.0/4")
360 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
361 step("Send the IGMP join from r0")
362 step("Send multicast traffic from r5")
364 step("r1 , r2, r3, r4: Delete existing RP configuration" "configure r1(LHR) as RP")
370 "rp_addr": "1.0.2.17",
371 "group_addr_range": GROUP_RANGE_ALL
,
381 "rp_addr": "1.0.2.17",
382 "group_addr_range": GROUP_RANGE_ALL
,
392 "rp_addr": "1.0.2.17",
393 "group_addr_range": GROUP_RANGE_ALL
,
403 "rp_addr": "1.0.2.17",
404 "group_addr_range": GROUP_RANGE_ALL
,
412 result
= create_pim_config(tgen
, TOPO
, input_dict
)
413 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
415 step("r1: Configure r1(LHR) as RP")
421 "rp_addr": "1.0.1.17",
422 "group_addr_range": GROUP_RANGE_ALL
,
431 "rp_addr": "1.0.1.17",
432 "group_addr_range": GROUP_RANGE_ALL
,
441 "rp_addr": "1.0.1.17",
442 "group_addr_range": GROUP_RANGE_ALL
,
451 "rp_addr": "1.0.1.17",
452 "group_addr_range": GROUP_RANGE_ALL
,
459 result
= create_pim_config(tgen
, TOPO
, input_dict
)
460 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
462 shutdown_bringup_interface(tgen
, "r1", "lo", False)
464 shutdown_bringup_interface(tgen
, "r1", "lo", True)
467 step("r1: Verify RP info")
469 rp_address
= "1.0.1.17"
471 result
= verify_pim_rp_info(
472 tgen
, TOPO
, dut
, GROUP_RANGE_ALL
, iif
, rp_address
, SOURCE
474 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
476 step("r0: Send IGMP join")
477 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
478 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
480 step("r1: Verify IGMP groups")
482 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
483 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
485 step("r5: Send multicast traffic for group 225.1.1.1")
486 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
487 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
489 step("r1: Verify (*, G) upstream IIF interface")
490 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
491 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
493 step("r1: Verify (*, G) upstream join state and join timer")
494 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
495 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
497 step("r1: Verify (*, G) ip mroutes")
498 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
499 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
501 step("r1: Verify (S, G) upstream IIF interface")
503 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
504 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
506 step("r1: Verify (S, G) upstream join state and join timer")
507 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
508 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
510 step("r1: Verify (S, G) ip mroutes")
511 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
512 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
514 step("r3: Verify (S, G) upstream IIF interface")
517 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
518 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
520 step("r3: Verify (S, G) upstream join state and join timer")
521 result
= verify_join_state_and_timer(
522 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
524 assert result
is not True, (
525 "Testcase {} : Failed \n "
526 "Expected: [{}]: Upstream Join State should not be Joined and "
527 "join timer should not run\n "
528 "Found: {}".format(tc_name
, dut
, result
)
531 step("r3: Verify (S, G) ip mroutes")
533 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
534 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
536 # Uncomment next line for debugging
539 write_test_footer(tc_name
)
542 def test_RP_configured_as_LHR_2_p1(request
):
544 TC_21_2_P1: Verify OIF and RPF for (*,G) and (S,G) when static RP configure
551 r0-----r1-------------r3-----r5
558 tc_name
= request
.node
.name
559 write_test_header(tc_name
)
561 # Don"t run this test if we have any failure.
562 if tgen
.routers_have_failure():
563 pytest
.skip(tgen
.errors
)
565 step("Creating configuration from JSON")
566 reset_config_on_routers(tgen
)
567 app_helper
.stop_all_hosts()
569 clear_pim_interface_traffic(tgen
, TOPO
)
571 step("Enable IGMP on r1 interface")
572 step("Configure RP on r1 (loopback interface) for the group range" " 224.0.0.0/4")
573 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
574 step("Send multicast traffic from r5")
575 step("Send the IGMP join from r0")
577 step("r1, r2, r3, r4: Delete existing RP configuration," "configure r1(LHR) as RP")
583 "rp_addr": "1.0.2.17",
584 "group_addr_range": GROUP_RANGE_ALL
,
594 "rp_addr": "1.0.2.17",
595 "group_addr_range": GROUP_RANGE_ALL
,
605 "rp_addr": "1.0.2.17",
606 "group_addr_range": GROUP_RANGE_ALL
,
616 "rp_addr": "1.0.2.17",
617 "group_addr_range": GROUP_RANGE_ALL
,
625 result
= create_pim_config(tgen
, TOPO
, input_dict
)
626 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
628 step("r1, r2, r3, r4: Configure r1(LHR) as RP")
634 "rp_addr": "1.0.1.17",
635 "group_addr_range": GROUP_RANGE_ALL
,
644 "rp_addr": "1.0.1.17",
645 "group_addr_range": GROUP_RANGE_ALL
,
654 "rp_addr": "1.0.1.17",
655 "group_addr_range": GROUP_RANGE_ALL
,
664 "rp_addr": "1.0.1.17",
665 "group_addr_range": GROUP_RANGE_ALL
,
672 result
= create_pim_config(tgen
, TOPO
, input_dict
)
673 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
675 step("r1: Verify RP info")
677 rp_address
= "1.0.1.17"
679 result
= verify_pim_rp_info(tgen
, TOPO
, dut
, GROUP_ADDRESS
, iif
, rp_address
, SOURCE
)
680 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
682 step("r5: Send multicast traffic for group 225.1.1.1")
683 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
684 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
686 step("r0: Send IGMP join")
687 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
688 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
690 step("r1: Verify IGMP groups")
692 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
693 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
695 step("r1: Verify (*, G) upstream IIF interface")
696 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
697 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
699 step("r1: Verify (*, G) upstream join state and join timer")
700 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
701 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
703 step("r1: Verify (*, G) ip mroutes")
704 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
705 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
707 step("r1: Verify (S, G) upstream IIF interface")
709 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
710 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
712 step("r1: Verify (S, G) upstream join state and join timer")
713 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
714 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
716 step("r1: Verify (S, G) ip mroutes")
717 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
718 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
720 step("r3: Verify (S, G) upstream IIF interface")
723 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
724 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
726 step("r3: Verify (S, G) upstream join state and join timer")
727 result
= verify_join_state_and_timer(
728 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
730 assert result
is not True, (
731 "Testcase {} : Failed \n "
732 "Expected: [{}]: Upstream Join State should not be Joined and "
733 "join timer should not run\n "
734 "Found: {}".format(tc_name
, dut
, result
)
737 step("r3: Verify (S, G) ip mroutes")
739 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
740 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
742 # Uncomment next line for debugging
745 write_test_footer(tc_name
)
748 def test_RP_configured_as_FHR_1_p1(request
):
750 TC_22_1_P1: Verify OIF and RFP for (*,G) and (S,G) when static RP configure
757 r0-----r1-------------r3-----r5
764 tc_name
= request
.node
.name
765 write_test_header(tc_name
)
767 # Don"t run this test if we have any failure.
768 if tgen
.routers_have_failure():
769 pytest
.skip(tgen
.errors
)
771 step("Creating configuration from JSON")
772 reset_config_on_routers(tgen
)
773 app_helper
.stop_all_hosts()
775 clear_pim_interface_traffic(tgen
, TOPO
)
777 step("Enable IGMP on r1 interface")
778 step("Configure RP on r2 (loopback interface) for the group range" " 225.1.1.0/24")
779 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
780 step("Send the IGMP join from r0")
781 step("Send multicast traffic from r5")
783 step("r1, r2, r3, r4: Delete existing RP configuration" "configure r3(FHR) as RP")
789 "rp_addr": "1.0.2.17",
790 "group_addr_range": GROUP_RANGE_ALL
,
800 "rp_addr": "1.0.2.17",
801 "group_addr_range": GROUP_RANGE_ALL
,
811 "rp_addr": "1.0.2.17",
812 "group_addr_range": GROUP_RANGE_ALL
,
822 "rp_addr": "1.0.2.17",
823 "group_addr_range": GROUP_RANGE_ALL
,
830 result
= create_pim_config(tgen
, TOPO
, input_dict
)
831 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
833 step("r1, r2, r3, r4: Configure r3(FHR) as RP")
839 "rp_addr": "1.0.3.17",
840 "group_addr_range": GROUP_RANGE_ALL
,
849 "rp_addr": "1.0.3.17",
850 "group_addr_range": GROUP_RANGE_ALL
,
859 "rp_addr": "1.0.3.17",
860 "group_addr_range": GROUP_RANGE_ALL
,
869 "rp_addr": "1.0.3.17",
870 "group_addr_range": GROUP_RANGE_ALL
,
877 result
= create_pim_config(tgen
, TOPO
, input_dict
)
878 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
880 step("r1: Verify RP info")
882 rp_address
= "1.0.3.17"
884 result
= verify_pim_rp_info(
885 tgen
, TOPO
, dut
, GROUP_RANGE_ALL
, iif
, rp_address
, SOURCE
887 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
889 step("r0: Send IGMP join")
890 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
891 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
893 step("r0: Verify IGMP groups")
895 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
896 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
898 step("r5: Send multicast traffic for group 225.1.1.1")
899 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
900 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
902 step("r1: Verify (*, G) upstream IIF interface")
903 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
904 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
906 step("r1: Verify (*, G) upstream join state and join timer")
907 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
908 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
910 step("r1: Verify (*, G) ip mroutes")
911 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
912 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
914 step("r1: Verify (S, G) upstream IIF interface")
915 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
916 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
918 step("r1: Verify (S, G) upstream join state and join timer")
919 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
920 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
922 step("r1: Verify (S, G) ip mroutes")
923 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
924 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
926 step("r3: Verify (S, G) upstream IIF interface")
929 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
930 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
932 step("r3: Verify (S, G) upstream join state and join timer")
933 result
= verify_join_state_and_timer(
934 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
936 assert result
is not True, (
937 "Testcase {} : Failed \n "
938 "Expected: [{}]: Upstream Join State should not be Joined and "
939 "join timer should not run\n "
940 "Found: {}".format(tc_name
, dut
, result
)
943 step("r3: Verify (S, G) ip mroutes")
945 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
946 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
948 # Uncomment next line for debugging
951 write_test_footer(tc_name
)
954 def test_RP_configured_as_FHR_2_p2(request
):
956 TC_22_2_P2: Verify OIF and RFP for (*,G) and (S,G) when static RP configure
963 r0-----r1-------------r3-----r5
969 tc_name
= request
.node
.name
970 write_test_header(tc_name
)
972 # Don"t run this test if we have any failure.
973 if tgen
.routers_have_failure():
974 pytest
.skip(tgen
.errors
)
976 step("Creating configuration from JSON")
977 reset_config_on_routers(tgen
)
978 app_helper
.stop_all_hosts()
980 clear_pim_interface_traffic(tgen
, TOPO
)
982 step("Enable IGMP on r1 interface")
983 step("Configure RP on r2 (loopback interface) for the group range" " 225.1.1.0/24")
984 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
985 step("Send multicast traffic from r5")
986 step("Send the IGMP join from r0")
988 step("r1, r2, r3, r4: Delete existing RP configuration" "configure r3(FHR) as RP")
994 "rp_addr": "1.0.2.17",
995 "group_addr_range": GROUP_RANGE_ALL
,
1005 "rp_addr": "1.0.2.17",
1006 "group_addr_range": GROUP_RANGE_ALL
,
1016 "rp_addr": "1.0.2.17",
1017 "group_addr_range": GROUP_RANGE_ALL
,
1027 "rp_addr": "1.0.2.17",
1028 "group_addr_range": GROUP_RANGE_ALL
,
1036 result
= create_pim_config(tgen
, TOPO
, input_dict
)
1037 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1039 step("r1, r2, r3, r4: Configure r3(FHR) as RP")
1045 "rp_addr": "1.0.3.17",
1046 "group_addr_range": GROUP_RANGE_ALL
,
1055 "rp_addr": "1.0.3.17",
1056 "group_addr_range": GROUP_RANGE_ALL
,
1065 "rp_addr": "1.0.3.17",
1066 "group_addr_range": GROUP_RANGE_ALL
,
1075 "rp_addr": "1.0.3.17",
1076 "group_addr_range": GROUP_RANGE_ALL
,
1083 result
= create_pim_config(tgen
, TOPO
, input_dict
)
1084 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1086 step("r1: Verify RP info")
1088 rp_address
= "1.0.3.17"
1090 result
= verify_pim_rp_info(
1091 tgen
, TOPO
, dut
, GROUP_RANGE_ALL
, iif
, rp_address
, SOURCE
1093 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1095 step("r5: Send multicast traffic for group 225.1.1.1")
1096 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
1097 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1099 step("r0: Send IGMP join")
1100 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
1101 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1103 step("r0: Verify IGMP groups")
1105 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
1106 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1108 step("r1: Verify (*, G) 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
)
1112 step("r1: Verify (*, G) 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
)
1116 step("r1: Verify (*, G) ip mroutes")
1117 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
1118 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1120 step("r1: Verify (S, G) upstream IIF interface")
1122 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1123 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1125 step("r1: Verify (S, G) upstream join state and join timer")
1126 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1127 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1129 step("r1: Verify (S, G) ip mroutes")
1130 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1131 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1133 step("r3: Verify (S, G) upstream IIF interface")
1136 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1137 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1139 step("r3: Verify (S, G) upstream join state and join timer")
1140 result
= verify_join_state_and_timer(
1141 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
1143 assert result
is not True, (
1144 "Testcase {} : Failed \n "
1145 "Expected: [{}]: Upstream Join State should not be Joined and "
1146 "join timer should not run\n "
1147 "Found: {}".format(tc_name
, dut
, result
)
1150 step("r3: Verify (S, G) ip mroutes")
1152 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1153 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1155 # Uncomment next line for debugging
1156 # tgen.mininet_cli()
1158 write_test_footer(tc_name
)
1161 def test_SPT_RPT_path_different_p1(request
):
1163 TC_23_P1: Verify (*,G) and (S,G) populated correctly when RPT and SPT path
1170 r0-----r1-------------r3-----r5
1177 tgen
= get_topogen()
1178 tc_name
= request
.node
.name
1179 write_test_header(tc_name
)
1181 # Don"t run this test if we have any failure.
1182 if tgen
.routers_have_failure():
1183 pytest
.skip(tgen
.errors
)
1185 step("Creating configuration from JSON")
1186 reset_config_on_routers(tgen
)
1187 app_helper
.stop_all_hosts()
1189 clear_pim_interface_traffic(tgen
, TOPO
)
1191 step("Enable IGMP on r1 interface and send IGMP join (225.1.1.1) to r1")
1192 step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4")
1193 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
1194 step("Send multicast traffic from r3")
1196 step("r2: Verify RP info")
1198 rp_address
= "1.0.2.17"
1200 result
= verify_pim_rp_info(tgen
, TOPO
, dut
, GROUP_ADDRESS
, iif
, rp_address
, SOURCE
)
1201 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1203 step("r0: Send IGMP join")
1204 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
1205 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1207 step("r1: Verify IGMP groups")
1210 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
1211 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1213 step("r5: Send multicast traffic for group 225.1.1.1")
1214 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
1215 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1217 step("r1: Verify (*, G) upstream IIF interface")
1219 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1220 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1222 step("r1: Verify (*, G) upstream join state and join timer")
1223 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1224 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1226 step("r1: Verify (*, G) ip mroutes")
1227 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
1228 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1230 step("r1: Verify (S, G) upstream IIF interface")
1232 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1233 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1235 step("r1: Verify (S, G) upstream join state and join timer")
1236 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1237 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1239 step("r1: Verify (S, G) ip mroutes")
1240 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1241 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1243 step("r2: Verify (*, G) upstream IIF interface")
1246 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1247 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1249 step("r2: Verify (*, G) upstream join state and join timer")
1250 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1251 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1253 step("r2: Verify (*, G) ip mroutes")
1255 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
1256 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1258 step("r3: Verify (S, G) upstream IIF interface")
1261 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1262 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1264 step("r3: Verify (S, G) upstream join state and join timer")
1265 result
= verify_join_state_and_timer(
1266 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
1268 assert result
is not True, (
1269 "Testcase {} : Failed \n "
1270 "Expected: [{}]: Upstream Join State should not be Joined and "
1271 "join timer should not run\n "
1272 "Found: {}".format(tc_name
, dut
, result
)
1275 step("r3: Verify (S, G) ip mroutes")
1277 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1278 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1280 step("r2: Verify (S, G) upstream IIF interface")
1283 result
= verify_upstream_iif(
1284 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, joinState
="NotJoined"
1286 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1288 step("r2: Verify (S, G) upstream join state and join timer")
1289 result
= verify_join_state_and_timer(
1290 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
1292 assert result
is not True, (
1293 "Testcase {} : Failed \n "
1294 "Expected: [{}]: Upstream Join State should not be Joined and "
1295 "join timer should not run\n "
1296 "Found: {}".format(tc_name
, dut
, result
)
1299 step("r2: Verify (S, G) ip mroutes")
1301 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1302 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1304 # Uncomment next line for debugging
1305 # tgen.mininet_cli()
1307 write_test_footer(tc_name
)
1310 def test_clear_pim_configuration_p1(request
):
1312 TC_25_P1: Verify (*,G) and (S,G) populated correctly after clearing the
1313 PIM,IGMP and mroutes joins
1319 r0-----r1-------------r3-----r5
1328 tgen
= get_topogen()
1329 tc_name
= request
.node
.name
1330 write_test_header(tc_name
)
1332 # Don"t run this test if we have any failure.
1333 if tgen
.routers_have_failure():
1334 pytest
.skip(tgen
.errors
)
1336 step("Creating configuration from JSON")
1337 reset_config_on_routers(tgen
)
1338 app_helper
.stop_all_hosts()
1340 clear_pim_interface_traffic(tgen
, TOPO
)
1342 step("Enable IGMP on r1 interface")
1343 step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4")
1344 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
1345 step("Send the IGMP join from r0")
1346 step("Send multicast traffic from r5")
1348 step("r2: Verify RP info")
1350 rp_address
= "1.0.2.17"
1352 result
= verify_pim_rp_info(
1353 tgen
, TOPO
, dut
, GROUP_RANGE_ALL
, oif
, rp_address
, SOURCE
1355 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1357 step("r0: Send IGMP join")
1358 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
1359 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1361 step("r1: Verify IGMP groups")
1364 result
= verify_igmp_groups(tgen
, dut
, iif
, GROUP_ADDRESS
)
1365 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1367 step("r5: Send multicast traffic for group 225.1.1.1")
1368 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
1369 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1371 step("r1: Verify (*, G) upstream IIF interface")
1374 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1375 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1377 step("r1: Verify (*, G) upstream join state and join timer")
1378 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1379 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1381 step("r1: Verify (*, G) ip mroutes")
1383 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
1384 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1386 step("r1: Verify IGMP groups timer restarted")
1387 result
= clear_igmp_interfaces(tgen
, dut
)
1388 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1390 step("r1: Verify PIM neighbor timer restarted")
1391 result
= clear_pim_interfaces(tgen
, dut
)
1392 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1394 step("r1: Verify PIM mroute timer restarted")
1395 result
= clear_mroute_verify(tgen
, dut
)
1396 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1398 # Uncomment next line for debugging
1399 # tgen.mininet_cli()
1401 write_test_footer(tc_name
)
1404 if __name__
== "__main__":
1405 ARGS
= ["-s"] + sys
.argv
[1:]
1406 sys
.exit(pytest
.main(ARGS
))