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