3 # Copyright (c) 2020 by VMware, Inc. ("VMware")
4 # Used Copyright (c) 2018 by Network Device Education Foundation,
5 # Inc. ("NetDEF") in this file.
7 # Permission to use, copy, modify, and/or distribute this software
8 # for any purpose with or without fee is hereby granted, provided
9 # that the above copyright notice and this permission notice appear
12 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
13 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
15 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
16 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
18 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 Following tests are covered to test PIM BSM processing basic functionality:
26 - Create topology (setup module)
29 Tests covered in this suite
30 1. Verify FRR router select higher IP BSR , when 2 BSR present in the network
31 2. Verify BSR and RP updated correctly after configuring as black hole address
32 3.1 Verify when new router added to the topology, FRR node will send
33 unicast BSM to new router
34 3.2 Verify if no forwarding bit is set , FRR is not forwarding the
36 3.3 Verify multicast BSM is sent to new router when unicast BSM is disabled
37 4.1 Verfiy BSM arrived on non bsm capable interface is dropped and
39 4.2 Verify group to RP info updated correctly in FRR node, after shut and
40 no-shut of BSM enable interfaces
41 5. Verify static RP is preferred over BSR
42 6.1 Verify adding/deleting the group to rp mapping and RP priority
44 6.2 Verify RP and (*,G) detail after PIM process restart on FRR node
45 7.1 Verify BSM timeout on FRR1
46 7.2 Verify RP state in FRR1 after Bootstrap timer expiry
47 8.1 Verify upstream interfaces(IIF) and join state are updated properly
48 after BSM received for FRR
49 8.2 Verify IIF and OIL in "show ip pim state" updated properly after
58 # Save the Current Working Directory to find configuration files.
59 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
60 sys
.path
.append(os
.path
.join(CWD
, "../"))
61 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
63 # Required to instantiate the topology builder class.
65 # pylint: disable=C0413
66 # Import topogen and topotest helpers
67 from lib
.topogen
import Topogen
, get_topogen
69 from lib
.common_config
import (
78 shutdown_bringup_interface
,
81 reset_config_on_routers
,
85 required_linux_kernel_version
,
91 add_rp_interfaces_and_pim_config
,
93 scapy_send_bsr_raw_packet
,
94 find_rp_from_bsrp_info
,
95 verify_pim_grp_rp_source
,
98 verify_join_state_and_timer
,
102 verify_ip_pim_upstream_rpf
,
103 enable_disable_pim_unicast_bsm
,
104 enable_disable_pim_bsm
,
106 clear_ip_pim_interface_traffic
,
107 get_pim_interface_traffic
,
110 from lib
.topolog
import logger
111 from lib
.topojson
import build_config_from_json
114 pytestmark
= [pytest
.mark
.pimd
, pytest
.mark
.staticd
]
121 s1-----f1-----i1-----l1----r1
130 i1 - Intermediate Router (also RP)
135 NEXT_HOP1
= "70.0.0.1"
136 NEXT_HOP2
= "65.0.0.1"
138 BSR_IP_2
= "10.2.1.1"
139 BSR1_ADDR
= "1.1.2.7/32"
140 BSR2_ADDR
= "10.2.1.1/32"
143 def setup_module(mod
):
145 Sets up the pytest environment
150 # Required linux kernel version for this suite to run.
151 result
= required_linux_kernel_version("4.15")
152 if result
is not True:
153 pytest
.skip("Kernel requirements are not met")
155 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
156 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
157 logger
.info("=" * 40)
158 logger
.info("Master Topology: \n {}".format(TOPOLOGY
))
160 logger
.info("Running setup_module to create topology")
162 # This function initiates the topology build with Topogen...
163 json_file
= "{}/mcast_pim_bsmp_01.json".format(CWD
)
164 tgen
= Topogen(json_file
, mod
.__name
__)
166 topo
= tgen
.json_topo
167 # ... and here it calls Mininet initialization functions.
169 # get list of daemons needs to be started for this suite.
170 daemons
= topo_daemons(tgen
, topo
)
172 # Starting topology, create tmp files which are loaded to routers
173 # to start deamons and then start routers
174 start_topology(tgen
, daemons
)
176 # Don"t run this test if we have any failure.
177 if tgen
.routers_have_failure():
178 pytest
.skip(tgen
.errors
)
180 # Creating configuration from JSON
181 build_config_from_json(tgen
, topo
)
183 # XXX Replace this using "with McastTesterHelper()... " in each test if possible.
185 app_helper
= McastTesterHelper(tgen
)
187 logger
.info("Running setup_module() done")
190 def teardown_module():
191 """Teardown the pytest environment"""
193 logger
.info("Running teardown_module to delete topology")
199 # Stop toplogy and Remove tmp files
203 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
205 logger
.info("=" * 40)
208 #####################################################
212 #####################################################
215 def clear_bsrp_data(tgen
, topo
):
218 clear bsm databas after test"
221 * `tgen`: topogen object
225 result = clear_bsrp_data(tgen, topo)
228 errormsg(str) or True
231 for dut
in tgen
.routers():
233 rnode
= tgen
.routers()[dut
]
235 logger
.info("[DUT: %s]: clear_bsrp_data")
237 run_frr_cmd(rnode
, "clear ip pim bsr-data")
242 def verify_state_incremented(state_before
, state_after
):
244 API to compare interface traffic state incrementing
248 * `state_before` : State dictionary for any particular instance
249 * `state_after` : State dictionary for any particular instance
252 for router
, state_data
in state_before
.items():
253 for state
, value
in state_data
.items():
254 if state_before
[router
][state
] >= state_after
[router
][state
]:
256 "[DUT: %s]: state %s value has not"
257 " incremented, Initial value: %s, "
258 "Current value: %s [FAILED!!]"
262 state_before
[router
][state
],
263 state_after
[router
][state
],
269 "[DUT: %s]: State %s value is "
270 "incremented, Initial value: %s, Current value: %s"
274 state_before
[router
][state
],
275 state_after
[router
][state
],
281 def pre_config_to_bsm(tgen
, topo
, tc_name
, bsr
, sender
, receiver
, fhr
, rp
, lhr
, packet
):
283 API to do required configuration to send and receive BSR packet
286 # Re-configure interfaces as per BSR packet
287 result
= reconfig_interfaces(tgen
, topo
, bsr
, fhr
, packet
)
288 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
290 # Create static routes
291 if "bsr" in topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]:
292 bsr_route
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["bsr"]
293 next_hop
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["src_ip"].split(
296 next_hop_rp
= topo
["routers"][fhr
]["links"][rp
]["ipv4"].split("/")[0]
297 next_hop_lhr
= topo
["routers"][rp
]["links"][lhr
]["ipv4"].split("/")[0]
301 fhr
: {"static_routes": [{"network": bsr_route
, "next_hop": next_hop
}]},
302 rp
: {"static_routes": [{"network": bsr_route
, "next_hop": next_hop_rp
}]},
303 lhr
: {"static_routes": [{"network": bsr_route
, "next_hop": next_hop_lhr
}]},
306 result
= create_static_routes(tgen
, input_dict
)
307 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
310 rp_mapping
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["rp_mapping"]
312 # Add interfaces in RP for all the RPs
313 result
= add_rp_interfaces_and_pim_config(tgen
, topo
, "lo", rp
, rp_mapping
)
314 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
316 # Add kernal routes to sender and receiver
317 for group
, rp_list
in rp_mapping
.items():
318 mask
= group
.split("/")[1]
320 group
= group
.split("/")[0]
322 # Add static routes for RPs in FHR and LHR
323 next_hop_fhr
= topo
["routers"][rp
]["links"][fhr
]["ipv4"].split("/")[0]
324 next_hop_lhr
= topo
["routers"][rp
]["links"][lhr
]["ipv4"].split("/")[0]
326 fhr
: {"static_routes": [{"network": rp_list
, "next_hop": next_hop_fhr
}]},
328 result
= create_static_routes(tgen
, input_dict
)
329 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
332 lhr
: {"static_routes": [{"network": rp_list
, "next_hop": next_hop_lhr
}]},
334 result
= create_static_routes(tgen
, input_dict
)
335 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
339 #####################################################
343 #####################################################
346 def test_BSR_higher_prefer_ip_p0(request
):
348 Verify FRR router select higher IP BSR , when 2 BSR present in the network
354 s1-----f1-----i1-----l1----r1
363 i1 - Intermediate Router (also RP)
368 tc_name
= request
.node
.name
369 write_test_header(tc_name
)
371 # Don"t run this test if we have any failure.
372 if tgen
.routers_have_failure():
373 pytest
.skip(tgen
.errors
)
375 app_helper
.stop_all_hosts()
376 clear_ip_mroute(tgen
)
377 reset_config_on_routers(tgen
)
378 clear_ip_pim_interface_traffic(tgen
, topo
)
380 reset_config_on_routers(tgen
)
381 step("pre-configure BSM packet")
382 step("Configure cisco-1 as BSR1 1.1.2.7")
383 result
= pre_config_to_bsm(
384 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
386 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
387 step("Configure cisco-1 as BSR1 10.2.1.1")
388 result
= pre_config_to_bsm(
389 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
391 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
392 step("configuring loopback address of b1 and b2 as BSR")
393 intf_lo_addr_b1
= topo
["routers"]["b1"]["links"]["lo"]["ipv4"]
394 intf_lo_addr_b2
= topo
["routers"]["b2"]["links"]["lo"]["ipv4"]
400 "no ip address {}".format(intf_lo_addr_b1
),
401 "ip address {}".format(BSR1_ADDR
),
408 "no ip address {}".format(intf_lo_addr_b2
),
409 "ip address {}".format(BSR2_ADDR
),
414 result
= apply_raw_config(tgen
, raw_config
)
415 assert result
is True, "Testcase {} : Failed Error: {}".format(tc_name
, result
)
417 GROUP_ADDRESS
= "225.200.100.100"
418 step("configuring static routes for both the BSR")
420 next_hop_rp
= topo
["routers"]["f1"]["links"]["i1"]["ipv4"].split("/")[0]
421 next_hop_lhr
= topo
["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0]
426 {"network": BSR1_ADDR
, "next_hop": NEXT_HOP1
},
427 {"network": BSR2_ADDR
, "next_hop": NEXT_HOP2
},
432 {"network": BSR1_ADDR
, "next_hop": next_hop_rp
},
433 {"network": BSR2_ADDR
, "next_hop": next_hop_rp
},
438 {"network": BSR1_ADDR
, "next_hop": next_hop_lhr
},
439 {"network": BSR2_ADDR
, "next_hop": next_hop_lhr
},
444 result
= create_static_routes(tgen
, input_dict
)
445 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
447 # Use scapy to send pre-defined packet from senser to receiver
448 step("Send BSR packet from b1 to FHR")
449 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
450 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
452 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
453 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
457 step("Verify if b1 chosen as BSR in f1")
458 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_1
)
459 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
461 group
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
462 step("Find the elected rp from bsrp-info in LHR l1")
463 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_1
, group
)
464 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
466 step("Verify RP in LHR")
467 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
468 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
470 step("Send BSR packet from b2 to FHR")
471 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b2", "f1", "packet3")
472 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
475 step("Verify if b2 chosen as BSR in f1")
476 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_2
)
477 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
479 step("Find the elected rp from bsrp-info in LHR l1")
480 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_2
, group
)
481 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
483 step("Verify RP in LHR")
484 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
485 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
487 step("Shut higher prefer BSR2 link f1 to b2")
489 f1_b2_eth1
= topo
["routers"]["f1"]["links"]["b2"]["interface"]
490 shutdown_bringup_interface(tgen
, "f1", "f1-b2-eth1", False)
492 step("clearing bsr to timeout old BSR")
493 clear_bsrp_data(tgen
, topo
)
495 step("Send BSR packet from b1 and b2 to FHR")
496 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
497 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
499 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b2", "f1", "packet3")
500 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
502 step("sleeping for 3 sec to leran new packet")
504 step("verify BSR1 is become prefered RP")
507 step("Verify if b1 chosen as BSR in f1")
508 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_1
)
509 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
511 step("Find the elected rp from bsrp-info in LHR l1")
512 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_1
, group
)
513 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
515 step("Verify RP in LHR")
516 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
517 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
519 step("NoShut higher prefer BSR2 link f1 to b2")
520 step("sleeping for 3 min to leran new packet")
522 f1_b2_eth1
= topo
["routers"]["f1"]["links"]["b2"]["interface"]
523 shutdown_bringup_interface(tgen
, "f1", "f1-b2-eth1", True)
524 step("verify BSR2 is become prefered RP")
527 step("Send BSR packet from b1 and b2 to FHR")
528 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
529 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
531 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b2", "f1", "packet3")
532 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
534 step("Verify if b2 chosen as BSR in f1")
535 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_2
)
536 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
538 step("Find the elected rp from bsrp-info in LHR l1")
539 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_2
, group
)
540 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
542 step("Verify RP in LHR")
543 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
544 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
546 step("Clear BSM database before moving to next case")
547 clear_bsrp_data(tgen
, topo
)
549 write_test_footer(tc_name
)
552 def test_BSR_CRP_with_blackhole_address_p1(request
):
554 Verify BSR and RP updated correctly after configuring as black hole address
560 s1-----f1-----i1-----l1----r1
569 i1 - Intermediate Router (also RP)
574 tc_name
= request
.node
.name
575 write_test_header(tc_name
)
577 # Don"t run this test if we have any failure.
578 if tgen
.routers_have_failure():
579 pytest
.skip(tgen
.errors
)
581 app_helper
.stop_all_hosts()
582 clear_ip_mroute(tgen
)
583 reset_config_on_routers(tgen
)
584 clear_ip_pim_interface_traffic(tgen
, topo
)
586 reset_config_on_routers(tgen
)
587 step("pre-configure BSM packet")
588 step("Configure cisco-1 as BSR1 1.1.2.7")
589 result
= pre_config_to_bsm(
590 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
592 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
594 step("configuring loopback address of b1 and b2 as BSR")
595 intf_lo_addr_b1
= topo
["routers"]["b1"]["links"]["lo"]["ipv4"]
601 "no ip address {}".format(intf_lo_addr_b1
),
602 "ip address {}".format(BSR1_ADDR
),
607 result
= apply_raw_config(tgen
, raw_config
)
608 assert result
is True, "Testcase {} : Failed Error: {}".format(tc_name
, result
)
610 GROUP_ADDRESS
= "225.200.100.100"
611 step("configuring static routes for both the BSR")
613 next_hop_rp
= topo
["routers"]["f1"]["links"]["i1"]["ipv4"].split("/")[0]
614 next_hop_lhr
= topo
["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0]
615 next_hop_fhr
= topo
["routers"]["i1"]["links"]["f1"]["ipv4"].split("/")[0]
616 CRP
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["candidate_rp"]
619 "i1": {"static_routes": [{"network": BSR1_ADDR
, "next_hop": next_hop_rp
}]},
620 "l1": {"static_routes": [{"network": BSR1_ADDR
, "next_hop": next_hop_lhr
}]},
623 {"network": CRP
, "next_hop": next_hop_fhr
, "delete": True}
628 result
= create_static_routes(tgen
, input_dict
)
629 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
631 # Use scapy to send pre-defined packet from senser to receiver
633 group
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
634 step("waiting for BSR to timeout before configuring blackhole route")
635 clear_bsrp_data(tgen
, topo
)
637 step("Configure black-hole address for BSR and candidate RP")
640 "static_routes": [{"network": [BSR1_ADDR
, CRP
], "next_hop": "blackhole"}]
644 result
= create_static_routes(tgen
, input_dict
)
645 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
647 intf_f1_i1
= topo
["routers"]["f1"]["links"]["i1"]["interface"]
648 step("Verify bsm transit count is not increamented" "show ip pim interface traffic")
649 state_dict
= {"f1": {intf_f1_i1
: ["bsmTx"]}}
651 state_before
= get_pim_interface_traffic(tgen
, state_dict
)
654 ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
658 step("Sending BSR after Configure black hole address for BSR and candidate RP")
659 step("Send BSR packet from b1 to FHR")
660 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
661 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
664 step("Find the elected rp from bsrp-info in LHR l1")
665 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_1
, group
)
666 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
668 step("Verify if b1 chosen as BSR in l1")
669 result
= verify_pim_bsr(tgen
, topo
, "l1", BSR_IP_1
, expected
=False)
672 ), "Testcase {} : Failed \n " "b1 is not chosen as BSR in l1 \n Error: {}".format(
676 state_after
= get_pim_interface_traffic(tgen
, state_dict
)
679 ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
683 result
= verify_state_incremented(state_before
, state_after
)
684 assert result
is not True, "Testcase{} : Failed Error: {}".format(tc_name
, result
)
686 step("Remove black-hole address for BSR and candidate RP")
690 {"network": [BSR1_ADDR
, CRP
], "next_hop": "blackhole", "delete": True},
691 {"network": BSR1_ADDR
, "next_hop": NEXT_HOP1
},
696 result
= create_static_routes(tgen
, input_dict
)
697 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
699 step("Sending BSR after removing black-hole address for BSR and candidate RP")
700 step("Send BSR packet from b1 to FHR")
701 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
702 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
704 step("Verify if b1 chosen as BSR in f1")
705 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_1
)
706 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
709 group
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
710 step("Find the elected rp from bsrp-info in LHR l1")
711 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_1
, group
)
712 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
714 step("Verify RP in LHR l1")
715 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
716 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
718 step("clear BSM database before moving to next case")
719 clear_bsrp_data(tgen
, topo
)
721 write_test_footer(tc_name
)
724 def test_new_router_fwd_p0(request
):
726 1. Verify when new router added to the topology, FRR node will send
727 unicast BSM to new router
728 2. Verify if no forwarding bit is set , FRR is not forwarding the
729 BSM to other PIM nbrs
730 3. Verify multicast BSM is sent to new router when unicast BSM is disabled
736 s1-----f1-----i1-----l1----r1
745 i1 - Intermediate Router (also RP)
751 tc_name
= request
.node
.name
752 write_test_header(tc_name
)
754 # Don"t run this test if we have any failure.
755 if tgen
.routers_have_failure():
756 pytest
.skip(tgen
.errors
)
758 app_helper
.stop_all_hosts()
759 clear_ip_mroute(tgen
)
760 reset_config_on_routers(tgen
)
761 clear_ip_pim_interface_traffic(tgen
, topo
)
763 reset_config_on_routers(tgen
)
765 result
= pre_config_to_bsm(
766 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
768 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
770 result
= pre_config_to_bsm(
771 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
773 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
775 GROUP_ADDRESS
= "225.1.1.1"
777 # Use scapy to send pre-defined packet from senser to receiver
778 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
779 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
781 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
784 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
785 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
787 # Verify bsr state in FHR
788 step("Verify if b1 chosen as BSR in f1")
789 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
790 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
792 # Verify bsr state in i1
793 step("Verify if b1 chosen as BSR in i1")
794 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
795 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
802 step("Verify mroute populated on l1")
803 result
= verify_ip_mroutes(tgen
, "l1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
804 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
807 step("Reloading i1 and l1. Stop both. bring up l1 and then i1")
808 stop_router(tgen
, "i1")
809 start_router(tgen
, "i1")
810 stop_router(tgen
, "l1")
811 start_router(tgen
, "l1")
813 # Verify bsr state in i1
814 step("Verify BSR in i1 after restart while no new bsm sent from b1")
815 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
816 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
818 # Verify bsr state in l1
819 step("Verify no BSR in l1 as i1 would not forward the no-forward bsm")
820 result
= verify_pim_bsr(tgen
, topo
, "l1", bsr_ip
, expected
=False)
821 assert result
is not True, (
822 "Testcase {} : Failed \n "
823 "BSR data is present after no-forward bsm also \n Error: {}".format(
828 # unconfigure unicast bsm on f1-i1-eth2
829 step("unconfigure unicast bsm on f1-i1-eth2, will forward with only mcast")
830 enable_disable_pim_unicast_bsm(tgen
, "f1", "f1-i1-eth2", enable
=False)
832 # Reboot i1 to check if still bsm received with multicast address
833 step("Reboot i1 to check if still bsm received with multicast address")
834 stop_router(tgen
, "i1")
835 start_router(tgen
, "i1")
837 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
838 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
840 # Verify again if BSR is installed from bsm forwarded by f1
841 step("Verify again if BSR is installed from bsm forwarded by f1")
842 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
843 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
845 # Use scapy to send pre-defined packet from senser to receiver
846 step("Send another BSM packet from b1 which will reach l1(LHR)")
847 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet2")
848 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
851 step("Verify again if BSR is installed from bsm forwarded by i1")
852 result
= verify_pim_bsr(tgen
, topo
, "l1", bsr_ip
)
853 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
855 # Verify ip mroute populated again
856 step("Verify mroute again on l1 (lhr)")
857 result
= verify_ip_mroutes(tgen
, "l1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
858 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
860 step("clear BSM database before moving to next case")
861 clear_bsrp_data(tgen
, topo
)
863 write_test_footer(tc_name
)
866 def test_int_bsm_config_p1(request
):
868 1. Verfiy BSM arrived on non bsm capable interface is dropped and
870 2. Verify group to RP info updated correctly in FRR node, after shut and
871 no-shut of BSM enable interfaces
877 s1-----f1-----i1-----l1----r1
886 i1 - Intermediate Router (also RP)
892 tc_name
= request
.node
.name
893 write_test_header(tc_name
)
895 # Don"t run this test if we have any failure.
896 if tgen
.routers_have_failure():
897 pytest
.skip(tgen
.errors
)
899 app_helper
.stop_all_hosts()
900 clear_ip_mroute(tgen
)
901 reset_config_on_routers(tgen
)
902 clear_ip_pim_interface_traffic(tgen
, topo
)
904 reset_config_on_routers(tgen
)
906 result
= pre_config_to_bsm(
907 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
909 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
911 result
= pre_config_to_bsm(
912 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
914 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
916 GROUP_ADDRESS
= "225.1.1.1"
918 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
921 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
922 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
924 # Use scapy to send pre-defined packet from senser to receiver
925 step("Send BSM packet from b1")
926 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
927 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
929 # Verify bsr state in i1
930 step("Verify if b1 is chosen as BSR in i1")
931 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
932 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
934 # check if mroute installed
935 step("check if mroute installed in i1")
940 result
= verify_ip_mroutes(tgen
, "i1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
941 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
943 # wait till bsm rp age out
944 step("wait till bsm rp age out")
945 clear_bsrp_data(tgen
, topo
)
947 # check if mroute uninstalled because of rp age out
948 step("check if mroute uninstalled because of rp age out in i1")
949 result
= verify_ip_mroutes(
950 tgen
, "i1", src_addr
, GROUP_ADDRESS
, iif
, oil
, expected
=False
954 ), "Testcase {} : Failed \n " "Mroutes are still present \n Error: {}".format(
958 # unconfigure bsm processing on f1 on f1-i1-eth2
959 step("unconfigure bsm processing on f1 in f1-i1-eth2, will drop bsm")
960 result
= enable_disable_pim_bsm(tgen
, "f1", "f1-i1-eth2", enable
=False)
961 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
963 # Use scapy to send pre-defined packet from senser to receiver
964 step("Send BSM packet from b1")
965 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
966 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
968 # Verify bsr state in FHR
969 step("Verify if b1 chosen as BSR in f1")
970 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
971 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
973 # Verify bsr state in i1
974 step("Verify if b1 is not chosen as BSR in i1")
975 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
, expected
=False)
978 ), "Testcase {} : Failed \n " "b1 is chosen as BSR in i1 \n Error: {}".format(
982 # check if mroute still not installed because of rp not available
983 step("check if mroute still not installed because of rp not available")
984 result
= verify_ip_mroutes(
985 tgen
, "i1", src_addr
, GROUP_ADDRESS
, iif
, oil
, expected
=False
987 assert result
is not True, (
988 "Testcase {} : Failed \n "
989 "mroute installed but rp not available \n Error: {}".format(tc_name
, result
)
992 # configure bsm processing on i1 on f1-i1-eth2
993 step("configure bsm processing on f1 in f1-i1-eth2, will accept bsm")
994 result
= enable_disable_pim_bsm(tgen
, "f1", "f1-i1-eth2", enable
=True)
995 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
997 # Use scapy to send pre-defined packet from senser to receiver
998 step("Send BSM packet again from b1")
999 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet2")
1000 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1002 # Verify again if BSR is installed from bsm forwarded by f1
1003 step("Verify again if BSR is installed from bsm forwarded by f1")
1004 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
1005 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1007 # verify ip mroute populated
1008 step("Verify ip mroute")
1009 result
= verify_ip_mroutes(tgen
, "i1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
1010 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1012 # Shut/No shut the bsm rpf interface and check mroute on lhr(l1)
1013 step("Shut/No shut the bsm rpf interface and check mroute on lhr(l1)")
1015 shutdown_bringup_interface(tgen
, "l1", intf
, False)
1016 shutdown_bringup_interface(tgen
, "l1", intf
, True)
1021 result
= verify_ip_mroutes(tgen
, "l1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
1022 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1024 step("clear BSM database before moving to next case")
1025 clear_bsrp_data(tgen
, topo
)
1027 write_test_footer(tc_name
)
1030 def test_static_rp_override_p1(request
):
1032 Verify static RP is preferred over BSR
1038 s1-----f1-----i1-----l1----r1
1047 i1 - Intermediate Router (also RP)
1052 tgen
= get_topogen()
1053 tc_name
= request
.node
.name
1054 write_test_header(tc_name
)
1056 # Don"t run this test if we have any failure.
1057 if tgen
.routers_have_failure():
1058 pytest
.skip(tgen
.errors
)
1060 app_helper
.stop_all_hosts()
1061 clear_ip_mroute(tgen
)
1062 reset_config_on_routers(tgen
)
1063 clear_ip_pim_interface_traffic(tgen
, topo
)
1065 reset_config_on_routers(tgen
)
1067 result
= pre_config_to_bsm(
1068 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1070 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1072 result
= pre_config_to_bsm(
1073 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
1075 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1077 GROUP_ADDRESS
= "225.1.1.1"
1078 # Use scapy to send pre-defined packet from senser to receiver
1079 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1080 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1082 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
1085 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1086 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1088 # Verify bsr state in FHR
1089 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1090 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1093 step("Verify IGMP groups in LHR")
1096 result
= verify_igmp_groups(tgen
, dut
, intf
, GROUP_ADDRESS
)
1097 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1099 group
= "225.1.1.1/32"
1101 # Find the elected rp from bsrp-info
1102 step("Find the elected rp from bsrp-info in LHR l1")
1103 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1104 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1106 # Check RP detail in LHR
1107 step("Verify that BS RP in LHR l1")
1108 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
1109 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1112 # Verify upstream rpf for 225.1.1.1 is chosen as rp1
1113 step("Verify upstream rpf for 225.1.1.1 is chosen as bsrp")
1114 result
= verify_ip_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, rp
[group
])
1115 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1117 # Configure a static rp for the group 225.1.1.1/32
1118 step("Configure a static rp 33.33.33.33 for the group 225.1.1.1/32 in l1")
1124 "rp_addr": "33.33.33.33",
1125 "group_addr_range": ["225.1.1.1/32"],
1131 result
= create_pim_config(tgen
, topo
, input_dict
)
1132 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1134 # Verify that static rp is configured over bsrp
1135 static_rp
= "33.33.33.33"
1136 step("Verify that Static RP in LHR in l1")
1137 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "Static", static_rp
)
1138 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1140 # Verify if upstream also reflects the static rp
1141 step("Verify upstream rpf for 225.1.1.1 is chosen as static in l1")
1142 result
= verify_ip_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, static_rp
)
1143 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1145 # delete static rp for the group 225.1.1.1/32
1146 step("Delete static rp 33.33.33.33 for the group 225.1.1.1/32 in l1")
1152 "rp_addr": "33.33.33.33",
1153 "group_addr_range": ["225.1.1.1/32"],
1160 result
= create_pim_config(tgen
, topo
, input_dict
)
1161 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1163 # Verify if bsrp is installed back for the group 225.1.1.1/32
1164 step("Verify that BS RP in installed in LHR")
1165 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
1166 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1168 # Verify upstream rpf for 225.1.1.1 is chosen as bsrp
1169 step("Verify upstream rpf for 225.1.1.1 is chosen as bsrp in l1")
1170 result
= verify_ip_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, rp
[group
])
1171 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1173 step("clear BSM database before moving to next case")
1174 clear_bsrp_data(tgen
, topo
)
1176 write_test_footer(tc_name
)
1179 def test_bsmp_stress_add_del_restart_p2(request
):
1181 1. Verify adding/deleting the group to rp mapping and RP priority
1183 2. Verify RP and (*,G) detail after PIM process restart on FRR node
1189 s1-----f1-----i1-----l1----r1
1198 i1 - Intermediate Router (also RP)
1203 tgen
= get_topogen()
1204 tc_name
= request
.node
.name
1205 write_test_header(tc_name
)
1207 # Don"t run this test if we have any failure.
1208 if tgen
.routers_have_failure():
1209 pytest
.skip(tgen
.errors
)
1211 app_helper
.stop_all_hosts()
1212 clear_ip_mroute(tgen
)
1213 reset_config_on_routers(tgen
)
1214 clear_ip_pim_interface_traffic(tgen
, topo
)
1216 reset_config_on_routers(tgen
)
1218 result
= pre_config_to_bsm(
1219 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1221 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1223 result
= pre_config_to_bsm(
1224 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
1226 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1228 GROUP_ADDRESS
= "225.1.1.1"
1230 # Use scapy to send pre-defined packet from senser to receiver
1231 step("Send BSR packet from b1 to FHR")
1232 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1233 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1235 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
1238 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1239 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1241 # Verify bsr state in FHR
1242 step("Verify if b1 is chosen as bsr in f1")
1243 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1244 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1247 group
= "225.1.1.0/24"
1248 # Find the elected rp from bsrp-info
1249 step("Find the elected rp from bsrp-info in LHR l1")
1250 rp1
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1251 assert rp1
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1253 # Check RP detail in LHR
1254 step("Verify RP in LHR l1")
1255 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp1
[group
])
1256 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1258 # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24
1259 step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24")
1260 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet6")
1261 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1263 # Find the elected rp from bsrp-info
1264 step("Find the elected rp from bsrp-info in LHR l1")
1265 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1266 assert rp2
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1267 logger
.info("RP old: %s RP2 new: %s", rp1
[group
], rp2
[group
])
1269 # Verify is the rp is different now
1270 assert rp1
[group
] != rp2
[group
], "Testcase {} :Failed \n Error {}".format(
1274 rp_add1
= rp1
[group
]
1275 rp_add2
= rp2
[group
]
1277 # Verify if that rp is installed
1278 step("Verify new RP in LHR installed")
1279 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add2
)
1280 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1282 step("Change rp priority in the bsm and send multiple times")
1285 # Send BSR pkt from b1 after putting back high prio rp for 225.1.1.0/24
1286 step("Send BSM from b1 to FHR put back high prio rp for 225.1.1.0/24")
1287 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1288 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1290 # Find the elected rp from bsrp-info
1291 step("Find the elected rp from bsrp-info in LHR")
1292 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1293 assert rp2
is not {}, "Testcase {} :Failed \n Error : RP not Found".format(
1297 # Verify is the rp is different now
1298 step("Verify now old RP is elected again")
1300 rp_add1
== rp2
[group
]
1301 ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format(
1302 tc_name
, rp_add1
, rp2
[group
]
1305 # Verify if that rp is installed
1306 step("Verify old RP in LHR installed")
1307 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add1
)
1308 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1310 # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24
1311 step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24")
1312 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet6")
1313 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1315 # Verify if that rp is installed
1316 step("Verify new RP(rp2) in LHR installed")
1317 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add2
)
1318 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1321 step("Restarting pimd in LHR")
1322 kill_router_daemons(tgen
, "l1", ["pimd"])
1323 start_router_daemons(tgen
, "l1", ["pimd"])
1324 logger
.info("Restarting done")
1326 # Verify if that rp is installed
1327 step("Verify old RP in LHR installed")
1328 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add2
)
1329 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1331 # Send IGMP join to LHR
1332 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1333 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1337 # VErify mroute created after pimd restart
1338 step("VErify mroute created after pimd restart")
1342 result
= verify_ip_mroutes(tgen
, "l1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
1343 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1345 write_test_footer(tc_name
)
1348 def test_BSM_timeout_p0(request
):
1350 Verify BSM timeout on FRR1
1351 Verify RP state in FRR1 after Bootstrap timer expiry
1357 s1-----f1-----i1-----l1----r1
1366 i1 - Intermediate Router (also RP)
1371 tgen
= get_topogen()
1372 tc_name
= request
.node
.name
1373 write_test_header(tc_name
)
1375 # Don"t run this test if we have any failure.
1376 if tgen
.routers_have_failure():
1377 pytest
.skip(tgen
.errors
)
1379 app_helper
.stop_all_hosts()
1380 clear_ip_mroute(tgen
)
1381 reset_config_on_routers(tgen
)
1382 clear_ip_pim_interface_traffic(tgen
, topo
)
1384 result
= pre_config_to_bsm(
1385 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1387 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1389 result
= pre_config_to_bsm(
1390 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
1392 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1394 GROUP_ADDRESS
= "225.1.1.1"
1396 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
1398 # Use scapy to send pre-defined packet from senser to receiver
1399 step("send BSR packet from b1")
1400 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1401 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1403 # Send IGMP join for group 225.1.1.1 from receiver
1404 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1405 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1407 # Verify bsr state in FHR
1408 step("Verify bsr state in FHR f1")
1409 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1410 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1412 # Verify ip mroute in LHR
1413 step(" Verify ip mroute in LHR l1")
1418 result
= verify_ip_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
1419 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1421 # Verify join state and join timer
1422 step("Verify join state and join timer in lhr l1")
1423 result
= verify_join_state_and_timer(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
1424 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1426 # Verify upstream IIF interface
1427 step("Verify upstream IIF interface in LHR l1")
1428 result
= verify_upstream_iif(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
1429 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1433 group
= "225.1.1.1/32"
1434 step("Verify RP mapping in LHR l1")
1435 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1436 assert rp
!= {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1438 logger
.info("Waiting for 130 secs to check BSR timeout")
1439 clear_bsrp_data(tgen
, topo
)
1441 # Verify if bsr has aged out
1442 step("Verify if bsr has aged out in f1")
1443 no_bsr_ip
= "0.0.0.0"
1444 result
= verify_pim_bsr(tgen
, topo
, "f1", no_bsr_ip
)
1445 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1447 result
= verify_pim_grp_rp_source(
1448 tgen
, topo
, "f1", group
, rp_source
="BSR", expected
=False
1453 ), "Testcase {} : Failed \n " "bsr has not aged out in f1 \n Error: {}".format(
1457 # Verify RP mapping removed after hold timer expires
1458 group
= "225.1.1.1/32"
1459 step("Verify RP mapping removed after hold timer expires in l1")
1460 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1461 assert rp
== {}, "Testcase {} :Failed \n Error : RP found when not expected".format(
1465 # Verify iif is unknown after RP timeout
1466 step("Verify iif is unknown after RP timeout in l1")
1468 result
= verify_upstream_iif(
1469 tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
, joinState
="NotJoined"
1471 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1473 # Verify join state and join timer
1474 step("Verify join state and join timer in l1")
1476 result
= verify_join_state_and_timer(
1477 tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
, expected
=False
1479 assert result
is not True, (
1480 "Testcase {} : Failed \n "
1481 "join state is up and join timer is running in l1 \n Error: {}".format(
1486 # Verify ip mroute is not installed
1487 step("Verify mroute not installed in l1")
1488 result
= verify_ip_mroutes(
1489 tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
, expected
=False
1493 ), "Testcase {} : Failed \n " "mroute installed in l1 \n Error: {}".format(
1497 step("clear BSM database before moving to next case")
1498 clear_bsrp_data(tgen
, topo
)
1500 write_test_footer(tc_name
)
1503 def test_iif_join_state_p0(request
):
1505 1. Verify upstream interfaces(IIF) and join state are updated properly
1506 after BSM received for FRR
1507 2. Verify IIF and OIL in "show ip pim state" updated properly after
1514 s1-----f1-----i1-----l1----r1
1523 i1 - Intermediate Router (also RP)
1528 tgen
= get_topogen()
1529 tc_name
= request
.node
.name
1530 write_test_header(tc_name
)
1532 # Don"t run this test if we have any failure.
1533 if tgen
.routers_have_failure():
1534 pytest
.skip(tgen
.errors
)
1536 app_helper
.stop_all_hosts()
1537 clear_ip_mroute(tgen
)
1538 reset_config_on_routers(tgen
)
1539 clear_ip_pim_interface_traffic(tgen
, topo
)
1541 reset_config_on_routers(tgen
)
1543 result
= pre_config_to_bsm(
1544 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1546 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1548 result
= pre_config_to_bsm(
1549 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
1551 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1553 GROUP_ADDRESS
= "225.1.1.1"
1555 # Use scapy to send pre-defined packet from senser to receiver
1556 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1557 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1559 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
1562 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1563 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1565 # Verify bsr state in FHR
1566 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1567 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1570 step("Verify IGMP groups in LHR l1")
1573 result
= verify_igmp_groups(tgen
, dut
, intf
, GROUP_ADDRESS
)
1574 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1576 group
= "225.1.1.1/32"
1578 # Find the elected rp from bsrp-info
1579 step("Find the elected rp from bsrp-info in LHR l1")
1580 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1581 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1583 # Check RP detail in LHR
1584 step("Verify RP in LHR l1")
1585 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
1586 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1588 # Verify join state and join timer
1589 step("Verify join state and join timer l1")
1592 result
= verify_join_state_and_timer(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
1593 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1595 # Verify upstream IIF interface
1596 step("Verify upstream IIF interface l1")
1597 result
= verify_upstream_iif(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
1598 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1600 # Verify IIF/OIL in pim state
1602 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
)
1603 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1607 step("Verify ip mroute in l1")
1608 result
= verify_ip_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
1609 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1611 # Make RP unreachanble in LHR
1612 step("Make RP unreachanble in LHR l1")
1613 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1614 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1616 next_hop_lhr
= topo
["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0]
1618 rp_ip
= rp
[group
] + "/32"
1622 {"network": rp_ip
, "next_hop": next_hop_lhr
, "delete": True}
1626 result
= create_static_routes(tgen
, input_dict
)
1627 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1629 # Check RP unreachable
1630 step("Check RP unreachability")
1632 result
= verify_upstream_iif(
1633 tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
, joinState
="NotJoined"
1635 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1637 # Verify that it is not installed
1638 step("Verify that it is not installed")
1640 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
, installed_fl
=0)
1641 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1643 # Verify mroute not installed
1644 step("Verify mroute not installed")
1645 result
= verify_ip_mroutes(
1646 tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
, expected
=False
1650 ), "Testcase {} : Failed \n " "mroute installed in l1 \n Error: {}".format(
1654 # Add back route for RP to make it reachable
1655 step("Add back route for RP to make it reachable")
1661 "next_hop": next_hop_lhr
,
1666 result
= create_static_routes(tgen
, input_dict
)
1667 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1669 # Verify that (*,G) installed in mroute again
1671 result
= verify_ip_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
1672 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1674 step("clear BSM database before moving to next case")
1675 clear_bsrp_data(tgen
, topo
)
1677 write_test_footer(tc_name
)
1680 if __name__
== "__main__":
1681 args
= ["-s"] + sys
.argv
[1:]
1682 sys
.exit(pytest
.main(args
))