4 # Copyright (c) 2019 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation,
6 # Inc. ("NetDEF") in this file.
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
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
24 Following tests are covered to test Multicast basic functionality:
31 r0-----r1-------------r3-----r5
37 - Create topology (setup module)
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
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
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
66 TC_17 : Verify prune is send to higher preferred RP when higher preferred RP
68 TC_18 : Verify RPF interface updated in mroute when higher preferred RP gets
70 TC_19 : Verify IIF and OIL in "show ip pim state" updated when higher
71 preferred overlapping RP is deleted
72 TC_20 : Verify PIM upstream IIF updated when higher preferred overlapping RP
74 TC_21_1 : Verify OIF and RFP for (*,G) and (S,G) when static RP configure in
76 TC_21_2 : Verify OIF and RFP for (*,G) and (S,G) when static RP configure in
78 TC_22_1 : Verify OIF and RPF for (*,G) and (S,G) when static RP configure in
80 TC_22_2 : Verify OIF and RPF for (*,G) and (S,G) when static RP configure in
82 TC_23 : Verify (*,G) and (S,G) populated correctly when RPT and SPT path are
84 TC_24 : Verify (*,G) and (S,G) populated correctly when SPT and RPT share the
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
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 interface
103 from time
import sleep
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/"))
112 # Required to instantiate the topology builder class.
114 # pylint: disable=C0413
115 # Import topogen and topotest helpers
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
121 from lib
.common_config
import (
125 reset_config_on_routers
,
127 shutdown_bringup_interface
,
129 start_router_daemons
,
130 create_static_routes
,
132 from lib
.pim
import (
136 verify_join_state_and_timer
,
138 verify_pim_neighbors
,
139 get_pim_interface_traffic
,
142 clear_pim_interface_traffic
,
143 clear_igmp_interfaces
,
144 clear_pim_interfaces
,
150 pytestmark
= [pytest
.mark
.pimd
, pytest
.mark
.staticd
]
154 GROUP_RANGE_ALL
= "224.0.0.0/4"
155 GROUP_RANGE
= "225.1.1.1/32"
156 GROUP_RANGE_LIST_1
= [
163 GROUP_RANGE_LIST_2
= [
170 GROUP_ADDRESS
= "225.1.1.1"
171 GROUP_ADDRESS_LIST_1
= ["225.1.1.1", "225.1.1.2", "225.1.1.3", "225.1.1.4", "225.1.1.5"]
172 GROUP_ADDRESS_LIST_2
= [
180 SOURCE_ADDRESS
= "10.0.6.2"
184 def build_topo(tgen
):
187 # Building topology from json file
188 build_topo_from_json(tgen
, TOPO
)
191 def setup_module(mod
):
193 Sets up the pytest environment
198 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
199 logger
.info("Testsuite start time: %s", testsuite_run_time
)
200 logger
.info("=" * 40)
207 r0-----r1-------------r3-----r5
213 logger
.info("Master Topology: \n %s", topology
)
215 logger
.info("Running setup_module to create topology")
217 # This function initiates the topology build with Topogen...
218 json_file
= "{}/multicast_pim_static_rp.json".format(CWD
)
219 tgen
= Topogen(json_file
, mod
.__name
__)
221 TOPO
= tgen
.json_topo
223 # ... and here it calls Mininet initialization functions.
225 # Starting topology, create tmp files which are loaded to routers
226 # to start daemons and then start routers
229 # Don"t run this test if we have any failure.
230 if tgen
.routers_have_failure():
231 pytest
.skip(tgen
.errors
)
233 # Creating configuration from JSON
234 build_config_from_json(tgen
, TOPO
)
236 # Verify PIM neighbors
237 result
= verify_pim_neighbors(tgen
, TOPO
)
238 assert result
is True, "setup_module :Failed \n Error:" " {}".format(result
)
240 # XXX Replace this using "with McastTesterHelper()... " in each test if possible.
242 app_helper
= McastTesterHelper(tgen
)
244 logger
.info("Running setup_module() done")
247 def teardown_module():
248 """Teardown the pytest environment"""
250 logger
.info("Running teardown_module to delete topology")
256 # Stop toplogy and Remove tmp files
259 logger
.info("Testsuite end time: %s", time
.asctime(time
.localtime(time
.time())))
260 logger
.info("=" * 40)
263 #####################################################
267 #####################################################
270 def verify_mroute_repopulated(uptime_before
, uptime_after
):
272 API to compare uptime for mroutes
276 * `uptime_before` : Uptime dictionary for any particular instance
277 * `uptime_after` : Uptime dictionary for any particular instance
280 for group
in uptime_before
.keys():
281 for source
in uptime_before
[group
].keys():
282 if set(uptime_before
[group
]) != set(uptime_after
[group
]):
284 "mroute (%s, %s) has not come"
285 " up after mroute clear [FAILED!!]" % (source
, group
)
289 d_1
= datetime
.datetime
.strptime(uptime_before
[group
][source
], "%H:%M:%S")
290 d_2
= datetime
.datetime
.strptime(uptime_after
[group
][source
], "%H:%M:%S")
292 errormsg
= "mroute (%s, %s) is not " "repopulated [FAILED!!]" % (
298 logger
.info("mroute (%s, %s) is " "repopulated [PASSED!!]", source
, group
)
303 def verify_state_incremented(state_before
, state_after
):
305 API to compare interface traffic state incrementing
309 * `state_before` : State dictionary for any particular instance
310 * `state_after` : State dictionary for any particular instance
313 for router
, state_data
in state_before
.items():
314 for state
, _
in state_data
.items():
315 if state_before
[router
][state
] >= state_after
[router
][state
]:
317 "[DUT: %s]: state %s value has not"
318 " incremented, Initial value: %s, "
319 "Current value: %s [FAILED!!]"
323 state_before
[router
][state
],
324 state_after
[router
][state
],
330 "[DUT: %s]: State %s value is "
331 "incremented, Initial value: %s, Current value: %s"
335 state_before
[router
][state
],
336 state_after
[router
][state
],
342 def test_RP_configured_as_LHR_1_p1(request
):
344 TC_21_1_P1: Verify OIF and RPF for (*,G) and (S,G) when static RP configure
351 r0-----r1-------------r3-----r5
358 tc_name
= request
.node
.name
359 write_test_header(tc_name
)
361 # Don"t run this test if we have any failure.
362 if tgen
.routers_have_failure():
363 pytest
.skip(tgen
.errors
)
365 step("Creating configuration from JSON")
366 reset_config_on_routers(tgen
)
367 app_helper
.stop_all_hosts()
369 clear_pim_interface_traffic(tgen
, TOPO
)
371 step("Enable IGMP on r1 interface")
372 step("Configure RP on r1 (loopback interface) for the group range" " 224.0.0.0/4")
373 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
374 step("Send the IGMP join from r0")
375 step("Send multicast traffic from r5")
377 step("r1 , r2, r3, r4: Delete existing RP configuration" "configure r1(LHR) as RP")
383 "rp_addr": "1.0.2.17",
384 "group_addr_range": GROUP_RANGE_ALL
,
394 "rp_addr": "1.0.2.17",
395 "group_addr_range": GROUP_RANGE_ALL
,
405 "rp_addr": "1.0.2.17",
406 "group_addr_range": GROUP_RANGE_ALL
,
416 "rp_addr": "1.0.2.17",
417 "group_addr_range": GROUP_RANGE_ALL
,
425 result
= create_pim_config(tgen
, TOPO
, input_dict
)
426 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
428 step("r1: Configure r1(LHR) as RP")
434 "rp_addr": "1.0.1.17",
435 "group_addr_range": GROUP_RANGE_ALL
,
444 "rp_addr": "1.0.1.17",
445 "group_addr_range": GROUP_RANGE_ALL
,
454 "rp_addr": "1.0.1.17",
455 "group_addr_range": GROUP_RANGE_ALL
,
464 "rp_addr": "1.0.1.17",
465 "group_addr_range": GROUP_RANGE_ALL
,
472 result
= create_pim_config(tgen
, TOPO
, input_dict
)
473 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
475 shutdown_bringup_interface(tgen
, "r1", "lo", False)
477 shutdown_bringup_interface(tgen
, "r1", "lo", True)
480 step("r1: Verify RP info")
482 rp_address
= "1.0.1.17"
484 result
= verify_pim_rp_info(
485 tgen
, TOPO
, dut
, GROUP_RANGE_ALL
, iif
, rp_address
, SOURCE
487 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
489 step("r0: Send IGMP join")
490 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
491 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
493 step("r1: Verify IGMP groups")
495 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
496 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
498 step("r5: Send multicast traffic for group 225.1.1.1")
499 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
500 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
502 step("r1: Verify (*, G) upstream IIF interface")
503 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
504 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
506 step("r1: Verify (*, G) upstream join state and join timer")
507 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
508 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
510 step("r1: Verify (*, G) ip mroutes")
511 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
512 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
514 step("r1: Verify (S, G) upstream IIF interface")
516 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
517 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
519 step("r1: Verify (S, G) upstream join state and join timer")
520 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
521 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
523 step("r1: Verify (S, G) ip mroutes")
524 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
525 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
527 step("r3: Verify (S, G) upstream IIF interface")
530 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
531 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
533 step("r3: Verify (S, G) upstream join state and join timer")
534 result
= verify_join_state_and_timer(
535 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
537 assert result
is not True, (
538 "Testcase {} : Failed \n "
539 "Expected: [{}]: Upstream Join State should not be Joined and "
540 "join timer should not run\n "
541 "Found: {}".format(tc_name
, dut
, result
)
544 step("r3: Verify (S, G) ip mroutes")
546 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
547 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
549 # Uncomment next line for debugging
552 write_test_footer(tc_name
)
555 def test_RP_configured_as_LHR_2_p1(request
):
557 TC_21_2_P1: Verify OIF and RPF for (*,G) and (S,G) when static RP configure
564 r0-----r1-------------r3-----r5
571 tc_name
= request
.node
.name
572 write_test_header(tc_name
)
574 # Don"t run this test if we have any failure.
575 if tgen
.routers_have_failure():
576 pytest
.skip(tgen
.errors
)
578 step("Creating configuration from JSON")
579 reset_config_on_routers(tgen
)
580 app_helper
.stop_all_hosts()
582 clear_pim_interface_traffic(tgen
, TOPO
)
584 step("Enable IGMP on r1 interface")
585 step("Configure RP on r1 (loopback interface) for the group range" " 224.0.0.0/4")
586 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
587 step("Send multicast traffic from r5")
588 step("Send the IGMP join from r0")
590 step("r1, r2, r3, r4: Delete existing RP configuration," "configure r1(LHR) as RP")
596 "rp_addr": "1.0.2.17",
597 "group_addr_range": GROUP_RANGE_ALL
,
607 "rp_addr": "1.0.2.17",
608 "group_addr_range": GROUP_RANGE_ALL
,
618 "rp_addr": "1.0.2.17",
619 "group_addr_range": GROUP_RANGE_ALL
,
629 "rp_addr": "1.0.2.17",
630 "group_addr_range": GROUP_RANGE_ALL
,
638 result
= create_pim_config(tgen
, TOPO
, input_dict
)
639 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
641 step("r1, r2, r3, r4: Configure r1(LHR) as RP")
647 "rp_addr": "1.0.1.17",
648 "group_addr_range": GROUP_RANGE_ALL
,
657 "rp_addr": "1.0.1.17",
658 "group_addr_range": GROUP_RANGE_ALL
,
667 "rp_addr": "1.0.1.17",
668 "group_addr_range": GROUP_RANGE_ALL
,
677 "rp_addr": "1.0.1.17",
678 "group_addr_range": GROUP_RANGE_ALL
,
685 result
= create_pim_config(tgen
, TOPO
, input_dict
)
686 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
688 step("r1: Verify RP info")
690 rp_address
= "1.0.1.17"
692 result
= verify_pim_rp_info(tgen
, TOPO
, dut
, GROUP_ADDRESS
, iif
, rp_address
, SOURCE
)
693 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
695 step("r5: Send multicast traffic for group 225.1.1.1")
696 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
697 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
699 step("r0: Send IGMP join")
700 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
701 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
703 step("r1: Verify IGMP groups")
705 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
706 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
708 step("r1: Verify (*, G) upstream IIF interface")
709 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
710 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
712 step("r1: Verify (*, G) upstream join state and join timer")
713 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
714 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
716 step("r1: Verify (*, G) ip mroutes")
717 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
718 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
720 step("r1: Verify (S, G) upstream IIF interface")
722 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
723 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
725 step("r1: Verify (S, G) upstream join state and join timer")
726 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
727 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
729 step("r1: Verify (S, G) ip mroutes")
730 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
731 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
733 step("r3: Verify (S, G) upstream IIF interface")
736 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
737 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
739 step("r3: Verify (S, G) upstream join state and join timer")
740 result
= verify_join_state_and_timer(
741 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
743 assert result
is not True, (
744 "Testcase {} : Failed \n "
745 "Expected: [{}]: Upstream Join State should not be Joined and "
746 "join timer should not run\n "
747 "Found: {}".format(tc_name
, dut
, result
)
750 step("r3: Verify (S, G) ip mroutes")
752 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
753 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
755 # Uncomment next line for debugging
758 write_test_footer(tc_name
)
761 def test_RP_configured_as_FHR_1_p1(request
):
763 TC_22_1_P1: Verify OIF and RFP for (*,G) and (S,G) when static RP configure
770 r0-----r1-------------r3-----r5
777 tc_name
= request
.node
.name
778 write_test_header(tc_name
)
780 # Don"t run this test if we have any failure.
781 if tgen
.routers_have_failure():
782 pytest
.skip(tgen
.errors
)
784 step("Creating configuration from JSON")
785 reset_config_on_routers(tgen
)
786 app_helper
.stop_all_hosts()
788 clear_pim_interface_traffic(tgen
, TOPO
)
790 step("Enable IGMP on r1 interface")
791 step("Configure RP on r2 (loopback interface) for the group range" " 225.1.1.0/24")
792 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
793 step("Send the IGMP join from r0")
794 step("Send multicast traffic from r5")
796 step("r1, r2, r3, r4: Delete existing RP configuration" "configure r3(FHR) as RP")
802 "rp_addr": "1.0.2.17",
803 "group_addr_range": GROUP_RANGE_ALL
,
813 "rp_addr": "1.0.2.17",
814 "group_addr_range": GROUP_RANGE_ALL
,
824 "rp_addr": "1.0.2.17",
825 "group_addr_range": GROUP_RANGE_ALL
,
835 "rp_addr": "1.0.2.17",
836 "group_addr_range": GROUP_RANGE_ALL
,
843 result
= create_pim_config(tgen
, TOPO
, input_dict
)
844 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
846 step("r1, r2, r3, r4: Configure r3(FHR) as RP")
852 "rp_addr": "1.0.3.17",
853 "group_addr_range": GROUP_RANGE_ALL
,
862 "rp_addr": "1.0.3.17",
863 "group_addr_range": GROUP_RANGE_ALL
,
872 "rp_addr": "1.0.3.17",
873 "group_addr_range": GROUP_RANGE_ALL
,
882 "rp_addr": "1.0.3.17",
883 "group_addr_range": GROUP_RANGE_ALL
,
890 result
= create_pim_config(tgen
, TOPO
, input_dict
)
891 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
893 step("r1: Verify RP info")
895 rp_address
= "1.0.3.17"
897 result
= verify_pim_rp_info(
898 tgen
, TOPO
, dut
, GROUP_RANGE_ALL
, iif
, rp_address
, SOURCE
900 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
902 step("r0: Send IGMP join")
903 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
904 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
906 step("r0: Verify IGMP groups")
908 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
909 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
911 step("r5: Send multicast traffic for group 225.1.1.1")
912 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
913 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
915 step("r1: Verify (*, G) upstream IIF interface")
916 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
917 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
919 step("r1: Verify (*, G) upstream join state and join timer")
920 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
921 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
923 step("r1: Verify (*, G) ip mroutes")
924 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
925 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
927 step("r1: Verify (S, G) upstream IIF interface")
928 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
929 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
931 step("r1: Verify (S, G) upstream join state and join timer")
932 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
933 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
935 step("r1: Verify (S, G) ip mroutes")
936 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
937 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
939 step("r3: Verify (S, G) upstream IIF interface")
942 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
943 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
945 step("r3: Verify (S, G) upstream join state and join timer")
946 result
= verify_join_state_and_timer(
947 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
949 assert result
is not True, (
950 "Testcase {} : Failed \n "
951 "Expected: [{}]: Upstream Join State should not be Joined and "
952 "join timer should not run\n "
953 "Found: {}".format(tc_name
, dut
, result
)
956 step("r3: Verify (S, G) ip mroutes")
958 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
959 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
961 # Uncomment next line for debugging
964 write_test_footer(tc_name
)
967 def test_RP_configured_as_FHR_2_p2(request
):
969 TC_22_2_P2: Verify OIF and RFP for (*,G) and (S,G) when static RP configure
976 r0-----r1-------------r3-----r5
982 tc_name
= request
.node
.name
983 write_test_header(tc_name
)
985 # Don"t run this test if we have any failure.
986 if tgen
.routers_have_failure():
987 pytest
.skip(tgen
.errors
)
989 step("Creating configuration from JSON")
990 reset_config_on_routers(tgen
)
991 app_helper
.stop_all_hosts()
993 clear_pim_interface_traffic(tgen
, TOPO
)
995 step("Enable IGMP on r1 interface")
996 step("Configure RP on r2 (loopback interface) for the group range" " 225.1.1.0/24")
997 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
998 step("Send multicast traffic from r5")
999 step("Send the IGMP join from r0")
1001 step("r1, r2, r3, r4: Delete existing RP configuration" "configure r3(FHR) as RP")
1007 "rp_addr": "1.0.2.17",
1008 "group_addr_range": GROUP_RANGE_ALL
,
1018 "rp_addr": "1.0.2.17",
1019 "group_addr_range": GROUP_RANGE_ALL
,
1029 "rp_addr": "1.0.2.17",
1030 "group_addr_range": GROUP_RANGE_ALL
,
1040 "rp_addr": "1.0.2.17",
1041 "group_addr_range": GROUP_RANGE_ALL
,
1049 result
= create_pim_config(tgen
, TOPO
, input_dict
)
1050 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1052 step("r1, r2, r3, r4: Configure r3(FHR) as RP")
1058 "rp_addr": "1.0.3.17",
1059 "group_addr_range": GROUP_RANGE_ALL
,
1068 "rp_addr": "1.0.3.17",
1069 "group_addr_range": GROUP_RANGE_ALL
,
1078 "rp_addr": "1.0.3.17",
1079 "group_addr_range": GROUP_RANGE_ALL
,
1088 "rp_addr": "1.0.3.17",
1089 "group_addr_range": GROUP_RANGE_ALL
,
1096 result
= create_pim_config(tgen
, TOPO
, input_dict
)
1097 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1099 step("r1: Verify RP info")
1101 rp_address
= "1.0.3.17"
1103 result
= verify_pim_rp_info(
1104 tgen
, TOPO
, dut
, GROUP_RANGE_ALL
, iif
, rp_address
, SOURCE
1106 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1108 step("r5: Send multicast traffic for group 225.1.1.1")
1109 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
1110 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1112 step("r0: Send IGMP join")
1113 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
1114 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1116 step("r0: Verify IGMP groups")
1118 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
1119 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1121 step("r1: Verify (*, G) upstream IIF interface")
1122 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1123 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1125 step("r1: Verify (*, G) upstream join state and join timer")
1126 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1127 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1129 step("r1: Verify (*, G) ip mroutes")
1130 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
1131 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1133 step("r1: Verify (S, G) upstream IIF interface")
1135 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1136 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1138 step("r1: Verify (S, G) upstream join state and join timer")
1139 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1140 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1142 step("r1: Verify (S, G) ip mroutes")
1143 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1144 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1146 step("r3: Verify (S, G) upstream IIF interface")
1149 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1150 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1152 step("r3: Verify (S, G) upstream join state and join timer")
1153 result
= verify_join_state_and_timer(
1154 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
1156 assert result
is not True, (
1157 "Testcase {} : Failed \n "
1158 "Expected: [{}]: Upstream Join State should not be Joined and "
1159 "join timer should not run\n "
1160 "Found: {}".format(tc_name
, dut
, result
)
1163 step("r3: Verify (S, G) ip mroutes")
1165 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1166 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1168 # Uncomment next line for debugging
1169 # tgen.mininet_cli()
1171 write_test_footer(tc_name
)
1174 def test_SPT_RPT_path_different_p1(request
):
1176 TC_23_P1: Verify (*,G) and (S,G) populated correctly when RPT and SPT path
1183 r0-----r1-------------r3-----r5
1190 tgen
= get_topogen()
1191 tc_name
= request
.node
.name
1192 write_test_header(tc_name
)
1194 # Don"t run this test if we have any failure.
1195 if tgen
.routers_have_failure():
1196 pytest
.skip(tgen
.errors
)
1198 step("Creating configuration from JSON")
1199 reset_config_on_routers(tgen
)
1200 app_helper
.stop_all_hosts()
1202 clear_pim_interface_traffic(tgen
, TOPO
)
1204 step("Enable IGMP on r1 interface and send IGMP join (225.1.1.1) to r1")
1205 step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4")
1206 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
1207 step("Send multicast traffic from r3")
1209 step("r2: Verify RP info")
1211 rp_address
= "1.0.2.17"
1213 result
= verify_pim_rp_info(tgen
, TOPO
, dut
, GROUP_ADDRESS
, iif
, rp_address
, SOURCE
)
1214 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1216 step("r0: Send IGMP join")
1217 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
1218 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1220 step("r1: Verify IGMP groups")
1223 result
= verify_igmp_groups(tgen
, dut
, oif
, GROUP_ADDRESS
)
1224 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1226 step("r5: Send multicast traffic for group 225.1.1.1")
1227 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
1228 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1230 step("r1: Verify (*, G) upstream IIF interface")
1232 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1233 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1235 step("r1: Verify (*, G) upstream join state and join timer")
1236 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1237 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1239 step("r1: Verify (*, G) ip mroutes")
1240 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
1241 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1243 step("r1: Verify (S, G) upstream IIF interface")
1245 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1246 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1248 step("r1: Verify (S, G) upstream join state and join timer")
1249 result
= verify_join_state_and_timer(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1250 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1252 step("r1: Verify (S, G) ip mroutes")
1253 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1254 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1256 step("r2: Verify (*, G) upstream IIF interface")
1259 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1260 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1262 step("r2: Verify (*, G) upstream join state and join timer")
1263 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1264 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1266 step("r2: Verify (*, G) ip mroutes")
1268 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
1269 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1271 step("r3: Verify (S, G) upstream IIF interface")
1274 result
= verify_upstream_iif(tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
)
1275 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1277 step("r3: Verify (S, G) upstream join state and join timer")
1278 result
= verify_join_state_and_timer(
1279 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
1281 assert result
is not True, (
1282 "Testcase {} : Failed \n "
1283 "Expected: [{}]: Upstream Join State should not be Joined and "
1284 "join timer should not run\n "
1285 "Found: {}".format(tc_name
, dut
, result
)
1288 step("r3: Verify (S, G) ip mroutes")
1290 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1291 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1293 step("r2: Verify (S, G) upstream IIF interface")
1296 result
= verify_upstream_iif(
1297 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, joinState
="NotJoined"
1299 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1301 step("r2: Verify (S, G) upstream join state and join timer")
1302 result
= verify_join_state_and_timer(
1303 tgen
, dut
, iif
, SOURCE_ADDRESS
, GROUP_ADDRESS
, expected
=False
1305 assert result
is not True, (
1306 "Testcase {} : Failed \n "
1307 "Expected: [{}]: Upstream Join State should not be Joined and "
1308 "join timer should not run\n "
1309 "Found: {}".format(tc_name
, dut
, result
)
1312 step("r2: Verify (S, G) ip mroutes")
1314 result
= verify_mroutes(tgen
, dut
, SOURCE_ADDRESS
, GROUP_ADDRESS
, iif
, oif
)
1315 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1317 # Uncomment next line for debugging
1318 # tgen.mininet_cli()
1320 write_test_footer(tc_name
)
1323 def test_clear_pim_configuration_p1(request
):
1325 TC_25_P1: Verify (*,G) and (S,G) populated correctly after clearing the
1326 PIM,IGMP and mroutes joins
1332 r0-----r1-------------r3-----r5
1341 tgen
= get_topogen()
1342 tc_name
= request
.node
.name
1343 write_test_header(tc_name
)
1345 # Don"t run this test if we have any failure.
1346 if tgen
.routers_have_failure():
1347 pytest
.skip(tgen
.errors
)
1349 step("Creating configuration from JSON")
1350 reset_config_on_routers(tgen
)
1351 app_helper
.stop_all_hosts()
1353 clear_pim_interface_traffic(tgen
, TOPO
)
1355 step("Enable IGMP on r1 interface")
1356 step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4")
1357 step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
1358 step("Send the IGMP join from r0")
1359 step("Send multicast traffic from r5")
1361 step("r2: Verify RP info")
1363 rp_address
= "1.0.2.17"
1365 result
= verify_pim_rp_info(
1366 tgen
, TOPO
, dut
, GROUP_RANGE_ALL
, oif
, rp_address
, SOURCE
1368 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1370 step("r0: Send IGMP join")
1371 result
= app_helper
.run_join("r0", GROUP_ADDRESS
, "r1")
1372 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1374 step("r1: Verify IGMP groups")
1377 result
= verify_igmp_groups(tgen
, dut
, iif
, GROUP_ADDRESS
)
1378 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1380 step("r5: Send multicast traffic for group 225.1.1.1")
1381 result
= app_helper
.run_traffic("r5", GROUP_ADDRESS
, "r3")
1382 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1384 step("r1: Verify (*, G) upstream IIF interface")
1387 result
= verify_upstream_iif(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1388 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1390 step("r1: Verify (*, G) upstream join state and join timer")
1391 result
= verify_join_state_and_timer(tgen
, dut
, iif
, STAR
, GROUP_ADDRESS
)
1392 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1394 step("r1: Verify (*, G) ip mroutes")
1396 result
= verify_mroutes(tgen
, dut
, STAR
, GROUP_ADDRESS
, iif
, oif
)
1397 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1399 step("r1: Verify IGMP groups timer restarted")
1400 result
= clear_igmp_interfaces(tgen
, dut
)
1401 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1403 step("r1: Verify PIM neighbor timer restarted")
1404 result
= clear_pim_interfaces(tgen
, dut
)
1405 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1407 step("r1: Verify PIM mroute timer restarted")
1408 result
= clear_mroute_verify(tgen
, dut
)
1409 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1411 # Uncomment next line for debugging
1412 # tgen.mininet_cli()
1414 write_test_footer(tc_name
)
1417 if __name__
== "__main__":
1418 ARGS
= ["-s"] + sys
.argv
[1:]
1419 sys
.exit(pytest
.main(ARGS
))