@@ -244,7 +244,7 @@ func TestCloudProvider_GetOptions(t *testing.T) {
244
244
client , m , teardown := setupTest (t )
245
245
defer teardown ()
246
246
247
- // test correct call
247
+ // test correct call, NodeGroupAutoscalingOptionsResponse will override default options
248
248
m .On (
249
249
"NodeGroupGetOptions" , mock .Anything , mock .MatchedBy (func (req * protos.NodeGroupAutoscalingOptionsRequest ) bool {
250
250
return req .Id == "nodeGroup1"
@@ -257,6 +257,8 @@ func TestCloudProvider_GetOptions(t *testing.T) {
257
257
ScaleDownUnneededTime : & v1.Duration {Duration : time .Minute },
258
258
ScaleDownUnreadyTime : & v1.Duration {Duration : time .Hour },
259
259
MaxNodeProvisionTime : & v1.Duration {Duration : time .Minute },
260
+ ZeroOrMaxNodeScaling : true ,
261
+ IgnoreDaemonSetsUtilization : true ,
260
262
},
261
263
},
262
264
nil ,
@@ -267,12 +269,15 @@ func TestCloudProvider_GetOptions(t *testing.T) {
267
269
client : client ,
268
270
grpcTimeout : defaultGRPCTimeout ,
269
271
}
272
+
270
273
defaultsOpts := config.NodeGroupAutoscalingOptions {
271
274
ScaleDownUtilizationThreshold : 0.6 ,
272
275
ScaleDownGpuUtilizationThreshold : 0.7 ,
273
276
ScaleDownUnneededTime : time .Minute ,
274
277
ScaleDownUnreadyTime : time .Hour ,
275
278
MaxNodeProvisionTime : time .Minute ,
279
+ ZeroOrMaxNodeScaling : false ,
280
+ IgnoreDaemonSetsUtilization : false ,
276
281
}
277
282
278
283
opts , err := ng1 .GetOptions (defaultsOpts )
@@ -282,16 +287,20 @@ func TestCloudProvider_GetOptions(t *testing.T) {
282
287
assert .Equal (t , time .Minute , opts .ScaleDownUnneededTime )
283
288
assert .Equal (t , time .Hour , opts .ScaleDownUnreadyTime )
284
289
assert .Equal (t , time .Minute , opts .MaxNodeProvisionTime )
290
+ assert .Equal (t , true , opts .ZeroOrMaxNodeScaling )
291
+ assert .Equal (t , true , opts .IgnoreDaemonSetsUtilization )
285
292
286
293
// test grpc error
287
294
m .On (
288
295
"NodeGroupGetOptions" , mock .Anything , mock .MatchedBy (func (req * protos.NodeGroupAutoscalingOptionsRequest ) bool {
289
296
return req .Id == "nodeGroup2"
290
297
}),
291
298
).Return (
292
- & protos.NodeGroupAutoscalingOptionsResponse {},
299
+ & protos.NodeGroupAutoscalingOptionsResponse {
300
+ NodeGroupAutoscalingOptions : & protos.NodeGroupAutoscalingOptions {},
301
+ },
293
302
fmt .Errorf ("mock error" ),
294
- )
303
+ ). Once ()
295
304
296
305
ng2 := NodeGroup {
297
306
id : "nodeGroup2" ,
@@ -343,6 +352,40 @@ func TestCloudProvider_GetOptions(t *testing.T) {
343
352
assert .Error (t , err )
344
353
assert .Equal (t , cloudprovider .ErrNotImplemented , err )
345
354
355
+ // test with default options
356
+ m .On (
357
+ "NodeGroupGetOptions" , mock .Anything , mock .MatchedBy (func (req * protos.NodeGroupAutoscalingOptionsRequest ) bool {
358
+ return req .Id == "nodeGroup5"
359
+ }),
360
+ ).Return (
361
+ & protos.NodeGroupAutoscalingOptionsResponse {
362
+ NodeGroupAutoscalingOptions : & protos.NodeGroupAutoscalingOptions {
363
+ ScaleDownUtilizationThreshold : 0.6 ,
364
+ ScaleDownGpuUtilizationThreshold : 0.7 ,
365
+ ScaleDownUnneededTime : & v1.Duration {Duration : time .Minute },
366
+ ScaleDownUnreadyTime : & v1.Duration {Duration : time .Hour },
367
+ MaxNodeProvisionTime : & v1.Duration {Duration : time .Minute },
368
+ },
369
+ },
370
+ nil ,
371
+ )
372
+
373
+ ng5 := NodeGroup {
374
+ id : "nodeGroup5" ,
375
+ client : client ,
376
+ grpcTimeout : defaultGRPCTimeout ,
377
+ }
378
+
379
+ opts , err = ng5 .GetOptions (defaultsOpts )
380
+ assert .NoError (t , err )
381
+ assert .Equal (t , 0.6 , opts .ScaleDownUtilizationThreshold )
382
+ assert .Equal (t , 0.7 , opts .ScaleDownGpuUtilizationThreshold )
383
+ assert .Equal (t , time .Minute , opts .ScaleDownUnneededTime )
384
+ assert .Equal (t , time .Hour , opts .ScaleDownUnreadyTime )
385
+ assert .Equal (t , time .Minute , opts .MaxNodeProvisionTime )
386
+ assert .Equal (t , false , opts .ZeroOrMaxNodeScaling )
387
+ assert .Equal (t , false , opts .IgnoreDaemonSetsUtilization )
388
+
346
389
}
347
390
348
391
func TestCloudProvider_TargetSize (t * testing.T ) {
0 commit comments