Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion scheduler/complex/cpu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func TestCPUReallocPlan(t *testing.T) {
"1": 30,
"2": 40,
}
scheduleInfo.CPU.Add(CPU)
si, remain, aff := cpuReallocPlan(scheduleInfo, 1, CPU, 100)
assert.EqualValues(t, 0, remain)
assert.True(t, reflect.DeepEqual(aff, types.CPUMap{"0": 100}))
Expand All @@ -101,6 +102,7 @@ func TestCPUReallocPlan(t *testing.T) {
"1": 30,
"2": 40,
}
scheduleInfo.CPU.Add(CPU)
si, remain, aff = cpuReallocPlan(scheduleInfo, 1.2, CPU, 100)
assert.EqualValues(t, 0, remain)
assert.True(t, reflect.DeepEqual(aff, types.CPUMap{"0": 100, "2": 20}))
Expand All @@ -124,6 +126,7 @@ func TestCPUReallocPlan(t *testing.T) {
"2": 40,
"3": 10,
}
scheduleInfo.CPU.Add(CPU)
si, remain, aff = cpuReallocPlan(scheduleInfo, 2, CPU, 100)
assert.EqualValues(t, 0, remain)
assert.True(t, reflect.DeepEqual(aff, types.CPUMap{"0": 100, "1": 100}))
Expand All @@ -145,6 +148,7 @@ func TestCPUReallocPlan(t *testing.T) {
"1": 30,
"2": 40,
}
scheduleInfo.CPU.Add(CPU)
si, remain, aff = cpuReallocPlan(scheduleInfo, 2, CPU, 100)
assert.EqualValues(t, 1, remain)
assert.True(t, reflect.DeepEqual(aff, types.CPUMap{"0": 100}))
Expand Down Expand Up @@ -174,6 +178,7 @@ func TestCPUReallocWithPriorPlan(t *testing.T) {
"1": 30,
"2": 40,
}
scheduleInfo.CPU.Add(CPU)
si, cpuPlans, total, err := po.ReselectCPUNodes(context.TODO(), scheduleInfo, CPU, 2, 0)
assert.Nil(t, err)
assert.EqualValues(t, 1, total)
Expand All @@ -198,6 +203,7 @@ func TestCPUReallocWithPriorPlan(t *testing.T) {
"1": 30,
"2": 40,
}
scheduleInfo.CPU.Add(CPU)
si, cpuPlans, total, err = po.ReselectCPUNodes(context.TODO(), scheduleInfo, CPU, 2, 0)
assert.Nil(t, err)
assert.EqualValues(t, 3, total)
Expand Down Expand Up @@ -233,6 +239,7 @@ func TestCPUReallocWithPriorPlan(t *testing.T) {
"1": 30,
"2": 40,
}
scheduleInfo.CPU.Add(CPU)
_, _, _, err = po.ReselectCPUNodes(context.TODO(), scheduleInfo, CPU, 2, 0)
assert.EqualError(t, err, "failed to reschedule cpu: no node remains 1.00 pieces of cpu and 0 bytes of memory at the same time: not enough resource")
}
Expand Down Expand Up @@ -262,7 +269,7 @@ func TestGetFullResult(t *testing.T) {
{"1": 100, "2": 100},
})

res = h.getFullResult(2, []resourceInfo{
res = h.getFullResult(2, []resourceInfo{
{
id: "0",
pieces: 200,
Expand Down
1 change: 1 addition & 0 deletions scheduler/complex/potassium.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ func cpuReallocPlan(scheduleInfo resourcetypes.ScheduleInfo, quota float64, CPU
cpuIDs = append(cpuIDs, cpuID)
}
sort.Slice(cpuIDs, func(i, j int) bool { return CPU[cpuIDs[i]] < CPU[cpuIDs[j]] })
scheduleInfo.CPU.Sub(CPU)

// shrink, ensure affinity
if diff <= 0 {
Expand Down