Skip to content

Commit 6cbf801

Browse files
committed
Patch TestCleaningSoftTaintsInScaleDown to be compatible with new isScaleDownInCooldown signature.
1 parent 18f10c1 commit 6cbf801

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

cluster-autoscaler/core/static_autoscaler_test.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,28 +2748,35 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
27482748
tests := []struct {
27492749
name string
27502750
testNodes []*apiv1.Node
2751-
expectedScaleDownCoolDown bool
2751+
scaleDownInCoolDown bool
27522752
expectedNodesWithSoftTaints []*apiv1.Node
27532753
expectedNodesWithNoSoftTaints []*apiv1.Node
27542754
}{
27552755
{
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",
27572757
testNodes: nodesToHaveNoTaints,
2758-
expectedScaleDownCoolDown: true,
2758+
scaleDownInCoolDown: false,
27592759
expectedNodesWithSoftTaints: []*apiv1.Node{},
27602760
expectedNodesWithNoSoftTaints: nodesToHaveNoTaints,
27612761
},
27622762
{
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",
27642771
testNodes: nodesToHaveTaints,
2765-
expectedScaleDownCoolDown: false,
2772+
scaleDownInCoolDown: false,
27662773
expectedNodesWithSoftTaints: nodesToHaveTaints,
27672774
expectedNodesWithNoSoftTaints: []*apiv1.Node{},
27682775
},
27692776
{
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",
27712778
testNodes: append(nodesToHaveNoTaints, nodesToHaveTaints...),
2772-
expectedScaleDownCoolDown: false,
2779+
scaleDownInCoolDown: false,
27732780
expectedNodesWithSoftTaints: nodesToHaveTaints,
27742781
expectedNodesWithNoSoftTaints: nodesToHaveNoTaints,
27752782
},
@@ -2780,13 +2787,12 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
27802787
fakeClient := buildFakeClient(t, test.testNodes...)
27812788

27822789
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)
27832792

27842793
err := autoscaler.RunOnce(time.Now())
27852794

27862795
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-
27902796
assertNodesSoftTaintsStatus(t, fakeClient, test.expectedNodesWithSoftTaints, true)
27912797
assertNodesSoftTaintsStatus(t, fakeClient, test.expectedNodesWithNoSoftTaints, false)
27922798
})

0 commit comments

Comments
 (0)