@@ -67,15 +67,16 @@ func buildTestClient(nodes []*v1.Node, pods []*v1.Pod, nodeGroups []NodeGroupOpt
67
67
// the controller should untaint all tainted nodes to get above the new min ASG size instead of bringing up new nodes first
68
68
func TestUntaintNodeGroupMinNodes (t * testing.T ) {
69
69
t .Run ("10 minNodes, 10 tainted, 0 untainted - scale up by untainting" , func (t * testing.T ) {
70
- nodeGroupName := "default"
71
70
minNodes := 10
72
71
maxNodes := 20
73
- nodeGroups := []NodeGroupOptions {{
74
- Name : nodeGroupName ,
72
+ nodeGroup := NodeGroupOptions {
73
+ Name : "default" ,
74
+ CloudProviderGroupName : "default" ,
75
75
MinNodes : minNodes ,
76
76
MaxNodes : maxNodes ,
77
77
ScaleUpThresholdPercent : 100 ,
78
- }}
78
+ }
79
+ nodeGroups := []NodeGroupOptions {nodeGroup }
79
80
80
81
nodes := test .BuildTestNodes (10 , test.NodeOpts {
81
82
CPU : 1000 ,
@@ -91,7 +92,8 @@ func TestUntaintNodeGroupMinNodes(t *testing.T) {
91
92
// Create a test (mock) cloud provider
92
93
testCloudProvider := test .NewCloudProvider (nodeGroupSize )
93
94
testNodeGroup := test .NewNodeGroup (
94
- nodeGroupName ,
95
+ nodeGroup .CloudProviderGroupName ,
96
+ nodeGroup .Name ,
95
97
int64 (minNodes ),
96
98
int64 (maxNodes ),
97
99
int64 (len (nodes )),
@@ -112,10 +114,10 @@ func TestUntaintNodeGroupMinNodes(t *testing.T) {
112
114
cloudProvider : testCloudProvider ,
113
115
}
114
116
115
- _ , err := controller .scaleNodeGroup (nodeGroupName , nodeGroupsState [nodeGroupName ])
117
+ _ , err := controller .scaleNodeGroup (nodeGroup . Name , nodeGroupsState [nodeGroup . Name ])
116
118
assert .NoError (t , err )
117
119
118
- untainted , tainted , _ := controller .filterNodes (nodeGroupsState [nodeGroupName ], nodes )
120
+ untainted , tainted , _ := controller .filterNodes (nodeGroupsState [nodeGroup . Name ], nodes )
119
121
// Ensure that the tainted nodes where untainted
120
122
assert .Equal (t , minNodes , len (untainted ))
121
123
assert .Equal (t , 0 , len (tainted ))
@@ -126,15 +128,16 @@ func TestUntaintNodeGroupMinNodes(t *testing.T) {
126
128
// it will untaint them before trying to scale up the cloud provider
127
129
func TestUntaintNodeGroupMaxNodes (t * testing.T ) {
128
130
t .Run ("10 maxNodes, 5 tainted, 5 untainted - scale up" , func (t * testing.T ) {
129
- nodeGroupName := "default"
130
131
minNodes := 2
131
132
maxNodes := 10
132
- nodeGroups := []NodeGroupOptions {{
133
- Name : nodeGroupName ,
133
+ nodeGroup := NodeGroupOptions {
134
+ Name : "default" ,
135
+ CloudProviderGroupName : "default" ,
134
136
MinNodes : minNodes ,
135
137
MaxNodes : maxNodes ,
136
138
ScaleUpThresholdPercent : 70 ,
137
- }}
139
+ }
140
+ nodeGroups := []NodeGroupOptions {nodeGroup }
138
141
139
142
nodes := test .BuildTestNodes (5 , test.NodeOpts {
140
143
CPU : 1000 ,
@@ -155,7 +158,8 @@ func TestUntaintNodeGroupMaxNodes(t *testing.T) {
155
158
// Create a test (mock) cloud provider
156
159
testCloudProvider := test .NewCloudProvider (nodeGroupSize )
157
160
testNodeGroup := test .NewNodeGroup (
158
- nodeGroupName ,
161
+ nodeGroup .CloudProviderGroupName ,
162
+ nodeGroup .Name ,
159
163
int64 (minNodes ),
160
164
int64 (maxNodes ),
161
165
int64 (len (nodes )),
@@ -176,9 +180,9 @@ func TestUntaintNodeGroupMaxNodes(t *testing.T) {
176
180
cloudProvider : testCloudProvider ,
177
181
}
178
182
179
- controller .scaleNodeGroup (nodeGroupName , nodeGroupsState [nodeGroupName ])
183
+ controller .scaleNodeGroup (nodeGroup . Name , nodeGroupsState [nodeGroup . Name ])
180
184
181
- untainted , tainted , _ := controller .filterNodes (nodeGroupsState [nodeGroupName ], nodes )
185
+ untainted , tainted , _ := controller .filterNodes (nodeGroupsState [nodeGroup . Name ], nodes )
182
186
// Ensure that the tainted nodes where untainted
183
187
assert .Equal (t , maxNodes , len (untainted ))
184
188
assert .Equal (t , 0 , len (tainted ))
@@ -307,8 +311,9 @@ func TestScaleNodeGroup(t *testing.T) {
307
311
nodeArgs {1 , 0 , 0 },
308
312
buildTestPods (0 , 0 , 0 ),
309
313
NodeGroupOptions {
310
- Name : "default" ,
311
- MinNodes : 5 ,
314
+ Name : "default" ,
315
+ CloudProviderGroupName : "default" ,
316
+ MinNodes : 5 ,
312
317
},
313
318
ListerOptions {},
314
319
},
@@ -320,8 +325,9 @@ func TestScaleNodeGroup(t *testing.T) {
320
325
nodeArgs {10 , 0 , 0 },
321
326
buildTestPods (0 , 0 , 0 ),
322
327
NodeGroupOptions {
323
- Name : "default" ,
324
- MaxNodes : 5 ,
328
+ Name : "default" ,
329
+ CloudProviderGroupName : "default" ,
330
+ MaxNodes : 5 ,
325
331
},
326
332
ListerOptions {},
327
333
},
@@ -333,9 +339,10 @@ func TestScaleNodeGroup(t *testing.T) {
333
339
nodeArgs {10 , 0 , 0 },
334
340
buildTestPods (5 , 0 , 0 ),
335
341
NodeGroupOptions {
336
- Name : "default" ,
337
- MinNodes : 1 ,
338
- MaxNodes : 100 ,
342
+ Name : "default" ,
343
+ CloudProviderGroupName : "default" ,
344
+ MinNodes : 1 ,
345
+ MaxNodes : 100 ,
339
346
},
340
347
ListerOptions {},
341
348
},
@@ -347,9 +354,10 @@ func TestScaleNodeGroup(t *testing.T) {
347
354
nodeArgs {10 , - 100 , 0 },
348
355
buildTestPods (5 , 0 , - 100 ),
349
356
NodeGroupOptions {
350
- Name : "default" ,
351
- MinNodes : 1 ,
352
- MaxNodes : 100 ,
357
+ Name : "default" ,
358
+ CloudProviderGroupName : "default" ,
359
+ MinNodes : 1 ,
360
+ MaxNodes : 100 ,
353
361
},
354
362
ListerOptions {},
355
363
},
@@ -361,9 +369,10 @@ func TestScaleNodeGroup(t *testing.T) {
361
369
nodeArgs {10 , - 100 , - 100 },
362
370
buildTestPods (5 , - 100 , - 100 ),
363
371
NodeGroupOptions {
364
- Name : "default" ,
365
- MinNodes : 1 ,
366
- MaxNodes : 100 ,
372
+ Name : "default" ,
373
+ CloudProviderGroupName : "default" ,
374
+ MinNodes : 1 ,
375
+ MaxNodes : 100 ,
367
376
},
368
377
ListerOptions {},
369
378
},
@@ -376,6 +385,7 @@ func TestScaleNodeGroup(t *testing.T) {
376
385
buildTestPods (5 , 1000 , 2000 ),
377
386
NodeGroupOptions {
378
387
Name : "default" ,
388
+ CloudProviderGroupName : "default" ,
379
389
MinNodes : 1 ,
380
390
MaxNodes : 100 ,
381
391
ScaleUpThresholdPercent : 70 ,
@@ -395,6 +405,7 @@ func TestScaleNodeGroup(t *testing.T) {
395
405
buildTestPods (5 , 1000 , 2000 ),
396
406
NodeGroupOptions {
397
407
Name : "default" ,
408
+ CloudProviderGroupName : "default" ,
398
409
MinNodes : 1 ,
399
410
MaxNodes : 100 ,
400
411
ScaleUpThresholdPercent : 70 ,
@@ -414,6 +425,7 @@ func TestScaleNodeGroup(t *testing.T) {
414
425
buildTestPods (5 , 1000 , 2000 ),
415
426
NodeGroupOptions {
416
427
Name : "default" ,
428
+ CloudProviderGroupName : "default" ,
417
429
MinNodes : 1 ,
418
430
MaxNodes : 100 ,
419
431
ScaleUpThresholdPercent : 70 ,
@@ -453,6 +465,7 @@ func TestScaleNodeGroup(t *testing.T) {
453
465
// Create a test (mock) cloud provider
454
466
testCloudProvider := test .NewCloudProvider (nodeGroupSize )
455
467
testNodeGroup := test .NewNodeGroup (
468
+ tt .args .nodeGroupOptions .CloudProviderGroupName ,
456
469
tt .args .nodeGroupOptions .Name ,
457
470
int64 (tt .args .nodeGroupOptions .MinNodes ),
458
471
int64 (tt .args .nodeGroupOptions .MaxNodes ),
@@ -673,6 +686,7 @@ func TestScaleNodeGroup_MultipleRuns(t *testing.T) {
673
686
// Create a test (mock) cloud provider
674
687
testCloudProvider := test .NewCloudProvider (nodeGroupSize )
675
688
testNodeGroup := test .NewNodeGroup (
689
+ tt .args .nodeGroupOptions .CloudProviderGroupName ,
676
690
tt .args .nodeGroupOptions .Name ,
677
691
int64 (tt .args .nodeGroupOptions .MinNodes ),
678
692
int64 (tt .args .nodeGroupOptions .MaxNodes ),
0 commit comments