1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
|
#!/usr/bin/env python
# SPDX-License-Identifier: ISC
#
# Copyright (c) 2020 by VMware, Inc. ("VMware")
# Used Copyright (c) 2018 by Network Device Education Foundation,
# Inc. ("NetDEF") in this file.
#
"""
Following tests are covered to test multicast pim sm:
Test steps
- Create topology (setup module)
- Bring up topology
Following tests are covered:
1. TC_1_1: Verify Multicast data traffic with static RP, (*,g) and
(s,g) OIL updated correctly
2. TC_1_2: Verify Multicast data traffic with static RP, (*,g) and
(s,g) OIL updated correctly
3. TC_4: Verify removing the RP should not impact the multicast
data traffic
4. TC_5: Verify (*,G) and (S,G) entry populated again after clear the
PIM nbr and mroute from FRR node
5. TC_9: Verify (s,g) timeout from FHR and RP when same receive
exist in LHR , FHR and RP
6. TC_19: Verify mroute detail when same receiver joining 5
different sources
7. TC_16: Verify (*,G) and (S,G) populated correctly
when FRR is the transit router
8. TC_23: Verify (S,G) should not create if RP is not reachable
9. TC_24: Verify modification of IGMP query timer should get update
accordingly
10. TC_25: Verify modification of IGMP max query response timer
should get update accordingly
"""
import os
import sys
import time
from time import sleep
import pytest
pytestmark = [pytest.mark.pimd]
# Save the Current Working Directory to find configuration files.
CWD = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(CWD, "../"))
sys.path.append(os.path.join(CWD, "../lib/"))
# Required to instantiate the topology builder class.
# pylint: disable=C0413
# Import topogen and topotest helpers
from lib.topogen import Topogen, get_topogen
from lib.common_config import (
start_topology,
write_test_header,
write_test_footer,
step,
apply_raw_config,
reset_config_on_routers,
shutdown_bringup_interface,
required_linux_kernel_version,
)
from lib.pim import (
create_pim_config,
create_igmp_config,
verify_igmp_groups,
verify_mroutes,
get_pim_interface_traffic,
verify_upstream_iif,
verify_pim_join,
clear_mroute,
clear_pim_interface_traffic,
verify_igmp_config,
McastTesterHelper,
)
from lib.topolog import logger
from lib.topojson import build_config_from_json
TOPOLOGY = """
i4-----c1-------------c2---i5
| |
| |
i1-----l1------r2-----f1---i2
| | | |
| | | |
i7 i6 i3 i8
Description:
i1, i2, i3. i4, i5, i6, i7, i8 - FRR running iperf to send IGMP
join and traffic
l1 - LHR (last hop router)
f1 - FHR (first hop router)
r2 - FRR router
c1 - FRR router
c2 - FRR router
"""
# Global variables
GROUP_RANGE = "225.0.0.0/8"
IGMP_JOIN = "225.1.1.1"
GROUP_RANGE_1 = [
"225.1.1.1/32",
"225.1.1.2/32",
"225.1.1.3/32",
"225.1.1.4/32",
"225.1.1.5/32",
]
IGMP_JOIN_RANGE_1 = ["225.1.1.1", "225.1.1.2", "225.1.1.3", "225.1.1.4", "225.1.1.5"]
GROUP_RANGE_2 = [
"226.1.1.1/32",
"226.1.1.2/32",
"226.1.1.3/32",
"226.1.1.4/32",
"226.1.1.5/32",
]
IGMP_JOIN_RANGE_2 = ["226.1.1.1", "226.1.1.2", "226.1.1.3", "226.1.1.4", "226.1.1.5"]
GROUP_RANGE_3 = [
"227.1.1.1/32",
"227.1.1.2/32",
"227.1.1.3/32",
"227.1.1.4/32",
"227.1.1.5/32",
]
IGMP_JOIN_RANGE_3 = ["227.1.1.1", "227.1.1.2", "227.1.1.3", "227.1.1.4", "227.1.1.5"]
def setup_module(mod):
"""
Sets up the pytest environment
* `mod`: module name
"""
# Required linux kernel version for this suite to run.
result = required_linux_kernel_version("4.19")
if result is not True:
pytest.skip("Kernel version should be >= 4.19")
testsuite_run_time = time.asctime(time.localtime(time.time()))
logger.info("Testsuite start time: {}".format(testsuite_run_time))
logger.info("=" * 40)
logger.info("Master Topology: \n {}".format(TOPOLOGY))
logger.info("Running setup_module to create topology")
testdir = os.path.dirname(os.path.realpath(__file__))
json_file = "{}/multicast_pim_sm_topo1.json".format(testdir)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers
# to start daemons and then start routers
start_topology(tgen)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
build_config_from_json(tgen, tgen.json_topo)
# XXX Replace this using "with McastTesterHelper()... " in each test if possible.
global app_helper
app_helper = McastTesterHelper(tgen)
logger.info("Running setup_module() done")
def teardown_module():
"""Teardown the pytest environment"""
logger.info("Running teardown_module to delete topology")
tgen = get_topogen()
app_helper.cleanup()
# Stop toplogy and Remove tmp files
tgen.stop_topology()
logger.info(
"Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
)
logger.info("=" * 40)
#####################################################
#
# Testcases
#
#####################################################
def verify_state_incremented(state_before, state_after):
"""
API to compare interface traffic state incrementing
Parameters
----------
* `state_before` : State dictionary for any particular instance
* `state_after` : State dictionary for any particular instance
"""
for router, state_data in state_before.items():
for state, _ in state_data.items():
if state_before[router][state] >= state_after[router][state]:
errormsg = (
"[DUT: %s]: state %s value has not"
" incremented, Initial value: %s, "
"Current value: %s [FAILED!!]"
% (
router,
state,
state_before[router][state],
state_after[router][state],
)
)
return errormsg
logger.info(
"[DUT: %s]: State %s value is "
"incremented, Initial value: %s, Current value: %s"
" [PASSED!!]",
router,
state,
state_before[router][state],
state_after[router][state],
)
return True
def test_multicast_data_traffic_static_RP_send_join_then_traffic_p0(request):
"""
TC_1_1: Verify Multicast data traffic with static RP, (*,g) and
(s,g) OIL updated correctly
"""
tgen = get_topogen()
topo = tgen.json_topo
tc_name = request.node.name
write_test_header(tc_name)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
step("Enable IGMP on FRR1 interface and send IGMP join (225.1.1.1)")
step("get joinRx value before join")
intf_r2_l1 = topo["routers"]["r2"]["links"]["l1"]["interface"]
state_dict = {"r2": {intf_r2_l1: ["joinRx"]}}
state_before = get_pim_interface_traffic(tgen, state_dict)
assert isinstance(
state_before, dict
), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format(
tc_name, state_before
)
result = app_helper.run_join("i1", IGMP_JOIN, "l1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Send the IGMP join first and then start the traffic")
step("Configure RP on R2 (loopback interface) for the" " group range 225.0.0.0/8")
input_dict = {
"r2": {
"pim": {
"rp": [
{
"rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
"/"
)[0],
"group_addr_range": GROUP_RANGE,
}
]
}
}
}
result = create_pim_config(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Send multicast traffic from FRR3 to 225.1.1.1 receiver")
result = app_helper.run_traffic("i2", IGMP_JOIN, "f1")
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Verify 'show ip mroute' showing correct RPF and OIF"
" interface for (*,G) and (S,G) entries on all the nodes"
)
source = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["interface"]
intf_l1_i1 = topo["routers"]["l1"]["links"]["i1"]["interface"]
intf_r2_l1 = topo["routers"]["r2"]["links"]["l1"]["interface"]
intf_r2_f1 = topo["routers"]["r2"]["links"]["f1"]["interface"]
intf_f1_i2 = topo["routers"]["f1"]["links"]["i2"]["interface"]
intf_f1_r2 = topo["routers"]["f1"]["links"]["r2"]["interface"]
input_dict = [
{"dut": "l1", "src_address": "*", "iif": intf_l1_r2, "oil": intf_l1_i1},
{"dut": "l1", "src_address": source, "iif": intf_l1_r2, "oil": intf_l1_i1},
{"dut": "r2", "src_address": "*", "iif": "lo", "oil": intf_r2_l1},
{"dut": "r2", "src_address": source, "iif": intf_r2_f1, "oil": intf_r2_l1},
{"dut": "f1", "src_address": source, "iif": intf_f1_i2, "oil": intf_f1_r2},
]
for data in input_dict:
result = verify_mroutes(
tgen, data["dut"], data["src_address"], IGMP_JOIN, data["iif"], data["oil"]
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Verify 'show ip pim upstream' showing correct OIL and IIF" " on all the nodes"
)
for data in input_dict:
result = verify_upstream_iif(
tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("joinRx value after join sent")
state_after = get_pim_interface_traffic(tgen, state_dict)
assert isinstance(
state_after, dict
), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format(
tc_name, result
)
step(
"l1 sent PIM (*,G) join to r2 verify using"
"'show ip pim interface traffic' on RP connected interface"
)
result = verify_state_incremented(state_before, state_after)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("l1 sent PIM (S,G) join to f1 , verify using 'show ip pim join'")
dut = "f1"
interface = intf_f1_r2
result = verify_pim_join(tgen, topo, dut, interface, IGMP_JOIN)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
write_test_footer(tc_name)
def test_multicast_data_traffic_static_RP_send_traffic_then_join_p0(request):
"""
TC_1_2: Verify Multicast data traffic with static RP, (*,g) and
(s,g) OIL updated correctly
"""
tgen = get_topogen()
topo = tgen.json_topo
tc_name = request.node.name
write_test_header(tc_name)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
app_helper.stop_all_hosts()
clear_mroute(tgen)
reset_config_on_routers(tgen)
clear_pim_interface_traffic(tgen, topo)
step("Configure RP on R2 (loopback interface) for the" " group range 225.0.0.0/8")
input_dict = {
"r2": {
"pim": {
"rp": [
{
"rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
"/"
)[0],
"group_addr_range": GROUP_RANGE,
}
]
}
}
}
result = create_pim_config(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Start traffic first and then send the IGMP join")
step("Send multicast traffic from FRR3 to 225.1.1.1 receiver")
result = app_helper.run_traffic("i2", IGMP_JOIN, "f1")
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Enable IGMP on FRR1 interface and send IGMP join (225.1.1.1)")
step("joinRx value before join sent")
state_dict = {"r2": {"r2-l1-eth2": ["joinRx"]}}
state_before = get_pim_interface_traffic(tgen, state_dict)
assert isinstance(
state_before, dict
), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format(
tc_name, result
)
result = app_helper.run_join("i1", IGMP_JOIN, "l1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step(
"Verify 'show ip mroute' showing correct RPF and OIF"
" interface for (*,G) and (S,G) entries on all the nodes"
)
source = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
input_dict = [
{"dut": "l1", "src_address": "*", "iif": "l1-r2-eth4", "oil": "l1-i1-eth1"},
{"dut": "l1", "src_address": source, "iif": "l1-r2-eth4", "oil": "l1-i1-eth1"},
{"dut": "r2", "src_address": "*", "iif": "lo", "oil": "r2-l1-eth2"},
{"dut": "r2", "src_address": source, "iif": "r2-f1-eth0", "oil": "r2-l1-eth2"},
{"dut": "f1", "src_address": source, "iif": "f1-i2-eth1", "oil": "f1-r2-eth3"},
]
# On timeout change from default of 80 to 120: failures logs indicate times 90+
# seconds for success on the 2nd entry in the above table. Using 100s here restores
# previous 80 retries with 2s wait if we assume .5s per vtysh/show ip mroute runtime
# (41 * (2 + .5)) == 102.
for data in input_dict:
result = verify_mroutes(
tgen,
data["dut"],
data["src_address"],
IGMP_JOIN,
data["iif"],
data["oil"],
retry_timeout=102,
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Verify 'show ip pim upstream' showing correct OIL and IIF" " on all the nodes"
)
for data in input_dict:
result = verify_upstream_iif(
tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("joinRx value after join sent")
state_after = get_pim_interface_traffic(tgen, state_dict)
assert isinstance(
state_after, dict
), "Testcase {} : Failed \n state_before is not dictionary \n Error: {}".format(
tc_name, result
)
step(
"l1 sent PIM (*,G) join to r2 verify using"
"'show ip pim interface traffic' on RP connected interface"
)
result = verify_state_incremented(state_before, state_after)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("l1 sent PIM (S,G) join to f1 , verify using 'show ip pim join'")
dut = "f1"
interface = "f1-r2-eth3"
result = verify_pim_join(tgen, topo, dut, interface, IGMP_JOIN)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
write_test_footer(tc_name)
def test_clear_pim_neighbors_and_mroute_p0(request):
"""
TC_5: Verify (*,G) and (S,G) entry populated again after clear the
PIM nbr and mroute from FRR node
"""
tgen = get_topogen()
topo = tgen.json_topo
tc_name = request.node.name
write_test_header(tc_name)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
app_helper.stop_all_hosts()
clear_mroute(tgen)
reset_config_on_routers(tgen)
clear_pim_interface_traffic(tgen, topo)
step("Configure static RP on c1 for group (225.1.1.1-5)")
input_dict = {
"c1": {
"pim": {
"rp": [
{
"rp_addr": topo["routers"]["c1"]["links"]["lo"]["ipv4"].split(
"/"
)[0],
"group_addr_range": GROUP_RANGE_1,
}
]
}
}
}
result = create_pim_config(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Enable IGMP on FRR1 interface and send IGMP join 225.1.1.1 "
"to 225.1.1.5 from different interfaces"
)
result = app_helper.run_join("i1", IGMP_JOIN_RANGE_1, "l1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Send multicast traffic from FRR3, wait for SPT switchover")
result = app_helper.run_traffic("i2", IGMP_JOIN_RANGE_1, "f1")
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Verify clear ip mroute (*,g) entries are populated by using "
"'show ip mroute' cli"
)
input_dict = [
{"dut": "l1", "src_address": "*", "iif": "l1-c1-eth0", "oil": "l1-i1-eth1"}
]
for data in input_dict:
result = verify_mroutes(
tgen, data["dut"], data["src_address"], IGMP_JOIN, data["iif"], data["oil"]
)
assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result)
step("Clear mroutes on l1")
clear_mroute(tgen, "l1")
step(
"After clear ip mroute (*,g) entries are re-populated again"
" with same OIL and IIF, verify using 'show ip mroute' and "
" 'show ip pim upstream' "
)
for data in input_dict:
result = verify_mroutes(
tgen, data["dut"], data["src_address"], IGMP_JOIN, data["iif"], data["oil"]
)
assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result)
step(
"Verify 'show ip pim upstream' showing correct OIL and IIF" " on all the nodes"
)
for data in input_dict:
result = verify_upstream_iif(
tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN
)
assert result is True, "Testcase{} : Failed Error: {}".format(tc_name, result)
write_test_footer(tc_name)
def test_verify_mroute_when_same_receiver_in_FHR_LHR_and_RP_p0(request):
"""
TC_9: Verify (s,g) timeout from FHR and RP when same receive
exist in LHR , FHR and RP
"""
tgen = get_topogen()
topo = tgen.json_topo
tc_name = request.node.name
write_test_header(tc_name)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
app_helper.stop_all_hosts()
clear_mroute(tgen)
reset_config_on_routers(tgen)
clear_pim_interface_traffic(tgen, topo)
step("Configure RP on R2 (loopback interface) for the" " group range 225.0.0.0/8")
input_dict = {
"r2": {
"pim": {
"rp": [
{
"rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
"/"
)[0],
"group_addr_range": GROUP_RANGE,
}
]
}
}
}
result = create_pim_config(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1) to R1")
input_dict = {
"f1": {
"igmp": {
"interfaces": {
"f1-i8-eth2": {
"igmp": {"version": "2", "query": {"query-interval": 15}}
}
}
}
},
"r2": {
"igmp": {
"interfaces": {
"r2-i3-eth1": {
"igmp": {"version": "2", "query": {"query-interval": 15}}
}
}
}
},
}
result = create_igmp_config(tgen, topo, input_dict)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
input_join = {"i1": "i1-l1-eth0", "i8": "i8-f1-eth0", "i3": "i3-r2-eth0"}
for recvr, recvr_intf in input_join.items():
result = app_helper.run_join(recvr, IGMP_JOIN, join_intf=recvr_intf)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Send multicast traffic from R3 to 225.1.1.1 receiver")
result = app_helper.run_traffic("i2", IGMP_JOIN, "f1")
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("IGMP is received on FRR1 , FRR2 , FRR3, using " "'show ip igmp groups'")
igmp_groups = {"l1": "l1-i1-eth1", "r2": "r2-i3-eth1", "f1": "f1-i8-eth2"}
for dut, interface in igmp_groups.items():
result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN, retry_timeout=80)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("(*,G) present on all the node with correct OIL" " using 'show ip mroute'")
source = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
input_dict = [
{"dut": "l1", "src_address": "*", "iif": "l1-r2-eth4", "oil": "l1-i1-eth1"},
{"dut": "l1", "src_address": source, "iif": "l1-r2-eth4", "oil": "l1-i1-eth1"},
{"dut": "r2", "src_address": "*", "iif": "lo", "oil": "r2-i3-eth1"},
{"dut": "r2", "src_address": source, "iif": "r2-f1-eth0", "oil": "r2-i3-eth1"},
{"dut": "f1", "src_address": "*", "iif": "f1-r2-eth3", "oil": "f1-i8-eth2"},
{"dut": "f1", "src_address": source, "iif": "f1-i2-eth1", "oil": "f1-i8-eth2"},
]
for data in input_dict:
result = verify_mroutes(
tgen, data["dut"], data["src_address"], IGMP_JOIN, data["iif"], data["oil"]
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
write_test_footer(tc_name)
def test_verify_mroute_when_same_receiver_joining_5_diff_sources_p0(request):
"""
TC_19: Verify mroute detail when same receiver joining 5
different sources
"""
tgen = get_topogen()
topo = tgen.json_topo
tc_name = request.node.name
write_test_header(tc_name)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
app_helper.stop_all_hosts()
clear_mroute(tgen)
reset_config_on_routers(tgen)
clear_pim_interface_traffic(tgen, topo)
step("Configure static RP for (226.1.1.1-5) and (232.1.1.1-5)" " in c1")
_GROUP_RANGE = GROUP_RANGE_2 + GROUP_RANGE_3
_IGMP_JOIN_RANGE = IGMP_JOIN_RANGE_2 + IGMP_JOIN_RANGE_3
input_dict = {
"c1": {
"pim": {
"rp": [
{
"rp_addr": topo["routers"]["c1"]["links"]["lo"]["ipv4"].split(
"/"
)[0],
"group_addr_range": _GROUP_RANGE,
}
]
}
}
}
result = create_pim_config(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Configure IGMP interface on FRR1 and FRR3 and send IGMP join"
"for group (226.1.1.1-5, 232.1.1.1-5)"
)
result = app_helper.run_join("i1", _IGMP_JOIN_RANGE, "l1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
input_dict = {
"f1": {
"igmp": {
"interfaces": {
"f1-i8-eth2": {
"igmp": {"version": "2", "query": {"query-interval": 15}}
}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = app_helper.run_join("i8", _IGMP_JOIN_RANGE, "f1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step(
"Send multicast traffic from all the sources to all the "
"receivers (226.1.1.1-5, 232.1.1.1-5)"
)
input_traffic = {
"i6": "i6-l1-eth0",
"i7": "i7-l1-eth0",
"i3": "i3-r2-eth0",
"i4": "i4-c1-eth0",
"i5": "i5-c2-eth0",
}
for src, src_intf in input_traffic.items():
result = app_helper.run_traffic(src, _IGMP_JOIN_RANGE, bind_intf=src_intf)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Verify (*,G) are created on FRR1 and FRR3 node " " 'show ip mroute' ")
source_i7 = topo["routers"]["i7"]["links"]["l1"]["ipv4"].split("/")[0]
source_i6 = topo["routers"]["i6"]["links"]["l1"]["ipv4"].split("/")[0]
source_i5 = topo["routers"]["i5"]["links"]["c2"]["ipv4"].split("/")[0]
source_i3 = topo["routers"]["i3"]["links"]["r2"]["ipv4"].split("/")[0]
input_dict = [
{"dut": "l1", "src_address": "*", "iif": "l1-c1-eth0", "oil": "l1-i1-eth1"},
{
"dut": "l1",
"src_address": source_i5,
"iif": "l1-c1-eth0",
"oil": "l1-i1-eth1",
},
{
"dut": "l1",
"src_address": source_i3,
"iif": "l1-r2-eth4",
"oil": "l1-i1-eth1",
},
{
"dut": "l1",
"src_address": source_i6,
"iif": "l1-i6-eth2",
"oil": "l1-i1-eth1",
},
{
"dut": "l1",
"src_address": source_i7,
"iif": "l1-i7-eth3",
"oil": "l1-i1-eth1",
},
{"dut": "f1", "src_address": "*", "iif": "f1-c2-eth0", "oil": "f1-i8-eth2"},
{
"dut": "f1",
"src_address": source_i5,
"iif": "f1-c2-eth0",
"oil": "f1-i8-eth2",
},
{
"dut": "f1",
"src_address": source_i3,
"iif": "f1-r2-eth3",
"oil": "f1-i8-eth2",
},
{
"dut": "f1",
"src_address": source_i6,
"iif": "f1-r2-eth3",
"oil": "f1-i8-eth2",
},
{
"dut": "f1",
"src_address": source_i7,
"iif": "f1-r2-eth3",
"oil": "f1-i8-eth2",
},
]
for data in input_dict:
result = verify_mroutes(
tgen,
data["dut"],
data["src_address"],
IGMP_JOIN_RANGE_2,
data["iif"],
data["oil"],
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Stop the source one by one on FRR1")
input_intf = {"i6": "i6-l1-eth0", "i7": "i7-l1-eth0"}
for dut, intf in input_intf.items():
shutdown_bringup_interface(tgen, dut, intf, False)
step(
"After removing the source verify traffic is stopped"
" immediately and (S,G) got timeout in sometime"
)
logger.info("After shut, waiting for SG timeout")
input_dict = [
{
"dut": "l1",
"src_address": source_i6,
"iif": "l1-i6-eth2",
"oil": "l1-i1-eth1",
},
{
"dut": "l1",
"src_address": source_i7,
"iif": "l1-i7-eth3",
"oil": "l1-i1-eth1",
},
]
for data in input_dict:
result = verify_mroutes(
tgen,
data["dut"],
data["src_address"],
IGMP_JOIN_RANGE_2,
data["iif"],
data["oil"],
expected=False,
)
assert result is not True, (
"Testcase {} : Failed \n "
"Expected: [{}]: mroute (S, G) should not be present in mroute table \n "
"Found: {}".format(tc_name, data["dut"], result)
)
step(
"Source which is stopped got removed , other source"
" after still present verify using 'show ip mroute' "
)
input_dict = [
{"dut": "l1", "src_address": "*", "iif": "l1-c1-eth0", "oil": "l1-i1-eth1"},
{
"dut": "l1",
"src_address": source_i5,
"iif": "l1-c1-eth0",
"oil": "l1-i1-eth1",
},
{
"dut": "l1",
"src_address": source_i3,
"iif": "l1-r2-eth4",
"oil": "l1-i1-eth1",
},
{"dut": "f1", "src_address": "*", "iif": "f1-c2-eth0", "oil": "f1-i8-eth2"},
{
"dut": "f1",
"src_address": source_i5,
"iif": "f1-c2-eth0",
"oil": "f1-i8-eth2",
},
{
"dut": "f1",
"src_address": source_i3,
"iif": "f1-r2-eth3",
"oil": "f1-i8-eth2",
},
]
for data in input_dict:
result = verify_mroutes(
tgen,
data["dut"],
data["src_address"],
IGMP_JOIN_RANGE_2,
data["iif"],
data["oil"],
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Start all the source again for all the receivers")
input_intf = {"i6": "i6-l1-eth0", "i7": "i7-l1-eth0"}
for dut, intf in input_intf.items():
shutdown_bringup_interface(tgen, dut, intf, True)
step(
"After starting source all the mroute entries got populated, "
"no duplicate entries present in mroute verify 'show ip mroute'"
)
input_dict = [
{"dut": "l1", "src_address": "*", "iif": "l1-c1-eth0", "oil": "l1-i1-eth1"},
{
"dut": "l1",
"src_address": source_i5,
"iif": "l1-c1-eth0",
"oil": "l1-i1-eth1",
},
{
"dut": "l1",
"src_address": source_i3,
"iif": "l1-r2-eth4",
"oil": "l1-i1-eth1",
},
{
"dut": "l1",
"src_address": source_i6,
"iif": "l1-i6-eth2",
"oil": "l1-i1-eth1",
},
{
"dut": "l1",
"src_address": source_i7,
"iif": "l1-i7-eth3",
"oil": "l1-i1-eth1",
},
{"dut": "f1", "src_address": "*", "iif": "f1-c2-eth0", "oil": "f1-i8-eth2"},
{
"dut": "f1",
"src_address": source_i5,
"iif": "f1-c2-eth0",
"oil": "f1-i8-eth2",
},
{
"dut": "f1",
"src_address": source_i3,
"iif": "f1-r2-eth3",
"oil": "f1-i8-eth2",
},
{
"dut": "f1",
"src_address": source_i6,
"iif": "f1-r2-eth3",
"oil": "f1-i8-eth2",
},
{
"dut": "f1",
"src_address": source_i7,
"iif": "f1-r2-eth3",
"oil": "f1-i8-eth2",
},
]
for data in input_dict:
result = verify_mroutes(
tgen,
data["dut"],
data["src_address"],
IGMP_JOIN_RANGE_2,
data["iif"],
data["oil"],
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
write_test_footer(tc_name)
def test_verify_mroute_when_frr_is_transit_router_p2(request):
"""
TC_16: Verify (*,G) and (S,G) populated correctly
when FRR is the transit router
"""
tgen = get_topogen()
topo = tgen.json_topo
tc_name = request.node.name
write_test_header(tc_name)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
app_helper.stop_all_hosts()
clear_mroute(tgen)
reset_config_on_routers(tgen)
clear_pim_interface_traffic(tgen, topo)
step("Configure static RP for (226.1.1.1-5) in c2")
input_dict = {
"c2": {
"pim": {
"rp": [
{
"rp_addr": topo["routers"]["c2"]["links"]["lo"]["ipv4"].split(
"/"
)[0],
"group_addr_range": GROUP_RANGE_1,
}
]
}
}
}
result = create_pim_config(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Enable IGMP on FRR1 interface and send IGMP join " "(225.1.1.1-5) to FRR1")
result = app_helper.run_join("i1", IGMP_JOIN_RANGE_1, "l1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Send multicast traffic from FRR3 to 225.1.1.1-5 receivers")
result = app_helper.run_traffic("i2", IGMP_JOIN_RANGE_1, "f1")
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
# Stop r2 router to make r2 router disabled from topology
input_intf = {"l1": "l1-r2-eth4", "f1": "f1-r2-eth3"}
for dut, intf in input_intf.items():
shutdown_bringup_interface(tgen, dut, intf, False)
step(
"FRR4 has (S,G) and (*,G) ,created where incoming interface"
" toward FRR3 and OIL toward R2, verify using 'show ip mroute'"
" 'show ip pim state' "
)
source = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
input_dict = [
{"dut": "c2", "src_address": "*", "iif": "lo", "oil": "c2-c1-eth0"},
{"dut": "c2", "src_address": source, "iif": "c2-f1-eth1", "oil": "c2-c1-eth0"},
]
for data in input_dict:
result = verify_mroutes(
tgen, data["dut"], data["src_address"], IGMP_JOIN, data["iif"], data["oil"]
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Stop multicast traffic from FRR3")
dut = "i2"
intf = "i2-f1-eth0"
shutdown_bringup_interface(tgen, dut, intf, False)
logger.info("Waiting for 20 sec to get traffic to be stopped..")
sleep(20)
step("top IGMP receiver from FRR1")
dut = "i1"
intf = "i1-l1-eth0"
shutdown_bringup_interface(tgen, dut, intf, False)
logger.info("Waiting for 20 sec to get mroutes to be flused out..")
sleep(20)
step(
"After stopping receiver (*,G) also got timeout from transit"
" router 'show ip mroute'"
)
result = verify_mroutes(
tgen, "c1", "*", IGMP_JOIN, "c1-c2-eth1", "c1-l1-eth0", expected=False
)
assert result is not True, (
"Testcase {} : Failed \n "
"Expected: [{}]: mroute (*, G) should not be present in mroute table \n "
"Found: {}".format(tc_name, "c1", result)
)
write_test_footer(tc_name)
def test_verify_mroute_when_RP_unreachable_p1(request):
"""
TC_23: Verify (S,G) should not create if RP is not reachable
"""
tgen = get_topogen()
topo = tgen.json_topo
tc_name = request.node.name
write_test_header(tc_name)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
app_helper.stop_all_hosts()
clear_mroute(tgen)
reset_config_on_routers(tgen)
clear_pim_interface_traffic(tgen, topo)
step("Configure RP on FRR2 (loopback interface) for " "the group range 225.0.0.0/8")
input_dict = {
"r2": {
"pim": {
"rp": [
{
"rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
"/"
)[0],
"group_addr_range": GROUP_RANGE,
}
]
}
}
}
result = create_pim_config(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Enable IGMP on FRR1 interface and send IGMP join (225.1.1.1)")
result = app_helper.run_join("i1", IGMP_JOIN, "l1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Send multicast traffic from FRR3 to 225.1.1.1 receiver")
result = app_helper.run_traffic("i2", IGMP_JOIN, "f1")
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Configure one IGMP interface on FRR3 node and send IGMP" " join (225.1.1.1)")
input_dict = {
"f1": {
"igmp": {
"interfaces": {
"f1-i8-eth2": {
"igmp": {"version": "2", "query": {"query-interval": 15}}
}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = app_helper.run_join("i8", IGMP_JOIN, "f1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
# Verify mroutes are present in FRR3(f1)
source = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
input_dict = [
{"dut": "f1", "src_address": "*", "iif": "f1-r2-eth3", "oil": "f1-i8-eth2"},
{"dut": "f1", "src_address": source, "iif": "f1-i2-eth1", "oil": "f1-i8-eth2"},
]
for data in input_dict:
result = verify_mroutes(
tgen, data["dut"], data["src_address"], IGMP_JOIN, data["iif"], data["oil"]
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Shut the RP connected interface from f1 ( r2 to f1) link")
dut = "f1"
intf = "f1-r2-eth3"
shutdown_bringup_interface(tgen, dut, intf, False)
logger.info("Waiting for 20 sec to get mroutes to be flushed out..")
sleep(20)
step("Clear the mroute on f1")
clear_mroute(tgen, "f1")
step(
"After Shut the RP interface and clear the mroute verify all "
"(*,G) and (S,G) got timeout from FRR3 node , verify using "
" 'show ip mroute' "
)
result = verify_mroutes(
tgen, "f1", "*", IGMP_JOIN, "f1-r2-eth3", "f1-i8-eth2", expected=False
)
assert result is not True, (
"Testcase {} : Failed \n "
"Expected: [{}]: mroute (*, G) should not be present in mroute table \n "
"Found: {}".format(tc_name, "f1", result)
)
step("IGMP groups are present verify using 'show ip igmp group'")
dut = "l1"
interface = "l1-i1-eth1"
result = verify_igmp_groups(tgen, dut, interface, IGMP_JOIN)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
write_test_footer(tc_name)
def test_modify_igmp_query_timer_p0(request):
"""
TC_24:
Verify modification of IGMP query timer should get update
accordingly
"""
tgen = get_topogen()
topo = tgen.json_topo
tc_name = request.node.name
write_test_header(tc_name)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
app_helper.stop_all_hosts()
clear_mroute(tgen)
reset_config_on_routers(tgen)
clear_pim_interface_traffic(tgen, topo)
step("Enable IGMP on FRR1 interface and send IGMP join (225.1.1.1)")
result = app_helper.run_join("i1", IGMP_JOIN, "l1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Configure RP on R2 (loopback interface) for the" " group range 225.0.0.0/8")
input_dict = {
"r2": {
"pim": {
"rp": [
{
"rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
"/"
)[0],
"group_addr_range": GROUP_RANGE,
}
]
}
}
}
result = create_pim_config(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Send multicast traffic from FRR3 to 225.1.1.1 receiver")
result = app_helper.run_traffic("i2", IGMP_JOIN, "f1")
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Verify 'show ip mroute' showing correct RPF and OIF"
" interface for (*,G) and (S,G) entries on all the nodes"
)
source = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
input_dict_4 = [
{"dut": "l1", "src_address": "*", "iif": "l1-r2-eth4", "oil": "l1-i1-eth1"},
{"dut": "l1", "src_address": source, "iif": "l1-r2-eth4", "oil": "l1-i1-eth1"},
{"dut": "f1", "src_address": source, "iif": "f1-i2-eth1", "oil": "f1-r2-eth3"},
]
for data in input_dict_4:
result = verify_mroutes(
tgen, data["dut"], data["src_address"], IGMP_JOIN, data["iif"], data["oil"]
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Verify 'show ip pim upstream' showing correct OIL and IIF" " on all the nodes"
)
for data in input_dict_4:
result = verify_upstream_iif(
tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Modify IGMP query interval default to other timer on FRR1" "3 times")
input_dict_1 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {"igmp": {"query": {"query-interval": 20}}}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_1)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = verify_igmp_config(tgen, input_dict_1)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
input_dict_2 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {"igmp": {"query": {"query-interval": 25}}}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_2)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = verify_igmp_config(tgen, input_dict_2)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
input_dict_3 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {"igmp": {"query": {"query-interval": 30}}}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = verify_igmp_config(tgen, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Verify that no core is observed")
if tgen.routers_have_failure():
assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
write_test_footer(tc_name)
def test_modify_igmp_max_query_response_timer_p0(request):
"""
TC_25:
Verify modification of IGMP max query response timer
should get update accordingly
"""
tgen = get_topogen()
topo = tgen.json_topo
tc_name = request.node.name
write_test_header(tc_name)
# Don"t run this test if we have any failure.
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
# Creating configuration from JSON
app_helper.stop_all_hosts()
clear_mroute(tgen)
reset_config_on_routers(tgen)
clear_pim_interface_traffic(tgen, topo)
step("Enable IGMP on FRR1 interface and send IGMP join (225.1.1.1)")
result = app_helper.run_join("i1", IGMP_JOIN, "l1")
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Configure IGMP query response time to 10 deci-sec on FRR1")
input_dict_1 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {
"igmp": {
"version": "2",
"query": {"query-max-response-time": 10},
}
}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_1)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = verify_igmp_config(tgen, input_dict_1)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Configure RP on R2 (loopback interface) for the" " group range 225.0.0.0/8")
input_dict = {
"r2": {
"pim": {
"rp": [
{
"rp_addr": topo["routers"]["r2"]["links"]["lo"]["ipv4"].split(
"/"
)[0],
"group_addr_range": GROUP_RANGE,
}
]
}
}
}
result = create_pim_config(tgen, topo, input_dict)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Send multicast traffic from FRR3 to 225.1.1.1 receiver")
result = app_helper.run_traffic("i2", IGMP_JOIN, "f1")
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Verify 'show ip mroute' showing correct RPF and OIF"
" interface for (*,G) and (S,G) entries on all the nodes"
)
source = topo["routers"]["i2"]["links"]["f1"]["ipv4"].split("/")[0]
input_dict_5 = [
{"dut": "l1", "src_address": "*", "iif": "l1-r2-eth4", "oil": "l1-i1-eth1"},
{"dut": "l1", "src_address": source, "iif": "l1-r2-eth4", "oil": "l1-i1-eth1"},
{"dut": "f1", "src_address": source, "iif": "f1-i2-eth1", "oil": "f1-r2-eth3"},
]
for data in input_dict_5:
result = verify_mroutes(
tgen, data["dut"], data["src_address"], IGMP_JOIN, data["iif"], data["oil"]
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step(
"Verify 'show ip pim upstream' showing correct OIL and IIF" " on all the nodes"
)
for data in input_dict_5:
result = verify_upstream_iif(
tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN
)
assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
step("Delete the PIM and IGMP on FRR1")
raw_config = {"l1": {"raw_config": ["interface l1-i1-eth1", "no ip pim"]}}
result = apply_raw_config(tgen, raw_config)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
input_dict_2 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {
"igmp": {
"version": "2",
"delete": True,
"query": {"query-max-response-time": 10, "delete": True},
}
}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_2)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Configure PIM on FRR")
result = create_pim_config(tgen, topo["routers"])
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Configure max query response timer 100 decisec on FRR1")
input_dict_3 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {
"igmp": {
"version": "2",
"query": {"query-max-response-time": 100},
}
}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = verify_igmp_config(tgen, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step(
"Remove and add max query response timer cli with different"
"timer 5 times on FRR1 Enable IGMP and IGMP version 2 on FRR1"
" on FRR1"
)
input_dict_3 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {
"igmp": {
"version": "2",
"query": {"query-max-response-time": 105},
}
}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = verify_igmp_config(tgen, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
input_dict_3 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {
"igmp": {
"version": "2",
"query": {"query-max-response-time": 110},
}
}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = verify_igmp_config(tgen, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
input_dict_3 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {
"igmp": {
"version": "2",
"query": {"query-max-response-time": 115},
}
}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = verify_igmp_config(tgen, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
input_dict_3 = {
"l1": {
"igmp": {
"interfaces": {
"l1-i1-eth1": {
"igmp": {
"version": "2",
"query": {"query-max-response-time": 120},
}
}
}
}
}
}
result = create_igmp_config(tgen, topo, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
result = verify_igmp_config(tgen, input_dict_3)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Enable IGMP and IGMP version 2 on FRR1 on FRR1")
input_dict_4 = {
"l1": {"igmp": {"interfaces": {"l1-i1-eth1": {"igmp": {"version": "2"}}}}}
}
result = create_igmp_config(tgen, topo, input_dict_4)
assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
step("Verify that no core is observed")
if tgen.routers_have_failure():
assert False, "Testcase {}: Failed Error: {}".format(tc_name, result)
write_test_footer(tc_name)
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))
|