@@ -2748,28 +2748,35 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
2748
2748
tests := []struct {
2749
2749
name string
2750
2750
testNodes []* apiv1.Node
2751
- expectedScaleDownCoolDown bool
2751
+ scaleDownInCoolDown bool
2752
2752
expectedNodesWithSoftTaints []* apiv1.Node
2753
2753
expectedNodesWithNoSoftTaints []* apiv1.Node
2754
2754
}{
2755
2755
{
2756
- name : "Soft tainted nodes are cleaned in case of scale down is in cool down " ,
2756
+ name : "Soft tainted nodes are cleaned when scale down skipped " ,
2757
2757
testNodes : nodesToHaveNoTaints ,
2758
- expectedScaleDownCoolDown : true ,
2758
+ scaleDownInCoolDown : false ,
2759
2759
expectedNodesWithSoftTaints : []* apiv1.Node {},
2760
2760
expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
2761
2761
},
2762
2762
{
2763
- name : "Soft tainted nodes are not cleaned in case of scale down isn't in cool down" ,
2763
+ name : "Soft tainted nodes are cleaned when scale down in cooldown" ,
2764
+ testNodes : nodesToHaveNoTaints ,
2765
+ scaleDownInCoolDown : true ,
2766
+ expectedNodesWithSoftTaints : []* apiv1.Node {},
2767
+ expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
2768
+ },
2769
+ {
2770
+ name : "Soft tainted nodes are not cleaned when scale down requested" ,
2764
2771
testNodes : nodesToHaveTaints ,
2765
- expectedScaleDownCoolDown : false ,
2772
+ scaleDownInCoolDown : false ,
2766
2773
expectedNodesWithSoftTaints : nodesToHaveTaints ,
2767
2774
expectedNodesWithNoSoftTaints : []* apiv1.Node {},
2768
2775
},
2769
2776
{
2770
- name : "Soft tainted nodes are cleaned only from min sized node group in case of scale down isn't in cool down " ,
2777
+ name : "Soft tainted nodes are cleaned only from min sized node group when scale down requested " ,
2771
2778
testNodes : append (nodesToHaveNoTaints , nodesToHaveTaints ... ),
2772
- expectedScaleDownCoolDown : false ,
2779
+ scaleDownInCoolDown : false ,
2773
2780
expectedNodesWithSoftTaints : nodesToHaveTaints ,
2774
2781
expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
2775
2782
},
@@ -2780,13 +2787,12 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
2780
2787
fakeClient := buildFakeClient (t , test .testNodes ... )
2781
2788
2782
2789
autoscaler := buildStaticAutoscaler (t , provider , test .testNodes , test .testNodes , fakeClient )
2790
+ autoscaler .processorCallbacks .disableScaleDownForLoop = test .scaleDownInCoolDown
2791
+ assert .Equal (t , autoscaler .isScaleDownInCooldown (time .Now ()), test .scaleDownInCoolDown )
2783
2792
2784
2793
err := autoscaler .RunOnce (time .Now ())
2785
2794
2786
2795
assert .NoError (t , err )
2787
- candidates , _ := autoscaler .processors .ScaleDownNodeProcessor .GetScaleDownCandidates (autoscaler .AutoscalingContext , test .testNodes )
2788
- assert .Equal (t , test .expectedScaleDownCoolDown , autoscaler .isScaleDownInCooldown (time .Now (), candidates ))
2789
-
2790
2796
assertNodesSoftTaintsStatus (t , fakeClient , test .expectedNodesWithSoftTaints , true )
2791
2797
assertNodesSoftTaintsStatus (t , fakeClient , test .expectedNodesWithNoSoftTaints , false )
2792
2798
})
0 commit comments