@@ -1438,17 +1438,64 @@ def test_bgp_26_ipv6_labeled_unicast_peer_group(self):
1438
1438
self .assertIn (f' neighbor { pg_ipv6 } maximum-prefix { ipv6_max_prefix } ' , afiv6_config )
1439
1439
1440
1440
def test_bgp_27_route_reflector_client (self ):
1441
- self .cli_set (base_path + ['peer-group' , 'peer1' , 'address-family' , 'l2vpn-evpn' , 'route-reflector-client' ])
1442
- with self .assertRaises (ConfigSessionError ) as e :
1443
- self .cli_commit ()
1444
-
1445
- self .cli_set (base_path + ['peer-group' , 'peer1' , 'remote-as' , 'internal' ])
1441
+ int_neighbors = ['192.0.2.2' , '192.0.2.3' , '192.0.2.4' , '192.0.2.5' ]
1442
+ int_interfaces = ['dum0' , 'dum1' , 'dum2' , 'dum3' ]
1443
+ int_pg_names = ['SMOKETESTINT0' , 'SMOKETESTINT1' , 'SMOKETESTINT2' ]
1444
+ remote_as_types = ['external' , 'internal' ]
1445
+ for int_interface in int_interfaces :
1446
+ self .cli_set (['interfaces' , 'dummy' , int_interface ])
1446
1447
self .cli_commit ()
1447
1448
1448
- conf = self .getFRRconfig (f'router bgp { ASN } ' , endsection = '^exit' ,
1449
- substring = ' address-family l2vpn evpn' , endsubsection = '^ exit-address-family' )
1450
-
1451
- self .assertIn ('neighbor peer1 route-reflector-client' , conf )
1449
+ def _set_neighbor_0 (neighbor , remote_as_type ):
1450
+ # set route-reflector-client in neighbor and set remote-as in peer_group
1451
+ interface_cmd = ['interface' ] if neighbor .startswith ('dum' ) else []
1452
+ self .cli_set (base_path + ['peer-group' , int_pg_names [0 ], 'remote-as' , remote_as_type ])
1453
+ self .cli_set (base_path + ['neighbor' , neighbor , 'address-family' , 'ipv4-unicast' , 'route-reflector-client' ])
1454
+ self .cli_set (base_path + ['neighbor' , neighbor ] + interface_cmd + ['peer-group' , int_pg_names [0 ]])
1455
+
1456
+ def _set_neighbor_1 (neighbor , remote_as_type ):
1457
+ # set route-reflector-client in peer_group and set remote-as in neighbor
1458
+ interface_cmd = ['interface' ] if neighbor .startswith ('dum' ) else []
1459
+ self .cli_set (base_path + ['peer-group' , int_pg_names [1 ], 'address-family' , 'ipv4-unicast' , 'route-reflector-client' ])
1460
+ self .cli_set (base_path + ['neighbor' , neighbor ] + interface_cmd + ['remote-as' , remote_as_type ])
1461
+ self .cli_set (base_path + ['neighbor' , neighbor ] + interface_cmd + ['peer-group' , int_pg_names [1 ]])
1462
+
1463
+ def _set_neighbor_2 (neighbor , remote_as_type ):
1464
+ # set route-reflector-client and remote-as in peer_group
1465
+ interface_cmd = ['interface' ] if neighbor .startswith ('dum' ) else []
1466
+ self .cli_set (base_path + ['peer-group' , int_pg_names [2 ], 'remote-as' , remote_as_type ])
1467
+ self .cli_set (base_path + ['peer-group' , int_pg_names [2 ], 'address-family' , 'ipv4-unicast' , 'route-reflector-client' ])
1468
+ self .cli_set (base_path + ['neighbor' , neighbor ] + interface_cmd + ['peer-group' , int_pg_names [2 ]])
1469
+
1470
+ def _set_neighbor_3 (neighbor , remote_as_type ):
1471
+ # set route-reflector-client and remote-as in neighbor
1472
+ interface_cmd = ['interface' ] if neighbor .startswith ('dum' ) else []
1473
+ self .cli_set (base_path + ['neighbor' , neighbor , 'address-family' , 'ipv4-unicast' , 'route-reflector-client' ])
1474
+ self .cli_set (base_path + ['neighbor' , neighbor ] + interface_cmd + ['remote-as' , remote_as_type ])
1475
+
1476
+ set_neighbor_funcs = [_set_neighbor_0 , _set_neighbor_1 , _set_neighbor_2 , _set_neighbor_3 ]
1477
+ for remote_as_type in remote_as_types :
1478
+ for func_count , set_neighbor_func in enumerate (set_neighbor_funcs ):
1479
+ for neighbors in [int_neighbors , int_interfaces ]:
1480
+ set_neighbor_func (neighbors [func_count ], remote_as_type )
1481
+ if remote_as_type == 'external' :
1482
+ with self .assertRaises (ConfigSessionError ) as e :
1483
+ self .cli_commit ()
1484
+ self .cli_discard ()
1485
+ else :
1486
+ self .cli_commit ()
1487
+
1488
+ frrconfig = self .getFRRconfig (f'router bgp { ASN } ' , endsection = '^exit' , substring = ' address-family ipv4 unicast' , endsubsection = '^ exit-address-family' )
1489
+ neighbor_has_rr_client = [
1490
+ int_neighbors [0 ], int_neighbors [3 ],
1491
+ int_interfaces [0 ], int_interfaces [3 ],
1492
+ int_pg_names [1 ], int_pg_names [2 ],
1493
+ ]
1494
+ [self .assertIn (f'neighbor { neighbor } route-reflector-client' , frrconfig ) for neighbor in neighbor_has_rr_client ]
1495
+
1496
+ # tearDown dummy interfaces
1497
+ self .cli_delete (['interfaces' , 'dummy' ])
1498
+ self .cli_commit ()
1452
1499
1453
1500
def test_bgp_28_peer_group_member_all_internal_or_external (self ):
1454
1501
def _common_config_check (conf , include_ras = True ):
0 commit comments