Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional test cases to scale down budget tests. #6055

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions cluster-autoscaler/core/scaledown/budgets/budgets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestCropNodesToBudgets(t *testing.T) {
testNg2 := testprovider.NewTestNodeGroup("test-ng2", 0, 100, 3, true, false, "n1-standard-2", nil, nil)
atomic3 := sizedNodeGroup("atomic-3", 3, true)
atomic4 := sizedNodeGroup("atomic-4", 4, true)
atomic5 := sizedNodeGroup("atomic-5", 5, true)
atomic8 := sizedNodeGroup("atomic-8", 8, true)
atomic11 := sizedNodeGroup("atomic-11", 11, true)
for tn, tc := range map[string]struct {
Expand Down Expand Up @@ -222,6 +223,30 @@ func TestCropNodesToBudgets(t *testing.T) {
wantEmpty: generateNodeGroupViewList(atomic8, 0, 8),
wantDrain: []*NodeGroupView{},
},
"empty&drain atomic nodes in same group within overall limit, no deletions in progress": {
empty: generateNodeGroupViewList(atomic8, 0, 5),
drain: generateNodeGroupViewList(atomic8, 5, 8),
wantEmpty: generateNodeGroupViewList(atomic8, 0, 5),
wantDrain: generateNodeGroupViewList(atomic8, 5, 8),
},
"empty&drain atomic nodes in same group exceeding overall limit, no deletions in progress": {
empty: generateNodeGroupViewList(atomic11, 0, 8),
drain: generateNodeGroupViewList(atomic11, 8, 11),
wantEmpty: generateNodeGroupViewList(atomic11, 0, 8),
wantDrain: generateNodeGroupViewList(atomic11, 8, 11),
},
"empty&drain atomic nodes in same group exceeding drain limit, no deletions in progress": {
empty: generateNodeGroupViewList(atomic8, 0, 2),
drain: generateNodeGroupViewList(atomic8, 2, 8),
wantEmpty: generateNodeGroupViewList(atomic8, 0, 2),
wantDrain: generateNodeGroupViewList(atomic8, 2, 8),
},
"empty&drain atomic nodes in same group not matching node group size, no deletions in progress": {
empty: generateNodeGroupViewList(atomic8, 0, 2),
drain: generateNodeGroupViewList(atomic8, 2, 4),
wantEmpty: []*NodeGroupView{},
wantDrain: []*NodeGroupView{},
},
"empty&drain atomic nodes exceeding drain limit, no deletions in progress": {
empty: generateNodeGroupViewList(atomic4, 0, 4),
drain: generateNodeGroupViewList(atomic8, 0, 8),
Expand All @@ -234,6 +259,24 @@ func TestCropNodesToBudgets(t *testing.T) {
wantEmpty: append(generateNodeGroupViewList(atomic3, 0, 3), generateNodeGroupViewList(testNg, 0, 5)...),
wantDrain: []*NodeGroupView{},
},
"empty&drain regular and atomic nodes in same group exceeding overall limit, no deletions in progress": {
empty: append(generateNodeGroupViewList(testNg, 0, 5), generateNodeGroupViewList(atomic11, 0, 8)...),
drain: generateNodeGroupViewList(atomic11, 8, 11),
wantEmpty: generateNodeGroupViewList(atomic11, 0, 8),
wantDrain: generateNodeGroupViewList(atomic11, 8, 11),
},
"empty&drain regular and multiple atomic nodes in same group exceeding drain limit, no deletions in progress": {
empty: append(append(generateNodeGroupViewList(testNg, 0, 5), generateNodeGroupViewList(atomic8, 0, 5)...), generateNodeGroupViewList(atomic11, 0, 8)...),
drain: append(generateNodeGroupViewList(atomic11, 8, 11), generateNodeGroupViewList(atomic8, 5, 8)...),
wantEmpty: append(generateNodeGroupViewList(atomic8, 0, 5), generateNodeGroupViewList(testNg, 0, 2)...),
wantDrain: generateNodeGroupViewList(atomic8, 5, 8),
},
"empty&drain multiple atomic nodes in same group exceeding overall limit, no deletions in progress": {
empty: append(append(generateNodeGroupViewList(atomic3, 0, 3), generateNodeGroupViewList(atomic4, 0, 2)...), generateNodeGroupViewList(atomic11, 0, 11)...),
drain: generateNodeGroupViewList(atomic4, 2, 4),
wantEmpty: append(generateNodeGroupViewList(atomic3, 0, 3), generateNodeGroupViewList(atomic4, 0, 2)...),
wantDrain: generateNodeGroupViewList(atomic4, 2, 4),
},
"empty regular and drain atomic nodes exceeding overall limit, no deletions in progress": {
drain: generateNodeGroupViewList(atomic8, 0, 8),
empty: generateNodeGroupViewList(testNg, 0, 5),
Expand All @@ -253,6 +296,20 @@ func TestCropNodesToBudgets(t *testing.T) {
wantEmpty: []*NodeGroupView{},
wantDrain: []*NodeGroupView{},
},
"empty&drain atomic nodes with deletions in progress, 0 overall budget left": {
emptyDeletionsInProgress: 10,
empty: generateNodeGroupViewList(atomic4, 0, 4),
drain: generateNodeGroupViewList(atomic3, 0, 3),
wantEmpty: []*NodeGroupView{},
wantDrain: []*NodeGroupView{},
},
"empty&drain atomic nodes in same group with deletions in progress, 0 overall budget left": {
emptyDeletionsInProgress: 10,
empty: generateNodeGroupViewList(atomic8, 0, 4),
drain: generateNodeGroupViewList(atomic8, 4, 8),
wantEmpty: []*NodeGroupView{},
wantDrain: []*NodeGroupView{},
},
"empty&drain nodes with deletions in progress, overall budget exceeded (shouldn't happen, just a sanity check)": {
emptyDeletionsInProgress: 50,
empty: generateNodeGroupViewList(testNg, 0, 5),
Expand All @@ -267,6 +324,13 @@ func TestCropNodesToBudgets(t *testing.T) {
wantEmpty: generateNodeGroupViewList(testNg, 0, 5),
wantDrain: []*NodeGroupView{},
},
"empty&drain atomic nodes with deletions in progress, 0 drain budget left": {
drainDeletionsInProgress: 5,
empty: generateNodeGroupViewList(atomic4, 0, 4),
drain: generateNodeGroupViewList(atomic3, 0, 3),
wantEmpty: generateNodeGroupViewList(atomic4, 0, 4),
wantDrain: []*NodeGroupView{},
},
"empty&drain nodes with deletions in progress, drain budget exceeded (shouldn't happen, just a sanity check)": {
drainDeletionsInProgress: 9,
empty: generateNodeGroupViewList(testNg, 0, 5),
Expand Down Expand Up @@ -298,6 +362,62 @@ func TestCropNodesToBudgets(t *testing.T) {
wantEmpty: generateNodeGroupViewList(testNg, 0, 4),
wantDrain: generateNodeGroupViewList(testNg, 0, 2),
},
"empty&drain atomic nodes with deletions in progress, overall budget exceeded, only empty nodes fit": {
emptyDeletionsInProgress: 5,
drainDeletionsInProgress: 2,
empty: generateNodeGroupViewList(atomic4, 0, 4),
drain: generateNodeGroupViewList(atomic3, 0, 3),
wantEmpty: generateNodeGroupViewList(atomic4, 0, 4),
wantDrain: []*NodeGroupView{},
},
"empty&drain atomic nodes in same group with deletions in progress, both empty&drain nodes fit": {
emptyDeletionsInProgress: 5,
drainDeletionsInProgress: 2,
empty: generateNodeGroupViewList(atomic3, 0, 2),
drain: generateNodeGroupViewList(atomic3, 2, 3),
wantEmpty: generateNodeGroupViewList(atomic3, 0, 2),
wantDrain: generateNodeGroupViewList(atomic3, 2, 3),
},
"empty&drain atomic nodes in same group with deletions in progress, overall budget exceeded, both empty&drain nodes fit": {
emptyDeletionsInProgress: 5,
drainDeletionsInProgress: 2,
empty: generateNodeGroupViewList(atomic8, 0, 6),
drain: generateNodeGroupViewList(atomic8, 6, 8),
wantEmpty: generateNodeGroupViewList(atomic8, 0, 6),
wantDrain: generateNodeGroupViewList(atomic8, 6, 8),
},
"empty&drain atomic nodes in same group with deletions in progress, drain budget exceeded, both empty&drain nodes fit": {
emptyDeletionsInProgress: 2,
drainDeletionsInProgress: 2,
empty: generateNodeGroupViewList(atomic5, 0, 1),
drain: generateNodeGroupViewList(atomic5, 1, 5),
wantEmpty: generateNodeGroupViewList(atomic5, 0, 1),
wantDrain: generateNodeGroupViewList(atomic5, 1, 5),
},
"empty&drain regular and atomic nodes with deletions in progress, overall budget exceeded, only empty atomic is deleted": {
emptyDeletionsInProgress: 5,
drainDeletionsInProgress: 2,
empty: append(generateNodeGroupViewList(testNg, 0, 4), generateNodeGroupViewList(atomic4, 0, 4)...),
drain: append(generateNodeGroupViewList(testNg2, 0, 4), generateNodeGroupViewList(atomic3, 0, 3)...),
wantEmpty: generateNodeGroupViewList(atomic4, 0, 4),
wantDrain: []*NodeGroupView{},
},
"empty&drain regular and atomic nodes in same group with deletions in progress, overall budget exceeded, both empty&drain atomic nodes fit": {
emptyDeletionsInProgress: 5,
drainDeletionsInProgress: 2,
empty: append(generateNodeGroupViewList(testNg, 0, 4), generateNodeGroupViewList(atomic4, 0, 2)...),
drain: append(generateNodeGroupViewList(testNg2, 0, 4), generateNodeGroupViewList(atomic4, 2, 4)...),
wantEmpty: generateNodeGroupViewList(atomic4, 0, 2),
wantDrain: generateNodeGroupViewList(atomic4, 2, 4),
},
"empty&drain regular and atomic nodes in same group with deletions in progress, both empty&drain nodes fit": {
emptyDeletionsInProgress: 2,
drainDeletionsInProgress: 2,
empty: append(generateNodeGroupViewList(testNg, 0, 4), generateNodeGroupViewList(atomic4, 0, 2)...),
drain: append(generateNodeGroupViewList(testNg2, 0, 4), generateNodeGroupViewList(atomic4, 2, 4)...),
wantEmpty: append(generateNodeGroupViewList(atomic4, 0, 2), generateNodeGroupViewList(testNg, 0, 2)...),
wantDrain: generateNodeGroupViewList(atomic4, 2, 4),
},
} {
t.Run(tn, func(t *testing.T) {
provider := testprovider.NewTestCloudProvider(nil, func(nodeGroup string, node string) error {
Expand Down