@@ -52,6 +52,9 @@ func TestCNSIPAMInvoker_Add_Overlay(t *testing.T) {
5252 macAddress := "12:34:56:78:9a:bc"
5353 parsedMacAddress , _ := net .ParseMAC (macAddress )
5454
55+ // parse default route (IP: 0.0.0.0 and mask /0)
56+ _ , ipNet , _ := net .ParseCIDR ("0.0.0.0/0" )
57+
5558 type fields struct {
5659 podName string
5760 podNamespace string
@@ -286,8 +289,15 @@ func TestCNSIPAMInvoker_Add_Overlay(t *testing.T) {
286289 IPAddress : "20.240.1.242" ,
287290 PrefixLength : 24 ,
288291 },
289- NICType : cns .NodeNetworkInterfaceFrontendNIC ,
290- MacAddress : macAddress ,
292+ NICType : cns .NodeNetworkInterfaceFrontendNIC ,
293+ MacAddress : macAddress ,
294+ SkipDefaultRoutes : false ,
295+ Routes : []cns.Route {
296+ {
297+ IPAddress : "0.0.0.0/0" ,
298+ GatewayIPAddress : "10.0.0.1" ,
299+ },
300+ },
291301 },
292302 },
293303 Response : cns.Response {
@@ -316,12 +326,7 @@ func TestCNSIPAMInvoker_Add_Overlay(t *testing.T) {
316326 Gateway : net .ParseIP ("10.0.0.1" ),
317327 },
318328 },
319- Routes : []network.RouteInfo {
320- {
321- Dst : network .Ipv4DefaultRouteDstPrefix ,
322- Gw : net .ParseIP ("10.0.0.1" ),
323- },
324- },
329+ Routes : ([]network.RouteInfo )(nil ),
325330 NICType : cns .InfraNIC ,
326331 SkipDefaultRoutes : true ,
327332 HostSubnetPrefix : * parseCIDR ("10.0.0.0/24" ),
@@ -332,7 +337,12 @@ func TestCNSIPAMInvoker_Add_Overlay(t *testing.T) {
332337 Address : * getCIDRNotationForAddress ("20.240.1.242/24" ),
333338 },
334339 },
335- Routes : []network.RouteInfo {},
340+ Routes : []network.RouteInfo {
341+ {
342+ Dst : * ipNet ,
343+ Gw : net .ParseIP ("10.0.0.1" ),
344+ },
345+ },
336346 NICType : cns .NodeNetworkInterfaceFrontendNIC ,
337347 MacAddress : parsedMacAddress ,
338348 // secondaries don't have a host subnet prefix
@@ -1459,6 +1469,9 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
14591469
14601470 pnpID := "PCI\\ VEN_15B3&DEV_101C&SUBSYS_000715B3&REV_00\\ 5&8c5acce&0&0"
14611471
1472+ // parse default route (IP: 0.0.0.0 and mask /0)
1473+ _ , ipNet , _ := net .ParseCIDR ("0.0.0.0/0" )
1474+
14621475 type fields struct {
14631476 podName string
14641477 podNamespace string
@@ -1664,6 +1677,12 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
16641677 NICType : cns .NodeNetworkInterfaceFrontendNIC ,
16651678 MacAddress : macAddress ,
16661679 SkipDefaultRoutes : false ,
1680+ Routes : []cns.Route {
1681+ {
1682+ IPAddress : "0.0.0.0/0" ,
1683+ GatewayIPAddress : "10.0.0.1" ,
1684+ },
1685+ },
16671686 },
16681687 {
16691688 MacAddress : ibMacAddress ,
@@ -1697,12 +1716,7 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
16971716 Gateway : net .ParseIP ("10.0.0.1" ),
16981717 },
16991718 },
1700- Routes : []network.RouteInfo {
1701- {
1702- Dst : network .Ipv4DefaultRouteDstPrefix ,
1703- Gw : net .ParseIP ("10.0.0.1" ),
1704- },
1705- },
1719+ Routes : ([]network.RouteInfo )(nil ),
17061720 NICType : cns .InfraNIC ,
17071721 SkipDefaultRoutes : true ,
17081722 HostSubnetPrefix : * parseCIDR ("10.0.0.0/24" ),
@@ -1714,14 +1728,18 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
17141728 Address : * getCIDRNotationForAddress ("20.1.1.10/24" ),
17151729 },
17161730 },
1717- Routes : []network.RouteInfo {},
1731+ Routes : []network.RouteInfo {{
1732+ Dst : * ipNet ,
1733+ Gw : net .ParseIP ("10.0.0.1" ),
1734+ }},
17181735 NICType : cns .NodeNetworkInterfaceFrontendNIC ,
17191736 MacAddress : parsedMacAddress ,
17201737 },
17211738 ibMacAddress : {
17221739 NICType : cns .BackendNIC ,
17231740 MacAddress : ibParsedMacAddress ,
17241741 PnPID : pnpID ,
1742+ Routes : ([]network.RouteInfo )(nil ),
17251743 },
17261744 },
17271745 wantErr : false ,
@@ -1744,7 +1762,6 @@ func TestCNSIPAMInvoker_Add_SwiftV2(t *testing.T) {
17441762
17451763 for _ , ifInfo := range ipamAddResult .interfaceInfo {
17461764 if ifInfo .NICType == cns .InfraNIC {
1747- fmt .Printf ("want:%+v\n rest:%+v\n " , tt .wantDefaultResult , ifInfo )
17481765 require .Equalf (tt .wantDefaultResult , ifInfo , "incorrect ipv4 response" )
17491766 }
17501767
0 commit comments