]>
Commit | Line | Data |
---|---|---|
676fa219 | 1 | #!/usr/bin/env python |
acddc0ed | 2 | # SPDX-License-Identifier: ISC |
676fa219 DS |
3 | |
4 | # | |
5 | # Copyright (c) 2019 by VMware, Inc. ("VMware") | |
6 | # Used Copyright (c) 2018 by Network Device Education Foundation, | |
7 | # Inc. ("NetDEF") in this file. | |
8 | # | |
676fa219 DS |
9 | |
10 | """ | |
11 | Following tests are covered to test Multicast basic functionality: | |
12 | ||
13 | Topology: | |
14 | ||
15 | _______r2_____ | |
16 | | | | |
17 | iperf | | iperf | |
18 | r0-----r1-------------r3-----r5 | |
19 | | | | |
20 | |_____________| | |
21 | r4 | |
22 | ||
23 | Test steps | |
24 | - Create topology (setup module) | |
25 | - Bring up topology | |
26 | ||
27 | TC_1 : Verify upstream interfaces(IIF) and join state are updated properly | |
28 | after adding and deleting the static RP | |
29 | TC_2 : Verify IIF and OIL in "show ip pim state" updated properly after | |
30 | adding and deleting the static RP | |
31 | TC_3: (*, G) Mroute entry are cleared when static RP gets deleted | |
32 | TC_4: Verify (*,G) prune is send towards the RP after deleting the static RP | |
33 | TC_5: Verify OIF entry for RP is cleared when RP becomes unreachable | |
34 | TC_6: Verify IIF and OIL in "show ip pim state" updated properly when RP | |
35 | becomes unreachable | |
36 | TC_7 : Verify upstream interfaces(IIF) and join state are updated properly | |
37 | after adding and deleting the static RP | |
38 | TC_8: Verify (*,G) prune is send towards the RP when RP becomes unreachable | |
39 | TC_9 : Verify RP configured after IGMP join received, PIM join towards RP is | |
40 | sent immediately | |
41 | TC_10 : Verify RP becomes reachable after IGMP join received, PIM join | |
42 | towards RP is sent immediately | |
43 | TC_11 : Verify PIM join send towards the higher preferred RP | |
44 | TC_12 : Verify PIM prune send towards the lower preferred RP | |
45 | TC_13 : Verify RPF interface is updated in mroute (kernel) when higher | |
46 | preferred overlapping RP configured | |
47 | TC_14 : Verify IIF and OIL in "show ip pim state" updated properly when higher | |
48 | preferred overlapping RP configured | |
49 | TC_15 : Verify upstream interfaces(IIF) and join state are updated when higher | |
50 | preferred overlapping RP is configured | |
51 | TC_16 : Verify join is send to lower preferred RP, when higher preferred RP | |
52 | gets deleted | |
53 | TC_17 : Verify prune is send to higher preferred RP when higher preferred RP | |
54 | gets deleted | |
55 | TC_18 : Verify RPF interface updated in mroute when higher preferred RP gets | |
56 | deleted | |
57 | TC_19 : Verify IIF and OIL in "show ip pim state" updated when higher | |
58 | preferred overlapping RP is deleted | |
59 | TC_20 : Verify PIM upstream IIF updated when higher preferred overlapping RP | |
60 | deleted | |
61 | TC_21_1 : Verify OIF and RFP for (*,G) and (S,G) when static RP configure in | |
62 | LHR router | |
63 | TC_21_2 : Verify OIF and RFP for (*,G) and (S,G) when static RP configure in | |
64 | LHR router | |
65 | TC_22_1 : Verify OIF and RPF for (*,G) and (S,G) when static RP configure in | |
66 | FHR router | |
67 | TC_22_2 : Verify OIF and RPF for (*,G) and (S,G) when static RP configure in | |
68 | FHR router | |
69 | TC_23 : Verify (*,G) and (S,G) populated correctly when RPT and SPT path are | |
70 | different | |
71 | TC_24 : Verify (*,G) and (S,G) populated correctly when SPT and RPT share the | |
72 | same path | |
73 | TC_25 : Verify (*,G) and (S,G) populated correctly after clearing the PIM , | |
74 | IGMP and mroutes joins | |
75 | TC_26 : Restart the PIMd process and verify PIM joins , and mroutes entries | |
76 | TC_27 : Configure multiple groups (10 grps) with same RP address | |
77 | TC_28 : Configure multiple groups (10 grps) with different RP address | |
78 | TC_29 : Verify IIF and OIL in updated in mroute when upstream interface | |
79 | configure as RP | |
80 | TC_30 : Verify IIF and OIL change to other path after shut the primary path | |
81 | TC_31 : Verify RP info and (*,G) mroute after deleting the RP and shut / no | |
82 | shut the RPF interface. | |
83 | TC_32 : Verify RP info and (*,G) mroute after deleting the RP and shut / no | |
84 | shut the RPF interface | |
85 | """ | |
86 | ||
87 | import os | |
88 | import sys | |
89 | import time | |
90 | from time import sleep | |
91 | import datetime | |
92 | import pytest | |
93 | ||
94 | # Save the Current Working Directory to find configuration files. | |
95 | CWD = os.path.dirname(os.path.realpath(__file__)) | |
96 | sys.path.append(os.path.join(CWD, "../")) | |
97 | sys.path.append(os.path.join(CWD, "../lib/")) | |
98 | ||
99 | # Required to instantiate the topology builder class. | |
100 | ||
101 | # pylint: disable=C0413 | |
102 | # Import topogen and topotest helpers | |
103 | ||
104 | from lib.topogen import Topogen, get_topogen | |
105 | from lib.topolog import logger | |
106 | from lib.topojson import build_topo_from_json, build_config_from_json | |
107 | ||
108 | from lib.common_config import ( | |
109 | start_topology, | |
110 | write_test_header, | |
111 | write_test_footer, | |
112 | reset_config_on_routers, | |
113 | step, | |
114 | shutdown_bringup_interface, | |
115 | kill_router_daemons, | |
116 | start_router_daemons, | |
117 | create_static_routes, | |
676fa219 DS |
118 | ) |
119 | from lib.pim import ( | |
120 | create_pim_config, | |
121 | verify_igmp_groups, | |
122 | verify_upstream_iif, | |
123 | verify_join_state_and_timer, | |
124 | verify_mroutes, | |
125 | verify_pim_neighbors, | |
126 | get_pim_interface_traffic, | |
127 | verify_pim_rp_info, | |
128 | verify_pim_state, | |
129 | clear_pim_interface_traffic, | |
130 | clear_igmp_interfaces, | |
131 | clear_pim_interfaces, | |
132 | clear_mroute, | |
133 | clear_mroute_verify, | |
134 | McastTesterHelper, | |
135 | ) | |
136 | ||
137 | pytestmark = [pytest.mark.pimd, pytest.mark.staticd] | |
138 | ||
139 | ||
140 | # Global variables | |
141 | GROUP_RANGE_ALL = "224.0.0.0/4" | |
142 | GROUP_RANGE = "225.1.1.1/32" | |
143 | GROUP_RANGE_LIST_1 = [ | |
144 | "225.1.1.1/32", | |
145 | "225.1.1.2/32", | |
146 | "225.1.1.3/32", | |
147 | "225.1.1.4/32", | |
148 | "225.1.1.5/32", | |
149 | ] | |
150 | GROUP_RANGE_LIST_2 = [ | |
151 | "225.1.1.6/32", | |
152 | "225.1.1.7/32", | |
153 | "225.1.1.8/32", | |
154 | "225.1.1.9/32", | |
155 | "225.1.1.10/32", | |
156 | ] | |
157 | GROUP_ADDRESS = "225.1.1.1" | |
158 | GROUP_ADDRESS_LIST_1 = ["225.1.1.1", "225.1.1.2", "225.1.1.3", "225.1.1.4", "225.1.1.5"] | |
159 | GROUP_ADDRESS_LIST_2 = [ | |
160 | "225.1.1.6", | |
161 | "225.1.1.7", | |
162 | "225.1.1.8", | |
163 | "225.1.1.9", | |
164 | "225.1.1.10", | |
165 | ] | |
166 | STAR = "*" | |
167 | SOURCE_ADDRESS = "10.0.6.2" | |
168 | SOURCE = "Static" | |
169 | ||
170 | ||
171 | def build_topo(tgen): | |
172 | """Build function""" | |
173 | ||
174 | # Building topology from json file | |
175 | build_topo_from_json(tgen, TOPO) | |
176 | ||
177 | ||
178 | def setup_module(mod): | |
179 | """ | |
180 | Sets up the pytest environment | |
181 | ||
182 | * `mod`: module name | |
183 | """ | |
184 | ||
185 | testsuite_run_time = time.asctime(time.localtime(time.time())) | |
186 | logger.info("Testsuite start time: %s", testsuite_run_time) | |
187 | logger.info("=" * 40) | |
188 | ||
189 | topology = """ | |
190 | ||
191 | _______r2_____ | |
192 | | | | |
193 | iperf | | iperf | |
194 | r0-----r1-------------r3-----r5 | |
195 | | | | |
196 | |_____________| | |
197 | r4 | |
198 | ||
199 | """ | |
200 | logger.info("Master Topology: \n %s", topology) | |
201 | ||
202 | logger.info("Running setup_module to create topology") | |
203 | ||
204 | # This function initiates the topology build with Topogen... | |
205 | json_file = "{}/multicast_pim_static_rp.json".format(CWD) | |
206 | tgen = Topogen(json_file, mod.__name__) | |
207 | global TOPO | |
208 | TOPO = tgen.json_topo | |
209 | ||
210 | # ... and here it calls Mininet initialization functions. | |
211 | ||
676fa219 DS |
212 | # Starting topology, create tmp files which are loaded to routers |
213 | # to start daemons and then start routers | |
991a971f | 214 | start_topology(tgen) |
676fa219 DS |
215 | |
216 | # Don"t run this test if we have any failure. | |
217 | if tgen.routers_have_failure(): | |
218 | pytest.skip(tgen.errors) | |
219 | ||
220 | # Creating configuration from JSON | |
221 | build_config_from_json(tgen, TOPO) | |
222 | ||
223 | # Verify PIM neighbors | |
224 | result = verify_pim_neighbors(tgen, TOPO) | |
225 | assert result is True, "setup_module :Failed \n Error:" " {}".format(result) | |
226 | ||
227 | # XXX Replace this using "with McastTesterHelper()... " in each test if possible. | |
228 | global app_helper | |
229 | app_helper = McastTesterHelper(tgen) | |
230 | ||
231 | logger.info("Running setup_module() done") | |
232 | ||
233 | ||
234 | def teardown_module(): | |
235 | """Teardown the pytest environment""" | |
236 | ||
237 | logger.info("Running teardown_module to delete topology") | |
238 | ||
239 | tgen = get_topogen() | |
240 | ||
241 | app_helper.cleanup() | |
242 | ||
243 | # Stop toplogy and Remove tmp files | |
244 | tgen.stop_topology() | |
245 | ||
246 | logger.info("Testsuite end time: %s", time.asctime(time.localtime(time.time()))) | |
247 | logger.info("=" * 40) | |
248 | ||
249 | ||
250 | ##################################################### | |
251 | # | |
252 | # Testcases | |
253 | # | |
254 | ##################################################### | |
255 | ||
256 | ||
257 | def verify_mroute_repopulated(uptime_before, uptime_after): | |
258 | """ | |
259 | API to compare uptime for mroutes | |
260 | ||
261 | Parameters | |
262 | ---------- | |
263 | * `uptime_before` : Uptime dictionary for any particular instance | |
264 | * `uptime_after` : Uptime dictionary for any particular instance | |
265 | """ | |
266 | ||
267 | for group in uptime_before.keys(): | |
268 | for source in uptime_before[group].keys(): | |
269 | if set(uptime_before[group]) != set(uptime_after[group]): | |
270 | errormsg = ( | |
271 | "mroute (%s, %s) has not come" | |
272 | " up after mroute clear [FAILED!!]" % (source, group) | |
273 | ) | |
274 | return errormsg | |
275 | ||
276 | d_1 = datetime.datetime.strptime(uptime_before[group][source], "%H:%M:%S") | |
277 | d_2 = datetime.datetime.strptime(uptime_after[group][source], "%H:%M:%S") | |
278 | if d_2 >= d_1: | |
279 | errormsg = "mroute (%s, %s) is not " "repopulated [FAILED!!]" % ( | |
280 | source, | |
281 | group, | |
282 | ) | |
283 | return errormsg | |
284 | ||
285 | logger.info("mroute (%s, %s) is " "repopulated [PASSED!!]", source, group) | |
286 | ||
287 | return True | |
288 | ||
289 | ||
290 | def verify_state_incremented(state_before, state_after): | |
291 | """ | |
292 | API to compare interface traffic state incrementing | |
293 | ||
294 | Parameters | |
295 | ---------- | |
296 | * `state_before` : State dictionary for any particular instance | |
297 | * `state_after` : State dictionary for any particular instance | |
298 | """ | |
299 | ||
300 | for router, state_data in state_before.items(): | |
301 | for state, _ in state_data.items(): | |
302 | if state_before[router][state] >= state_after[router][state]: | |
303 | errormsg = ( | |
304 | "[DUT: %s]: state %s value has not" | |
305 | " incremented, Initial value: %s, " | |
306 | "Current value: %s [FAILED!!]" | |
307 | % ( | |
308 | router, | |
309 | state, | |
310 | state_before[router][state], | |
311 | state_after[router][state], | |
312 | ) | |
313 | ) | |
314 | return errormsg | |
315 | ||
316 | logger.info( | |
317 | "[DUT: %s]: State %s value is " | |
318 | "incremented, Initial value: %s, Current value: %s" | |
319 | " [PASSED!!]", | |
320 | router, | |
321 | state, | |
322 | state_before[router][state], | |
323 | state_after[router][state], | |
324 | ) | |
325 | ||
326 | return True | |
327 | ||
328 | ||
329 | def test_RP_configured_as_LHR_1_p1(request): | |
330 | """ | |
331 | TC_21_1_P1: Verify OIF and RPF for (*,G) and (S,G) when static RP configure | |
332 | in LHR router | |
333 | ||
334 | Topology used: | |
335 | ________r2_____ | |
336 | | | | |
337 | iperf | | iperf | |
338 | r0-----r1-------------r3-----r5 | |
339 | ||
340 | r1 : LHR/RP | |
341 | r3 : FHR | |
342 | """ | |
343 | ||
344 | tgen = get_topogen() | |
345 | tc_name = request.node.name | |
346 | write_test_header(tc_name) | |
347 | ||
348 | # Don"t run this test if we have any failure. | |
349 | if tgen.routers_have_failure(): | |
350 | pytest.skip(tgen.errors) | |
351 | ||
352 | step("Creating configuration from JSON") | |
353 | reset_config_on_routers(tgen) | |
354 | app_helper.stop_all_hosts() | |
355 | clear_mroute(tgen) | |
356 | clear_pim_interface_traffic(tgen, TOPO) | |
357 | ||
358 | step("Enable IGMP on r1 interface") | |
359 | step("Configure RP on r1 (loopback interface) for the group range" " 224.0.0.0/4") | |
360 | step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers") | |
361 | step("Send the IGMP join from r0") | |
362 | step("Send multicast traffic from r5") | |
363 | ||
364 | step("r1 , r2, r3, r4: Delete existing RP configuration" "configure r1(LHR) as RP") | |
365 | input_dict = { | |
366 | "r1": { | |
367 | "pim": { | |
368 | "rp": [ | |
369 | { | |
370 | "rp_addr": "1.0.2.17", | |
371 | "group_addr_range": GROUP_RANGE_ALL, | |
372 | "delete": True, | |
373 | } | |
374 | ] | |
375 | } | |
376 | }, | |
377 | "r2": { | |
378 | "pim": { | |
379 | "rp": [ | |
380 | { | |
381 | "rp_addr": "1.0.2.17", | |
382 | "group_addr_range": GROUP_RANGE_ALL, | |
383 | "delete": True, | |
384 | } | |
385 | ] | |
386 | } | |
387 | }, | |
388 | "r3": { | |
389 | "pim": { | |
390 | "rp": [ | |
391 | { | |
392 | "rp_addr": "1.0.2.17", | |
393 | "group_addr_range": GROUP_RANGE_ALL, | |
394 | "delete": True, | |
395 | } | |
396 | ] | |
397 | } | |
398 | }, | |
399 | "r4": { | |
400 | "pim": { | |
401 | "rp": [ | |
402 | { | |
403 | "rp_addr": "1.0.2.17", | |
404 | "group_addr_range": GROUP_RANGE_ALL, | |
405 | "delete": True, | |
406 | } | |
407 | ] | |
408 | } | |
409 | }, | |
410 | } | |
411 | ||
412 | result = create_pim_config(tgen, TOPO, input_dict) | |
413 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
414 | ||
415 | step("r1: Configure r1(LHR) as RP") | |
416 | input_dict = { | |
417 | "r1": { | |
418 | "pim": { | |
419 | "rp": [ | |
420 | { | |
421 | "rp_addr": "1.0.1.17", | |
422 | "group_addr_range": GROUP_RANGE_ALL, | |
423 | } | |
424 | ] | |
425 | } | |
426 | }, | |
427 | "r2": { | |
428 | "pim": { | |
429 | "rp": [ | |
430 | { | |
431 | "rp_addr": "1.0.1.17", | |
432 | "group_addr_range": GROUP_RANGE_ALL, | |
433 | } | |
434 | ] | |
435 | } | |
436 | }, | |
437 | "r3": { | |
438 | "pim": { | |
439 | "rp": [ | |
440 | { | |
441 | "rp_addr": "1.0.1.17", | |
442 | "group_addr_range": GROUP_RANGE_ALL, | |
443 | } | |
444 | ] | |
445 | } | |
446 | }, | |
447 | "r4": { | |
448 | "pim": { | |
449 | "rp": [ | |
450 | { | |
451 | "rp_addr": "1.0.1.17", | |
452 | "group_addr_range": GROUP_RANGE_ALL, | |
453 | } | |
454 | ] | |
455 | } | |
456 | }, | |
457 | } | |
458 | ||
459 | result = create_pim_config(tgen, TOPO, input_dict) | |
460 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
461 | ||
462 | shutdown_bringup_interface(tgen, "r1", "lo", False) | |
463 | sleep(5) | |
464 | shutdown_bringup_interface(tgen, "r1", "lo", True) | |
465 | sleep(5) | |
466 | ||
467 | step("r1: Verify RP info") | |
468 | dut = "r1" | |
469 | rp_address = "1.0.1.17" | |
470 | iif = "lo" | |
471 | result = verify_pim_rp_info( | |
472 | tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE | |
473 | ) | |
474 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
475 | ||
476 | step("r0: Send IGMP join") | |
477 | result = app_helper.run_join("r0", GROUP_ADDRESS, "r1") | |
478 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
479 | ||
480 | step("r1: Verify IGMP groups") | |
481 | oif = "r1-r0-eth0" | |
482 | result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS) | |
483 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
484 | ||
485 | step("r5: Send multicast traffic for group 225.1.1.1") | |
486 | result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3") | |
487 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
488 | ||
489 | step("r1: Verify (*, G) upstream IIF interface") | |
490 | result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
491 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
492 | ||
493 | step("r1: Verify (*, G) upstream join state and join timer") | |
494 | result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
495 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
496 | ||
497 | step("r1: Verify (*, G) ip mroutes") | |
498 | result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) | |
499 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
500 | ||
501 | step("r1: Verify (S, G) upstream IIF interface") | |
502 | iif = "r1-r3-eth2" | |
503 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
504 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
505 | ||
506 | step("r1: Verify (S, G) upstream join state and join timer") | |
507 | result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
508 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
509 | ||
510 | step("r1: Verify (S, G) ip mroutes") | |
511 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
512 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
513 | ||
514 | step("r3: Verify (S, G) upstream IIF interface") | |
515 | dut = "r3" | |
516 | iif = "r3-r5-eth3" | |
517 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
518 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
519 | ||
520 | step("r3: Verify (S, G) upstream join state and join timer") | |
521 | result = verify_join_state_and_timer( | |
522 | tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False | |
523 | ) | |
524 | assert result is not True, ( | |
525 | "Testcase {} : Failed \n " | |
db726bb8 KK |
526 | "Expected: [{}]: Upstream Join State should not be Joined and " |
527 | "join timer should not run\n " | |
528 | "Found: {}".format(tc_name, dut, result) | |
676fa219 DS |
529 | ) |
530 | ||
531 | step("r3: Verify (S, G) ip mroutes") | |
532 | oif = "r3-r1-eth0" | |
533 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
534 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
535 | ||
536 | # Uncomment next line for debugging | |
537 | # tgen.mininet_cli() | |
538 | ||
539 | write_test_footer(tc_name) | |
540 | ||
541 | ||
542 | def test_RP_configured_as_LHR_2_p1(request): | |
543 | """ | |
544 | TC_21_2_P1: Verify OIF and RPF for (*,G) and (S,G) when static RP configure | |
545 | in LHR router | |
546 | ||
547 | Topology used: | |
548 | ________r2_____ | |
549 | | | | |
550 | iperf | | iperf | |
551 | r0-----r1-------------r3-----r5 | |
552 | ||
553 | r1 : LHR/RP | |
554 | r3 : FHR | |
555 | ||
556 | """ | |
557 | tgen = get_topogen() | |
558 | tc_name = request.node.name | |
559 | write_test_header(tc_name) | |
560 | ||
561 | # Don"t run this test if we have any failure. | |
562 | if tgen.routers_have_failure(): | |
563 | pytest.skip(tgen.errors) | |
564 | ||
565 | step("Creating configuration from JSON") | |
566 | reset_config_on_routers(tgen) | |
567 | app_helper.stop_all_hosts() | |
568 | clear_mroute(tgen) | |
569 | clear_pim_interface_traffic(tgen, TOPO) | |
570 | ||
571 | step("Enable IGMP on r1 interface") | |
572 | step("Configure RP on r1 (loopback interface) for the group range" " 224.0.0.0/4") | |
573 | step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers") | |
574 | step("Send multicast traffic from r5") | |
575 | step("Send the IGMP join from r0") | |
576 | ||
577 | step("r1, r2, r3, r4: Delete existing RP configuration," "configure r1(LHR) as RP") | |
578 | input_dict = { | |
579 | "r1": { | |
580 | "pim": { | |
581 | "rp": [ | |
582 | { | |
583 | "rp_addr": "1.0.2.17", | |
584 | "group_addr_range": GROUP_RANGE_ALL, | |
585 | "delete": True, | |
586 | } | |
587 | ] | |
588 | } | |
589 | }, | |
590 | "r2": { | |
591 | "pim": { | |
592 | "rp": [ | |
593 | { | |
594 | "rp_addr": "1.0.2.17", | |
595 | "group_addr_range": GROUP_RANGE_ALL, | |
596 | "delete": True, | |
597 | } | |
598 | ] | |
599 | } | |
600 | }, | |
601 | "r3": { | |
602 | "pim": { | |
603 | "rp": [ | |
604 | { | |
605 | "rp_addr": "1.0.2.17", | |
606 | "group_addr_range": GROUP_RANGE_ALL, | |
607 | "delete": True, | |
608 | } | |
609 | ] | |
610 | } | |
611 | }, | |
612 | "r4": { | |
613 | "pim": { | |
614 | "rp": [ | |
615 | { | |
616 | "rp_addr": "1.0.2.17", | |
617 | "group_addr_range": GROUP_RANGE_ALL, | |
618 | "delete": True, | |
619 | } | |
620 | ] | |
621 | } | |
622 | }, | |
623 | } | |
624 | ||
625 | result = create_pim_config(tgen, TOPO, input_dict) | |
626 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
627 | ||
628 | step("r1, r2, r3, r4: Configure r1(LHR) as RP") | |
629 | input_dict = { | |
630 | "r1": { | |
631 | "pim": { | |
632 | "rp": [ | |
633 | { | |
634 | "rp_addr": "1.0.1.17", | |
635 | "group_addr_range": GROUP_RANGE_ALL, | |
636 | } | |
637 | ] | |
638 | } | |
639 | }, | |
640 | "r2": { | |
641 | "pim": { | |
642 | "rp": [ | |
643 | { | |
644 | "rp_addr": "1.0.1.17", | |
645 | "group_addr_range": GROUP_RANGE_ALL, | |
646 | } | |
647 | ] | |
648 | } | |
649 | }, | |
650 | "r3": { | |
651 | "pim": { | |
652 | "rp": [ | |
653 | { | |
654 | "rp_addr": "1.0.1.17", | |
655 | "group_addr_range": GROUP_RANGE_ALL, | |
656 | } | |
657 | ] | |
658 | } | |
659 | }, | |
660 | "r4": { | |
661 | "pim": { | |
662 | "rp": [ | |
663 | { | |
664 | "rp_addr": "1.0.1.17", | |
665 | "group_addr_range": GROUP_RANGE_ALL, | |
666 | } | |
667 | ] | |
668 | } | |
669 | }, | |
670 | } | |
671 | ||
672 | result = create_pim_config(tgen, TOPO, input_dict) | |
673 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
674 | ||
675 | step("r1: Verify RP info") | |
676 | dut = "r1" | |
677 | rp_address = "1.0.1.17" | |
678 | iif = "lo" | |
679 | result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) | |
680 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
681 | ||
682 | step("r5: Send multicast traffic for group 225.1.1.1") | |
683 | result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3") | |
684 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
685 | ||
686 | step("r0: Send IGMP join") | |
687 | result = app_helper.run_join("r0", GROUP_ADDRESS, "r1") | |
688 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
689 | ||
690 | step("r1: Verify IGMP groups") | |
691 | oif = "r1-r0-eth0" | |
692 | result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS) | |
693 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
694 | ||
695 | step("r1: Verify (*, G) upstream IIF interface") | |
696 | result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
697 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
698 | ||
699 | step("r1: Verify (*, G) upstream join state and join timer") | |
700 | result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
701 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
702 | ||
703 | step("r1: Verify (*, G) ip mroutes") | |
704 | result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) | |
705 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
706 | ||
707 | step("r1: Verify (S, G) upstream IIF interface") | |
708 | iif = "r1-r3-eth2" | |
709 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
710 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
711 | ||
712 | step("r1: Verify (S, G) upstream join state and join timer") | |
713 | result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
714 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
715 | ||
716 | step("r1: Verify (S, G) ip mroutes") | |
717 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
718 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
719 | ||
720 | step("r3: Verify (S, G) upstream IIF interface") | |
721 | dut = "r3" | |
722 | iif = "r3-r5-eth3" | |
723 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
724 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
725 | ||
726 | step("r3: Verify (S, G) upstream join state and join timer") | |
727 | result = verify_join_state_and_timer( | |
728 | tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False | |
729 | ) | |
730 | assert result is not True, ( | |
731 | "Testcase {} : Failed \n " | |
db726bb8 KK |
732 | "Expected: [{}]: Upstream Join State should not be Joined and " |
733 | "join timer should not run\n " | |
734 | "Found: {}".format(tc_name, dut, result) | |
676fa219 DS |
735 | ) |
736 | ||
737 | step("r3: Verify (S, G) ip mroutes") | |
738 | oif = "r3-r1-eth0" | |
739 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
740 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
741 | ||
742 | # Uncomment next line for debugging | |
743 | # tgen.mininet_cli() | |
744 | ||
745 | write_test_footer(tc_name) | |
746 | ||
747 | ||
748 | def test_RP_configured_as_FHR_1_p1(request): | |
749 | """ | |
750 | TC_22_1_P1: Verify OIF and RFP for (*,G) and (S,G) when static RP configure | |
751 | in FHR router | |
752 | ||
753 | Topology used: | |
754 | ________r2_____ | |
755 | | | | |
756 | iperf | | iperf | |
757 | r0-----r1-------------r3-----r5 | |
758 | ||
759 | r1 : LHR | |
760 | r3 : FHR/RP | |
761 | """ | |
762 | ||
763 | tgen = get_topogen() | |
764 | tc_name = request.node.name | |
765 | write_test_header(tc_name) | |
766 | ||
767 | # Don"t run this test if we have any failure. | |
768 | if tgen.routers_have_failure(): | |
769 | pytest.skip(tgen.errors) | |
770 | ||
771 | step("Creating configuration from JSON") | |
772 | reset_config_on_routers(tgen) | |
773 | app_helper.stop_all_hosts() | |
774 | clear_mroute(tgen) | |
775 | clear_pim_interface_traffic(tgen, TOPO) | |
776 | ||
777 | step("Enable IGMP on r1 interface") | |
778 | step("Configure RP on r2 (loopback interface) for the group range" " 225.1.1.0/24") | |
779 | step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers") | |
780 | step("Send the IGMP join from r0") | |
781 | step("Send multicast traffic from r5") | |
782 | ||
783 | step("r1, r2, r3, r4: Delete existing RP configuration" "configure r3(FHR) as RP") | |
784 | input_dict = { | |
785 | "r1": { | |
786 | "pim": { | |
787 | "rp": [ | |
788 | { | |
789 | "rp_addr": "1.0.2.17", | |
790 | "group_addr_range": GROUP_RANGE_ALL, | |
791 | "delete": True, | |
792 | } | |
793 | ] | |
794 | } | |
795 | }, | |
796 | "r2": { | |
797 | "pim": { | |
798 | "rp": [ | |
799 | { | |
800 | "rp_addr": "1.0.2.17", | |
801 | "group_addr_range": GROUP_RANGE_ALL, | |
802 | "delete": True, | |
803 | } | |
804 | ] | |
805 | } | |
806 | }, | |
807 | "r3": { | |
808 | "pim": { | |
809 | "rp": [ | |
810 | { | |
811 | "rp_addr": "1.0.2.17", | |
812 | "group_addr_range": GROUP_RANGE_ALL, | |
813 | "delete": True, | |
814 | } | |
815 | ] | |
816 | } | |
817 | }, | |
818 | "r4": { | |
819 | "pim": { | |
820 | "rp": [ | |
821 | { | |
822 | "rp_addr": "1.0.2.17", | |
823 | "group_addr_range": GROUP_RANGE_ALL, | |
824 | "delete": True, | |
825 | } | |
826 | ] | |
827 | } | |
828 | }, | |
829 | } | |
830 | result = create_pim_config(tgen, TOPO, input_dict) | |
831 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
832 | ||
833 | step("r1, r2, r3, r4: Configure r3(FHR) as RP") | |
834 | input_dict = { | |
835 | "r1": { | |
836 | "pim": { | |
837 | "rp": [ | |
838 | { | |
839 | "rp_addr": "1.0.3.17", | |
840 | "group_addr_range": GROUP_RANGE_ALL, | |
841 | } | |
842 | ] | |
843 | } | |
844 | }, | |
845 | "r2": { | |
846 | "pim": { | |
847 | "rp": [ | |
848 | { | |
849 | "rp_addr": "1.0.3.17", | |
850 | "group_addr_range": GROUP_RANGE_ALL, | |
851 | } | |
852 | ] | |
853 | } | |
854 | }, | |
855 | "r3": { | |
856 | "pim": { | |
857 | "rp": [ | |
858 | { | |
859 | "rp_addr": "1.0.3.17", | |
860 | "group_addr_range": GROUP_RANGE_ALL, | |
861 | } | |
862 | ] | |
863 | } | |
864 | }, | |
865 | "r4": { | |
866 | "pim": { | |
867 | "rp": [ | |
868 | { | |
869 | "rp_addr": "1.0.3.17", | |
870 | "group_addr_range": GROUP_RANGE_ALL, | |
871 | } | |
872 | ] | |
873 | } | |
874 | }, | |
875 | } | |
876 | ||
877 | result = create_pim_config(tgen, TOPO, input_dict) | |
878 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
879 | ||
880 | step("r1: Verify RP info") | |
881 | dut = "r1" | |
882 | rp_address = "1.0.3.17" | |
883 | iif = "r1-r3-eth2" | |
884 | result = verify_pim_rp_info( | |
885 | tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE | |
886 | ) | |
887 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
888 | ||
889 | step("r0: Send IGMP join") | |
890 | result = app_helper.run_join("r0", GROUP_ADDRESS, "r1") | |
891 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
892 | ||
893 | step("r0: Verify IGMP groups") | |
894 | oif = "r1-r0-eth0" | |
895 | result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS) | |
896 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
897 | ||
898 | step("r5: Send multicast traffic for group 225.1.1.1") | |
899 | result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3") | |
900 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
901 | ||
902 | step("r1: Verify (*, G) upstream IIF interface") | |
903 | result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
904 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
905 | ||
906 | step("r1: Verify (*, G) upstream join state and join timer") | |
907 | result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
908 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
909 | ||
910 | step("r1: Verify (*, G) ip mroutes") | |
911 | result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) | |
912 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
913 | ||
914 | step("r1: Verify (S, G) upstream IIF interface") | |
915 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
916 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
917 | ||
918 | step("r1: Verify (S, G) upstream join state and join timer") | |
919 | result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
920 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
921 | ||
922 | step("r1: Verify (S, G) ip mroutes") | |
923 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
924 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
925 | ||
926 | step("r3: Verify (S, G) upstream IIF interface") | |
927 | dut = "r3" | |
928 | iif = "r3-r5-eth3" | |
929 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
930 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
931 | ||
932 | step("r3: Verify (S, G) upstream join state and join timer") | |
933 | result = verify_join_state_and_timer( | |
934 | tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False | |
935 | ) | |
936 | assert result is not True, ( | |
937 | "Testcase {} : Failed \n " | |
db726bb8 KK |
938 | "Expected: [{}]: Upstream Join State should not be Joined and " |
939 | "join timer should not run\n " | |
940 | "Found: {}".format(tc_name, dut, result) | |
676fa219 DS |
941 | ) |
942 | ||
943 | step("r3: Verify (S, G) ip mroutes") | |
944 | oif = "r3-r1-eth0" | |
945 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
946 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
947 | ||
948 | # Uncomment next line for debugging | |
949 | # tgen.mininet_cli() | |
950 | ||
951 | write_test_footer(tc_name) | |
952 | ||
953 | ||
954 | def test_RP_configured_as_FHR_2_p2(request): | |
955 | """ | |
956 | TC_22_2_P2: Verify OIF and RFP for (*,G) and (S,G) when static RP configure | |
957 | in FHR router | |
958 | ||
959 | Topology used: | |
960 | ________r2_____ | |
961 | | | | |
962 | iperf | | iperf | |
963 | r0-----r1-------------r3-----r5 | |
964 | ||
965 | r1 : LHR | |
966 | r3 : FHR/RP | |
967 | """ | |
968 | tgen = get_topogen() | |
969 | tc_name = request.node.name | |
970 | write_test_header(tc_name) | |
971 | ||
972 | # Don"t run this test if we have any failure. | |
973 | if tgen.routers_have_failure(): | |
974 | pytest.skip(tgen.errors) | |
975 | ||
976 | step("Creating configuration from JSON") | |
977 | reset_config_on_routers(tgen) | |
978 | app_helper.stop_all_hosts() | |
979 | clear_mroute(tgen) | |
980 | clear_pim_interface_traffic(tgen, TOPO) | |
981 | ||
982 | step("Enable IGMP on r1 interface") | |
983 | step("Configure RP on r2 (loopback interface) for the group range" " 225.1.1.0/24") | |
984 | step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers") | |
985 | step("Send multicast traffic from r5") | |
986 | step("Send the IGMP join from r0") | |
987 | ||
988 | step("r1, r2, r3, r4: Delete existing RP configuration" "configure r3(FHR) as RP") | |
989 | input_dict = { | |
990 | "r1": { | |
991 | "pim": { | |
992 | "rp": [ | |
993 | { | |
994 | "rp_addr": "1.0.2.17", | |
995 | "group_addr_range": GROUP_RANGE_ALL, | |
996 | "delete": True, | |
997 | } | |
998 | ] | |
999 | } | |
1000 | }, | |
1001 | "r2": { | |
1002 | "pim": { | |
1003 | "rp": [ | |
1004 | { | |
1005 | "rp_addr": "1.0.2.17", | |
1006 | "group_addr_range": GROUP_RANGE_ALL, | |
1007 | "delete": True, | |
1008 | } | |
1009 | ] | |
1010 | } | |
1011 | }, | |
1012 | "r3": { | |
1013 | "pim": { | |
1014 | "rp": [ | |
1015 | { | |
1016 | "rp_addr": "1.0.2.17", | |
1017 | "group_addr_range": GROUP_RANGE_ALL, | |
1018 | "delete": True, | |
1019 | } | |
1020 | ] | |
1021 | } | |
1022 | }, | |
1023 | "r4": { | |
1024 | "pim": { | |
1025 | "rp": [ | |
1026 | { | |
1027 | "rp_addr": "1.0.2.17", | |
1028 | "group_addr_range": GROUP_RANGE_ALL, | |
1029 | "delete": True, | |
1030 | } | |
1031 | ] | |
1032 | } | |
1033 | }, | |
1034 | } | |
1035 | ||
1036 | result = create_pim_config(tgen, TOPO, input_dict) | |
1037 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1038 | ||
1039 | step("r1, r2, r3, r4: Configure r3(FHR) as RP") | |
1040 | input_dict = { | |
1041 | "r1": { | |
1042 | "pim": { | |
1043 | "rp": [ | |
1044 | { | |
1045 | "rp_addr": "1.0.3.17", | |
1046 | "group_addr_range": GROUP_RANGE_ALL, | |
1047 | } | |
1048 | ] | |
1049 | } | |
1050 | }, | |
1051 | "r2": { | |
1052 | "pim": { | |
1053 | "rp": [ | |
1054 | { | |
1055 | "rp_addr": "1.0.3.17", | |
1056 | "group_addr_range": GROUP_RANGE_ALL, | |
1057 | } | |
1058 | ] | |
1059 | } | |
1060 | }, | |
1061 | "r3": { | |
1062 | "pim": { | |
1063 | "rp": [ | |
1064 | { | |
1065 | "rp_addr": "1.0.3.17", | |
1066 | "group_addr_range": GROUP_RANGE_ALL, | |
1067 | } | |
1068 | ] | |
1069 | } | |
1070 | }, | |
1071 | "r4": { | |
1072 | "pim": { | |
1073 | "rp": [ | |
1074 | { | |
1075 | "rp_addr": "1.0.3.17", | |
1076 | "group_addr_range": GROUP_RANGE_ALL, | |
1077 | } | |
1078 | ] | |
1079 | } | |
1080 | }, | |
1081 | } | |
1082 | ||
1083 | result = create_pim_config(tgen, TOPO, input_dict) | |
1084 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1085 | ||
1086 | step("r1: Verify RP info") | |
1087 | dut = "r1" | |
1088 | rp_address = "1.0.3.17" | |
1089 | iif = "r1-r3-eth2" | |
1090 | result = verify_pim_rp_info( | |
1091 | tgen, TOPO, dut, GROUP_RANGE_ALL, iif, rp_address, SOURCE | |
1092 | ) | |
1093 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1094 | ||
1095 | step("r5: Send multicast traffic for group 225.1.1.1") | |
1096 | result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3") | |
1097 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1098 | ||
1099 | step("r0: Send IGMP join") | |
1100 | result = app_helper.run_join("r0", GROUP_ADDRESS, "r1") | |
1101 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1102 | ||
1103 | step("r0: Verify IGMP groups") | |
1104 | oif = "r1-r0-eth0" | |
1105 | result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS) | |
1106 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1107 | ||
1108 | step("r1: Verify (*, G) upstream IIF interface") | |
1109 | result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
1110 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1111 | ||
1112 | step("r1: Verify (*, G) upstream join state and join timer") | |
1113 | result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
1114 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1115 | ||
1116 | step("r1: Verify (*, G) ip mroutes") | |
1117 | result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) | |
1118 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1119 | ||
1120 | step("r1: Verify (S, G) upstream IIF interface") | |
1121 | iif = "r1-r3-eth2" | |
1122 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
1123 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1124 | ||
1125 | step("r1: Verify (S, G) upstream join state and join timer") | |
1126 | result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
1127 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1128 | ||
1129 | step("r1: Verify (S, G) ip mroutes") | |
1130 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
1131 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1132 | ||
1133 | step("r3: Verify (S, G) upstream IIF interface") | |
1134 | dut = "r3" | |
1135 | iif = "r3-r5-eth3" | |
1136 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
1137 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1138 | ||
1139 | step("r3: Verify (S, G) upstream join state and join timer") | |
1140 | result = verify_join_state_and_timer( | |
1141 | tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False | |
1142 | ) | |
1143 | assert result is not True, ( | |
1144 | "Testcase {} : Failed \n " | |
db726bb8 KK |
1145 | "Expected: [{}]: Upstream Join State should not be Joined and " |
1146 | "join timer should not run\n " | |
1147 | "Found: {}".format(tc_name, dut, result) | |
676fa219 DS |
1148 | ) |
1149 | ||
1150 | step("r3: Verify (S, G) ip mroutes") | |
1151 | oif = "r3-r1-eth0" | |
1152 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
1153 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1154 | ||
1155 | # Uncomment next line for debugging | |
1156 | # tgen.mininet_cli() | |
1157 | ||
1158 | write_test_footer(tc_name) | |
1159 | ||
1160 | ||
1161 | def test_SPT_RPT_path_different_p1(request): | |
1162 | """ | |
1163 | TC_23_P1: Verify (*,G) and (S,G) populated correctly when RPT and SPT path | |
1164 | are different | |
1165 | ||
1166 | Topology used: | |
1167 | ________r2_____ | |
1168 | | | | |
1169 | iperf | | iperf | |
1170 | r0-----r1-------------r3-----r5 | |
1171 | ||
1172 | r1: LHR | |
1173 | r2: RP | |
1174 | r3: FHR | |
1175 | """ | |
1176 | ||
1177 | tgen = get_topogen() | |
1178 | tc_name = request.node.name | |
1179 | write_test_header(tc_name) | |
1180 | ||
1181 | # Don"t run this test if we have any failure. | |
1182 | if tgen.routers_have_failure(): | |
1183 | pytest.skip(tgen.errors) | |
1184 | ||
1185 | step("Creating configuration from JSON") | |
1186 | reset_config_on_routers(tgen) | |
1187 | app_helper.stop_all_hosts() | |
1188 | clear_mroute(tgen) | |
1189 | clear_pim_interface_traffic(tgen, TOPO) | |
1190 | ||
1191 | step("Enable IGMP on r1 interface and send IGMP join (225.1.1.1) to r1") | |
1192 | step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4") | |
1193 | step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers") | |
1194 | step("Send multicast traffic from r3") | |
1195 | ||
1196 | step("r2: Verify RP info") | |
1197 | dut = "r2" | |
1198 | rp_address = "1.0.2.17" | |
1199 | iif = "lo" | |
1200 | result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_ADDRESS, iif, rp_address, SOURCE) | |
1201 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1202 | ||
1203 | step("r0: Send IGMP join") | |
1204 | result = app_helper.run_join("r0", GROUP_ADDRESS, "r1") | |
1205 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1206 | ||
1207 | step("r1: Verify IGMP groups") | |
1208 | dut = "r1" | |
1209 | oif = "r1-r0-eth0" | |
1210 | result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS) | |
1211 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1212 | ||
1213 | step("r5: Send multicast traffic for group 225.1.1.1") | |
1214 | result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3") | |
1215 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1216 | ||
1217 | step("r1: Verify (*, G) upstream IIF interface") | |
1218 | iif = "r1-r2-eth1" | |
1219 | result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
1220 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1221 | ||
1222 | step("r1: Verify (*, G) upstream join state and join timer") | |
1223 | result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
1224 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1225 | ||
1226 | step("r1: Verify (*, G) ip mroutes") | |
1227 | result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) | |
1228 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1229 | ||
1230 | step("r1: Verify (S, G) upstream IIF interface") | |
1231 | iif = "r1-r3-eth2" | |
1232 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
1233 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1234 | ||
1235 | step("r1: Verify (S, G) upstream join state and join timer") | |
1236 | result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
1237 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1238 | ||
1239 | step("r1: Verify (S, G) ip mroutes") | |
1240 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
1241 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1242 | ||
1243 | step("r2: Verify (*, G) upstream IIF interface") | |
1244 | dut = "r2" | |
1245 | iif = "lo" | |
1246 | result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
1247 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1248 | ||
1249 | step("r2: Verify (*, G) upstream join state and join timer") | |
1250 | result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
1251 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1252 | ||
1253 | step("r2: Verify (*, G) ip mroutes") | |
1254 | oif = "r2-r1-eth0" | |
1255 | result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) | |
1256 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1257 | ||
1258 | step("r3: Verify (S, G) upstream IIF interface") | |
1259 | dut = "r3" | |
1260 | iif = "r3-r5-eth3" | |
1261 | result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS) | |
1262 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1263 | ||
1264 | step("r3: Verify (S, G) upstream join state and join timer") | |
1265 | result = verify_join_state_and_timer( | |
1266 | tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False | |
1267 | ) | |
1268 | assert result is not True, ( | |
1269 | "Testcase {} : Failed \n " | |
db726bb8 KK |
1270 | "Expected: [{}]: Upstream Join State should not be Joined and " |
1271 | "join timer should not run\n " | |
1272 | "Found: {}".format(tc_name, dut, result) | |
676fa219 DS |
1273 | ) |
1274 | ||
1275 | step("r3: Verify (S, G) ip mroutes") | |
1276 | oif = "r3-r1-eth0" | |
1277 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
1278 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1279 | ||
1280 | step("r2: Verify (S, G) upstream IIF interface") | |
1281 | dut = "r2" | |
1282 | iif = "r2-r3-eth1" | |
1283 | result = verify_upstream_iif( | |
1284 | tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, joinState="NotJoined" | |
1285 | ) | |
1286 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1287 | ||
1288 | step("r2: Verify (S, G) upstream join state and join timer") | |
1289 | result = verify_join_state_and_timer( | |
1290 | tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS, expected=False | |
1291 | ) | |
1292 | assert result is not True, ( | |
1293 | "Testcase {} : Failed \n " | |
db726bb8 KK |
1294 | "Expected: [{}]: Upstream Join State should not be Joined and " |
1295 | "join timer should not run\n " | |
1296 | "Found: {}".format(tc_name, dut, result) | |
676fa219 DS |
1297 | ) |
1298 | ||
1299 | step("r2: Verify (S, G) ip mroutes") | |
1300 | oif = "none" | |
1301 | result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif) | |
1302 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1303 | ||
1304 | # Uncomment next line for debugging | |
1305 | # tgen.mininet_cli() | |
1306 | ||
1307 | write_test_footer(tc_name) | |
1308 | ||
1309 | ||
1310 | def test_clear_pim_configuration_p1(request): | |
1311 | """ | |
1312 | TC_25_P1: Verify (*,G) and (S,G) populated correctly after clearing the | |
1313 | PIM,IGMP and mroutes joins | |
1314 | ||
1315 | Topology used: | |
1316 | ________r2_____ | |
1317 | | | | |
1318 | iperf | | iperf | |
1319 | r0-----r1-------------r3-----r5 | |
1320 | | | | |
1321 | |_____________| | |
1322 | r4 | |
1323 | r1 : LHR | |
1324 | r2 : RP | |
1325 | r3 : FHR | |
1326 | """ | |
1327 | ||
1328 | tgen = get_topogen() | |
1329 | tc_name = request.node.name | |
1330 | write_test_header(tc_name) | |
1331 | ||
1332 | # Don"t run this test if we have any failure. | |
1333 | if tgen.routers_have_failure(): | |
1334 | pytest.skip(tgen.errors) | |
1335 | ||
1336 | step("Creating configuration from JSON") | |
1337 | reset_config_on_routers(tgen) | |
1338 | app_helper.stop_all_hosts() | |
1339 | clear_mroute(tgen) | |
1340 | clear_pim_interface_traffic(tgen, TOPO) | |
1341 | ||
1342 | step("Enable IGMP on r1 interface") | |
1343 | step("Configure RP on r2 (loopback interface) for the group range" " 224.0.0.0/4") | |
1344 | step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers") | |
1345 | step("Send the IGMP join from r0") | |
1346 | step("Send multicast traffic from r5") | |
1347 | ||
1348 | step("r2: Verify RP info") | |
1349 | dut = "r2" | |
1350 | rp_address = "1.0.2.17" | |
1351 | oif = "lo" | |
1352 | result = verify_pim_rp_info( | |
1353 | tgen, TOPO, dut, GROUP_RANGE_ALL, oif, rp_address, SOURCE | |
1354 | ) | |
1355 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1356 | ||
1357 | step("r0: Send IGMP join") | |
1358 | result = app_helper.run_join("r0", GROUP_ADDRESS, "r1") | |
1359 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1360 | ||
1361 | step("r1: Verify IGMP groups") | |
1362 | dut = "r1" | |
1363 | iif = "r1-r0-eth0" | |
1364 | result = verify_igmp_groups(tgen, dut, iif, GROUP_ADDRESS) | |
1365 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1366 | ||
1367 | step("r5: Send multicast traffic for group 225.1.1.1") | |
1368 | result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3") | |
1369 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1370 | ||
1371 | step("r1: Verify (*, G) upstream IIF interface") | |
1372 | dut = "r1" | |
1373 | iif = "r1-r2-eth1" | |
1374 | result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
1375 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1376 | ||
1377 | step("r1: Verify (*, G) upstream join state and join timer") | |
1378 | result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS) | |
1379 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1380 | ||
1381 | step("r1: Verify (*, G) ip mroutes") | |
1382 | oif = "r1-r0-eth0" | |
1383 | result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif) | |
1384 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1385 | ||
1386 | step("r1: Verify IGMP groups timer restarted") | |
1387 | result = clear_igmp_interfaces(tgen, dut) | |
1388 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1389 | ||
1390 | step("r1: Verify PIM neighbor timer restarted") | |
1391 | result = clear_pim_interfaces(tgen, dut) | |
1392 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1393 | ||
1394 | step("r1: Verify PIM mroute timer restarted") | |
1395 | result = clear_mroute_verify(tgen, dut) | |
1396 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1397 | ||
1398 | # Uncomment next line for debugging | |
1399 | # tgen.mininet_cli() | |
1400 | ||
1401 | write_test_footer(tc_name) | |
1402 | ||
1403 | ||
676fa219 DS |
1404 | if __name__ == "__main__": |
1405 | ARGS = ["-s"] + sys.argv[1:] | |
1406 | sys.exit(pytest.main(ARGS)) |