mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
scheduler: improve the comment and add more unit test cases for DefaultNormalizeScore
This commit is contained in:
parent
9d577d8a29
commit
9a2eaa8e3f
@ -21,8 +21,9 @@ import (
|
||||
)
|
||||
|
||||
// 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
|
||||
// subtracting it from maxPriority.
|
||||
// scores from [0, max(scores)] to [0, maxPriority]. If reverse is set to true, it
|
||||
// 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 {
|
||||
var maxCount int64
|
||||
for i := range scores {
|
||||
|
@ -61,6 +61,15 @@ func TestDefaultNormalizeScore(t *testing.T) {
|
||||
scores: []int64{0, 1, 1, 1},
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user