@@ -2651,28 +2651,35 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
26512651 tests := []struct {
26522652 name string
26532653 testNodes []* apiv1.Node
2654- expectedScaleDownCoolDown bool
2654+ scaleDownInCoolDown bool
26552655 expectedNodesWithSoftTaints []* apiv1.Node
26562656 expectedNodesWithNoSoftTaints []* apiv1.Node
26572657 }{
26582658 {
2659- name : "Soft tainted nodes are cleaned in case of scale down is in cool down " ,
2659+ name : "Soft tainted nodes are cleaned when scale down skipped " ,
26602660 testNodes : nodesToHaveNoTaints ,
2661- expectedScaleDownCoolDown : true ,
2661+ scaleDownInCoolDown : false ,
26622662 expectedNodesWithSoftTaints : []* apiv1.Node {},
26632663 expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
26642664 },
26652665 {
2666- name : "Soft tainted nodes are not cleaned in case of scale down isn't in cool down" ,
2666+ name : "Soft tainted nodes are cleaned when scale down in cooldown" ,
2667+ testNodes : nodesToHaveNoTaints ,
2668+ scaleDownInCoolDown : true ,
2669+ expectedNodesWithSoftTaints : []* apiv1.Node {},
2670+ expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
2671+ },
2672+ {
2673+ name : "Soft tainted nodes are not cleaned when scale down requested" ,
26672674 testNodes : nodesToHaveTaints ,
2668- expectedScaleDownCoolDown : false ,
2675+ scaleDownInCoolDown : false ,
26692676 expectedNodesWithSoftTaints : nodesToHaveTaints ,
26702677 expectedNodesWithNoSoftTaints : []* apiv1.Node {},
26712678 },
26722679 {
2673- name : "Soft tainted nodes are cleaned only from min sized node group in case of scale down isn't in cool down " ,
2680+ name : "Soft tainted nodes are cleaned only from min sized node group when scale down requested " ,
26742681 testNodes : append (nodesToHaveNoTaints , nodesToHaveTaints ... ),
2675- expectedScaleDownCoolDown : false ,
2682+ scaleDownInCoolDown : false ,
26762683 expectedNodesWithSoftTaints : nodesToHaveTaints ,
26772684 expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
26782685 },
@@ -2683,12 +2690,12 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
26832690 fakeClient := buildFakeClient (t , test .testNodes ... )
26842691
26852692 autoscaler := buildStaticAutoscaler (t , provider , test .testNodes , test .testNodes , fakeClient )
2693+ autoscaler .processorCallbacks .disableScaleDownForLoop = test .scaleDownInCoolDown
2694+ assert .Equal (t , autoscaler .isScaleDownInCooldown (time .Now ()), test .scaleDownInCoolDown )
26862695
26872696 err := autoscaler .RunOnce (time .Now ())
26882697
26892698 assert .NoError (t , err )
2690- candidates , _ := autoscaler .processors .ScaleDownNodeProcessor .GetScaleDownCandidates (autoscaler .AutoscalingContext , test .testNodes )
2691- assert .Equal (t , test .expectedScaleDownCoolDown , autoscaler .isScaleDownInCooldown (time .Now (), candidates ))
26922699
26932700 assertNodesSoftTaintsStatus (t , fakeClient , test .expectedNodesWithSoftTaints , true )
26942701 assertNodesSoftTaintsStatus (t , fakeClient , test .expectedNodesWithNoSoftTaints , false )
0 commit comments