@@ -17,6 +17,7 @@ limitations under the License.
17
17
package ipam
18
18
19
19
import (
20
+ "fmt"
20
21
"net"
21
22
"testing"
22
23
"time"
@@ -63,6 +64,9 @@ func TestOccupyPreExistingCIDR(t *testing.T) {
63
64
ObjectMeta : metav1.ObjectMeta {
64
65
Name : "node0" ,
65
66
},
67
+ Spec : v1.NodeSpec {
68
+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
69
+ },
66
70
},
67
71
},
68
72
Clientset : fake .NewSimpleClientset (),
@@ -90,7 +94,8 @@ func TestOccupyPreExistingCIDR(t *testing.T) {
90
94
Name : "node0" ,
91
95
},
92
96
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 ),
94
99
},
95
100
},
96
101
},
@@ -120,7 +125,8 @@ func TestOccupyPreExistingCIDR(t *testing.T) {
120
125
Name : "node0" ,
121
126
},
122
127
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 ),
124
130
},
125
131
},
126
132
},
@@ -181,6 +187,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
181
187
ObjectMeta : metav1.ObjectMeta {
182
188
Name : "node0" ,
183
189
},
190
+ Spec : v1.NodeSpec {
191
+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
192
+ },
184
193
Status : v1.NodeStatus {
185
194
Addresses : []v1.NodeAddress {
186
195
{
@@ -216,6 +225,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
216
225
ObjectMeta : metav1.ObjectMeta {
217
226
Name : "node0" ,
218
227
},
228
+ Spec : v1.NodeSpec {
229
+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
230
+ },
219
231
Status : v1.NodeStatus {
220
232
Addresses : []v1.NodeAddress {
221
233
{
@@ -255,6 +267,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
255
267
ObjectMeta : metav1.ObjectMeta {
256
268
Name : "node0" ,
257
269
},
270
+ Spec : v1.NodeSpec {
271
+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
272
+ },
258
273
Status : v1.NodeStatus {
259
274
Addresses : []v1.NodeAddress {
260
275
{
@@ -297,7 +312,8 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
297
312
Name : "node0" ,
298
313
},
299
314
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 ),
301
317
},
302
318
Status : v1.NodeStatus {
303
319
Addresses : []v1.NodeAddress {
@@ -313,7 +329,8 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
313
329
Name : "node1" ,
314
330
},
315
331
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 ),
317
334
},
318
335
Status : v1.NodeStatus {
319
336
Addresses : []v1.NodeAddress {
@@ -328,6 +345,9 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
328
345
ObjectMeta : metav1.ObjectMeta {
329
346
Name : "node2" ,
330
347
},
348
+ Spec : v1.NodeSpec {
349
+ ProviderID : fmt .Sprintf ("%s32345" , providerIDPrefix ),
350
+ },
331
351
Status : v1.NodeStatus {
332
352
Addresses : []v1.NodeAddress {
333
353
{
@@ -361,12 +381,6 @@ func TestAllocateOrOccupyCIDRSuccess(t *testing.T) {
361
381
testFunc := func (tc testCase ) {
362
382
fakeNodeInformer := test .FakeNodeInformer (tc .fakeNodeHandler )
363
383
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 )
370
384
tc .linodeClient .EXPECT ().ListInstanceConfigs (gomock .Any (), gomock .Any (), gomock .Any ()).AnyTimes ().Return ([]linodego.InstanceConfig {
371
385
{
372
386
Interfaces : []linodego.InstanceConfigInterface {
@@ -463,6 +477,9 @@ func TestAllocateOrOccupyCIDRFailure(t *testing.T) {
463
477
ObjectMeta : metav1.ObjectMeta {
464
478
Name : "node0" ,
465
479
},
480
+ Spec : v1.NodeSpec {
481
+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
482
+ },
466
483
},
467
484
},
468
485
Clientset : fake .NewSimpleClientset (),
@@ -572,6 +589,9 @@ func TestReleaseCIDRSuccess(t *testing.T) {
572
589
ObjectMeta : metav1.ObjectMeta {
573
590
Name : "node0" ,
574
591
},
592
+ Spec : v1.NodeSpec {
593
+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
594
+ },
575
595
Status : v1.NodeStatus {
576
596
Addresses : []v1.NodeAddress {
577
597
{
@@ -613,6 +633,9 @@ func TestReleaseCIDRSuccess(t *testing.T) {
613
633
ObjectMeta : metav1.ObjectMeta {
614
634
Name : "node0" ,
615
635
},
636
+ Spec : v1.NodeSpec {
637
+ ProviderID : fmt .Sprintf ("%s12345" , providerIDPrefix ),
638
+ },
616
639
Status : v1.NodeStatus {
617
640
Addresses : []v1.NodeAddress {
618
641
{
@@ -650,12 +673,6 @@ func TestReleaseCIDRSuccess(t *testing.T) {
650
673
}
651
674
logger , tCtx := ktesting .NewTestContext (t )
652
675
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 )
659
676
tc .linodeClient .EXPECT ().ListInstanceConfigs (gomock .Any (), gomock .Any (), gomock .Any ()).AnyTimes ().Return ([]linodego.InstanceConfig {
660
677
{
661
678
Interfaces : []linodego.InstanceConfigInterface {
@@ -782,8 +799,9 @@ func TestNodeDeletionReleaseCIDR(t *testing.T) {
782
799
Name : "node0" ,
783
800
},
784
801
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 ),
787
805
},
788
806
},
789
807
},
@@ -799,8 +817,9 @@ func TestNodeDeletionReleaseCIDR(t *testing.T) {
799
817
DeletionTimestamp : & metav1.Time {Time : time .Now ()},
800
818
},
801
819
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 ),
804
823
},
805
824
},
806
825
},
0 commit comments