]>
Commit | Line | Data |
---|---|---|
6f863215 KK |
1 | #!/usr/bin/env python |
2 | # | |
3 | # Copyright (c) 2020 by VMware, Inc. ("VMware") | |
4 | # Used Copyright (c) 2018 by Network Device Education Foundation, | |
5 | # Inc. ("NetDEF") in this file. | |
6 | # | |
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 | |
10 | # in all copies. | |
11 | # | |
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 | |
19 | # OF THIS SOFTWARE. | |
20 | # | |
21 | ||
22 | """ | |
23 | Following tests are covered to test PIM BSM processing basic functionality: | |
24 | ||
25 | Test steps | |
26 | - Create topology (setup module) | |
27 | - Bring up topology | |
28 | ||
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 | |
42 | """ | |
43 | ||
44 | import os | |
45 | import sys | |
6f863215 KK |
46 | import time |
47 | import pytest | |
48 | ||
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/")) | |
53 | ||
54 | # Required to instantiate the topology builder class. | |
55 | ||
56 | # pylint: disable=C0413 | |
57 | # Import topogen and topotest helpers | |
58 | from lib.topogen import Topogen, get_topogen | |
6f863215 KK |
59 | |
60 | from lib.common_config import ( | |
61 | start_topology, | |
62 | write_test_header, | |
63 | write_test_footer, | |
64 | step, | |
65 | addKernelRoute, | |
66 | create_static_routes, | |
6f863215 | 67 | reset_config_on_routers, |
6f863215 KK |
68 | run_frr_cmd, |
69 | required_linux_kernel_version, | |
697ce62f | 70 | verify_rib, |
6f863215 KK |
71 | ) |
72 | ||
73 | from lib.pim import ( | |
6f863215 KK |
74 | add_rp_interfaces_and_pim_config, |
75 | reconfig_interfaces, | |
76 | scapy_send_bsr_raw_packet, | |
77 | find_rp_from_bsrp_info, | |
78 | verify_pim_grp_rp_source, | |
79 | verify_pim_bsr, | |
4fafd29f | 80 | verify_mroutes, |
6f863215 KK |
81 | verify_join_state_and_timer, |
82 | verify_pim_state, | |
83 | verify_upstream_iif, | |
84 | verify_igmp_groups, | |
4fafd29f KK |
85 | verify_pim_upstream_rpf, |
86 | clear_mroute, | |
87 | clear_pim_interface_traffic, | |
1973df1d | 88 | McastTesterHelper, |
697ce62f | 89 | verify_pim_neighbors, |
6f863215 KK |
90 | ) |
91 | from lib.topolog import logger | |
4953ca97 | 92 | from lib.topojson import build_config_from_json |
6f863215 | 93 | |
4be92408 | 94 | pytestmark = [pytest.mark.pimd, pytest.mark.staticd] |
98ca91e1 DS |
95 | |
96 | ||
6f863215 KK |
97 | TOPOLOGY = """ |
98 | ||
99 | b1_____ | |
100 | | | |
101 | | | |
102 | s1-----f1-----i1-----l1----r1 | |
103 | | | |
104 | ______| | |
105 | b2 | |
106 | ||
107 | b1 - BSR 1 | |
108 | b2 - BSR 2 | |
109 | s1 - Source | |
110 | f1 - FHR | |
111 | i1 - Intermediate Router (also RP) | |
112 | r1 - Receiver | |
113 | ||
114 | """ | |
115 | # Global variables | |
116 | NEXT_HOP1 = "70.0.0.1" | |
117 | NEXT_HOP2 = "65.0.0.1" | |
118 | BSR_IP_1 = "1.1.2.7" | |
119 | BSR_IP_2 = "10.2.1.1" | |
120 | BSR1_ADDR = "1.1.2.7/32" | |
121 | BSR2_ADDR = "10.2.1.1/32" | |
122 | ||
123 | ||
6f863215 KK |
124 | def setup_module(mod): |
125 | """ | |
126 | Sets up the pytest environment | |
127 | ||
128 | * `mod`: module name | |
129 | """ | |
130 | ||
131 | # Required linux kernel version for this suite to run. | |
132 | result = required_linux_kernel_version("4.15") | |
133 | if result is not True: | |
db726bb8 | 134 | pytest.skip("Kernel version should be >= 4.15") |
6f863215 KK |
135 | |
136 | testsuite_run_time = time.asctime(time.localtime(time.time())) | |
137 | logger.info("Testsuite start time: {}".format(testsuite_run_time)) | |
138 | logger.info("=" * 40) | |
139 | logger.info("Master Topology: \n {}".format(TOPOLOGY)) | |
140 | ||
141 | logger.info("Running setup_module to create topology") | |
142 | ||
143 | # This function initiates the topology build with Topogen... | |
e82b531d CH |
144 | json_file = "{}/mcast_pim_bsmp_02.json".format(CWD) |
145 | tgen = Topogen(json_file, mod.__name__) | |
146 | global topo | |
147 | topo = tgen.json_topo | |
6f863215 KK |
148 | # ... and here it calls Mininet initialization functions. |
149 | ||
6f863215 | 150 | # Starting topology, create tmp files which are loaded to routers |
d60a3f0e | 151 | # to start daemons and then start routers |
991a971f | 152 | start_topology(tgen) |
6f863215 KK |
153 | |
154 | # Don"t run this test if we have any failure. | |
155 | if tgen.routers_have_failure(): | |
156 | pytest.skip(tgen.errors) | |
157 | ||
158 | # Creating configuration from JSON | |
159 | build_config_from_json(tgen, topo) | |
160 | ||
697ce62f KK |
161 | # Verify PIM neighbors |
162 | result = verify_pim_neighbors(tgen, topo) | |
163 | assert result is True, " Verify PIM neighbor: Failed Error: {}".format(result) | |
164 | ||
1973df1d CH |
165 | # XXX Replace this using "with McastTesterHelper()... " in each test if possible. |
166 | global app_helper | |
167 | app_helper = McastTesterHelper(tgen) | |
168 | ||
6f863215 KK |
169 | logger.info("Running setup_module() done") |
170 | ||
171 | ||
172 | def teardown_module(): | |
173 | """Teardown the pytest environment""" | |
174 | ||
175 | logger.info("Running teardown_module to delete topology") | |
176 | ||
177 | tgen = get_topogen() | |
178 | ||
1973df1d | 179 | app_helper.cleanup() |
8db751b8 | 180 | |
6f863215 KK |
181 | # Stop toplogy and Remove tmp files |
182 | tgen.stop_topology() | |
183 | ||
184 | logger.info( | |
185 | "Testsuite end time: {}".format(time.asctime(time.localtime(time.time()))) | |
186 | ) | |
187 | logger.info("=" * 40) | |
188 | ||
189 | ||
190 | ##################################################### | |
191 | # | |
192 | # Local APIs | |
193 | # | |
194 | ##################################################### | |
195 | ||
196 | ||
197 | def clear_bsrp_data(tgen, topo): | |
198 | ||
199 | """ | |
200 | clear bsm databas after test" | |
201 | Parameters | |
202 | ---------- | |
203 | * `tgen`: topogen object | |
204 | ||
205 | Usage | |
206 | ----- | |
207 | result = clear_bsrp_data(tgen, topo) | |
208 | Returns | |
209 | ------- | |
210 | errormsg(str) or True | |
211 | """ | |
212 | ||
213 | for dut in tgen.routers(): | |
214 | ||
215 | rnode = tgen.routers()[dut] | |
216 | ||
217 | logger.info("[DUT: %s]: clear_bsrp_data") | |
218 | ||
219 | run_frr_cmd(rnode, "clear ip pim bsr-data") | |
220 | ||
221 | return True | |
222 | ||
223 | ||
224 | def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr, packet): | |
225 | """ | |
226 | API to do required configuration to send and receive BSR packet | |
227 | """ | |
228 | ||
229 | # Re-configure interfaces as per BSR packet | |
230 | result = reconfig_interfaces(tgen, topo, bsr, fhr, packet) | |
231 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
232 | ||
233 | # Create static routes | |
234 | if "bsr" in topo["routers"][bsr]["bsm"]["bsr_packets"][packet]: | |
235 | bsr_route = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["bsr"] | |
236 | next_hop = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["src_ip"].split( | |
237 | "/" | |
238 | )[0] | |
239 | next_hop_rp = topo["routers"][fhr]["links"][rp]["ipv4"].split("/")[0] | |
240 | next_hop_lhr = topo["routers"][rp]["links"][lhr]["ipv4"].split("/")[0] | |
241 | ||
242 | # Add static routes | |
243 | input_dict = { | |
6f863215 KK |
244 | rp: {"static_routes": [{"network": bsr_route, "next_hop": next_hop_rp}]}, |
245 | lhr: {"static_routes": [{"network": bsr_route, "next_hop": next_hop_lhr}]}, | |
246 | } | |
247 | ||
248 | result = create_static_routes(tgen, input_dict) | |
249 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
250 | ||
697ce62f | 251 | # Verifying static routes are installed |
a7bccdc5 | 252 | for dut, _nexthop in zip([rp, lhr], [next_hop_rp, next_hop_lhr]): |
697ce62f | 253 | input_routes = {dut: input_dict[dut]} |
a7bccdc5 KK |
254 | result = verify_rib( |
255 | tgen, "ipv4", dut, input_routes, _nexthop, protocol="static" | |
256 | ) | |
697ce62f KK |
257 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
258 | tc_name, result | |
259 | ) | |
260 | ||
953ef149 | 261 | # Add kernel route for source |
6f863215 KK |
262 | group = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["pkt_dst"] |
263 | bsr_interface = topo["routers"][bsr]["links"][fhr]["interface"] | |
264 | result = addKernelRoute(tgen, bsr, bsr_interface, group) | |
265 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
266 | ||
267 | # RP Mapping | |
268 | rp_mapping = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["rp_mapping"] | |
269 | ||
270 | # Add interfaces in RP for all the RPs | |
271 | result = add_rp_interfaces_and_pim_config(tgen, topo, "lo", rp, rp_mapping) | |
272 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
273 | ||
953ef149 | 274 | # Add kernel routes to sender and receiver |
6f863215 KK |
275 | for group, rp_list in rp_mapping.items(): |
276 | mask = group.split("/")[1] | |
277 | if int(mask) == 32: | |
278 | group = group.split("/")[0] | |
279 | ||
953ef149 | 280 | # Add kernel routes for sender |
6f863215 KK |
281 | s_interface = topo["routers"][sender]["links"][fhr]["interface"] |
282 | result = addKernelRoute(tgen, sender, s_interface, group) | |
283 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
284 | ||
953ef149 | 285 | # Add kernel routes for receiver |
6f863215 KK |
286 | r_interface = topo["routers"][receiver]["links"][lhr]["interface"] |
287 | result = addKernelRoute(tgen, receiver, r_interface, group) | |
288 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
289 | ||
290 | # Add static routes for RPs in FHR and LHR | |
291 | next_hop_fhr = topo["routers"][rp]["links"][fhr]["ipv4"].split("/")[0] | |
292 | next_hop_lhr = topo["routers"][rp]["links"][lhr]["ipv4"].split("/")[0] | |
293 | input_dict = { | |
294 | fhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_fhr}]}, | |
295 | } | |
296 | result = create_static_routes(tgen, input_dict) | |
297 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
298 | ||
697ce62f | 299 | # Verifying static routes are installed |
a7bccdc5 KK |
300 | result = verify_rib( |
301 | tgen, "ipv4", fhr, input_dict, next_hop_fhr, protocol="static" | |
302 | ) | |
697ce62f KK |
303 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
304 | tc_name, result | |
305 | ) | |
306 | ||
6f863215 KK |
307 | input_dict = { |
308 | lhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_lhr}]}, | |
309 | } | |
310 | result = create_static_routes(tgen, input_dict) | |
311 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
697ce62f KK |
312 | |
313 | # Verifying static routes are installed | |
a7bccdc5 KK |
314 | result = verify_rib( |
315 | tgen, "ipv4", lhr, input_dict, next_hop_lhr, protocol="static" | |
316 | ) | |
697ce62f KK |
317 | assert result is True, "Testcase {} : Failed \n Error {}".format( |
318 | tc_name, result | |
319 | ) | |
320 | ||
6f863215 KK |
321 | return True |
322 | ||
323 | ||
324 | ##################################################### | |
325 | # | |
326 | # Testcases | |
327 | # | |
328 | ##################################################### | |
329 | ||
330 | ||
331 | def test_starg_mroute_p0(request): | |
332 | """ | |
333 | 1. Verify (*,G) mroute detail on FRR router after BSM rp installed | |
334 | ||
335 | Topology used: | |
336 | b1_____ | |
337 | | | |
338 | | | |
339 | s1-----f1-----i1-----l1----r1 | |
340 | | | |
341 | ______| | |
342 | b2 | |
343 | ||
344 | b1 - BSR 1 | |
345 | b2 - BSR 2 | |
346 | s1 - Source | |
347 | f1 - FHR | |
348 | i1 - Intermediate Router (also RP) | |
349 | r1 - Receiver | |
350 | ||
351 | """ | |
352 | ||
353 | tgen = get_topogen() | |
354 | tc_name = request.node.name | |
355 | write_test_header(tc_name) | |
356 | ||
8db751b8 CH |
357 | # Don"t run this test if we have any failure. |
358 | if tgen.routers_have_failure(): | |
359 | pytest.skip(tgen.errors) | |
360 | ||
1973df1d | 361 | app_helper.stop_all_hosts() |
4fafd29f | 362 | clear_mroute(tgen) |
6f863215 | 363 | reset_config_on_routers(tgen) |
4fafd29f | 364 | clear_pim_interface_traffic(tgen, topo) |
6f863215 | 365 | |
6f863215 KK |
366 | result = pre_config_to_bsm( |
367 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
368 | ) | |
369 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
370 | ||
371 | result = pre_config_to_bsm( | |
372 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
373 | ) | |
374 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
375 | ||
376 | GROUP_ADDRESS = "226.1.1.1" | |
377 | ||
378 | # Use scapy to send pre-defined packet from senser to receiver | |
379 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
380 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
381 | ||
382 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
383 | time.sleep(1) | |
384 | ||
1973df1d | 385 | result = app_helper.run_join("r1", GROUP_ADDRESS, "l1") |
6f863215 KK |
386 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
387 | ||
388 | # Verify bsr state in FHR | |
389 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
390 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
391 | ||
392 | # Check igmp groups | |
393 | step("Verify IGMP groups in LHR l1") | |
394 | dut = "l1" | |
395 | intf = "l1-r1-eth1" | |
396 | result = verify_igmp_groups(tgen, dut, intf, GROUP_ADDRESS) | |
397 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
398 | ||
399 | group = "226.1.1.1/32" | |
400 | src_addr = "*" | |
401 | ||
402 | # Find the elected rp from bsrp-info | |
403 | step("Find the elected rp from bsrp-info in LHR in l1") | |
404 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
405 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
406 | ||
407 | # Check RP detail in LHR | |
408 | step("Verify RP in LHR in l1") | |
409 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
410 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
411 | ||
412 | # Verify join state and join timer | |
413 | step("Verify join state and join timer in l1") | |
414 | iif = "l1-i1-eth0" | |
415 | result = verify_join_state_and_timer(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
416 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
417 | ||
418 | # Verify upstream IIF interface | |
419 | step("Verify upstream IIF interface in l1") | |
420 | result = verify_upstream_iif(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
421 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
422 | ||
423 | # Verify IIF/OIL in pim state | |
424 | oil = "l1-r1-eth1" | |
425 | result = verify_pim_state(tgen, dut, iif, oil, GROUP_ADDRESS) | |
426 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
427 | ||
428 | # Verify ip mroute | |
429 | step("Verify ip mroute in l1") | |
430 | src_addr = "*" | |
4fafd29f | 431 | result = verify_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil) |
6f863215 KK |
432 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
433 | ||
434 | # Remove the group rp mapping and send bsm | |
435 | step("Remove the grp-rp mapping by sending bsm with hold time 0 for grp-rp") | |
436 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2") | |
437 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
438 | ||
439 | # Check RP unreachable | |
440 | step("Check RP unreachability in l1") | |
441 | iif = "Unknown" | |
442 | result = verify_upstream_iif( | |
443 | tgen, dut, iif, src_addr, GROUP_ADDRESS, joinState="NotJoined" | |
444 | ) | |
445 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
446 | ||
447 | # Verify that it is not installed | |
448 | step("Verify that iif is not installed in l1") | |
449 | iif = "<iif?>" | |
450 | result = verify_pim_state(tgen, dut, iif, oil, GROUP_ADDRESS, installed_fl=0) | |
451 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
452 | ||
453 | # Verify mroute not installed | |
454 | step("Verify mroute not installed in l1") | |
4fafd29f | 455 | result = verify_mroutes( |
ed776e38 | 456 | tgen, dut, src_addr, GROUP_ADDRESS, iif, oil, retry_timeout=20, expected=False |
6f863215 | 457 | ) |
244f2df0 KK |
458 | assert result is not True, ( |
459 | "Testcase {} : Failed \n " | |
db726bb8 | 460 | "Expected: [{}]: mroute (S, G) should not be installed \n " |
244f2df0 KK |
461 | "Found: {}".format(tc_name, dut, result) |
462 | ) | |
6f863215 KK |
463 | |
464 | # Send BSM again to configure rp | |
465 | step("Add back RP by sending BSM from b1") | |
466 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
467 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
468 | ||
469 | # Verify that (*,G) installed in mroute again | |
470 | iif = "l1-i1-eth0" | |
4fafd29f | 471 | result = verify_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil) |
6f863215 KK |
472 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
473 | ||
474 | step("clear BSM database before moving to next case") | |
475 | clear_bsrp_data(tgen, topo) | |
476 | ||
477 | write_test_footer(tc_name) | |
478 | ||
479 | ||
480 | def test_overlapping_group_p0(request): | |
481 | """ | |
482 | Verify group to RP updated correctly on FRR router, when BSR advertising | |
483 | the overlapping group address | |
484 | ||
485 | Topology used: | |
486 | b1_____ | |
487 | | | |
488 | | | |
489 | s1-----f1-----i1-----l1----r1 | |
490 | | | |
491 | ______| | |
492 | b2 | |
493 | ||
494 | b1 - BSR 1 | |
495 | b2 - BSR 2 | |
496 | s1 - Source | |
497 | f1 - FHR | |
498 | i1 - Intermediate Router (also RP) | |
499 | r1 - Receiver | |
500 | ||
501 | """ | |
502 | ||
503 | tgen = get_topogen() | |
504 | tc_name = request.node.name | |
505 | write_test_header(tc_name) | |
506 | ||
8db751b8 CH |
507 | # Don"t run this test if we have any failure. |
508 | if tgen.routers_have_failure(): | |
509 | pytest.skip(tgen.errors) | |
510 | ||
1973df1d | 511 | app_helper.stop_all_hosts() |
4fafd29f | 512 | clear_mroute(tgen) |
6f863215 | 513 | reset_config_on_routers(tgen) |
4fafd29f | 514 | clear_pim_interface_traffic(tgen, topo) |
6f863215 | 515 | |
6f863215 KK |
516 | result = pre_config_to_bsm( |
517 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
518 | ) | |
519 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
520 | ||
521 | result = pre_config_to_bsm( | |
522 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
523 | ) | |
524 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
525 | ||
526 | GROUP_ADDRESS = "225.1.1.1" | |
527 | ||
528 | # Use scapy to send pre-defined packet from senser to receiver | |
529 | step("Send BSR packet from b1 to FHR") | |
530 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet4") | |
531 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
532 | ||
533 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
534 | time.sleep(1) | |
535 | ||
1973df1d | 536 | result = app_helper.run_join("r1", GROUP_ADDRESS, "l1") |
6f863215 KK |
537 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
538 | ||
539 | # Verify bsr state in FHR | |
540 | step("Verify if b1 is chosen as bsr in f1") | |
541 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
542 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
543 | ||
544 | dut = "l1" | |
545 | group1 = "225.1.1.1/32" | |
546 | # Find the elected rp from bsrp-info fro group 225.1.1.1/32 | |
547 | step("Find the elected rp from bsrp-info in LHR for 225.1.1.1/32") | |
548 | rp1 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group1) | |
549 | assert rp1 is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
550 | ||
551 | group2 = "225.1.1.0/24" | |
552 | # Find the elected rp from bsrp-info fro group 225.1.1.0/24 | |
553 | step("Find the elected rp from bsrp-info in LHR for 225.1.1.0/24") | |
554 | rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group2) | |
555 | assert rp2 is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
556 | ||
557 | iif = "l1-i1-eth0" | |
558 | # Verify upstream rpf for 225.1.1.1 is chosen as rp1 | |
559 | step("Verify upstream rpf for 225.1.1.1 is chosen as rp1 in l1") | |
4fafd29f | 560 | result = verify_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, rp1) |
6f863215 KK |
561 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
562 | ||
563 | # Send BSR packet from b1 with rp for 225.1.1.1/32 removed | |
564 | step("Send BSR packet from b1 with rp for 225.1.1.1/32 removed") | |
565 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet5") | |
566 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
567 | ||
568 | # Verify upstream rpf for 225.1.1.1 is chosen as rp1 | |
569 | step("Verify upstream rpf for 225.1.1.1 is chosen as rp2 in l1") | |
4fafd29f | 570 | result = verify_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, rp2) |
6f863215 KK |
571 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
572 | ||
573 | # Verify IIF/OIL in pim state | |
574 | step("Verify iif is installed after rp change in l1") | |
575 | oil = "l1-r1-eth1" | |
576 | result = verify_pim_state(tgen, dut, iif, oil, GROUP_ADDRESS) | |
577 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
578 | ||
579 | step("clear BSM database before moving to next case") | |
580 | clear_bsrp_data(tgen, topo) | |
581 | ||
582 | write_test_footer(tc_name) | |
583 | ||
584 | ||
585 | def test_RP_priority_p0(request): | |
586 | """ | |
587 | Verify group to RP info is updated correctly, when BSR advertising the | |
588 | same RP with different priority | |
589 | ||
590 | Topology used: | |
591 | b1_____ | |
592 | | | |
593 | | | |
594 | s1-----f1-----i1-----l1----r1 | |
595 | | | |
596 | ______| | |
597 | b2 | |
598 | ||
599 | b1 - BSR 1 | |
600 | b2 - BSR 2 | |
601 | s1 - Source | |
602 | f1 - FHR | |
603 | i1 - Intermediate Router (also RP) | |
604 | r1 - Receiver | |
605 | """ | |
606 | ||
607 | tgen = get_topogen() | |
608 | tc_name = request.node.name | |
609 | write_test_header(tc_name) | |
610 | ||
8db751b8 CH |
611 | # Don"t run this test if we have any failure. |
612 | if tgen.routers_have_failure(): | |
613 | pytest.skip(tgen.errors) | |
614 | ||
1973df1d | 615 | app_helper.stop_all_hosts() |
4fafd29f | 616 | clear_mroute(tgen) |
6f863215 | 617 | reset_config_on_routers(tgen) |
4fafd29f | 618 | clear_pim_interface_traffic(tgen, topo) |
6f863215 | 619 | |
6f863215 KK |
620 | result = pre_config_to_bsm( |
621 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
622 | ) | |
623 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
624 | ||
625 | result = pre_config_to_bsm( | |
626 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
627 | ) | |
628 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
629 | ||
630 | GROUP_ADDRESS = "225.1.1.1" | |
631 | ||
632 | # Use scapy to send pre-defined packet from senser to receiver | |
633 | step("Send BSR packet from b1 to FHR") | |
634 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
635 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
636 | ||
637 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
638 | time.sleep(1) | |
639 | ||
1973df1d | 640 | result = app_helper.run_join("r1", GROUP_ADDRESS, "l1") |
6f863215 KK |
641 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
642 | ||
643 | # Verify bsr state in FHR | |
644 | step("Verify if b1 is chosen as bsr in f1") | |
645 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
646 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
647 | ||
648 | dut = "l1" | |
649 | group = "225.1.1.0/24" | |
650 | # Find the elected rp from bsrp-info | |
651 | step("Find the elected rp from bsrp-info in LHR l1") | |
652 | rp1 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
653 | assert rp1 is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
654 | ||
655 | # Check RP detail in LHR | |
656 | step("Verify RP in LHR l1") | |
657 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp1[group]) | |
658 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
659 | ||
660 | # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24 | |
661 | step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24") | |
662 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet6") | |
663 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
664 | ||
665 | # Find the elected rp from bsrp-info | |
666 | step("Find the elected rp from bsrp-info in LHR l1") | |
667 | rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
668 | assert rp2 is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
669 | logger.info("RP old: {} RP2 new: {} ".format(rp1[group], rp2[group])) | |
670 | ||
671 | # Verify is the rp is different now | |
672 | assert rp1[group] != rp2[group], "Testcase {} :Failed \n Error {}".format( | |
673 | tc_name, result | |
674 | ) | |
675 | ||
676 | rp_add1 = rp1[group] | |
677 | rp_add2 = rp2[group] | |
678 | ||
679 | # Verify if that rp is installed | |
680 | step("Verify new RP in LHR installed") | |
681 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add2) | |
682 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
683 | ||
684 | # Send BSR packet from b1 after putting back high prio rp for 225.1.1.0/24 | |
685 | step("Send BSM from b1 to FHR put back old high prio rp for 225.1.1.0/24") | |
686 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
687 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
688 | ||
689 | # Find the elected rp from bsrp-info | |
690 | step("Find the elected rp from bsrp-info in LHR") | |
691 | rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
692 | assert rp2 is not {}, "Testcase {} :Failed \n Error : RP not Found".format(tc_name) | |
693 | ||
694 | # Verify is the rp is different now | |
695 | step("Verify now old RP is elected again") | |
696 | assert ( | |
697 | rp_add1 == rp2[group] | |
698 | ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format( | |
a53c08bc | 699 | tc_name, rp_add1, rp2[group] if group in rp2 else None |
6f863215 KK |
700 | ) |
701 | ||
702 | # Verify if that rp is installed | |
703 | step("Verify new RP in LHR installed") | |
704 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add1) | |
705 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
706 | ||
707 | step("clear BSM database before moving to next case") | |
708 | clear_bsrp_data(tgen, topo) | |
709 | ||
710 | write_test_footer(tc_name) | |
711 | ||
712 | ||
713 | def test_BSR_election_p0(request): | |
714 | """ | |
715 | Verify group to RP mapping in FRR node when 2 BSR are present in the network | |
716 | and both are having same BSR priority | |
717 | ||
718 | Topology used: | |
719 | b1_____ | |
720 | | | |
721 | | | |
722 | s1-----f1-----i1-----l1----r1 | |
723 | | | |
724 | ______| | |
725 | b2 | |
726 | ||
727 | b1 - BSR 1 | |
728 | b2 - BSR 2 | |
729 | s1 - Source | |
730 | f1 - FHR | |
731 | i1 - Intermediate Router (also RP) | |
732 | r1 - Receiver | |
733 | ||
734 | """ | |
735 | ||
736 | tgen = get_topogen() | |
737 | tc_name = request.node.name | |
738 | write_test_header(tc_name) | |
739 | ||
1973df1d | 740 | app_helper.stop_all_hosts() |
4fafd29f | 741 | clear_mroute(tgen) |
6f863215 | 742 | reset_config_on_routers(tgen) |
4fafd29f | 743 | clear_pim_interface_traffic(tgen, topo) |
6f863215 KK |
744 | |
745 | # Don"t run this test if we have any failure. | |
746 | if tgen.routers_have_failure(): | |
747 | pytest.skip(tgen.errors) | |
748 | ||
6f863215 KK |
749 | result = pre_config_to_bsm( |
750 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
751 | ) | |
752 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
753 | ||
754 | result = pre_config_to_bsm( | |
755 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
756 | ) | |
757 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
758 | ||
759 | GROUP_ADDRESS = "225.1.1.1" | |
760 | ||
761 | # Use scapy to send pre-defined packet from senser to receiver | |
762 | step("Send BSR packet from b1 to FHR") | |
763 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet3") | |
764 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
765 | ||
766 | bsr_ip1 = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[ | |
767 | 0 | |
768 | ] | |
769 | time.sleep(1) | |
770 | ||
1973df1d | 771 | result = app_helper.run_join("r1", GROUP_ADDRESS, "l1") |
6f863215 KK |
772 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
773 | ||
774 | # Verify bsr state in FHR | |
775 | step("Verify if b1 is chosen as bsr in f1") | |
776 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip1) | |
777 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
778 | ||
779 | dut = "l1" | |
780 | group = "225.1.1.0/24" | |
781 | # Find the elected rp from bsrp-info | |
782 | step("Find the elected rp from bsrp-info in LHR in l1") | |
783 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip1, group) | |
784 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
785 | ||
786 | # Check RP detail in LHR | |
787 | step("Verify RP in LHR l1") | |
788 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
789 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
790 | ||
791 | # Send BSR packet from b2 with same priority | |
792 | step("Send BSR packet from b2 to FHR with same priority") | |
793 | result = scapy_send_bsr_raw_packet(tgen, topo, "b2", "f1", "packet1") | |
794 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
795 | ||
796 | bsr_ip2 = topo["routers"]["b2"]["bsm"]["bsr_packets"]["packet2"]["bsr"].split("/")[ | |
797 | 0 | |
798 | ] | |
799 | time.sleep(1) | |
800 | ||
801 | logger.info("BSR b1:" + bsr_ip1 + " BSR b2:" + bsr_ip2) | |
802 | # Verify bsr state in FHR | |
803 | step("Verify if b2 is not chosen as bsr in f1") | |
804 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip2, expected=False) | |
244f2df0 KK |
805 | assert result is not True, ( |
806 | "Testcase {} : Failed \n " | |
db726bb8 | 807 | "Expected: [{}]: b2 should not be chosen as bsr \n " |
244f2df0 KK |
808 | "Found: {}".format(tc_name, "f1", result) |
809 | ) | |
6f863215 KK |
810 | |
811 | # Verify if b1 is still chosen as bsr | |
812 | step("Verify if b1 is still chosen as bsr in f1") | |
813 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip1) | |
814 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
815 | ||
816 | # Verify if that rp is installed | |
817 | step("Verify that same RP in istalled in LHR l1") | |
818 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
819 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
820 | ||
821 | step("clear BSM database before moving to next case") | |
822 | clear_bsrp_data(tgen, topo) | |
823 | ||
824 | write_test_footer(tc_name) | |
825 | ||
826 | ||
827 | def test_RP_hash_p0(request): | |
828 | """ | |
829 | Verify RP is selected based on hash function, when BSR advertising the group | |
830 | to RP mapping with same priority | |
831 | ||
832 | Topology used: | |
833 | b1_____ | |
834 | | | |
835 | | | |
836 | s1-----f1-----i1-----l1----r1 | |
837 | | | |
838 | ______| | |
839 | b2 | |
840 | ||
841 | b1 - BSR 1 | |
842 | b2 - BSR 2 | |
843 | s1 - Source | |
844 | f1 - FHR | |
845 | i1 - Intermediate Router (also RP) | |
846 | r1 - Receiver | |
847 | ||
848 | """ | |
849 | ||
850 | tgen = get_topogen() | |
851 | tc_name = request.node.name | |
852 | write_test_header(tc_name) | |
853 | ||
8db751b8 CH |
854 | # Don"t run this test if we have any failure. |
855 | if tgen.routers_have_failure(): | |
856 | pytest.skip(tgen.errors) | |
857 | ||
1973df1d | 858 | app_helper.stop_all_hosts() |
4fafd29f | 859 | clear_mroute(tgen) |
6f863215 | 860 | reset_config_on_routers(tgen) |
4fafd29f | 861 | clear_pim_interface_traffic(tgen, topo) |
6f863215 | 862 | |
6f863215 KK |
863 | result = pre_config_to_bsm( |
864 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
865 | ) | |
866 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
867 | ||
868 | result = pre_config_to_bsm( | |
869 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
870 | ) | |
871 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
872 | ||
873 | GROUP_ADDRESS = "225.1.1.1" | |
874 | ||
875 | # Use scapy to send pre-defined packet from senser to receiver | |
876 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet7") | |
877 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
878 | ||
879 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
880 | time.sleep(1) | |
881 | ||
1973df1d | 882 | result = app_helper.run_join("r1", GROUP_ADDRESS, "l1") |
6f863215 KK |
883 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
884 | ||
885 | dut = "l1" | |
886 | ||
887 | # Verify bsr state in FHR | |
888 | step("Verify if b1 chosen as BSR in f1") | |
889 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
890 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
891 | ||
892 | group = "225.1.1.0/24" | |
893 | ||
894 | # Find the elected rp from bsrp-info | |
895 | step("Find the elected rp from bsrp-info in LHR l1") | |
896 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
897 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
898 | ||
899 | # Verify if RP with highest hash value is chosen | |
900 | step("Verify if RP(2.2.2.2) with highest hash value is chosen in l1") | |
901 | if rp[group] == "2.2.2.2": | |
902 | result = True | |
903 | else: | |
904 | result = "rp expected: 2.2.2.2 got:" + rp[group] | |
905 | ||
906 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
907 | ||
908 | # Check RP detail in LHR | |
909 | step("Verify RP in LHR") | |
910 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
911 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
912 | ||
913 | step("clear BSM database before moving to next case") | |
914 | clear_bsrp_data(tgen, topo) | |
915 | ||
916 | write_test_footer(tc_name) | |
917 | ||
918 | ||
919 | def test_BSM_fragmentation_p1(request): | |
920 | """ | |
921 | Verify fragmentation of bootstrap message | |
922 | ||
923 | Topology used: | |
924 | b1_____ | |
925 | | | |
926 | | | |
927 | s1-----f1-----i1-----l1----r1 | |
928 | | | |
929 | ______| | |
930 | b2 | |
931 | ||
932 | b1 - BSR 1 | |
933 | b2 - BSR 2 | |
934 | s1 - Source | |
935 | f1 - FHR | |
936 | i1 - Intermediate Router (also RP) | |
937 | r1 - Receiver | |
938 | ||
939 | """ | |
940 | ||
941 | tgen = get_topogen() | |
942 | tc_name = request.node.name | |
943 | write_test_header(tc_name) | |
944 | ||
8db751b8 CH |
945 | # Don"t run this test if we have any failure. |
946 | if tgen.routers_have_failure(): | |
947 | pytest.skip(tgen.errors) | |
948 | ||
1973df1d | 949 | app_helper.stop_all_hosts() |
4fafd29f | 950 | clear_mroute(tgen) |
6f863215 | 951 | reset_config_on_routers(tgen) |
4fafd29f | 952 | clear_pim_interface_traffic(tgen, topo) |
6f863215 | 953 | |
6f863215 KK |
954 | result = pre_config_to_bsm( |
955 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
956 | ) | |
957 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
958 | ||
959 | result = pre_config_to_bsm( | |
960 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
961 | ) | |
962 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
963 | ||
964 | GROUP_ADDRESS = "225.1.1.1" | |
965 | ||
966 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
967 | ||
968 | step("Send BSM and verify if all routers have same bsrp before fragment") | |
969 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
970 | # Verify bsr state in FHR | |
971 | step("Verify if b1 chosen as BSR in f1") | |
972 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
973 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
974 | ||
975 | fhr_node = tgen.routers()["f1"] | |
976 | inter_node = tgen.routers()["i1"] | |
977 | lhr_node = tgen.routers()["l1"] | |
978 | ||
979 | # Verify if bsrp list is same across f1, i1 and l1 | |
980 | step("Verify if bsrp list is same across f1, i1 and l1") | |
981 | bsrp_f1 = fhr_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True) | |
982 | logger.info("show_ip_pim_bsrp_info_json f1: \n %s", bsrp_f1) | |
983 | bsrp_i1 = inter_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True) | |
984 | logger.info("show_ip_pim_bsrp_info_json i1: \n %s", bsrp_i1) | |
985 | bsrp_l1 = lhr_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True) | |
986 | logger.info("show_ip_pim_bsrp_info_json l1: \n %s", bsrp_l1) | |
987 | ||
988 | if bsrp_f1 == bsrp_l1: | |
989 | result = True | |
990 | else: | |
991 | result = "bsrp info in f1 is not same in l1" | |
992 | ||
993 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
994 | ||
995 | # set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments | |
996 | step("set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments") | |
6a95bfc8 CH |
997 | fhr_node.run("ip link set f1-i1-eth2 mtu 100") |
998 | inter_node.run("ip link set i1-f1-eth0 mtu 100") | |
6f863215 KK |
999 | |
1000 | # Use scapy to send pre-defined packet from senser to receiver | |
1001 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2") | |
1002 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1003 | ||
1973df1d | 1004 | result = app_helper.run_join("r1", GROUP_ADDRESS, "l1") |
6f863215 KK |
1005 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
1006 | ||
1007 | # Verify bsr state in FHR | |
1008 | step("Verify if b1 chosen as BSR") | |
1009 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1010 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1011 | ||
1012 | # Verify if bsrp list is same across f1, i1 and l1 | |
1013 | step("Verify if bsrp list is same across f1, i1 and l1 after fragmentation") | |
1014 | bsrp_f1 = fhr_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True) | |
1015 | logger.info("show_ip_pim_bsrp_info_json f1: \n %s", bsrp_f1) | |
1016 | bsrp_i1 = inter_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True) | |
1017 | logger.info("show_ip_pim_bsrp_info_json i1: \n %s", bsrp_i1) | |
1018 | bsrp_l1 = lhr_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True) | |
1019 | logger.info("show_ip_pim_bsrp_info_json l1: \n %s", bsrp_l1) | |
1020 | ||
1021 | if bsrp_f1 == bsrp_l1: | |
1022 | result = True | |
1023 | else: | |
1024 | result = "bsrp info in f1 is not same in l1" | |
1025 | ||
1026 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1027 | ||
1028 | step("clear BSM database before moving to next case") | |
1029 | clear_bsrp_data(tgen, topo) | |
1030 | ||
1031 | write_test_footer(tc_name) | |
1032 | ||
1033 | ||
1034 | def test_RP_with_all_ip_octet_p1(request): | |
1035 | """ | |
1036 | Verify when candidate RP advertised with 32 mask length | |
1037 | and contain all the contacts | |
1038 | ||
1039 | Topology used: | |
1040 | b1_____ | |
1041 | | | |
1042 | | | |
1043 | s1-----f1-----i1-----l1----r1 | |
1044 | | | |
1045 | ______| | |
1046 | b2 | |
1047 | ||
1048 | b1 - BSR 1 | |
1049 | b2 - BSR 2 | |
1050 | s1 - Source | |
1051 | f1 - FHR | |
1052 | i1 - Intermediate Router (also RP) | |
1053 | r1 - Receiver | |
1054 | ||
1055 | """ | |
1056 | ||
1057 | tgen = get_topogen() | |
1058 | tc_name = request.node.name | |
1059 | write_test_header(tc_name) | |
1060 | ||
8db751b8 CH |
1061 | # Don"t run this test if we have any failure. |
1062 | if tgen.routers_have_failure(): | |
1063 | pytest.skip(tgen.errors) | |
1064 | ||
1973df1d | 1065 | app_helper.stop_all_hosts() |
4fafd29f | 1066 | clear_mroute(tgen) |
6f863215 | 1067 | reset_config_on_routers(tgen) |
4fafd29f | 1068 | clear_pim_interface_traffic(tgen, topo) |
6f863215 | 1069 | |
6f863215 KK |
1070 | step("pre-configure BSM packet") |
1071 | result = pre_config_to_bsm( | |
1072 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1073 | ) | |
1074 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1075 | ||
1076 | step("Send the IGMP group (225.100.100.100) from receiver connected to FRR") | |
1077 | GROUP_ADDRESS = "225.200.100.100" | |
1078 | ||
1079 | # Use scapy to send pre-defined packet from senser to receiver | |
1080 | step("Configure cisco-1 as BSR1") | |
1081 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet8") | |
1082 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1083 | ||
1084 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet8"]["bsr"].split("/")[0] | |
1085 | time.sleep(1) | |
1086 | ||
1973df1d | 1087 | result = app_helper.run_join("r1", GROUP_ADDRESS, "l1") |
6f863215 KK |
1088 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) |
1089 | ||
1090 | dut = "l1" | |
1091 | step( | |
1092 | "Groups are shown with candidate RP with correct mask length 'show ip pim bsrp-info'" | |
1093 | ) | |
1094 | step("Verify if b1 chosen as BSR in f1") | |
1095 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1096 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1097 | ||
1098 | group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"] | |
1099 | step("Find the elected rp from bsrp-info in LHR l1") | |
1100 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1101 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1102 | ||
1103 | step("Verify RP in LHR") | |
1104 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
1105 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1106 | ||
1107 | step("clear BSM database before moving to next case") | |
1108 | clear_bsrp_data(tgen, topo) | |
1109 | ||
1110 | write_test_footer(tc_name) | |
1111 | ||
1112 | ||
1113 | if __name__ == "__main__": | |
1114 | args = ["-s"] + sys.argv[1:] | |
1115 | sys.exit(pytest.main(args)) |