Skip to content

Commit

Permalink
test: update eligibility test cases for IgnoreDaemonSetsUtilization
Browse files Browse the repository at this point in the history
Signed-off-by: vadasambar <[email protected]>
  • Loading branch information
vadasambar committed Apr 19, 2023
1 parent 1f2f0a3 commit ca74c9c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cluster-autoscaler/core/scaledown/eligibility/eligibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func TestFilterOutUnremovable(t *testing.T) {
smallPod := BuildTestPod("smallPod", 100, 0)
smallPod.Spec.NodeName = "regular"

dsPod := BuildDSTestPod("dsPod", 500, 0)
dsPod.Spec.NodeName = "regular"

testCases := []testCase{
{
desc: "regular node stays",
Expand Down Expand Up @@ -122,6 +125,27 @@ func TestFilterOutUnremovable(t *testing.T) {
allTestCases = append(allTestCases, t)
}

ignoreDsCases := []testCase{
{
desc: "high utilization daemonsets node is filtered out",
nodes: []*apiv1.Node{regularNode},
pods: []*apiv1.Pod{smallPod, dsPod},
want: []string{},
scaleDownUnready: true,
ignoreDaemonSetsUtilization: false,
},
{
desc: "high utilization daemonsets node stays",
nodes: []*apiv1.Node{regularNode},
pods: []*apiv1.Pod{smallPod, dsPod},
want: []string{"regular"},
scaleDownUnready: true,
ignoreDaemonSetsUtilization: true,
},
}

allTestCases = append(allTestCases, ignoreDsCases...)

for _, tc := range allTestCases {
tc := tc
t.Run(tc.desc, func(t *testing.T) {
Expand Down
9 changes: 9 additions & 0 deletions cluster-autoscaler/utils/test/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ func BuildTestPod(name string, cpu int64, mem int64) *apiv1.Pod {
return pod
}

// BuildDSTestPod creates a DaemonSet pod with cpu and memory.
func BuildDSTestPod(name string, cpu int64, mem int64) *apiv1.Pod {

pod := BuildTestPod(name, cpu, mem)
pod.OwnerReferences = GenerateOwnerReferences("ds", "DaemonSet", "apps/v1", "some-uid")

return pod
}

// BuildTestPodWithEphemeralStorage creates a pod with cpu, memory and ephemeral storage resources.
func BuildTestPodWithEphemeralStorage(name string, cpu, mem, ephemeralStorage int64) *apiv1.Pod {
startTime := metav1.Unix(0, 0)
Expand Down

0 comments on commit ca74c9c

Please sign in to comment.