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 DominantResourceFairness test #2617

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion internal/scheduler/context/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func testNSmallCpuJobSchedulingContext(queue, priorityClassName string, n int) [
}

func testSmallCpuJobSchedulingContext(queue, priorityClassName string) *JobSchedulingContext {
job := testfixtures.Test1CpuJob(queue, priorityClassName)
job := testfixtures.Test1Cpu4GiJob(queue, priorityClassName)
return &JobSchedulingContext{
JobId: job.GetId(),
Job: job,
Expand Down
72 changes: 36 additions & 36 deletions internal/scheduler/gang_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ func TestGangScheduler(t *testing.T) {
SchedulingConfig: testfixtures.TestSchedulingConfig(),
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32),
},
ExpectedScheduledIndices: testfixtures.IntRange(0, 0),
},
"simple failure": {
SchedulingConfig: testfixtures.TestSchedulingConfig(),
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 33),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 33),
},
ExpectedScheduledIndices: nil,
},
"one success and one failure": {
SchedulingConfig: testfixtures.TestSchedulingConfig(),
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
},
ExpectedScheduledIndices: testfixtures.IntRange(0, 0),
},
"multiple nodes": {
SchedulingConfig: testfixtures.TestSchedulingConfig(),
Nodes: testfixtures.N32CpuNodes(2, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 64),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 64),
},
ExpectedScheduledIndices: testfixtures.IntRange(0, 0),
},
Expand All @@ -73,9 +73,9 @@ func TestGangScheduler(t *testing.T) {
),
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 8),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 16),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 8),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 8),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 16),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 8),
},
ExpectedScheduledIndices: []int{0, 1},
},
Expand All @@ -89,11 +89,11 @@ func TestGangScheduler(t *testing.T) {
),
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
},
ExpectedScheduledIndices: []int{0, 1, 2},
},
Expand All @@ -107,11 +107,11 @@ func TestGangScheduler(t *testing.T) {
),
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
},
ExpectedScheduledIndices: []int{0, 1, 2, 3},
},
Expand All @@ -127,14 +127,14 @@ func TestGangScheduler(t *testing.T) {
),
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 2),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass1, 2),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass1, 3),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass2, 3),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass2, 4),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass3, 4),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass3, 5),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 2),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass1, 2),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass1, 3),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass2, 3),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass2, 4),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass3, 4),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass3, 5),
},
ExpectedScheduledIndices: []int{0, 2, 4, 6},
},
Expand All @@ -148,12 +148,12 @@ func TestGangScheduler(t *testing.T) {
),
Nodes: testfixtures.N32CpuNodes(3, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
},
ExpectedScheduledIndices: testfixtures.IntRange(0, 5),
},
Expand All @@ -167,10 +167,10 @@ func TestGangScheduler(t *testing.T) {
),
Nodes: testfixtures.N32CpuNodes(3, testfixtures.TestPriorities),
Gangs: [][]*jobdb.Job{
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N16Cpu128GiJobs("A", testfixtures.PriorityClass0, 1),
},
ExpectedScheduledIndices: testfixtures.IntRange(0, 2),
},
Expand Down
62 changes: 31 additions & 31 deletions internal/scheduler/nodedb/nodedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestSelectNodeForPod_NodeIdLabel_Success(t *testing.T) {
require.NoError(t, err)
jobs := testfixtures.WithNodeSelectorJobs(
map[string]string{schedulerconfig.NodeIdLabel: nodeId},
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
)
jctxs := schedulercontext.JobSchedulingContextsFromJobs(testfixtures.TestPriorityClasses, jobs)
for _, jctx := range jctxs {
Expand All @@ -98,7 +98,7 @@ func TestSelectNodeForPod_NodeIdLabel_Failure(t *testing.T) {
require.NoError(t, err)
jobs := testfixtures.WithNodeSelectorJobs(
map[string]string{schedulerconfig.NodeIdLabel: "this node does not exist"},
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
)
jctxs := schedulercontext.JobSchedulingContextsFromJobs(testfixtures.TestPriorityClasses, jobs)
for _, jctx := range jctxs {
Expand Down Expand Up @@ -263,12 +263,12 @@ func TestScheduleIndividually(t *testing.T) {
}{
"all jobs fit": {
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Jobs: testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32),
Jobs: testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32),
ExpectSuccess: testfixtures.Repeat(true, 32),
},
"not all jobs fit": {
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Jobs: testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 33),
Jobs: testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 33),
ExpectSuccess: append(testfixtures.Repeat(true, 32), testfixtures.Repeat(false, 1)...),
},
"unavailable resource": {
Expand All @@ -284,29 +284,29 @@ func TestScheduleIndividually(t *testing.T) {
"gibberish": resource.MustParse("1"),
},
},
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
),
ExpectSuccess: testfixtures.Repeat(false, 1),
},
"preemption": {
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Jobs: append(
append(
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass1, 32)...,
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass1, 32)...,
),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32)...,
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32)...,
),
ExpectSuccess: append(testfixtures.Repeat(true, 64), testfixtures.Repeat(false, 32)...),
},
"taints/tolerations": {
Nodes: testfixtures.NTainted32CpuNodes(1, testfixtures.TestPriorities),
Jobs: append(
append(
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1GpuJobs("A", testfixtures.PriorityClass0, 1)...,
),
testfixtures.N32CpuJobs("A", testfixtures.PriorityClass0, 1)...,
testfixtures.N32Cpu256GiJobs("A", testfixtures.PriorityClass0, 1)...,
),
ExpectSuccess: []bool{false, false, true},
},
Expand All @@ -324,7 +324,7 @@ func TestScheduleIndividually(t *testing.T) {
map[string]string{
"key": "value",
},
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 33),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 33),
),
ExpectSuccess: append(testfixtures.Repeat(true, 32), testfixtures.Repeat(false, 1)...),
},
Expand All @@ -339,7 +339,7 @@ func TestScheduleIndividually(t *testing.T) {
map[string]string{
"key": "this is the wrong value",
},
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
),
ExpectSuccess: testfixtures.Repeat(false, 1),
},
Expand All @@ -349,7 +349,7 @@ func TestScheduleIndividually(t *testing.T) {
map[string]string{
"this label does not exist": "value",
},
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
),
ExpectSuccess: testfixtures.Repeat(false, 1),
},
Expand All @@ -375,7 +375,7 @@ func TestScheduleIndividually(t *testing.T) {
},
},
},
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 33),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 33),
),
ExpectSuccess: append(testfixtures.Repeat(true, 32), testfixtures.Repeat(false, 1)...),
},
Expand Down Expand Up @@ -432,31 +432,31 @@ func TestScheduleMany(t *testing.T) {
}{
"simple success": {
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Jobs: [][]*jobdb.Job{testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32)},
Jobs: [][]*jobdb.Job{testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32)},
ExpectSuccess: []bool{true},
},
"simple failure": {
Nodes: testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
Jobs: [][]*jobdb.Job{testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 33)},
Jobs: [][]*jobdb.Job{testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 33)},
ExpectSuccess: []bool{false},
},
"correct rollback": {
Nodes: testfixtures.N32CpuNodes(2, testfixtures.TestPriorities),
Jobs: [][]*jobdb.Job{
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 33),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 33),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32),
},
ExpectSuccess: []bool{true, false, true},
},
"varying job size": {
Nodes: testfixtures.N32CpuNodes(2, testfixtures.TestPriorities),
Jobs: [][]*jobdb.Job{
append(
testfixtures.N32CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32)...,
testfixtures.N32Cpu256GiJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32)...,
),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1),
},
ExpectSuccess: []bool{true, false},
},
Expand Down Expand Up @@ -541,47 +541,47 @@ func BenchmarkScheduleMany10CpuNodes320SmallJobs(b *testing.B) {
benchmarkScheduleMany(
b,
testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 320),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 320),
)
}

