mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #111047 from SataQiu/fix-scheduler-20220709
scheduler: improve the comment and add more unit test cases for DefaultNormalizeScore
This commit is contained in:
commit
e56cda48d3
@ -21,8 +21,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// DefaultNormalizeScore generates a Normalize Score function that can normalize the
|
// DefaultNormalizeScore generates a Normalize Score function that can normalize the
|
||||||
// scores to [0, maxPriority]. If reverse is set to true, it reverses the scores by
|
// scores from [0, max(scores)] to [0, maxPriority]. If reverse is set to true, it
|
||||||
// subtracting it from maxPriority.
|
// reverses the scores by subtracting it from maxPriority.
|
||||||
|
// Note: The input scores are always assumed to be non-negative integers.
|
||||||
func DefaultNormalizeScore(maxPriority int64, reverse bool, scores framework.NodeScoreList) *framework.Status {
|
func DefaultNormalizeScore(maxPriority int64, reverse bool, scores framework.NodeScoreList) *framework.Status {
|
||||||
var maxCount int64
|
var maxCount int64
|
||||||
for i := range scores {
|
for i := range scores {
|
||||||
|
@ -61,6 +61,15 @@ func TestDefaultNormalizeScore(t *testing.T) {
|
|||||||
scores: []int64{0, 1, 1, 1},
|
scores: []int64{0, 1, 1, 1},
|
||||||
expectedScores: []int64{100, 0, 0, 0},
|
expectedScores: []int64{100, 0, 0, 0},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
scores: []int64{0, 0, 0, 0},
|
||||||
|
expectedScores: []int64{0, 0, 0, 0},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
reverse: true,
|
||||||
|
scores: []int64{0, 0, 0, 0},
|
||||||
|
expectedScores: []int64{100, 100, 100, 100},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user