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_ip_pim_upstream_rpf
,
87 clear_ip_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()
334 clear_ip_mroute(tgen
)
335 reset_config_on_routers(tgen
)
336 clear_ip_pim_interface_traffic(tgen
, topo
)
338 reset_config_on_routers(tgen
)
340 result
= pre_config_to_bsm(
341 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
343 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
345 result
= pre_config_to_bsm(
346 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
348 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
350 GROUP_ADDRESS
= "226.1.1.1"
352 # Use scapy to send pre-defined packet from senser to receiver
353 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
354 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
356 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
359 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
360 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
362 # Verify bsr state in FHR
363 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
364 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
367 step("Verify IGMP groups in LHR l1")
370 result
= verify_igmp_groups(tgen
, dut
, intf
, GROUP_ADDRESS
)
371 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
373 group
= "226.1.1.1/32"
376 # Find the elected rp from bsrp-info
377 step("Find the elected rp from bsrp-info in LHR in l1")
378 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
379 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
381 # Check RP detail in LHR
382 step("Verify RP in LHR in l1")
383 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
384 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
386 # Verify join state and join timer
387 step("Verify join state and join timer in l1")
389 result
= verify_join_state_and_timer(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
390 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
392 # Verify upstream IIF interface
393 step("Verify upstream IIF interface in l1")
394 result
= verify_upstream_iif(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
395 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
397 # Verify IIF/OIL in pim state
399 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
)
400 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
403 step("Verify ip mroute in l1")
405 result
= verify_ip_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
406 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
408 # Remove the group rp mapping and send bsm
409 step("Remove the grp-rp mapping by sending bsm with hold time 0 for grp-rp")
410 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet2")
411 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
413 # Check RP unreachable
414 step("Check RP unreachability in l1")
416 result
= verify_upstream_iif(
417 tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
, joinState
="NotJoined"
419 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
421 # Verify that it is not installed
422 step("Verify that iif is not installed in l1")
424 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
, installed_fl
=0)
425 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
427 # Verify mroute not installed
428 step("Verify mroute not installed in l1")
429 result
= verify_ip_mroutes(
430 tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
, retry_timeout
=20, expected
=False
434 ), "Testcase {} : Failed \n " "mroute installed in l1 \n Error: {}".format(
438 # Send BSM again to configure rp
439 step("Add back RP by sending BSM from b1")
440 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
441 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
443 # Verify that (*,G) installed in mroute again
445 result
= verify_ip_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
446 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
448 step("clear BSM database before moving to next case")
449 clear_bsrp_data(tgen
, topo
)
451 write_test_footer(tc_name
)
454 def test_overlapping_group_p0(request
):
456 Verify group to RP updated correctly on FRR router, when BSR advertising
457 the overlapping group address
463 s1-----f1-----i1-----l1----r1
472 i1 - Intermediate Router (also RP)
478 tc_name
= request
.node
.name
479 write_test_header(tc_name
)
481 # Don"t run this test if we have any failure.
482 if tgen
.routers_have_failure():
483 pytest
.skip(tgen
.errors
)
485 app_helper
.stop_all_hosts()
486 clear_ip_mroute(tgen
)
487 reset_config_on_routers(tgen
)
488 clear_ip_pim_interface_traffic(tgen
, topo
)
490 reset_config_on_routers(tgen
)
492 result
= pre_config_to_bsm(
493 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
495 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
497 result
= pre_config_to_bsm(
498 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
500 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
502 GROUP_ADDRESS
= "225.1.1.1"
504 # Use scapy to send pre-defined packet from senser to receiver
505 step("Send BSR packet from b1 to FHR")
506 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet4")
507 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
509 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
512 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
513 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
515 # Verify bsr state in FHR
516 step("Verify if b1 is chosen as bsr in f1")
517 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
518 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
521 group1
= "225.1.1.1/32"
522 # Find the elected rp from bsrp-info fro group 225.1.1.1/32
523 step("Find the elected rp from bsrp-info in LHR for 225.1.1.1/32")
524 rp1
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group1
)
525 assert rp1
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
527 group2
= "225.1.1.0/24"
528 # Find the elected rp from bsrp-info fro group 225.1.1.0/24
529 step("Find the elected rp from bsrp-info in LHR for 225.1.1.0/24")
530 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group2
)
531 assert rp2
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
534 # Verify upstream rpf for 225.1.1.1 is chosen as rp1
535 step("Verify upstream rpf for 225.1.1.1 is chosen as rp1 in l1")
536 result
= verify_ip_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, rp1
)
537 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
539 # Send BSR packet from b1 with rp for 225.1.1.1/32 removed
540 step("Send BSR packet from b1 with rp for 225.1.1.1/32 removed")
541 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet5")
542 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
544 # Verify upstream rpf for 225.1.1.1 is chosen as rp1
545 step("Verify upstream rpf for 225.1.1.1 is chosen as rp2 in l1")
546 result
= verify_ip_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, rp2
)
547 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
549 # Verify IIF/OIL in pim state
550 step("Verify iif is installed after rp change in l1")
552 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
)
553 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
555 step("clear BSM database before moving to next case")
556 clear_bsrp_data(tgen
, topo
)
558 write_test_footer(tc_name
)
561 def test_RP_priority_p0(request
):
563 Verify group to RP info is updated correctly, when BSR advertising the
564 same RP with different priority
570 s1-----f1-----i1-----l1----r1
579 i1 - Intermediate Router (also RP)
584 tc_name
= request
.node
.name
585 write_test_header(tc_name
)
587 # Don"t run this test if we have any failure.
588 if tgen
.routers_have_failure():
589 pytest
.skip(tgen
.errors
)
591 app_helper
.stop_all_hosts()
592 clear_ip_mroute(tgen
)
593 reset_config_on_routers(tgen
)
594 clear_ip_pim_interface_traffic(tgen
, topo
)
596 reset_config_on_routers(tgen
)
598 result
= pre_config_to_bsm(
599 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
601 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
603 result
= pre_config_to_bsm(
604 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
606 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
608 GROUP_ADDRESS
= "225.1.1.1"
610 # Use scapy to send pre-defined packet from senser to receiver
611 step("Send BSR packet from b1 to FHR")
612 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
613 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
615 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
618 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
619 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
621 # Verify bsr state in FHR
622 step("Verify if b1 is chosen as bsr in f1")
623 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
624 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
627 group
= "225.1.1.0/24"
628 # Find the elected rp from bsrp-info
629 step("Find the elected rp from bsrp-info in LHR l1")
630 rp1
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
631 assert rp1
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
633 # Check RP detail in LHR
634 step("Verify RP in LHR l1")
635 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp1
[group
])
636 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
638 # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24
639 step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24")
640 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet6")
641 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
643 # Find the elected rp from bsrp-info
644 step("Find the elected rp from bsrp-info in LHR l1")
645 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
646 assert rp2
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
647 logger
.info("RP old: {} RP2 new: {} ".format(rp1
[group
], rp2
[group
]))
649 # Verify is the rp is different now
650 assert rp1
[group
] != rp2
[group
], "Testcase {} :Failed \n Error {}".format(
657 # Verify if that rp is installed
658 step("Verify new RP in LHR installed")
659 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add2
)
660 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
662 # Send BSR packet from b1 after putting back high prio rp for 225.1.1.0/24
663 step("Send BSM from b1 to FHR put back old high prio rp for 225.1.1.0/24")
664 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
665 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
667 # Find the elected rp from bsrp-info
668 step("Find the elected rp from bsrp-info in LHR")
669 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
670 assert rp2
is not {}, "Testcase {} :Failed \n Error : RP not Found".format(tc_name
)
672 # Verify is the rp is different now
673 step("Verify now old RP is elected again")
675 rp_add1
== rp2
[group
]
676 ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format(
677 tc_name
, rp_add1
, rp2
[group
] if group
in rp2
else None
680 # Verify if that rp is installed
681 step("Verify new RP in LHR installed")
682 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add1
)
683 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
685 step("clear BSM database before moving to next case")
686 clear_bsrp_data(tgen
, topo
)
688 write_test_footer(tc_name
)
691 def test_BSR_election_p0(request
):
693 Verify group to RP mapping in FRR node when 2 BSR are present in the network
694 and both are having same BSR priority
700 s1-----f1-----i1-----l1----r1
709 i1 - Intermediate Router (also RP)
715 tc_name
= request
.node
.name
716 write_test_header(tc_name
)
718 app_helper
.stop_all_hosts()
719 clear_ip_mroute(tgen
)
720 reset_config_on_routers(tgen
)
721 clear_ip_pim_interface_traffic(tgen
, topo
)
723 # Don"t run this test if we have any failure.
724 if tgen
.routers_have_failure():
725 pytest
.skip(tgen
.errors
)
727 reset_config_on_routers(tgen
)
729 result
= pre_config_to_bsm(
730 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
732 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
734 result
= pre_config_to_bsm(
735 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
737 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
739 GROUP_ADDRESS
= "225.1.1.1"
741 # Use scapy to send pre-defined packet from senser to receiver
742 step("Send BSR packet from b1 to FHR")
743 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet3")
744 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
746 bsr_ip1
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[
751 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
752 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
754 # Verify bsr state in FHR
755 step("Verify if b1 is chosen as bsr in f1")
756 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip1
)
757 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
760 group
= "225.1.1.0/24"
761 # Find the elected rp from bsrp-info
762 step("Find the elected rp from bsrp-info in LHR in l1")
763 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip1
, group
)
764 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
766 # Check RP detail in LHR
767 step("Verify RP in LHR l1")
768 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
769 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
771 # Send BSR packet from b2 with same priority
772 step("Send BSR packet from b2 to FHR with same priority")
773 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b2", "f1", "packet1")
774 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
776 bsr_ip2
= topo
["routers"]["b2"]["bsm"]["bsr_packets"]["packet2"]["bsr"].split("/")[
781 logger
.info("BSR b1:" + bsr_ip1
+ " BSR b2:" + bsr_ip2
)
782 # Verify bsr state in FHR
783 step("Verify if b2 is not chosen as bsr in f1")
784 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip2
, expected
=False)
787 ), "Testcase {} : Failed \n " "b2 is chosen as bsr in f1 \n Error: {}".format(
791 # Verify if b1 is still chosen as bsr
792 step("Verify if b1 is still chosen as bsr in f1")
793 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip1
)
794 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
796 # Verify if that rp is installed
797 step("Verify that same RP in istalled in LHR l1")
798 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
799 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
801 step("clear BSM database before moving to next case")
802 clear_bsrp_data(tgen
, topo
)
804 write_test_footer(tc_name
)
807 def test_RP_hash_p0(request
):
809 Verify RP is selected based on hash function, when BSR advertising the group
810 to RP mapping with same priority
816 s1-----f1-----i1-----l1----r1
825 i1 - Intermediate Router (also RP)
831 tc_name
= request
.node
.name
832 write_test_header(tc_name
)
834 # Don"t run this test if we have any failure.
835 if tgen
.routers_have_failure():
836 pytest
.skip(tgen
.errors
)
838 app_helper
.stop_all_hosts()
839 clear_ip_mroute(tgen
)
840 reset_config_on_routers(tgen
)
841 clear_ip_pim_interface_traffic(tgen
, topo
)
843 reset_config_on_routers(tgen
)
845 result
= pre_config_to_bsm(
846 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
848 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
850 result
= pre_config_to_bsm(
851 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
853 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
855 GROUP_ADDRESS
= "225.1.1.1"
857 # Use scapy to send pre-defined packet from senser to receiver
858 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet7")
859 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
861 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
864 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
865 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
869 # Verify bsr state in FHR
870 step("Verify if b1 chosen as BSR in f1")
871 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
872 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
874 group
= "225.1.1.0/24"
876 # Find the elected rp from bsrp-info
877 step("Find the elected rp from bsrp-info in LHR l1")
878 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
879 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
881 # Verify if RP with highest hash value is chosen
882 step("Verify if RP(2.2.2.2) with highest hash value is chosen in l1")
883 if rp
[group
] == "2.2.2.2":
886 result
= "rp expected: 2.2.2.2 got:" + rp
[group
]
888 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
890 # Check RP detail in LHR
891 step("Verify RP in LHR")
892 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
893 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
895 step("clear BSM database before moving to next case")
896 clear_bsrp_data(tgen
, topo
)
898 write_test_footer(tc_name
)
901 def test_BSM_fragmentation_p1(request
):
903 Verify fragmentation of bootstrap message
909 s1-----f1-----i1-----l1----r1
918 i1 - Intermediate Router (also RP)
924 tc_name
= request
.node
.name
925 write_test_header(tc_name
)
927 # Don"t run this test if we have any failure.
928 if tgen
.routers_have_failure():
929 pytest
.skip(tgen
.errors
)
931 app_helper
.stop_all_hosts()
932 clear_ip_mroute(tgen
)
933 reset_config_on_routers(tgen
)
934 clear_ip_pim_interface_traffic(tgen
, topo
)
936 reset_config_on_routers(tgen
)
938 result
= pre_config_to_bsm(
939 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
941 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
943 result
= pre_config_to_bsm(
944 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
946 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
948 GROUP_ADDRESS
= "225.1.1.1"
950 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
952 step("Send BSM and verify if all routers have same bsrp before fragment")
953 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
954 # Verify bsr state in FHR
955 step("Verify if b1 chosen as BSR in f1")
956 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
957 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
959 fhr_node
= tgen
.routers()["f1"]
960 inter_node
= tgen
.routers()["i1"]
961 lhr_node
= tgen
.routers()["l1"]
963 # Verify if bsrp list is same across f1, i1 and l1
964 step("Verify if bsrp list is same across f1, i1 and l1")
965 bsrp_f1
= fhr_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
966 logger
.info("show_ip_pim_bsrp_info_json f1: \n %s", bsrp_f1
)
967 bsrp_i1
= inter_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
968 logger
.info("show_ip_pim_bsrp_info_json i1: \n %s", bsrp_i1
)
969 bsrp_l1
= lhr_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
970 logger
.info("show_ip_pim_bsrp_info_json l1: \n %s", bsrp_l1
)
972 if bsrp_f1
== bsrp_l1
:
975 result
= "bsrp info in f1 is not same in l1"
977 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
979 # set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments
980 step("set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments")
981 fhr_node
.run("ip link set f1-i1-eth2 mtu 100")
982 inter_node
.run("ip link set i1-f1-eth0 mtu 100")
984 # Use scapy to send pre-defined packet from senser to receiver
985 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet2")
986 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
988 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
989 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
991 # Verify bsr state in FHR
992 step("Verify if b1 chosen as BSR")
993 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
994 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
996 # Verify if bsrp list is same across f1, i1 and l1
997 step("Verify if bsrp list is same across f1, i1 and l1 after fragmentation")
998 bsrp_f1
= fhr_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
999 logger
.info("show_ip_pim_bsrp_info_json f1: \n %s", bsrp_f1
)
1000 bsrp_i1
= inter_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
1001 logger
.info("show_ip_pim_bsrp_info_json i1: \n %s", bsrp_i1
)
1002 bsrp_l1
= lhr_node
.vtysh_cmd("show ip pim bsrp-info json", isjson
=True)
1003 logger
.info("show_ip_pim_bsrp_info_json l1: \n %s", bsrp_l1
)
1005 if bsrp_f1
== bsrp_l1
:
1008 result
= "bsrp info in f1 is not same in l1"
1010 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1012 step("clear BSM database before moving to next case")
1013 clear_bsrp_data(tgen
, topo
)
1015 write_test_footer(tc_name
)
1018 def test_RP_with_all_ip_octet_p1(request
):
1020 Verify when candidate RP advertised with 32 mask length
1021 and contain all the contacts
1027 s1-----f1-----i1-----l1----r1
1036 i1 - Intermediate Router (also RP)
1041 tgen
= get_topogen()
1042 tc_name
= request
.node
.name
1043 write_test_header(tc_name
)
1045 # Don"t run this test if we have any failure.
1046 if tgen
.routers_have_failure():
1047 pytest
.skip(tgen
.errors
)
1049 app_helper
.stop_all_hosts()
1050 clear_ip_mroute(tgen
)
1051 reset_config_on_routers(tgen
)
1052 clear_ip_pim_interface_traffic(tgen
, topo
)
1054 step("pre-configure BSM packet")
1055 result
= pre_config_to_bsm(
1056 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1058 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1060 step("Send the IGMP group (225.100.100.100) from receiver connected to FRR")
1061 GROUP_ADDRESS
= "225.200.100.100"
1063 # Use scapy to send pre-defined packet from senser to receiver
1064 step("Configure cisco-1 as BSR1")
1065 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet8")
1066 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1068 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet8"]["bsr"].split("/")[0]
1071 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1072 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1076 "Groups are shown with candidate RP with correct mask length 'show ip pim bsrp-info'"
1078 step("Verify if b1 chosen as BSR in f1")
1079 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1080 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1082 group
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
1083 step("Find the elected rp from bsrp-info in LHR l1")
1084 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1085 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1087 step("Verify RP in LHR")
1088 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
1089 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1091 step("clear BSM database before moving to next case")
1092 clear_bsrp_data(tgen
, topo
)
1094 write_test_footer(tc_name
)
1097 if __name__
== "__main__":
1098 args
= ["-s"] + sys
.argv
[1:]
1099 sys
.exit(pytest
.main(args
))