func BenchmarkScheduleMany10CpuNodes640SmallJobs(b *testing.B) {
benchmarkScheduleMany(
b,
testfixtures.N32CpuNodes(1, testfixtures.TestPriorities),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 640),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 640),
)
}

func BenchmarkScheduleMany100CpuNodes3200SmallJobs(b *testing.B) {
benchmarkScheduleMany(
b,
testfixtures.N32CpuNodes(100, testfixtures.TestPriorities),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 3200),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 3200),
)
}

func BenchmarkScheduleMany100CpuNodes6400SmallJobs(b *testing.B) {
benchmarkScheduleMany(
b,
testfixtures.N32CpuNodes(100, testfixtures.TestPriorities),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 6400),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 6400),
)
}

func BenchmarkScheduleMany1000CpuNodes32000SmallJobs(b *testing.B) {
benchmarkScheduleMany(
b,
testfixtures.N32CpuNodes(1000, testfixtures.TestPriorities),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 32000),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 32000),
)
}

func BenchmarkScheduleMany1000CpuNodes64000SmallJobs(b *testing.B) {
benchmarkScheduleMany(
b,
testfixtures.N32CpuNodes(1000, testfixtures.TestPriorities),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 64000),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 64000),
)
}

Expand All @@ -593,7 +593,7 @@ func BenchmarkScheduleMany100CpuNodes1CpuUnused(b *testing.B) {
schedulerobjects.ResourceList{Resources: map[string]resource.Quantity{"cpu": resource.MustParse("31")}},
testfixtures.N32CpuNodes(100, testfixtures.TestPriorities),
),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 100),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 100),
)
}

Expand All @@ -605,7 +605,7 @@ func BenchmarkScheduleMany1000CpuNodes1CpuUnused(b *testing.B) {
schedulerobjects.ResourceList{Resources: map[string]resource.Quantity{"cpu": resource.MustParse("31")}},
testfixtures.N32CpuNodes(1000, testfixtures.TestPriorities),
),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 1000),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 1000),
)
}

Expand All @@ -617,7 +617,7 @@ func BenchmarkScheduleMany10000CpuNodes1CpuUnused(b *testing.B) {
schedulerobjects.ResourceList{Resources: map[string]resource.Quantity{"cpu": resource.MustParse("31")}},
testfixtures.N32CpuNodes(10000, testfixtures.TestPriorities),
),
testfixtures.N1CpuJobs("A", testfixtures.PriorityClass0, 10000),
testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 10000),
)
}

Expand Down
Loading