Merge pull request #113499 from kerthcet/cleanup/map-empty-judgement

Fix: resourceToWeightMap will never be nil here
This commit is contained in:
Kubernetes Prow Robot
2022-12-12 00:15:33 -08:00
committed by GitHub
3 changed files with 11 additions and 7 deletions

View File

@@ -40,6 +40,7 @@ func TestMostAllocatedScoringStrategy(t *testing.T) {
expectedScores framework.NodeScoreList
resources []config.ResourceSpec
wantErrs field.ErrorList
wantStatusCode framework.Code
}{
{
// Node1 scores (used resources) on 0-MaxNodeScore scale
@@ -83,7 +84,7 @@ func TestMostAllocatedScoringStrategy(t *testing.T) {
resources: defaultResources,
},
{
name: "Resources not set, nothing scheduled, resources requested, differently sized nodes",
name: "Resources not set, pods scheduled with error",
requestedPod: st.MakePod().
Req(map[v1.ResourceName]string{"cpu": "1000", "memory": "2000"}).
Req(map[v1.ResourceName]string{"cpu": "2000", "memory": "3000"}).
@@ -95,6 +96,7 @@ func TestMostAllocatedScoringStrategy(t *testing.T) {
existingPods: nil,
expectedScores: []framework.NodeScore{{Name: "node1", Score: framework.MinNodeScore}, {Name: "node2", Score: framework.MinNodeScore}},
resources: nil,
wantStatusCode: framework.Error,
},
{
// Node1 scores on 0-MaxNodeScore scale
@@ -344,8 +346,8 @@ func TestMostAllocatedScoringStrategy(t *testing.T) {
var gotScores framework.NodeScoreList
for _, n := range test.nodes {
score, status := p.(framework.ScorePlugin).Score(ctx, state, test.requestedPod, n.Name)
if !status.IsSuccess() {
t.Errorf("unexpected error: %v", status)
if status.Code() != test.wantStatusCode {
t.Errorf("unexpected status code, want: %v, got: %v", test.wantStatusCode, status.Code())
}
gotScores = append(gotScores, framework.NodeScore{Name: n.Name, Score: score})
}