@@ -1151,12 +1151,13 @@ func Test_addExportPolicies(t *testing.T) {
11511151		{
11521152			"has nodes and services" ,
11531153			& NetworkRoutingController {
1154- 				clientset :        fake .NewSimpleClientset (),
1155- 				hostnameOverride : "node-1" ,
1156- 				bgpFullMeshMode :  false ,
1157- 				bgpServer :        gobgp .NewBgpServer (),
1158- 				activeNodes :      make (map [string ]bool ),
1159- 				nodeAsnNumber :    100 ,
1154+ 				clientset :         fake .NewSimpleClientset (),
1155+ 				hostnameOverride :  "node-1" ,
1156+ 				bgpFullMeshMode :   false ,
1157+ 				bgpEnableInternal : true ,
1158+ 				bgpServer :         gobgp .NewBgpServer (),
1159+ 				activeNodes :       make (map [string ]bool ),
1160+ 				nodeAsnNumber :     100 ,
11601161			},
11611162			[]* v1core.Node {
11621163				{
@@ -1251,11 +1252,12 @@ func Test_addExportPolicies(t *testing.T) {
12511252		{
12521253			"has nodes, services with external peers" ,
12531254			& NetworkRoutingController {
1254- 				clientset :        fake .NewSimpleClientset (),
1255- 				hostnameOverride : "node-1" ,
1256- 				bgpFullMeshMode :  false ,
1257- 				bgpServer :        gobgp .NewBgpServer (),
1258- 				activeNodes :      make (map [string ]bool ),
1255+ 				clientset :         fake .NewSimpleClientset (),
1256+ 				hostnameOverride :  "node-1" ,
1257+ 				bgpFullMeshMode :   false ,
1258+ 				bgpEnableInternal : true ,
1259+ 				bgpServer :         gobgp .NewBgpServer (),
1260+ 				activeNodes :       make (map [string ]bool ),
12591261				globalPeerRouters : []* config.NeighborConfig {
12601262					{
12611263						NeighborAddress : "10.10.0.1" ,
@@ -1382,6 +1384,125 @@ func Test_addExportPolicies(t *testing.T) {
13821384			},
13831385			nil ,
13841386		},
1387+ 		{
1388+ 			"has nodes, services with external peers and iBGP disabled" ,
1389+ 			& NetworkRoutingController {
1390+ 				clientset :         fake .NewSimpleClientset (),
1391+ 				hostnameOverride :  "node-1" ,
1392+ 				bgpFullMeshMode :   false ,
1393+ 				bgpEnableInternal : false ,
1394+ 				bgpServer :         gobgp .NewBgpServer (),
1395+ 				activeNodes :       make (map [string ]bool ),
1396+ 				globalPeerRouters : []* config.NeighborConfig {
1397+ 					{
1398+ 						NeighborAddress : "10.10.0.1" ,
1399+ 					},
1400+ 					{
1401+ 						NeighborAddress : "10.10.0.2" ,
1402+ 					},
1403+ 				},
1404+ 				nodeAsnNumber : 100 ,
1405+ 			},
1406+ 			[]* v1core.Node {
1407+ 				{
1408+ 					ObjectMeta : metav1.ObjectMeta {
1409+ 						Name : "node-1" ,
1410+ 						Annotations : map [string ]string {
1411+ 							"kube-router.io/node.asn" : "100" ,
1412+ 						},
1413+ 					},
1414+ 					Status : v1core.NodeStatus {
1415+ 						Addresses : []v1core.NodeAddress {
1416+ 							{
1417+ 								Type :    v1core .NodeInternalIP ,
1418+ 								Address : "10.0.0.1" ,
1419+ 							},
1420+ 						},
1421+ 					},
1422+ 					Spec : v1core.NodeSpec {
1423+ 						PodCIDR : "172.20.0.0/24" ,
1424+ 					},
1425+ 				},
1426+ 			},
1427+ 			[]* v1core.Service {
1428+ 				{
1429+ 					ObjectMeta : metav1.ObjectMeta {
1430+ 						Name : "svc-1" ,
1431+ 					},
1432+ 					Spec : v1core.ServiceSpec {
1433+ 						Type :        "ClusterIP" ,
1434+ 						ClusterIP :   "10.0.0.1" ,
1435+ 						ExternalIPs : []string {"1.1.1.1" },
1436+ 					},
1437+ 				},
1438+ 			},
1439+ 			& config.DefinedSets {
1440+ 				PrefixSets : []config.PrefixSet {
1441+ 					{
1442+ 						PrefixSetName : "podcidrprefixset" ,
1443+ 						PrefixList : []config.Prefix {
1444+ 							{
1445+ 								IpPrefix :        "172.20.0.0/24" ,
1446+ 								MasklengthRange : "24..24" ,
1447+ 							},
1448+ 						},
1449+ 					},
1450+ 				},
1451+ 				NeighborSets :   []config.NeighborSet {},
1452+ 				TagSets :        []config.TagSet {},
1453+ 				BgpDefinedSets : config.BgpDefinedSets {},
1454+ 			},
1455+ 			& config.DefinedSets {
1456+ 				PrefixSets : []config.PrefixSet {
1457+ 					{
1458+ 						PrefixSetName : "clusteripprefixset" ,
1459+ 						PrefixList : []config.Prefix {
1460+ 							{
1461+ 								IpPrefix :        "1.1.1.1/32" ,
1462+ 								MasklengthRange : "32..32" ,
1463+ 							},
1464+ 							{
1465+ 								IpPrefix :        "10.0.0.1/32" ,
1466+ 								MasklengthRange : "32..32" ,
1467+ 							},
1468+ 						},
1469+ 					},
1470+ 				},
1471+ 				NeighborSets :   []config.NeighborSet {},
1472+ 				TagSets :        []config.TagSet {},
1473+ 				BgpDefinedSets : config.BgpDefinedSets {},
1474+ 			},
1475+ 			& config.DefinedSets {
1476+ 				PrefixSets : []config.PrefixSet {},
1477+ 				NeighborSets : []config.NeighborSet {
1478+ 					{
1479+ 						NeighborSetName :  "externalpeerset" ,
1480+ 						NeighborInfoList : []string {"10.10.0.1/32" , "10.10.0.2/32" },
1481+ 					},
1482+ 				},
1483+ 				TagSets :        []config.TagSet {},
1484+ 				BgpDefinedSets : config.BgpDefinedSets {},
1485+ 			},
1486+ 			[]* config.Statement {
1487+ 				{
1488+ 					Name : "kube_router_stmt0" ,
1489+ 					Conditions : config.Conditions {
1490+ 						MatchPrefixSet : config.MatchPrefixSet {
1491+ 							PrefixSet :       "clusteripprefixset" ,
1492+ 							MatchSetOptions : config .MATCH_SET_OPTIONS_RESTRICTED_TYPE_ANY ,
1493+ 						},
1494+ 						MatchNeighborSet : config.MatchNeighborSet {
1495+ 							NeighborSet :     "externalpeerset" ,
1496+ 							MatchSetOptions : config .MATCH_SET_OPTIONS_RESTRICTED_TYPE_ANY ,
1497+ 						},
1498+ 					},
1499+ 					Actions : config.Actions {
1500+ 						RouteDisposition : config .ROUTE_DISPOSITION_ACCEPT_ROUTE ,
1501+ 					},
1502+ 				},
1503+ 			},
1504+ 			nil ,
1505+ 		},
13851506	}
13861507
13871508	for  _ , testcase  :=  range  testcases  {
0 commit comments