@@ -17,6 +17,7 @@ limitations under the License.
1717package ipam
1818
1919import (
20+ "fmt"
2021 "net"
2122 "testing"
2223 "time"
@@ -63,6 +64,9 @@ func TestOccupyPreExistingCIDR(t *testing.T) {
6364 ObjectMeta : metav1.ObjectMeta {
6465 Name : "node0" ,
6566 },
67+ Spec : v1.NodeSpec {
68+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
69+ },
6670 },
6771 },
6872 Clientset : fake .NewSimpleClientset (),
@@ -90,7 +94,8 @@ func TestOccupyPreExistingCIDR(t *testing.T) {
9094 Name : "node0" ,
9195 },
9296 Spec : v1.NodeSpec {
93- PodCIDRs : []string {"10.10.1.0/24" },
97+ PodCIDRs : []string {"10.10.1.0/24" },
98+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
9499 },
95100 },
96101 },
@@ -120,7 +125,8 @@ func TestOccupyPreExistingCIDR(t *testing.T) {
120125 Name : "node0" ,
121126 },
122127 Spec : v1.NodeSpec {
123- PodCIDRs : []string {"172.10.1.0/24" },
128+ PodCIDRs : []string {"172.10.1.0/24" },
129+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
124130 },
125131 },
126132 },
@@ -181,6 +187,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
181187 ObjectMeta : metav1.ObjectMeta {
182188 Name : "node0" ,
183189 },
190+ Spec : v1.NodeSpec {
191+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
192+ },
184193 Status : v1.NodeStatus {
185194 Addresses : []v1.NodeAddress {
186195 {
@@ -216,6 +225,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
216225 ObjectMeta : metav1.ObjectMeta {
217226 Name : "node0" ,
218227 },
228+ Spec : v1.NodeSpec {
229+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
230+ },
219231 Status : v1.NodeStatus {
220232 Addresses : []v1.NodeAddress {
221233 {
@@ -255,6 +267,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
255267 ObjectMeta : metav1.ObjectMeta {
256268 Name : "node0" ,
257269 },
270+ Spec : v1.NodeSpec {
271+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
272+ },
258273 Status : v1.NodeStatus {
259274 Addresses : []v1.NodeAddress {
260275 {
@@ -297,7 +312,8 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
297312 Name : "node0" ,
298313 },
299314 Spec : v1.NodeSpec {
300- PodCIDRs : []string {"10.10.0.0/24" },
315+ PodCIDRs : []string {"10.10.0.0/24" },
316+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
301317 },
302318 Status : v1.NodeStatus {
303319 Addresses : []v1.NodeAddress {
@@ -313,7 +329,8 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
313329 Name : "node1" ,
314330 },
315331 Spec : v1.NodeSpec {
316- PodCIDRs : []string {"10.10.2.0/24" },
332+ PodCIDRs : []string {"10.10.2.0/24" },
333+ ProviderID : fmt .Sprintf ("%s22345" , providerIDPrefix ),
317334 },
318335 Status : v1.NodeStatus {
319336 Addresses : []v1.NodeAddress {
@@ -328,6 +345,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
328345 ObjectMeta : metav1.ObjectMeta {
329346 Name : "node2" ,
330347 },
348+ Spec : v1.NodeSpec {
349+ ProviderID : fmt .Sprintf ("%s32345" , providerIDPrefix ),
350+ },
331351 Status : v1.NodeStatus {
332352 Addresses : []v1.NodeAddress {
333353 {
@@ -361,12 +381,6 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
361381 testFunc := func (tc testCase ) {
362382 fakeNodeInformer := test .FakeNodeInformer (tc .fakeNodeHandler )
363383 nodeList , _ := tc .fakeNodeHandler .List (tCtx , metav1.ListOptions {})
364- // Initialize the range allocator.
365- tc .linodeClient .EXPECT ().ListInstances (gomock .Any (), gomock .Any ()).AnyTimes ().Return ([]linodego.Instance {
366- {
367- ID : 12345 ,
368- },
369- }, nil )
370384 tc .linodeClient .EXPECT ().ListInstanceConfigs (gomock .Any (), gomock .Any (), gomock .Any ()).AnyTimes ().Return ([]linodego.InstanceConfig {
371385 {
372386 Interfaces : []linodego.InstanceConfigInterface {
@@ -463,6 +477,9 @@ func TestAllocateOrOccupyCIDRFailure(t *testing.T) {
463477 ObjectMeta : metav1.ObjectMeta {
464478 Name : "node0" ,
465479 },
480+ Spec : v1.NodeSpec {
481+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
482+ },
466483 },
467484 },
468485 Clientset : fake .NewSimpleClientset (),
@@ -572,6 +589,9 @@ func TestReleaseCIDRSuccess(t *testing.T) {
572589 ObjectMeta : metav1.ObjectMeta {
573590 Name : "node0" ,
574591 },
592+ Spec : v1.NodeSpec {
593+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
594+ },
575595 Status : v1.NodeStatus {
576596 Addresses : []v1.NodeAddress {
577597 {
@@ -613,6 +633,9 @@ func TestReleaseCIDRSuccess(t *testing.T) {
613633 ObjectMeta : metav1.ObjectMeta {
614634 Name : "node0" ,
615635 },
636+ Spec : v1.NodeSpec {
637+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
638+ },
616639 Status : v1.NodeStatus {
617640 Addresses : []v1.NodeAddress {
618641 {
@@ -650,12 +673,6 @@ func TestReleaseCIDRSuccess(t *testing.T) {
650673 }
651674 logger , tCtx := ktesting .NewTestContext (t )
652675 testFunc := func (tc releaseTestCase ) {
653- // Initialize the range allocator.
654- tc .linodeClient .EXPECT ().ListInstances (gomock .Any (), gomock .Any ()).AnyTimes ().Return ([]linodego.Instance {
655- {
656- ID : 12345 ,
657- },
658- }, nil )
659676 tc .linodeClient .EXPECT ().ListInstanceConfigs (gomock .Any (), gomock .Any (), gomock .Any ()).AnyTimes ().Return ([]linodego.InstanceConfig {
660677 {
661678 Interfaces : []linodego.InstanceConfigInterface {
@@ -782,8 +799,9 @@ func TestNodeDeletionReleaseCIDR(t *testing.T) {
782799 Name : "node0" ,
783800 },
784801 Spec : v1.NodeSpec {
785- PodCIDR : allocatedCIDR .String (),
786- PodCIDRs : []string {allocatedCIDR .String ()},
802+ PodCIDR : allocatedCIDR .String (),
803+ PodCIDRs : []string {allocatedCIDR .String ()},
804+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
787805 },
788806 },
789807 },
@@ -799,8 +817,9 @@ func TestNodeDeletionReleaseCIDR(t *testing.T) {
799817 DeletionTimestamp : & metav1.Time {Time : time .Now ()},
800818 },
801819 Spec : v1.NodeSpec {
802- PodCIDR : allocatedCIDR .String (),
803- PodCIDRs : []string {allocatedCIDR .String ()},
820+ PodCIDR : allocatedCIDR .String (),
821+ PodCIDRs : []string {allocatedCIDR .String ()},
822+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
804823 },
805824 },
806825 },
0 commit comments