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 (*,G) mroute detail on FRR router after BSM rp installed
31 2. Verify group to RP updated correctly on FRR router, when BSR advertising
32 the overlapping group address
33 3. Verify group to RP info is updated correctly, when BSR advertising the
34 same RP with different priority
35 4. Verify group to RP mapping in FRR node when 2 BSR are present in the network
36 and both are having same BSR priority
37 5. Verify RP is selected based on hash function, when BSR advertising the group
38 to RP mapping with same priority
39 6. Verify fragmentation of bootstrap message
40 7. Verify when candidate RP advertised with 32 mask length
41 and contain all the contacts
49 # Save the Current Working Directory to find configuration files.
50 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
51 sys
.path
.append(os
.path
.join(CWD
, "../"))
52 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
54 # Required to instantiate the topology builder class.
56 # pylint: disable=C0413
57 # Import topogen and topotest helpers
58 from lib
.topogen
import Topogen
, get_topogen
60 from lib
.common_config
import (
67 reset_config_on_routers
,
69 required_linux_kernel_version
,
74 add_rp_interfaces_and_pim_config
,
76 scapy_send_bsr_raw_packet
,
77 find_rp_from_bsrp_info
,
78 verify_pim_grp_rp_source
,
81 verify_join_state_and_timer
,
85 verify_pim_upstream_rpf
,
87 clear_pim_interface_traffic
,
90 from lib
.topolog
import logger
91 from lib
.topojson
import build_config_from_json
93 pytestmark
= [pytest
.mark
.pimd
, pytest
.mark
.staticd
]
101 s1-----f1-----i1-----l1----r1
110 i1 - Intermediate Router (also RP)
115 NEXT_HOP1
= "70.0.0.1"
116 NEXT_HOP2
= "65.0.0.1"
118 BSR_IP_2
= "10.2.1.1"
119 BSR1_ADDR
= "1.1.2.7/32"
120 BSR2_ADDR
= "10.2.1.1/32"
123 def setup_module(mod
):
125 Sets up the pytest environment
130 # Required linux kernel version for this suite to run.
131 result
= required_linux_kernel_version("4.15")
132 if result
is not True:
133 pytest
.skip("Kernel requirements are not met")
135 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
136 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
137 logger
.info("=" * 40)
138 logger
.info("Master Topology: \n {}".format(TOPOLOGY
))
140 logger
.info("Running setup_module to create topology")
142 # This function initiates the topology build with Topogen...
143 json_file
= "{}/mcast_pim_bsmp_02.json".format(CWD
)
144 tgen
= Topogen(json_file
, mod
.__name
__)
146 topo
= tgen
.json_topo
147 # ... and here it calls Mininet initialization functions.
149 # get list of daemons needs to be started for this suite.
150 daemons
= topo_daemons(tgen
, topo
)
152 # Starting topology, create tmp files which are loaded to routers
153 # to start daemons and then start routers
154 start_topology(tgen
, daemons
)
156 # Don"t run this test if we have any failure.
157 if tgen
.routers_have_failure():
158 pytest
.skip(tgen
.errors
)
160 # Creating configuration from JSON
161 build_config_from_json(tgen
, topo
)
163 # XXX Replace this using "with McastTesterHelper()... " in each test if possible.
165 app_helper
= McastTesterHelper(tgen
)
167 logger
.info("Running setup_module() done")
170 def teardown_module():
171 """Teardown the pytest environment"""
173 logger
.info("Running teardown_module to delete topology")
179 # Stop toplogy and Remove tmp files
183 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
185 logger
.info("=" * 40)
188 #####################################################
192 #####################################################
195 def clear_bsrp_data(tgen
, topo
):
198 clear bsm databas after test"
201 * `tgen`: topogen object
205 result = clear_bsrp_data(tgen, topo)
208 errormsg(str) or True
211 for dut
in tgen
.routers():
213 rnode
= tgen
.routers()[dut
]
215 logger
.info("[DUT: %s]: clear_bsrp_data")
217 run_frr_cmd(rnode
, "clear ip pim bsr-data")
222 def pre_config_to_bsm(tgen
, topo
, tc_name
, bsr
, sender
, receiver
, fhr
, rp
, lhr
, packet
):
224 API to do required configuration to send and receive BSR packet
227 # Re-configure interfaces as per BSR packet
228 result
= reconfig_interfaces(tgen
, topo
, bsr
, fhr
, packet
)
229 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
231 # Create static routes
232 if "bsr" in topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]:
233 bsr_route
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["bsr"]
234 next_hop
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["src_ip"].split(
237 next_hop_rp
= topo
["routers"][fhr
]["links"][rp
]["ipv4"].split("/")[0]
238 next_hop_lhr
= topo
["routers"][rp
]["links"][lhr
]["ipv4"].split("/")[0]
242 fhr
: {"static_routes": [{"network": bsr_route
, "next_hop": next_hop
}]},
243 rp
: {"static_routes": [{"network": bsr_route
, "next_hop": next_hop_rp
}]},
244 lhr
: {"static_routes": [{"network": bsr_route
, "next_hop": next_hop_lhr
}]},
247 result
= create_static_routes(tgen
, input_dict
)
248 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
250 # Add kernel route for source
251 group
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["pkt_dst"]
252 bsr_interface
= topo
["routers"][bsr
]["links"][fhr
]["interface"]
253 result
= addKernelRoute(tgen
, bsr
, bsr_interface
, group
)
254 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
257 rp_mapping
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["rp_mapping"]
259 # Add interfaces in RP for all the RPs
260 result
= add_rp_interfaces_and_pim_config(tgen
, topo
, "lo", rp
, rp_mapping
)
261 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
263 # Add kernel routes to sender and receiver
264 for group
, rp_list
in rp_mapping
.items():
265 mask
= group
.split("/")[1]
267 group
= group
.split("/")[0]
269 # Add kernel routes for sender
270 s_interface
= topo
["routers"][sender
]["links"][fhr
]["interface"]
271 result
= addKernelRoute(tgen
, sender
, s_interface
, group
)
272 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
274 # Add kernel routes for receiver
275 r_interface
= topo
["routers"][receiver
]["links"][lhr
]["interface"]
276 result
= addKernelRoute(tgen
, receiver
, r_interface
, group
)
277 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
279 # Add static routes for RPs in FHR and LHR
280 next_hop_fhr
= topo
["routers"][rp
]["links"][fhr
]["ipv4"].split("/")[0]
281 next_hop_lhr
= topo
["routers"][rp
]["links"][lhr
]["ipv4"].split("/")[0]
283 fhr
: {"static_routes": [{"network": rp_list
, "next_hop": next_hop_fhr
}]},
285 result
= create_static_routes(tgen
, input_dict
)
286 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
289 lhr
: {"static_routes": [{"network": rp_list
, "next_hop": next_hop_lhr
}]},
291 result
= create_static_routes(tgen
, input_dict
)
292 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
296 #####################################################
300 #####################################################
303 def test_starg_mroute_p0(request
):
305 1. Verify (*,G) mroute detail on FRR router after BSM rp installed
311 s1-----f1-----i1-----l1----r1
320 i1 - Intermediate Router (also RP)
326 tc_name
= request
.node
.name
327 write_test_header(tc_name
)
329 # Don"t run this test if we have any failure.
330 if tgen
.routers_have_failure():
331 pytest
.skip(tgen
.errors
)
333 app_helper
.stop_all_hosts()
335 reset_config_on_routers(tgen
)
336 clear_pim_interface_traffic(tgen
, topo
)
338 result
= pre_config_to_bsm(
339 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
341 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
343 result
= pre_config_to_bsm(
344 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
346 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
348 GROUP_ADDRESS
= "226.1.1.1"
350 # Use scapy to send pre-defined packet from senser to receiver
351 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
352 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
354 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
357 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
358 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
360 # Verify bsr state in FHR
361 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
362 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
365 step("Verify IGMP groups in LHR l1")
368 result
= verify_igmp_groups(tgen
, dut
, intf
, GROUP_ADDRESS
)
369 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
371 group
= "226.1.1.1/32"
374 # Find the elected rp from bsrp-info
375 step("Find the elected rp from bsrp-info in LHR in l1")
376 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
377 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
379 # Check RP detail in LHR
380 step("Verify RP in LHR in l1")
381 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
382 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
384 # Verify join state and join timer
385 step("Verify join state and join timer in l1")
387 result
= verify_join_state_and_timer(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
388 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
390 # Verify upstream IIF interface
391 step("Verify upstream IIF interface in l1")
392 result
= verify_upstream_iif(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
393 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
395 # Verify IIF/OIL in pim state
397 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
)
398 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
401 step("Verify ip mroute in l1")
403 result
= verify_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
404 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
406 # Remove the group rp mapping and send bsm
407 step("Remove the grp-rp mapping by sending bsm with hold time 0 for grp-rp")
408 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet2")
409 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
411 # Check RP unreachable
412 step("Check RP unreachability in l1")
414 result
= verify_upstream_iif(
415 tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
, joinState
="NotJoined"
417 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
419 # Verify that it is not installed
420 step("Verify that iif is not installed in l1")
422 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
, installed_fl
=0)
423 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
425 # Verify mroute not installed
426 step("Verify mroute not installed in l1")
427 result
= verify_mroutes(
428 tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
, retry_timeout
=20, expected
=False
432 ), "Testcase {} : Failed \n " "mroute installed in l1 \n Error: {}".format(
436 # Send BSM again to configure rp
437 step("Add back RP by sending BSM from b1")
438 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
439 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
441 # Verify that (*,G) installed in mroute again
443 result
= verify_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
444 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
446 step("clear BSM database before moving to next case")
447 clear_bsrp_data(tgen
, topo
)
449 write_test_footer(tc_name
)
452 def test_overlapping_group_p0(request
):
454 Verify group to RP updated correctly on FRR router, when BSR advertising
455 the overlapping group address
461 s1-----f1-----i1-----l1----r1
470 i1 - Intermediate Router (also RP)
476 tc_name
= request
.node
.name
477 write_test_header(tc_name
)
479 # Don"t run this test if we have any failure.
480 if tgen
.routers_have_failure():
481 pytest
.skip(tgen
.errors
)
483 app_helper
.stop_all_hosts()
485 reset_config_on_routers(tgen
)
486 clear_pim_interface_traffic(tgen
, topo
)
488 result
= pre_config_to_bsm(
489 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
491 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
493 result
= pre_config_to_bsm(
494 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
496 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
498 GROUP_ADDRESS
= "225.1.1.1"
500 # Use scapy to send pre-defined packet from senser to receiver
501 step("Send BSR packet from b1 to FHR")
502 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet4")
503 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
505 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
508 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
509 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
511 # Verify bsr state in FHR
512 step("Verify if b1 is chosen as bsr in f1")
513 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
514 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
517 group1
= "225.1.1.1/32"
518 # Find the elected rp from bsrp-info fro group 225.1.1.1/32
519 step("Find the elected rp from bsrp-info in LHR for 225.1.1.1/32")
520 rp1
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group1
)
521 assert rp1
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
523 group2
= "225.1.1.0/24"
524 # Find the elected rp from bsrp-info fro group 225.1.1.0/24
525 step("Find the elected rp from bsrp-info in LHR for 225.1.1.0/24")
526 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group2
)
527 assert rp2
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
530 # Verify upstream rpf for 225.1.1.1 is chosen as rp1
531 step("Verify upstream rpf for 225.1.1.1 is chosen as rp1 in l1")
532 result
= verify_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, rp1
)
533 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
535 # Send BSR packet from b1 with rp for 225.1.1.1/32 removed
536 step("Send BSR packet from b1 with rp for 225.1.1.1/32 removed")
537 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet5")
538 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
540 # Verify upstream rpf for 225.1.1.1 is chosen as rp1
541 step("Verify upstream rpf for 225.1.1.1 is chosen as rp2 in l1")
542 result
= verify_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, rp2
)
543 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
545 # Verify IIF/OIL in pim state
546 step("Verify iif is installed after rp change in l1")
548 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
)
549 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
551 step("clear BSM database before moving to next case")
552 clear_bsrp_data(tgen
, topo
)
554 write_test_footer(tc_name
)
557 def test_RP_priority_p0(request
):
559 Verify group to RP info is updated correctly, when BSR advertising the
560 same RP with different priority
566 s1-----f1-----i1-----l1----r1
575 i1 - Intermediate Router (also RP)
580 tc_name
= request
.node
.name
581 write_test_header(tc_name
)
583 # Don"t run this test if we have any failure.
584 if tgen
.routers_have_failure():
585 pytest
.skip(tgen
.errors
)
587 app_helper
.stop_all_hosts()
589 reset_config_on_routers(tgen
)
590 clear_pim_interface_traffic(tgen
, topo
)
592 result
= pre_config_to_bsm(
593 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
595 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
597 result
= pre_config_to_bsm(
598 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
600 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
602 GROUP_ADDRESS
= "225.1.1.1"
604 # Use scapy to send pre-defined packet from senser to receiver
605 step("Send BSR packet from b1 to FHR")
606 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
607 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
609 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
612 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
613 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
615 # Verify bsr state in FHR
616 step("Verify if b1 is chosen as bsr in f1")
617 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
618 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
621 group
= "225.1.1.0/24"
622 # Find the elected rp from bsrp-info
623 step("Find the elected rp from bsrp-info in LHR l1")
624 rp1
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
625 assert rp1
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
627 # Check RP detail in LHR
628 step("Verify RP in LHR l1")
629 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp1
[group
])
630 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
632 # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24
633 step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24")
634 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet6")
635 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
637 # Find the elected rp from bsrp-info
638 step("Find the elected rp from bsrp-info in LHR l1")
639 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
640 assert rp2
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
641 logger
.info("RP old: {} RP2 new: {} ".format(rp1
[group
], rp2
[group
]))
643 # Verify is the rp is different now
644 assert rp1
[group
] != rp2
[group
], "Testcase {} :Failed \n Error {}".format(
651 # Verify if that rp is installed
652 step("Verify new RP in LHR installed")
653 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add2
)
654 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
656 # Send BSR packet from b1 after putting back high prio rp for 225.1.1.0/24
657 step("Send BSM from b1 to FHR put back old high prio rp for 225.1.1.0/24")
658 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
659 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
661 # Find the elected rp from bsrp-info
662 step("Find the elected rp from bsrp-info in LHR")
663 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
664 assert rp2
is not {}, "Testcase {} :Failed \n Error : RP not Found".format(tc_name
)
666 # Verify is the rp is different now
667 step("Verify now old RP is elected again")
669 rp_add1
== rp2
[group
]
670 ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format(
671 tc_name
, rp_add1
, rp2
[group
] if group
in rp2
else None
674 # Verify if that rp is installed
675 step("Verify new RP in LHR installed")
676 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add1
)
677 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
679 step("clear BSM database before moving to next case")
680 clear_bsrp_data(tgen
, topo
)
682 write_test_footer(tc_name
)
685 def test_BSR_election_p0(request
):
687 Verify group to RP mapping in FRR node when 2 BSR are present in the network
688 and both are having same BSR priority
694 s1-----f1-----i1-----l1----r1
703 i1 - Intermediate Router (also RP)
709 tc_name
= request
.node
.name
710 write_test_header(tc_name
)
712 app_helper
.stop_all_hosts()
714 reset_config_on_routers(tgen
)
715 clear_pim_interface_traffic(tgen
, topo
)
717 # Don"t run this test if we have any failure.
718 if tgen
.routers_have_failure():
719 pytest
.skip(tgen
.errors
)
721 result
= pre_config_to_bsm(
722 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
724 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
726 result
= pre_config_to_bsm(
727 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
729 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
731 GROUP_ADDRESS
= "225.1.1.1"
733 # Use scapy to send pre-defined packet from senser to receiver
734 step("Send BSR packet from b1 to FHR")
735 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet3")
736 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
738 bsr_ip1
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[
743 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
744 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
746 # Verify bsr state in FHR
747 step("Verify if b1 is chosen as bsr in f1")
748 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip1
)
749 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
752 group
= "225.1.1.0/24"
753 # Find the elected rp from bsrp-info
754 step("Find the elected rp from bsrp-info in LHR in l1")
755 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip1
, group
)
756 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
758 # Check RP detail in LHR
759 step("Verify RP in LHR l1")
760 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
761 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
763 # Send BSR packet from b2 with same priority
764 step("Send BSR packet from b2 to FHR with same priority")
765 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b2", "f1", "packet1")
766 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
768 bsr_ip2
= topo
["routers"]["b2"]["bsm"]["bsr_packets"]["packet2"]["bsr"].split("/")[
773 logger
.info("BSR b1:" + bsr_ip1
+ " BSR b2:" + bsr_ip2
)
774 # Verify bsr state in FHR
775 step("Verify if b2 is not chosen as bsr in f1")
776 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip2
, expected
=False)
779 ), "Testcase {} : Failed \n " "b2 is chosen as bsr in f1 \n Error: {}".format(
783 # Verify if b1 is still chosen as bsr
784 step("Verify if b1 is still chosen as bsr in f1")
785 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip1
)
786 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
788 # Verify if that rp is installed
789 step("Verify that same RP in istalled in LHR l1")
790 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
791 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
793 step("clear BSM database before moving to next case")
794 clear_bsrp_data(tgen
, topo
)
796 write_test_footer(tc_name
)
799 def test_RP_hash_p0(request
):
801 Verify RP is selected based on hash function, when BSR advertising the group
802 to RP mapping with same priority
808 s1-----f1-----i1-----l1----r1
817 i1 - Intermediate Router (also RP)
823 tc_name
= request
.node
.name
824 write_test_header(tc_name
)
826 # Don"t run this test if we have any failure.
827 if tgen
.routers_have_failure():
828 pytest
.skip(tgen
.errors
)
830 app_helper
.stop_all_hosts()
832 reset_config_on_routers(tgen
)
833 clear_pim_interface_traffic(tgen
, topo
)
835 result
= pre_config_to_bsm(
836 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
838 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
840 result
= pre_config_to_bsm(
841 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
843 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
845 GROUP_ADDRESS
= "225.1.1.1"
847 # Use scapy to send pre-defined packet from senser to receiver
848 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet7")
849 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
851 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
854 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
855 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
859 # Verify bsr state in FHR
860 step("Verify if b1 chosen as BSR in f1")
861 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
862 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
864 group
= "225.1.1.0/24"
866 # Find the elected rp from bsrp-info
867 step("Find the elected rp from bsrp-info in LHR l1")
868 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
869 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
871 # Verify if RP with highest hash value is chosen
872 step("Verify if RP(2.2.2.2) with highest hash value is chosen in l1")
873 if rp
[group
] == "2.2.2.2":
876 result
= "rp expected: 2.2.2.2 got:" + rp
[group
]
878 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
880 # Check RP detail in LHR
881 step("Verify RP in LHR")
882 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
883 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
885 step("clear BSM database before moving to next case")
886 clear_bsrp_data(tgen
, topo
)
888 write_test_footer(tc_name
)
891 def test_BSM_fragmentation_p1(request
):
893 Verify fragmentation of bootstrap message
899 s1-----f1-----i1-----l1----r1
908 i1 - Intermediate Router (also RP)
914 tc_name
= request
.node
.name
915 write_test_header(tc_name
)
917 # Don"t run this test if we have any failure.
918 if tgen
.routers_have_failure():
919 pytest
.skip(tgen
.errors
)
921 app_helper
.stop_all_hosts()
923 reset_config_on_routers(tgen
)
924 clear_pim_interface_traffic(tgen
, topo
)
926 result
= pre_config_to_bsm(
927 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
929 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
931 result
= pre_config_to_bsm(
932 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
934 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
936 GROUP_ADDRESS
= "225.1.1.1"
938 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
940 step("Send BSM and verify if all routers have same bsrp before fragment")
941 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
942 # Verify bsr state in FHR
943 step("Verify if b1 chosen as BSR in f1")
944 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
945 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
947 fhr_node
= tgen
.routers()["f1"]
948 inter_node
= tgen
.routers()["i1"]
949 lhr_node
= tgen
.routers()["l1"]
951 # Verify if bsrp list is same across f1, i1 and l1
952 step("Verify if bsrp list is same across f1, i1 and l1")
953 bsrp_f1
= fhr_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
954 logger
.info("show_ip_pim_bsrp_info_json f1: \n %s", bsrp_f1
)
955 bsrp_i1
= inter_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
956 logger
.info("show_ip_pim_bsrp_info_json i1: \n %s", bsrp_i1
)
957 bsrp_l1
= lhr_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
958 logger
.info("show_ip_pim_bsrp_info_json l1: \n %s", bsrp_l1
)
960 if bsrp_f1
== bsrp_l1
:
963 result
= "bsrp info in f1 is not same in l1"
965 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
967 # set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments
968 step("set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments")
969 fhr_node
.run("ip link set f1-i1-eth2 mtu 100")
970 inter_node
.run("ip link set i1-f1-eth0 mtu 100")
972 # Use scapy to send pre-defined packet from senser to receiver
973 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet2")
974 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
976 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
977 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
979 # Verify bsr state in FHR
980 step("Verify if b1 chosen as BSR")
981 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
982 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
984 # Verify if bsrp list is same across f1, i1 and l1
985 step("Verify if bsrp list is same across f1, i1 and l1 after fragmentation")
986 bsrp_f1
= fhr_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
987 logger
.info("show_ip_pim_bsrp_info_json f1: \n %s", bsrp_f1
)
988 bsrp_i1
= inter_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
989 logger
.info("show_ip_pim_bsrp_info_json i1: \n %s", bsrp_i1
)
990 bsrp_l1
= lhr_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
991 logger
.info("show_ip_pim_bsrp_info_json l1: \n %s", bsrp_l1
)
993 if bsrp_f1
== bsrp_l1
:
996 result
= "bsrp info in f1 is not same in l1"
998 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1000 step("clear BSM database before moving to next case")
1001 clear_bsrp_data(tgen
, topo
)
1003 write_test_footer(tc_name
)
1006 def test_RP_with_all_ip_octet_p1(request
):
1008 Verify when candidate RP advertised with 32 mask length
1009 and contain all the contacts
1015 s1-----f1-----i1-----l1----r1
1024 i1 - Intermediate Router (also RP)
1029 tgen
= get_topogen()
1030 tc_name
= request
.node
.name
1031 write_test_header(tc_name
)
1033 # Don"t run this test if we have any failure.
1034 if tgen
.routers_have_failure():
1035 pytest
.skip(tgen
.errors
)
1037 app_helper
.stop_all_hosts()
1039 reset_config_on_routers(tgen
)
1040 clear_pim_interface_traffic(tgen
, topo
)
1042 step("pre-configure BSM packet")
1043 result
= pre_config_to_bsm(
1044 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1046 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1048 step("Send the IGMP group (225.100.100.100) from receiver connected to FRR")
1049 GROUP_ADDRESS
= "225.200.100.100"
1051 # Use scapy to send pre-defined packet from senser to receiver
1052 step("Configure cisco-1 as BSR1")
1053 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet8")
1054 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1056 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet8"]["bsr"].split("/")[0]
1059 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1060 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1064 "Groups are shown with candidate RP with correct mask length 'show ip pim bsrp-info'"
1066 step("Verify if b1 chosen as BSR in f1")
1067 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1068 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1070 group
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
1071 step("Find the elected rp from bsrp-info in LHR l1")
1072 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1073 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1075 step("Verify RP in LHR")
1076 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
1077 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1079 step("clear BSM database before moving to next case")
1080 clear_bsrp_data(tgen
, topo
)
1082 write_test_footer(tc_name
)
1085 if __name__
== "__main__":
1086 args
= ["-s"] + sys
.argv
[1:]
1087 sys
.exit(pytest
.main(args
))