]>
Commit | Line | Data |
---|---|---|
df94c7e8 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 FRR router select higher IP BSR , when 2 BSR present in the network | |
31 | 2. Verify BSR and RP updated correctly after configuring as black hole address | |
32 | 3.1 Verify when new router added to the topology, FRR node will send | |
33 | unicast BSM to new router | |
34 | 3.2 Verify if no forwarding bit is set , FRR is not forwarding the | |
35 | BSM to other PIM nbrs | |
36 | 3.3 Verify multicast BSM is sent to new router when unicast BSM is disabled | |
37 | 4.1 Verfiy BSM arrived on non bsm capable interface is dropped and | |
38 | not processed | |
39 | 4.2 Verify group to RP info updated correctly in FRR node, after shut and | |
40 | no-shut of BSM enable interfaces | |
41 | 5. Verify static RP is preferred over BSR | |
42 | 6.1 Verify adding/deleting the group to rp mapping and RP priority | |
43 | multiple times | |
44 | 6.2 Verify RP and (*,G) detail after PIM process restart on FRR node | |
45 | 7.1 Verify BSM timeout on FRR1 | |
46 | 7.2 Verify RP state in FRR1 after Bootstrap timer expiry | |
47 | 8.1 Verify upstream interfaces(IIF) and join state are updated properly | |
48 | after BSM received for FRR | |
49 | 8.2 Verify IIF and OIL in "show ip pim state" updated properly after | |
50 | BSM received | |
51 | """ | |
52 | ||
53 | import os | |
54 | import sys | |
55 | import json | |
56 | import time | |
57 | import pytest | |
58 | ||
59 | # Save the Current Working Directory to find configuration files. | |
60 | CWD = os.path.dirname(os.path.realpath(__file__)) | |
61 | sys.path.append(os.path.join(CWD, "../")) | |
62 | sys.path.append(os.path.join(CWD, "../lib/")) | |
63 | ||
64 | # Required to instantiate the topology builder class. | |
65 | ||
66 | # pylint: disable=C0413 | |
67 | # Import topogen and topotest helpers | |
68 | from lib.topogen import Topogen, get_topogen | |
8db751b8 | 69 | from lib.micronet_compat import Topo |
df94c7e8 KK |
70 | |
71 | from lib.common_config import ( | |
72 | start_topology, | |
73 | write_test_header, | |
74 | write_test_footer, | |
75 | step, | |
76 | addKernelRoute, | |
77 | create_static_routes, | |
78 | iperfSendIGMPJoin, | |
79 | stop_router, | |
80 | start_router, | |
81 | shutdown_bringup_interface, | |
82 | kill_router_daemons, | |
83 | start_router_daemons, | |
84 | reset_config_on_routers, | |
85 | do_countdown, | |
86 | apply_raw_config, | |
87 | kill_iperf, | |
88 | run_frr_cmd, | |
89 | required_linux_kernel_version, | |
90 | topo_daemons, | |
91 | ) | |
92 | ||
93 | from lib.pim import ( | |
94 | create_pim_config, | |
95 | add_rp_interfaces_and_pim_config, | |
96 | reconfig_interfaces, | |
97 | scapy_send_bsr_raw_packet, | |
98 | find_rp_from_bsrp_info, | |
99 | verify_pim_grp_rp_source, | |
100 | verify_pim_bsr, | |
101 | verify_ip_mroutes, | |
102 | verify_join_state_and_timer, | |
103 | verify_pim_state, | |
104 | verify_upstream_iif, | |
105 | verify_igmp_groups, | |
106 | verify_ip_pim_upstream_rpf, | |
107 | enable_disable_pim_unicast_bsm, | |
108 | enable_disable_pim_bsm, | |
109 | clear_ip_mroute, | |
110 | clear_ip_pim_interface_traffic, | |
111 | verify_pim_interface_traffic, | |
112 | ) | |
113 | from lib.topolog import logger | |
114 | from lib.topojson import build_topo_from_json, build_config_from_json | |
115 | ||
4be92408 DS |
116 | pytestmark = [pytest.mark.pimd, pytest.mark.staticd] |
117 | ||
118 | ||
df94c7e8 KK |
119 | # Reading the data from JSON File for topology creation |
120 | jsonFile = "{}/mcast_pim_bsmp_01.json".format(CWD) | |
121 | try: | |
122 | with open(jsonFile, "r") as topoJson: | |
123 | topo = json.load(topoJson) | |
124 | except IOError: | |
125 | assert False, "Could not read file {}".format(jsonFile) | |
126 | ||
127 | TOPOLOGY = """ | |
128 | ||
129 | b1_____ | |
130 | | | |
131 | | | |
132 | s1-----f1-----i1-----l1----r1 | |
133 | | | |
134 | ______| | |
135 | b2 | |
136 | ||
137 | b1 - BSR 1 | |
138 | b2 - BSR 2 | |
139 | s1 - Source | |
140 | f1 - FHR | |
141 | i1 - Intermediate Router (also RP) | |
142 | r1 - Receiver | |
143 | ||
144 | """ | |
145 | # Global variables | |
146 | NEXT_HOP1 = "70.0.0.1" | |
147 | NEXT_HOP2 = "65.0.0.1" | |
148 | BSR_IP_1 = "1.1.2.7" | |
149 | BSR_IP_2 = "10.2.1.1" | |
150 | BSR1_ADDR = "1.1.2.7/32" | |
151 | BSR2_ADDR = "10.2.1.1/32" | |
152 | ||
153 | ||
154 | class CreateTopo(Topo): | |
155 | """ | |
156 | Test BasicTopo - topology 1 | |
157 | ||
158 | * `Topo`: Topology object | |
159 | """ | |
160 | ||
161 | def build(self, *_args, **_opts): | |
162 | """Build function""" | |
163 | tgen = get_topogen(self) | |
164 | ||
165 | # Building topology from json file | |
166 | build_topo_from_json(tgen, topo) | |
167 | ||
168 | ||
169 | def setup_module(mod): | |
170 | """ | |
171 | Sets up the pytest environment | |
172 | ||
173 | * `mod`: module name | |
174 | """ | |
175 | ||
176 | # Required linux kernel version for this suite to run. | |
177 | result = required_linux_kernel_version("4.15") | |
178 | if result is not True: | |
179 | pytest.skip("Kernel requirements are not met") | |
180 | ||
181 | testsuite_run_time = time.asctime(time.localtime(time.time())) | |
182 | logger.info("Testsuite start time: {}".format(testsuite_run_time)) | |
183 | logger.info("=" * 40) | |
184 | logger.info("Master Topology: \n {}".format(TOPOLOGY)) | |
185 | ||
186 | logger.info("Running setup_module to create topology") | |
187 | ||
188 | # This function initiates the topology build with Topogen... | |
189 | tgen = Topogen(CreateTopo, mod.__name__) | |
190 | # ... and here it calls Mininet initialization functions. | |
191 | ||
192 | # get list of daemons needs to be started for this suite. | |
193 | daemons = topo_daemons(tgen, topo) | |
194 | ||
195 | # Starting topology, create tmp files which are loaded to routers | |
196 | # to start deamons and then start routers | |
197 | start_topology(tgen, daemons) | |
198 | ||
199 | # Don"t run this test if we have any failure. | |
200 | if tgen.routers_have_failure(): | |
201 | pytest.skip(tgen.errors) | |
202 | ||
203 | # Creating configuration from JSON | |
204 | build_config_from_json(tgen, topo) | |
205 | ||
206 | logger.info("Running setup_module() done") | |
207 | ||
208 | ||
209 | def teardown_module(): | |
210 | """Teardown the pytest environment""" | |
211 | ||
212 | logger.info("Running teardown_module to delete topology") | |
213 | ||
214 | tgen = get_topogen() | |
215 | ||
8db751b8 CH |
216 | # Kill any iperfs we left running. |
217 | kill_iperf(tgen) | |
218 | ||
df94c7e8 KK |
219 | # Stop toplogy and Remove tmp files |
220 | tgen.stop_topology() | |
221 | ||
222 | logger.info( | |
223 | "Testsuite end time: {}".format(time.asctime(time.localtime(time.time()))) | |
224 | ) | |
225 | logger.info("=" * 40) | |
226 | ||
227 | ||
228 | ##################################################### | |
229 | # | |
230 | # Local APIs | |
231 | # | |
232 | ##################################################### | |
233 | ||
234 | ||
235 | def clear_bsrp_data(tgen, topo): | |
236 | ||
237 | """ | |
238 | clear bsm databas after test" | |
239 | Parameters | |
240 | ---------- | |
241 | * `tgen`: topogen object | |
242 | ||
243 | Usage | |
244 | ----- | |
245 | result = clear_bsrp_data(tgen, topo) | |
246 | Returns | |
247 | ------- | |
248 | errormsg(str) or True | |
249 | """ | |
250 | ||
251 | for dut in tgen.routers(): | |
252 | ||
253 | rnode = tgen.routers()[dut] | |
254 | ||
255 | logger.info("[DUT: %s]: clear_bsrp_data") | |
256 | ||
257 | run_frr_cmd(rnode, "clear ip pim bsr-data") | |
258 | ||
259 | return True | |
260 | ||
261 | ||
262 | def verify_state_incremented(state_before, state_after): | |
263 | """ | |
264 | API to compare interface traffic state incrementing | |
265 | ||
266 | Parameters | |
267 | ---------- | |
268 | * `state_before` : State dictionary for any particular instance | |
269 | * `state_after` : State dictionary for any particular instance | |
270 | """ | |
271 | ||
272 | for router, state_data in state_before.items(): | |
273 | for state, value in state_data.items(): | |
274 | if state_before[router][state] >= state_after[router][state]: | |
275 | errormsg = ( | |
276 | "[DUT: %s]: state %s value has not" | |
277 | " incremented, Initial value: %s, " | |
278 | "Current value: %s [FAILED!!]" | |
279 | % ( | |
280 | router, | |
281 | state, | |
282 | state_before[router][state], | |
283 | state_after[router][state], | |
284 | ) | |
285 | ) | |
286 | return errormsg | |
287 | ||
288 | logger.info( | |
289 | "[DUT: %s]: State %s value is " | |
290 | "incremented, Initial value: %s, Current value: %s" | |
291 | " [PASSED!!]", | |
292 | router, | |
293 | state, | |
294 | state_before[router][state], | |
295 | state_after[router][state], | |
296 | ) | |
297 | ||
298 | return True | |
299 | ||
300 | ||
301 | def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr, packet): | |
302 | """ | |
303 | API to do required configuration to send and receive BSR packet | |
304 | """ | |
305 | ||
306 | # Re-configure interfaces as per BSR packet | |
307 | result = reconfig_interfaces(tgen, topo, bsr, fhr, packet) | |
308 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
309 | ||
310 | # Create static routes | |
311 | if "bsr" in topo["routers"][bsr]["bsm"]["bsr_packets"][packet]: | |
312 | bsr_route = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["bsr"] | |
313 | next_hop = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["src_ip"].split( | |
314 | "/" | |
315 | )[0] | |
316 | next_hop_rp = topo["routers"][fhr]["links"][rp]["ipv4"].split("/")[0] | |
317 | next_hop_lhr = topo["routers"][rp]["links"][lhr]["ipv4"].split("/")[0] | |
318 | ||
319 | # Add static routes | |
320 | input_dict = { | |
321 | fhr: {"static_routes": [{"network": bsr_route, "next_hop": next_hop}]}, | |
322 | rp: {"static_routes": [{"network": bsr_route, "next_hop": next_hop_rp}]}, | |
323 | lhr: {"static_routes": [{"network": bsr_route, "next_hop": next_hop_lhr}]}, | |
324 | } | |
325 | ||
326 | result = create_static_routes(tgen, input_dict) | |
327 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
328 | ||
329 | # Add kernal route for source | |
330 | group = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["pkt_dst"] | |
331 | bsr_interface = topo["routers"][bsr]["links"][fhr]["interface"] | |
332 | result = addKernelRoute(tgen, bsr, bsr_interface, group) | |
333 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
334 | ||
335 | # RP Mapping | |
336 | rp_mapping = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["rp_mapping"] | |
337 | ||
338 | # Add interfaces in RP for all the RPs | |
339 | result = add_rp_interfaces_and_pim_config(tgen, topo, "lo", rp, rp_mapping) | |
340 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
341 | ||
342 | # Add kernal routes to sender and receiver | |
343 | for group, rp_list in rp_mapping.items(): | |
344 | mask = group.split("/")[1] | |
345 | if int(mask) == 32: | |
346 | group = group.split("/")[0] | |
347 | ||
348 | # Add kernal routes for sender | |
349 | s_interface = topo["routers"][sender]["links"][fhr]["interface"] | |
350 | result = addKernelRoute(tgen, sender, s_interface, group) | |
351 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
352 | ||
353 | # Add kernal routes for receiver | |
354 | r_interface = topo["routers"][receiver]["links"][lhr]["interface"] | |
355 | result = addKernelRoute(tgen, receiver, r_interface, group) | |
356 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
357 | ||
358 | # Add static routes for RPs in FHR and LHR | |
359 | next_hop_fhr = topo["routers"][rp]["links"][fhr]["ipv4"].split("/")[0] | |
360 | next_hop_lhr = topo["routers"][rp]["links"][lhr]["ipv4"].split("/")[0] | |
361 | input_dict = { | |
362 | fhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_fhr}]}, | |
363 | } | |
364 | result = create_static_routes(tgen, input_dict) | |
365 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
366 | ||
367 | input_dict = { | |
368 | lhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_lhr}]}, | |
369 | } | |
370 | result = create_static_routes(tgen, input_dict) | |
371 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
372 | return True | |
373 | ||
374 | ||
375 | ##################################################### | |
376 | # | |
377 | # Testcases | |
378 | # | |
379 | ##################################################### | |
380 | ||
381 | ||
382 | def test_BSR_higher_prefer_ip_p0(request): | |
383 | """ | |
384 | Verify FRR router select higher IP BSR , when 2 BSR present in the network | |
385 | ||
386 | Topology used: | |
387 | b1_____ | |
388 | | | |
389 | | | |
390 | s1-----f1-----i1-----l1----r1 | |
391 | | | |
392 | ______| | |
393 | b2 | |
394 | ||
395 | b1 - BSR 1 | |
396 | b2 - BSR 2 | |
397 | s1 - Source | |
398 | f1 - FHR | |
399 | i1 - Intermediate Router (also RP) | |
400 | r1 - Receiver | |
401 | """ | |
402 | ||
403 | tgen = get_topogen() | |
404 | tc_name = request.node.name | |
405 | write_test_header(tc_name) | |
406 | ||
8db751b8 CH |
407 | # Don"t run this test if we have any failure. |
408 | if tgen.routers_have_failure(): | |
409 | pytest.skip(tgen.errors) | |
410 | ||
df94c7e8 KK |
411 | kill_iperf(tgen) |
412 | clear_ip_mroute(tgen) | |
413 | reset_config_on_routers(tgen) | |
414 | clear_ip_pim_interface_traffic(tgen, topo) | |
415 | ||
df94c7e8 KK |
416 | reset_config_on_routers(tgen) |
417 | step("pre-configure BSM packet") | |
418 | step("Configure cisco-1 as BSR1 1.1.2.7") | |
419 | result = pre_config_to_bsm( | |
420 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
421 | ) | |
422 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
423 | step("Configure cisco-1 as BSR1 10.2.1.1") | |
424 | result = pre_config_to_bsm( | |
425 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
426 | ) | |
427 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
428 | step("configuring loopback address of b1 and b2 as BSR") | |
429 | intf_lo_addr_b1 = topo["routers"]["b1"]["links"]["lo"]["ipv4"] | |
430 | intf_lo_addr_b2 = topo["routers"]["b2"]["links"]["lo"]["ipv4"] | |
431 | ||
432 | raw_config = { | |
433 | "b1": { | |
434 | "raw_config": [ | |
435 | "interface lo", | |
436 | "no ip address {}".format(intf_lo_addr_b1), | |
437 | "ip address {}".format(BSR1_ADDR), | |
438 | "ip pim", | |
439 | ] | |
440 | }, | |
441 | "b2": { | |
442 | "raw_config": [ | |
443 | "interface lo", | |
444 | "no ip address {}".format(intf_lo_addr_b2), | |
445 | "ip address {}".format(BSR2_ADDR), | |
446 | "ip pim", | |
447 | ] | |
448 | }, | |
449 | } | |
450 | result = apply_raw_config(tgen, raw_config) | |
451 | assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) | |
452 | ||
453 | GROUP_ADDRESS = "225.200.100.100" | |
454 | step("configuring static routes for both the BSR") | |
455 | ||
456 | next_hop_rp = topo["routers"]["f1"]["links"]["i1"]["ipv4"].split("/")[0] | |
457 | next_hop_lhr = topo["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0] | |
458 | ||
459 | input_dict = { | |
460 | "f1": { | |
461 | "static_routes": [ | |
462 | {"network": BSR1_ADDR, "next_hop": NEXT_HOP1}, | |
463 | {"network": BSR2_ADDR, "next_hop": NEXT_HOP2}, | |
464 | ] | |
465 | }, | |
466 | "i1": { | |
467 | "static_routes": [ | |
468 | {"network": BSR1_ADDR, "next_hop": next_hop_rp}, | |
469 | {"network": BSR2_ADDR, "next_hop": next_hop_rp}, | |
470 | ] | |
471 | }, | |
472 | "l1": { | |
473 | "static_routes": [ | |
474 | {"network": BSR1_ADDR, "next_hop": next_hop_lhr}, | |
475 | {"network": BSR2_ADDR, "next_hop": next_hop_lhr}, | |
476 | ] | |
477 | }, | |
478 | } | |
479 | ||
480 | result = create_static_routes(tgen, input_dict) | |
481 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
482 | ||
483 | # Use scapy to send pre-defined packet from senser to receiver | |
484 | step("Send BSR packet from b1 to FHR") | |
485 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
486 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
487 | ||
488 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
489 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
490 | do_countdown(5) | |
491 | ||
492 | dut = "l1" | |
493 | step("Verify if b1 chosen as BSR in f1") | |
494 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_1) | |
495 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
496 | ||
497 | group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"] | |
498 | step("Find the elected rp from bsrp-info in LHR l1") | |
499 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_1, group) | |
500 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
501 | ||
502 | step("Verify RP in LHR") | |
503 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
504 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
505 | ||
506 | step("Send BSR packet from b2 to FHR") | |
507 | result = scapy_send_bsr_raw_packet(tgen, topo, "b2", "f1", "packet3") | |
508 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
509 | ||
510 | dut = "l1" | |
511 | step("Verify if b2 chosen as BSR in f1") | |
512 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_2) | |
513 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
514 | ||
515 | step("Find the elected rp from bsrp-info in LHR l1") | |
516 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_2, group) | |
517 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
518 | ||
519 | step("Verify RP in LHR") | |
520 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
521 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
522 | ||
523 | step("Shut higher prefer BSR2 link f1 to b2") | |
524 | ||
525 | f1_b2_eth1 = topo["routers"]["f1"]["links"]["b2"]["interface"] | |
526 | shutdown_bringup_interface(tgen, "f1", "f1-b2-eth1", False) | |
527 | ||
528 | step("clearing bsr to timeout old BSR") | |
529 | clear_bsrp_data(tgen, topo) | |
530 | ||
531 | step("Send BSR packet from b1 and b2 to FHR") | |
532 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
533 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
534 | ||
535 | result = scapy_send_bsr_raw_packet(tgen, topo, "b2", "f1", "packet3") | |
536 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
537 | ||
538 | step("sleeping for 3 sec to leran new packet") | |
539 | do_countdown(3) | |
540 | step("verify BSR1 is become prefered RP") | |
541 | dut = "l1" | |
542 | ||
543 | step("Verify if b1 chosen as BSR in f1") | |
544 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_1) | |
545 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
546 | ||
547 | step("Find the elected rp from bsrp-info in LHR l1") | |
548 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_1, group) | |
549 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
550 | ||
551 | step("Verify RP in LHR") | |
552 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
553 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
554 | ||
555 | step("NoShut higher prefer BSR2 link f1 to b2") | |
556 | step("sleeping for 3 min to leran new packet") | |
557 | do_countdown(3) | |
558 | f1_b2_eth1 = topo["routers"]["f1"]["links"]["b2"]["interface"] | |
559 | shutdown_bringup_interface(tgen, "f1", "f1-b2-eth1", True) | |
560 | step("verify BSR2 is become prefered RP") | |
561 | dut = "l1" | |
562 | ||
563 | step("Send BSR packet from b1 and b2 to FHR") | |
564 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
565 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
566 | ||
567 | result = scapy_send_bsr_raw_packet(tgen, topo, "b2", "f1", "packet3") | |
568 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
569 | ||
570 | step("Verify if b2 chosen as BSR in f1") | |
571 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_2) | |
572 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
573 | ||
574 | step("Find the elected rp from bsrp-info in LHR l1") | |
575 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_2, group) | |
576 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
577 | ||
578 | step("Verify RP in LHR") | |
579 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
580 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
581 | ||
582 | step("Clear BSM database before moving to next case") | |
583 | clear_bsrp_data(tgen, topo) | |
584 | ||
585 | write_test_footer(tc_name) | |
586 | ||
587 | ||
588 | def test_BSR_CRP_with_blackhole_address_p1(request): | |
589 | """ | |
590 | Verify BSR and RP updated correctly after configuring as black hole address | |
591 | ||
592 | Topology used: | |
593 | b1_____ | |
594 | | | |
595 | | | |
596 | s1-----f1-----i1-----l1----r1 | |
597 | | | |
598 | ______| | |
599 | b2 | |
600 | ||
601 | b1 - BSR 1 | |
602 | b2 - BSR 2 | |
603 | s1 - Source | |
604 | f1 - FHR | |
605 | i1 - Intermediate Router (also RP) | |
606 | r1 - Receiver | |
607 | """ | |
608 | ||
609 | tgen = get_topogen() | |
610 | tc_name = request.node.name | |
611 | write_test_header(tc_name) | |
612 | ||
8db751b8 CH |
613 | # Don"t run this test if we have any failure. |
614 | if tgen.routers_have_failure(): | |
615 | pytest.skip(tgen.errors) | |
616 | ||
df94c7e8 KK |
617 | kill_iperf(tgen) |
618 | clear_ip_mroute(tgen) | |
619 | reset_config_on_routers(tgen) | |
620 | clear_ip_pim_interface_traffic(tgen, topo) | |
621 | ||
df94c7e8 KK |
622 | reset_config_on_routers(tgen) |
623 | step("pre-configure BSM packet") | |
624 | step("Configure cisco-1 as BSR1 1.1.2.7") | |
625 | result = pre_config_to_bsm( | |
626 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
627 | ) | |
628 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
629 | ||
630 | step("configuring loopback address of b1 and b2 as BSR") | |
631 | intf_lo_addr_b1 = topo["routers"]["b1"]["links"]["lo"]["ipv4"] | |
632 | ||
633 | raw_config = { | |
634 | "b1": { | |
635 | "raw_config": [ | |
636 | "interface lo", | |
637 | "no ip address {}".format(intf_lo_addr_b1), | |
638 | "ip address {}".format(BSR1_ADDR), | |
639 | "ip pim", | |
640 | ] | |
641 | } | |
642 | } | |
643 | result = apply_raw_config(tgen, raw_config) | |
644 | assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) | |
645 | ||
646 | GROUP_ADDRESS = "225.200.100.100" | |
647 | step("configuring static routes for both the BSR") | |
648 | ||
649 | next_hop_rp = topo["routers"]["f1"]["links"]["i1"]["ipv4"].split("/")[0] | |
650 | next_hop_lhr = topo["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0] | |
d99438d2 KK |
651 | next_hop_fhr = topo["routers"]["i1"]["links"]["f1"]["ipv4"].split("/")[0] |
652 | CRP = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["candidate_rp"] | |
df94c7e8 KK |
653 | |
654 | input_dict = { | |
df94c7e8 KK |
655 | "i1": {"static_routes": [{"network": BSR1_ADDR, "next_hop": next_hop_rp}]}, |
656 | "l1": {"static_routes": [{"network": BSR1_ADDR, "next_hop": next_hop_lhr}]}, | |
0b25370e DS |
657 | "f1": { |
658 | "static_routes": [ | |
659 | {"network": CRP, "next_hop": next_hop_fhr, "delete": True} | |
660 | ] | |
661 | }, | |
df94c7e8 KK |
662 | } |
663 | ||
664 | result = create_static_routes(tgen, input_dict) | |
665 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
666 | ||
667 | # Use scapy to send pre-defined packet from senser to receiver | |
668 | ||
669 | group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"] | |
df94c7e8 KK |
670 | step("waiting for BSR to timeout before configuring blackhole route") |
671 | clear_bsrp_data(tgen, topo) | |
672 | ||
673 | step("Configure black-hole address for BSR and candidate RP") | |
674 | input_dict = { | |
675 | "f1": { | |
676 | "static_routes": [{"network": [BSR1_ADDR, CRP], "next_hop": "blackhole"}] | |
677 | } | |
678 | } | |
679 | ||
680 | result = create_static_routes(tgen, input_dict) | |
681 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
682 | ||
683 | intf_f1_i1 = topo["routers"]["f1"]["links"]["i1"]["interface"] | |
684 | step("Verify bsm transit count is not increamented" "show ip pim interface traffic") | |
685 | state_dict = {"f1": {intf_f1_i1: ["bsmTx"]}} | |
686 | ||
687 | state_before = verify_pim_interface_traffic(tgen, state_dict) | |
688 | assert isinstance( | |
689 | state_before, dict | |
690 | ), "Testcase{} : Failed \n state_before is not dictionary \n " | |
691 | "Error: {}".format(tc_name, result) | |
692 | ||
693 | step("Sending BSR after Configure black hole address for BSR and candidate RP") | |
694 | step("Send BSR packet from b1 to FHR") | |
695 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
696 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
697 | ||
698 | dut = "l1" | |
699 | step("Find the elected rp from bsrp-info in LHR l1") | |
700 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_1, group) | |
701 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
702 | ||
703 | step("Verify if b1 chosen as BSR in l1") | |
704 | result = verify_pim_bsr(tgen, topo, "l1", BSR_IP_1, expected=False) | |
0b25370e DS |
705 | assert ( |
706 | result is not True | |
707 | ), "Testcase {} : Failed \n " "b1 is not chosen as BSR in l1 \n Error: {}".format( | |
5cbb02eb | 708 | tc_name, result |
0b25370e | 709 | ) |
df94c7e8 KK |
710 | |
711 | state_after = verify_pim_interface_traffic(tgen, state_dict) | |
712 | assert isinstance( | |
713 | state_after, dict | |
714 | ), "Testcase{} : Failed \n state_before is not dictionary \n " | |
715 | "Error: {}".format(tc_name, result) | |
716 | ||
717 | result = verify_state_incremented(state_before, state_after) | |
718 | assert result is not True, "Testcase{} : Failed Error: {}".format(tc_name, result) | |
719 | ||
720 | step("Remove black-hole address for BSR and candidate RP") | |
721 | input_dict = { | |
722 | "f1": { | |
723 | "static_routes": [ | |
5900cf46 | 724 | {"network": [BSR1_ADDR, CRP], "next_hop": "blackhole", "delete": True}, |
5980ad0a | 725 | {"network": BSR1_ADDR, "next_hop": NEXT_HOP1}, |
df94c7e8 KK |
726 | ] |
727 | } | |
728 | } | |
729 | ||
730 | result = create_static_routes(tgen, input_dict) | |
731 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
732 | ||
733 | step("Sending BSR after removing black-hole address for BSR and candidate RP") | |
734 | step("Send BSR packet from b1 to FHR") | |
735 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
736 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
737 | ||
738 | step("Verify if b1 chosen as BSR in f1") | |
739 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_1) | |
740 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
741 | ||
742 | dut = "l1" | |
743 | group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"] | |
744 | step("Find the elected rp from bsrp-info in LHR l1") | |
745 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_1, group) | |
746 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
747 | ||
748 | step("Verify RP in LHR l1") | |
749 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
750 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
751 | ||
752 | step("clear BSM database before moving to next case") | |
753 | clear_bsrp_data(tgen, topo) | |
754 | ||
755 | write_test_footer(tc_name) | |
756 | ||
757 | ||
758 | def test_new_router_fwd_p0(request): | |
759 | """ | |
760 | 1. Verify when new router added to the topology, FRR node will send | |
761 | unicast BSM to new router | |
762 | 2. Verify if no forwarding bit is set , FRR is not forwarding the | |
763 | BSM to other PIM nbrs | |
764 | 3. Verify multicast BSM is sent to new router when unicast BSM is disabled | |
765 | ||
766 | Topology used: | |
767 | b1_____ | |
768 | | | |
769 | | | |
770 | s1-----f1-----i1-----l1----r1 | |
771 | | | |
772 | ______| | |
773 | b2 | |
774 | ||
775 | b1 - BSR 1 | |
776 | b2 - BSR 2 | |
777 | s1 - Source | |
778 | f1 - FHR | |
779 | i1 - Intermediate Router (also RP) | |
780 | r1 - Receiver | |
781 | ||
782 | """ | |
783 | ||
784 | tgen = get_topogen() | |
785 | tc_name = request.node.name | |
786 | write_test_header(tc_name) | |
787 | ||
8db751b8 CH |
788 | # Don"t run this test if we have any failure. |
789 | if tgen.routers_have_failure(): | |
790 | pytest.skip(tgen.errors) | |
791 | ||
df94c7e8 KK |
792 | kill_iperf(tgen) |
793 | clear_ip_mroute(tgen) | |
794 | reset_config_on_routers(tgen) | |
795 | clear_ip_pim_interface_traffic(tgen, topo) | |
796 | ||
df94c7e8 KK |
797 | reset_config_on_routers(tgen) |
798 | ||
799 | result = pre_config_to_bsm( | |
800 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
801 | ) | |
802 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
803 | ||
804 | result = pre_config_to_bsm( | |
805 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
806 | ) | |
807 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
808 | ||
809 | GROUP_ADDRESS = "225.1.1.1" | |
810 | ||
811 | # Use scapy to send pre-defined packet from senser to receiver | |
812 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
813 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
814 | ||
815 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
816 | time.sleep(1) | |
817 | ||
818 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
819 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
820 | ||
821 | # Verify bsr state in FHR | |
822 | step("Verify if b1 chosen as BSR in f1") | |
823 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
824 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
825 | ||
826 | # Verify bsr state in i1 | |
827 | step("Verify if b1 chosen as BSR in i1") | |
828 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
829 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
830 | ||
831 | # Verify ip mroute | |
832 | iif = "l1-i1-eth0" | |
833 | src_addr = "*" | |
834 | oil = "l1-r1-eth1" | |
835 | ||
836 | step("Verify mroute populated on l1") | |
837 | result = verify_ip_mroutes(tgen, "l1", src_addr, GROUP_ADDRESS, iif, oil) | |
838 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
839 | ||
840 | # Reload i1 and l1 | |
841 | step("Reloading i1 and l1. Stop both. bring up l1 and then i1") | |
842 | stop_router(tgen, "i1") | |
843 | start_router(tgen, "i1") | |
844 | stop_router(tgen, "l1") | |
845 | start_router(tgen, "l1") | |
846 | ||
847 | # Verify bsr state in i1 | |
848 | step("Verify BSR in i1 after restart while no new bsm sent from b1") | |
849 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
850 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
851 | ||
852 | # Verify bsr state in l1 | |
853 | step("Verify no BSR in l1 as i1 would not forward the no-forward bsm") | |
854 | result = verify_pim_bsr(tgen, topo, "l1", bsr_ip, expected=False) | |
0b25370e DS |
855 | assert result is not True, ( |
856 | "Testcase {} : Failed \n " | |
5cbb02eb | 857 | "BSR data is present after no-forward bsm also \n Error: {}".format( |
0b25370e DS |
858 | tc_name, result |
859 | ) | |
860 | ) | |
df94c7e8 KK |
861 | |
862 | # unconfigure unicast bsm on f1-i1-eth2 | |
863 | step("unconfigure unicast bsm on f1-i1-eth2, will forward with only mcast") | |
864 | enable_disable_pim_unicast_bsm(tgen, "f1", "f1-i1-eth2", enable=False) | |
865 | ||
866 | # Reboot i1 to check if still bsm received with multicast address | |
867 | step("Reboot i1 to check if still bsm received with multicast address") | |
868 | stop_router(tgen, "i1") | |
869 | start_router(tgen, "i1") | |
870 | ||
871 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
872 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
873 | ||
874 | # Verify again if BSR is installed from bsm forwarded by f1 | |
875 | step("Verify again if BSR is installed from bsm forwarded by f1") | |
876 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
877 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
878 | ||
879 | # Use scapy to send pre-defined packet from senser to receiver | |
880 | step("Send another BSM packet from b1 which will reach l1(LHR)") | |
881 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2") | |
882 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
883 | do_countdown(5) | |
884 | ||
885 | # Verify ip mroute populated again | |
886 | step("Verify mroute again on l1 (lhr)") | |
887 | result = verify_ip_mroutes(tgen, "l1", src_addr, GROUP_ADDRESS, iif, oil) | |
888 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
889 | ||
890 | step("clear BSM database before moving to next case") | |
891 | clear_bsrp_data(tgen, topo) | |
892 | ||
893 | write_test_footer(tc_name) | |
894 | ||
895 | ||
896 | def test_int_bsm_config_p1(request): | |
897 | """ | |
898 | 1. Verfiy BSM arrived on non bsm capable interface is dropped and | |
899 | not processed | |
900 | 2. Verify group to RP info updated correctly in FRR node, after shut and | |
901 | no-shut of BSM enable interfaces | |
902 | ||
903 | Topology used: | |
904 | b1_____ | |
905 | | | |
906 | | | |
907 | s1-----f1-----i1-----l1----r1 | |
908 | | | |
909 | ______| | |
910 | b2 | |
911 | ||
912 | b1 - BSR 1 | |
913 | b2 - BSR 2 | |
914 | s1 - Source | |
915 | f1 - FHR | |
916 | i1 - Intermediate Router (also RP) | |
917 | r1 - Receiver | |
918 | ||
919 | """ | |
920 | ||
921 | tgen = get_topogen() | |
922 | tc_name = request.node.name | |
923 | write_test_header(tc_name) | |
924 | ||
8db751b8 CH |
925 | # Don"t run this test if we have any failure. |
926 | if tgen.routers_have_failure(): | |
927 | pytest.skip(tgen.errors) | |
928 | ||
df94c7e8 KK |
929 | kill_iperf(tgen) |
930 | clear_ip_mroute(tgen) | |
931 | reset_config_on_routers(tgen) | |
932 | clear_ip_pim_interface_traffic(tgen, topo) | |
933 | ||
df94c7e8 KK |
934 | reset_config_on_routers(tgen) |
935 | ||
936 | result = pre_config_to_bsm( | |
937 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
938 | ) | |
939 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
940 | ||
941 | result = pre_config_to_bsm( | |
942 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
943 | ) | |
944 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
945 | ||
946 | GROUP_ADDRESS = "225.1.1.1" | |
947 | ||
948 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
949 | time.sleep(1) | |
950 | ||
951 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
952 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
953 | ||
954 | # Use scapy to send pre-defined packet from senser to receiver | |
955 | step("Send BSM packet from b1") | |
956 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
957 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
958 | ||
959 | # Verify bsr state in i1 | |
960 | step("Verify if b1 is chosen as BSR in i1") | |
961 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
962 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
963 | ||
964 | # check if mroute installed | |
965 | step("check if mroute installed in i1") | |
966 | iif = "lo" | |
967 | src_addr = "*" | |
968 | oil = "i1-l1-eth1" | |
969 | ||
970 | result = verify_ip_mroutes(tgen, "i1", src_addr, GROUP_ADDRESS, iif, oil) | |
971 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
972 | ||
973 | # wait till bsm rp age out | |
974 | step("wait till bsm rp age out") | |
975 | clear_bsrp_data(tgen, topo) | |
976 | ||
977 | # check if mroute uninstalled because of rp age out | |
978 | step("check if mroute uninstalled because of rp age out in i1") | |
979 | result = verify_ip_mroutes( | |
980 | tgen, "i1", src_addr, GROUP_ADDRESS, iif, oil, expected=False | |
981 | ) | |
0b25370e DS |
982 | assert ( |
983 | result is not True | |
984 | ), "Testcase {} : Failed \n " "Mroutes are still present \n Error: {}".format( | |
5cbb02eb | 985 | tc_name, result |
0b25370e | 986 | ) |
df94c7e8 KK |
987 | |
988 | # unconfigure bsm processing on f1 on f1-i1-eth2 | |
989 | step("unconfigure bsm processing on f1 in f1-i1-eth2, will drop bsm") | |
990 | result = enable_disable_pim_bsm(tgen, "f1", "f1-i1-eth2", enable=False) | |
991 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
992 | ||
993 | # Use scapy to send pre-defined packet from senser to receiver | |
994 | step("Send BSM packet from b1") | |
995 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
996 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
997 | ||
998 | # Verify bsr state in FHR | |
999 | step("Verify if b1 chosen as BSR in f1") | |
1000 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1001 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1002 | ||
1003 | # Verify bsr state in i1 | |
1004 | step("Verify if b1 is not chosen as BSR in i1") | |
1005 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip, expected=False) | |
0b25370e DS |
1006 | assert ( |
1007 | result is not True | |
1008 | ), "Testcase {} : Failed \n " "b1 is chosen as BSR in i1 \n Error: {}".format( | |
5cbb02eb | 1009 | tc_name, result |
0b25370e | 1010 | ) |
df94c7e8 KK |
1011 | |
1012 | # check if mroute still not installed because of rp not available | |
1013 | step("check if mroute still not installed because of rp not available") | |
1014 | result = verify_ip_mroutes( | |
1015 | tgen, "i1", src_addr, GROUP_ADDRESS, iif, oil, expected=False | |
1016 | ) | |
0b25370e DS |
1017 | assert result is not True, ( |
1018 | "Testcase {} : Failed \n " | |
1019 | "mroute installed but rp not available \n Error: {}".format(tc_name, result) | |
1020 | ) | |
df94c7e8 KK |
1021 | |
1022 | # configure bsm processing on i1 on f1-i1-eth2 | |
1023 | step("configure bsm processing on f1 in f1-i1-eth2, will accept bsm") | |
1024 | result = enable_disable_pim_bsm(tgen, "f1", "f1-i1-eth2", enable=True) | |
1025 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1026 | ||
1027 | # Use scapy to send pre-defined packet from senser to receiver | |
1028 | step("Send BSM packet again from b1") | |
1029 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2") | |
1030 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1031 | ||
1032 | # Verify again if BSR is installed from bsm forwarded by f1 | |
1033 | step("Verify again if BSR is installed from bsm forwarded by f1") | |
1034 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
1035 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1036 | ||
1037 | # verify ip mroute populated | |
1038 | step("Verify ip mroute") | |
1039 | result = verify_ip_mroutes(tgen, "i1", src_addr, GROUP_ADDRESS, iif, oil) | |
1040 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1041 | ||
1042 | # Shut/No shut the bsm rpf interface and check mroute on lhr(l1) | |
1043 | step("Shut/No shut the bsm rpf interface and check mroute on lhr(l1)") | |
1044 | intf = "l1-i1-eth0" | |
1045 | shutdown_bringup_interface(tgen, "l1", intf, False) | |
1046 | shutdown_bringup_interface(tgen, "l1", intf, True) | |
1047 | ||
1048 | iif = "l1-i1-eth0" | |
1049 | oil = "l1-r1-eth1" | |
1050 | ||
1051 | result = verify_ip_mroutes(tgen, "l1", src_addr, GROUP_ADDRESS, iif, oil) | |
1052 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1053 | ||
1054 | step("clear BSM database before moving to next case") | |
1055 | clear_bsrp_data(tgen, topo) | |
1056 | ||
1057 | write_test_footer(tc_name) | |
1058 | ||
1059 | ||
1060 | def test_static_rp_override_p1(request): | |
1061 | """ | |
1062 | Verify static RP is preferred over BSR | |
1063 | ||
1064 | Topology used: | |
1065 | b1_____ | |
1066 | | | |
1067 | | | |
1068 | s1-----f1-----i1-----l1----r1 | |
1069 | | | |
1070 | ______| | |
1071 | b2 | |
1072 | ||
1073 | b1 - BSR 1 | |
1074 | b2 - BSR 2 | |
1075 | s1 - Source | |
1076 | f1 - FHR | |
1077 | i1 - Intermediate Router (also RP) | |
1078 | r1 - Receiver | |
1079 | ||
1080 | """ | |
1081 | ||
1082 | tgen = get_topogen() | |
1083 | tc_name = request.node.name | |
1084 | write_test_header(tc_name) | |
1085 | ||
8db751b8 CH |
1086 | # Don"t run this test if we have any failure. |
1087 | if tgen.routers_have_failure(): | |
1088 | pytest.skip(tgen.errors) | |
1089 | ||
df94c7e8 KK |
1090 | kill_iperf(tgen) |
1091 | clear_ip_mroute(tgen) | |
1092 | reset_config_on_routers(tgen) | |
1093 | clear_ip_pim_interface_traffic(tgen, topo) | |
1094 | ||
df94c7e8 KK |
1095 | reset_config_on_routers(tgen) |
1096 | ||
1097 | result = pre_config_to_bsm( | |
1098 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1099 | ) | |
1100 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1101 | ||
1102 | result = pre_config_to_bsm( | |
1103 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1104 | ) | |
1105 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1106 | ||
1107 | GROUP_ADDRESS = "225.1.1.1" | |
1108 | # Use scapy to send pre-defined packet from senser to receiver | |
1109 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1110 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1111 | ||
1112 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
1113 | time.sleep(1) | |
1114 | ||
1115 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1116 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1117 | ||
1118 | # Verify bsr state in FHR | |
1119 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1120 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1121 | ||
1122 | # Check igmp groups | |
1123 | step("Verify IGMP groups in LHR") | |
1124 | dut = "l1" | |
1125 | intf = "l1-r1-eth1" | |
1126 | result = verify_igmp_groups(tgen, dut, intf, GROUP_ADDRESS) | |
1127 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1128 | ||
1129 | group = "225.1.1.1/32" | |
1130 | ||
1131 | # Find the elected rp from bsrp-info | |
1132 | step("Find the elected rp from bsrp-info in LHR l1") | |
1133 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1134 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1135 | ||
1136 | # Check RP detail in LHR | |
1137 | step("Verify that BS RP in LHR l1") | |
1138 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
1139 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1140 | ||
1141 | iif = "l1-i1-eth0" | |
1142 | # Verify upstream rpf for 225.1.1.1 is chosen as rp1 | |
1143 | step("Verify upstream rpf for 225.1.1.1 is chosen as bsrp") | |
1144 | result = verify_ip_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, rp[group]) | |
1145 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1146 | ||
1147 | # Configure a static rp for the group 225.1.1.1/32 | |
1148 | step("Configure a static rp 33.33.33.33 for the group 225.1.1.1/32 in l1") | |
1149 | input_dict = { | |
1150 | "l1": { | |
1151 | "pim": { | |
1152 | "rp": [ | |
5980ad0a DS |
1153 | { |
1154 | "rp_addr": "33.33.33.33", | |
1155 | "group_addr_range": ["225.1.1.1/32"], | |
1156 | } | |
df94c7e8 KK |
1157 | ] |
1158 | } | |
1159 | } | |
1160 | } | |
1161 | result = create_pim_config(tgen, topo, input_dict) | |
1162 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1163 | ||
1164 | # Verify that static rp is configured over bsrp | |
1165 | static_rp = "33.33.33.33" | |
1166 | step("Verify that Static RP in LHR in l1") | |
1167 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "Static", static_rp) | |
1168 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1169 | ||
1170 | # Verify if upstream also reflects the static rp | |
1171 | step("Verify upstream rpf for 225.1.1.1 is chosen as static in l1") | |
1172 | result = verify_ip_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, static_rp) | |
1173 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1174 | ||
1175 | # delete static rp for the group 225.1.1.1/32 | |
1176 | step("Delete static rp 33.33.33.33 for the group 225.1.1.1/32 in l1") | |
1177 | input_dict = { | |
1178 | "l1": { | |
1179 | "pim": { | |
1180 | "rp": [ | |
1181 | { | |
1182 | "rp_addr": "33.33.33.33", | |
1183 | "group_addr_range": ["225.1.1.1/32"], | |
1184 | "delete": True, | |
1185 | } | |
1186 | ] | |
1187 | } | |
1188 | } | |
1189 | } | |
1190 | result = create_pim_config(tgen, topo, input_dict) | |
1191 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1192 | ||
1193 | # Verify if bsrp is installed back for the group 225.1.1.1/32 | |
1194 | step("Verify that BS RP in installed in LHR") | |
1195 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
1196 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1197 | ||
1198 | # Verify upstream rpf for 225.1.1.1 is chosen as bsrp | |
1199 | step("Verify upstream rpf for 225.1.1.1 is chosen as bsrp in l1") | |
1200 | result = verify_ip_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, rp[group]) | |
1201 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1202 | ||
1203 | step("clear BSM database before moving to next case") | |
1204 | clear_bsrp_data(tgen, topo) | |
1205 | ||
1206 | write_test_footer(tc_name) | |
1207 | ||
1208 | ||
1209 | def test_bsmp_stress_add_del_restart_p2(request): | |
1210 | """ | |
1211 | 1. Verify adding/deleting the group to rp mapping and RP priority | |
1212 | multiple times | |
1213 | 2. Verify RP and (*,G) detail after PIM process restart on FRR node | |
1214 | ||
1215 | Topology used: | |
1216 | b1_____ | |
1217 | | | |
1218 | | | |
1219 | s1-----f1-----i1-----l1----r1 | |
1220 | | | |
1221 | ______| | |
1222 | b2 | |
1223 | ||
1224 | b1 - BSR 1 | |
1225 | b2 - BSR 2 | |
1226 | s1 - Source | |
1227 | f1 - FHR | |
1228 | i1 - Intermediate Router (also RP) | |
1229 | r1 - Receiver | |
1230 | ||
1231 | """ | |
1232 | ||
1233 | tgen = get_topogen() | |
1234 | tc_name = request.node.name | |
1235 | write_test_header(tc_name) | |
1236 | ||
8db751b8 CH |
1237 | # Don"t run this test if we have any failure. |
1238 | if tgen.routers_have_failure(): | |
1239 | pytest.skip(tgen.errors) | |
1240 | ||
df94c7e8 KK |
1241 | kill_iperf(tgen) |
1242 | clear_ip_mroute(tgen) | |
1243 | reset_config_on_routers(tgen) | |
1244 | clear_ip_pim_interface_traffic(tgen, topo) | |
1245 | ||
df94c7e8 KK |
1246 | reset_config_on_routers(tgen) |
1247 | ||
1248 | result = pre_config_to_bsm( | |
1249 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1250 | ) | |
1251 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1252 | ||
1253 | result = pre_config_to_bsm( | |
1254 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1255 | ) | |
1256 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1257 | ||
1258 | GROUP_ADDRESS = "225.1.1.1" | |
1259 | ||
1260 | # Use scapy to send pre-defined packet from senser to receiver | |
1261 | step("Send BSR packet from b1 to FHR") | |
1262 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1263 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1264 | ||
1265 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
1266 | time.sleep(1) | |
1267 | ||
1268 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1269 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1270 | ||
1271 | # Verify bsr state in FHR | |
1272 | step("Verify if b1 is chosen as bsr in f1") | |
1273 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1274 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1275 | ||
1276 | dut = "l1" | |
1277 | group = "225.1.1.0/24" | |
1278 | # Find the elected rp from bsrp-info | |
1279 | step("Find the elected rp from bsrp-info in LHR l1") | |
1280 | rp1 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1281 | assert rp1 is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1282 | ||
1283 | # Check RP detail in LHR | |
1284 | step("Verify RP in LHR l1") | |
1285 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp1[group]) | |
1286 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1287 | ||
1288 | # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24 | |
1289 | step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24") | |
1290 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet6") | |
1291 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1292 | ||
1293 | # Find the elected rp from bsrp-info | |
1294 | step("Find the elected rp from bsrp-info in LHR l1") | |
1295 | rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1296 | assert rp2 is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1297 | logger.info("RP old: %s RP2 new: %s", rp1[group], rp2[group]) | |
1298 | ||
1299 | # Verify is the rp is different now | |
1300 | assert rp1[group] != rp2[group], "Testcase {} :Failed \n Error {}".format( | |
1301 | tc_name, result | |
1302 | ) | |
1303 | ||
1304 | rp_add1 = rp1[group] | |
1305 | rp_add2 = rp2[group] | |
1306 | ||
1307 | # Verify if that rp is installed | |
1308 | step("Verify new RP in LHR installed") | |
1309 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add2) | |
1310 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1311 | ||
1312 | step("Change rp priority in the bsm and send multiple times") | |
1313 | ||
1314 | for i in range(4): | |
1315 | # Send BSR pkt from b1 after putting back high prio rp for 225.1.1.0/24 | |
1316 | step("Send BSM from b1 to FHR put back high prio rp for 225.1.1.0/24") | |
1317 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1318 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1319 | ||
1320 | # Find the elected rp from bsrp-info | |
1321 | step("Find the elected rp from bsrp-info in LHR") | |
1322 | rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1323 | assert rp2 is not {}, "Testcase {} :Failed \n Error : RP not Found".format( | |
1324 | tc_name | |
1325 | ) | |
1326 | ||
1327 | # Verify is the rp is different now | |
1328 | step("Verify now old RP is elected again") | |
1329 | assert ( | |
1330 | rp_add1 == rp2[group] | |
1331 | ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format( | |
5980ad0a DS |
1332 | tc_name, |
1333 | rp_add1, | |
df94c7e8 KK |
1334 | ) |
1335 | ||
1336 | # Verify if that rp is installed | |
1337 | step("Verify old RP in LHR installed") | |
1338 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add1) | |
1339 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1340 | ||
1341 | # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24 | |
1342 | step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24") | |
1343 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet6") | |
1344 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1345 | ||
1346 | # Verify if that rp is installed | |
1347 | step("Verify new RP(rp2) in LHR installed") | |
1348 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add2) | |
1349 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1350 | ||
1351 | # Restart pimd | |
1352 | step("Restarting pimd in LHR") | |
1353 | kill_router_daemons(tgen, "l1", ["pimd"]) | |
1354 | start_router_daemons(tgen, "l1", ["pimd"]) | |
1355 | logger.info("Restarting done") | |
1356 | ||
1357 | # Verify if that rp is installed | |
1358 | step("Verify old RP in LHR installed") | |
1359 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add2) | |
1360 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1361 | ||
1362 | # Send IGMP join to LHR | |
1363 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1364 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1365 | ||
1366 | do_countdown(5) | |
1367 | ||
1368 | # VErify mroute created after pimd restart | |
1369 | step("VErify mroute created after pimd restart") | |
1370 | iif = "l1-i1-eth0" | |
1371 | src_addr = "*" | |
1372 | oil = "l1-r1-eth1" | |
1373 | result = verify_ip_mroutes(tgen, "l1", src_addr, GROUP_ADDRESS, iif, oil) | |
1374 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1375 | ||
1376 | write_test_footer(tc_name) | |
1377 | ||
1378 | ||
1379 | def test_BSM_timeout_p0(request): | |
1380 | """ | |
1381 | Verify BSM timeout on FRR1 | |
1382 | Verify RP state in FRR1 after Bootstrap timer expiry | |
1383 | ||
1384 | Topology used: | |
1385 | b1_____ | |
1386 | | | |
1387 | | | |
1388 | s1-----f1-----i1-----l1----r1 | |
1389 | | | |
1390 | ______| | |
1391 | b2 | |
1392 | ||
1393 | b1 - BSR 1 | |
1394 | b2 - BSR 2 | |
1395 | s1 - Source | |
1396 | f1 - FHR | |
1397 | i1 - Intermediate Router (also RP) | |
1398 | r1 - Receiver | |
1399 | ||
1400 | """ | |
1401 | ||
1402 | tgen = get_topogen() | |
1403 | tc_name = request.node.name | |
1404 | write_test_header(tc_name) | |
1405 | ||
8db751b8 CH |
1406 | # Don"t run this test if we have any failure. |
1407 | if tgen.routers_have_failure(): | |
1408 | pytest.skip(tgen.errors) | |
1409 | ||
df94c7e8 KK |
1410 | kill_iperf(tgen) |
1411 | clear_ip_mroute(tgen) | |
1412 | reset_config_on_routers(tgen) | |
1413 | clear_ip_pim_interface_traffic(tgen, topo) | |
1414 | ||
df94c7e8 KK |
1415 | result = pre_config_to_bsm( |
1416 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1417 | ) | |
1418 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1419 | ||
1420 | result = pre_config_to_bsm( | |
1421 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1422 | ) | |
1423 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1424 | ||
1425 | GROUP_ADDRESS = "225.1.1.1" | |
1426 | ||
1427 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
1428 | ||
1429 | # Use scapy to send pre-defined packet from senser to receiver | |
1430 | step("send BSR packet from b1") | |
1431 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1432 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1433 | ||
1434 | # Send IGMP join for group 225.1.1.1 from receiver | |
1435 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1436 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1437 | ||
1438 | # Verify bsr state in FHR | |
1439 | step("Verify bsr state in FHR f1") | |
1440 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1441 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1442 | ||
1443 | # Verify ip mroute in LHR | |
1444 | step(" Verify ip mroute in LHR l1") | |
1445 | dut = "l1" | |
1446 | iif = "l1-i1-eth0" | |
1447 | src_addr = "*" | |
1448 | oil = "l1-r1-eth1" | |
1449 | result = verify_ip_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil) | |
1450 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1451 | ||
1452 | # Verify join state and join timer | |
1453 | step("Verify join state and join timer in lhr l1") | |
1454 | result = verify_join_state_and_timer(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
1455 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1456 | ||
1457 | # Verify upstream IIF interface | |
1458 | step("Verify upstream IIF interface in LHR l1") | |
1459 | result = verify_upstream_iif(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
1460 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1461 | ||
1462 | # Verify RP mapping | |
1463 | dut = "l1" | |
1464 | group = "225.1.1.1/32" | |
1465 | step("Verify RP mapping in LHR l1") | |
1466 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1467 | assert rp != {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1468 | ||
1469 | logger.info("Waiting for 130 secs to check BSR timeout") | |
1470 | clear_bsrp_data(tgen, topo) | |
1471 | ||
1472 | # Verify if bsr has aged out | |
1473 | step("Verify if bsr has aged out in f1") | |
1474 | no_bsr_ip = "0.0.0.0" | |
1475 | result = verify_pim_bsr(tgen, topo, "f1", no_bsr_ip) | |
1476 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1477 | ||
1478 | result = verify_pim_grp_rp_source( | |
1479 | tgen, topo, "f1", group, rp_source="BSR", expected=False | |
1480 | ) | |
1481 | ||
0b25370e DS |
1482 | assert ( |
1483 | result is not True | |
1484 | ), "Testcase {} : Failed \n " "bsr has not aged out in f1 \n Error: {}".format( | |
5cbb02eb | 1485 | tc_name, result |
0b25370e | 1486 | ) |
df94c7e8 KK |
1487 | |
1488 | # Verify RP mapping removed after hold timer expires | |
1489 | group = "225.1.1.1/32" | |
1490 | step("Verify RP mapping removed after hold timer expires in l1") | |
1491 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1492 | assert rp == {}, "Testcase {} :Failed \n Error : RP found when not expected".format( | |
1493 | tc_name | |
1494 | ) | |
1495 | ||
1496 | # Verify iif is unknown after RP timeout | |
1497 | step("Verify iif is unknown after RP timeout in l1") | |
1498 | iif = "Unknown" | |
1499 | result = verify_upstream_iif( | |
1500 | tgen, dut, iif, src_addr, GROUP_ADDRESS, joinState="NotJoined" | |
1501 | ) | |
1502 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1503 | ||
1504 | # Verify join state and join timer | |
1505 | step("Verify join state and join timer in l1") | |
1506 | iif = "l1-i1-eth0" | |
1507 | result = verify_join_state_and_timer( | |
1508 | tgen, dut, iif, src_addr, GROUP_ADDRESS, expected=False | |
1509 | ) | |
0b25370e DS |
1510 | assert result is not True, ( |
1511 | "Testcase {} : Failed \n " | |
5cbb02eb | 1512 | "join state is up and join timer is running in l1 \n Error: {}".format( |
0b25370e DS |
1513 | tc_name, result |
1514 | ) | |
1515 | ) | |
df94c7e8 KK |
1516 | |
1517 | # Verify ip mroute is not installed | |
1518 | step("Verify mroute not installed in l1") | |
1519 | result = verify_ip_mroutes( | |
1520 | tgen, dut, src_addr, GROUP_ADDRESS, iif, oil, expected=False | |
1521 | ) | |
0b25370e DS |
1522 | assert ( |
1523 | result is not True | |
1524 | ), "Testcase {} : Failed \n " "mroute installed in l1 \n Error: {}".format( | |
5cbb02eb | 1525 | tc_name, result |
0b25370e | 1526 | ) |
df94c7e8 KK |
1527 | |
1528 | step("clear BSM database before moving to next case") | |
1529 | clear_bsrp_data(tgen, topo) | |
1530 | ||
1531 | write_test_footer(tc_name) | |
1532 | ||
1533 | ||
1534 | def test_iif_join_state_p0(request): | |
1535 | """ | |
1536 | 1. Verify upstream interfaces(IIF) and join state are updated properly | |
1537 | after BSM received for FRR | |
1538 | 2. Verify IIF and OIL in "show ip pim state" updated properly after | |
1539 | BSM received | |
1540 | ||
1541 | Topology used: | |
1542 | b1_____ | |
1543 | | | |
1544 | | | |
1545 | s1-----f1-----i1-----l1----r1 | |
1546 | | | |
1547 | ______| | |
1548 | b2 | |
1549 | ||
1550 | b1 - BSR 1 | |
1551 | b2 - BSR 2 | |
1552 | s1 - Source | |
1553 | f1 - FHR | |
1554 | i1 - Intermediate Router (also RP) | |
1555 | r1 - Receiver | |
1556 | ||
1557 | """ | |
1558 | ||
1559 | tgen = get_topogen() | |
1560 | tc_name = request.node.name | |
1561 | write_test_header(tc_name) | |
1562 | ||
8db751b8 CH |
1563 | # Don"t run this test if we have any failure. |
1564 | if tgen.routers_have_failure(): | |
1565 | pytest.skip(tgen.errors) | |
1566 | ||
df94c7e8 KK |
1567 | kill_iperf(tgen) |
1568 | clear_ip_mroute(tgen) | |
1569 | reset_config_on_routers(tgen) | |
1570 | clear_ip_pim_interface_traffic(tgen, topo) | |
1571 | ||
df94c7e8 KK |
1572 | reset_config_on_routers(tgen) |
1573 | ||
1574 | result = pre_config_to_bsm( | |
1575 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1576 | ) | |
1577 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1578 | ||
1579 | result = pre_config_to_bsm( | |
1580 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1581 | ) | |
1582 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1583 | ||
1584 | GROUP_ADDRESS = "225.1.1.1" | |
1585 | ||
1586 | # Use scapy to send pre-defined packet from senser to receiver | |
1587 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1588 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1589 | ||
1590 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
1591 | time.sleep(1) | |
1592 | ||
1593 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1594 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1595 | ||
1596 | # Verify bsr state in FHR | |
1597 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1598 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1599 | ||
1600 | # Check igmp groups | |
1601 | step("Verify IGMP groups in LHR l1") | |
1602 | dut = "l1" | |
1603 | intf = "l1-r1-eth1" | |
1604 | result = verify_igmp_groups(tgen, dut, intf, GROUP_ADDRESS) | |
1605 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1606 | ||
1607 | group = "225.1.1.1/32" | |
1608 | ||
1609 | # Find the elected rp from bsrp-info | |
1610 | step("Find the elected rp from bsrp-info in LHR l1") | |
1611 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1612 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1613 | ||
1614 | # Check RP detail in LHR | |
1615 | step("Verify RP in LHR l1") | |
1616 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
1617 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1618 | ||
1619 | # Verify join state and join timer | |
1620 | step("Verify join state and join timer l1") | |
1621 | iif = "l1-i1-eth0" | |
1622 | src_addr = "*" | |
1623 | result = verify_join_state_and_timer(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
1624 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1625 | ||
1626 | # Verify upstream IIF interface | |
1627 | step("Verify upstream IIF interface l1") | |
1628 | result = verify_upstream_iif(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
1629 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1630 | ||
1631 | # Verify IIF/OIL in pim state | |
1632 | oil = "l1-r1-eth1" | |
1633 | result = verify_pim_state(tgen, dut, iif, oil, GROUP_ADDRESS) | |
1634 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1635 | ||
1636 | # Verify ip mroute | |
1637 | src_addr = "*" | |
1638 | step("Verify ip mroute in l1") | |
1639 | result = verify_ip_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil) | |
1640 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1641 | ||
1642 | # Make RP unreachanble in LHR | |
1643 | step("Make RP unreachanble in LHR l1") | |
1644 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1645 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1646 | ||
1647 | next_hop_lhr = topo["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0] | |
1648 | ||
1649 | rp_ip = rp[group] + "/32" | |
1650 | input_dict = { | |
1651 | "l1": { | |
1652 | "static_routes": [ | |
1653 | {"network": rp_ip, "next_hop": next_hop_lhr, "delete": True} | |
1654 | ] | |
1655 | } | |
1656 | } | |
1657 | result = create_static_routes(tgen, input_dict) | |
1658 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1659 | ||
1660 | # Check RP unreachable | |
1661 | step("Check RP unreachability") | |
1662 | iif = "Unknown" | |
1663 | result = verify_upstream_iif( | |
1664 | tgen, dut, iif, src_addr, GROUP_ADDRESS, joinState="NotJoined" | |
1665 | ) | |
1666 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1667 | ||
1668 | # Verify that it is not installed | |
1669 | step("Verify that it is not installed") | |
1670 | iif = "<iif?>" | |
1671 | result = verify_pim_state(tgen, dut, iif, oil, GROUP_ADDRESS, installed_fl=0) | |
1672 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1673 | ||
1674 | # Verify mroute not installed | |
1675 | step("Verify mroute not installed") | |
1676 | result = verify_ip_mroutes( | |
1677 | tgen, dut, src_addr, GROUP_ADDRESS, iif, oil, expected=False | |
1678 | ) | |
0b25370e DS |
1679 | assert ( |
1680 | result is not True | |
1681 | ), "Testcase {} : Failed \n " "mroute installed in l1 \n Error: {}".format( | |
5cbb02eb | 1682 | tc_name, result |
0b25370e | 1683 | ) |
df94c7e8 KK |
1684 | |
1685 | # Add back route for RP to make it reachable | |
1686 | step("Add back route for RP to make it reachable") | |
1687 | input_dict = { | |
5980ad0a DS |
1688 | "l1": { |
1689 | "static_routes": [ | |
1690 | { | |
1691 | "network": rp_ip, | |
1692 | "next_hop": next_hop_lhr, | |
1693 | } | |
1694 | ] | |
1695 | } | |
df94c7e8 KK |
1696 | } |
1697 | result = create_static_routes(tgen, input_dict) | |
1698 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1699 | ||
1700 | # Verify that (*,G) installed in mroute again | |
1701 | iif = "l1-i1-eth0" | |
1702 | result = verify_ip_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil) | |
1703 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1704 | ||
1705 | step("clear BSM database before moving to next case") | |
1706 | clear_bsrp_data(tgen, topo) | |
1707 | ||
1708 | write_test_footer(tc_name) | |
1709 | ||
1710 | ||
1711 | if __name__ == "__main__": | |
1712 | args = ["-s"] + sys.argv[1:] | |
1713 | sys.exit(pytest.main(args)) |