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

Scheduler: remove reflect.DeepEqual for defaultpreemption, helper, imagelocality package #98949

Merged
merged 1 commit into from Feb 16, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"math/rand"
"reflect"
"sort"
"strings"
"testing"
Expand Down Expand Up @@ -302,11 +301,11 @@ func TestPostFilter(t *testing.T) {
}

gotResult, gotStatus := p.PostFilter(context.TODO(), state, tt.pod, tt.filteredNodesStatuses)
if !reflect.DeepEqual(gotStatus, tt.wantStatus) {
t.Errorf("Status does not match: %v, want: %v", gotStatus, tt.wantStatus)
if diff := cmp.Diff(tt.wantStatus, gotStatus); diff != "" {
t.Errorf("Unexpected status (-want, +got):\n%s", diff)
}
if diff := cmp.Diff(gotResult, tt.wantResult); diff != "" {
t.Errorf("Unexpected postFilterResult (-want, +got): %s", diff)
if diff := cmp.Diff(tt.wantResult, gotResult); diff != "" {
t.Errorf("Unexpected postFilterResult (-want, +got):\n%s", diff)
}
})
}
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/framework/plugins/helper/BUILD
Expand Up @@ -35,6 +35,7 @@ go_test(
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/client-go/informers:go_default_library",
"//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library",
"//vendor/github.com/google/go-cmp/cmp:go_default_library",
],
)

Expand Down
Expand Up @@ -18,9 +18,9 @@ package helper

import (
"fmt"
"reflect"
"testing"

"github.com/google/go-cmp/cmp"
"k8s.io/kubernetes/pkg/scheduler/framework"
)

Expand Down Expand Up @@ -76,8 +76,8 @@ func TestDefaultNormalizeScore(t *testing.T) {
}

DefaultNormalizeScore(framework.MaxNodeScore, test.reverse, scores)
if !reflect.DeepEqual(scores, expectedScores) {
t.Errorf("expected %v, got %v", expectedScores, scores)
if diff := cmp.Diff(expectedScores, scores); diff != "" {
t.Errorf("Unexpected scores (-want, +got):\n%s", diff)
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/scheduler/framework/plugins/helper/spread_test.go
Expand Up @@ -18,10 +18,10 @@ package helper

import (
"fmt"
"reflect"
"testing"
"time"

"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/informers"
Expand Down Expand Up @@ -97,8 +97,8 @@ func TestGetPodServices(t *testing.T) {
get, err := GetPodServices(fakeInformerFactory.Core().V1().Services().Lister(), test.pod)
if err != nil {
t.Errorf("Error from GetPodServices: %v", err)
} else if !reflect.DeepEqual(get, test.expect) {
t.Errorf("Expect services %v, but got %v", test.expect, get)
} else if diff := cmp.Diff(test.expect, get); diff != "" {
t.Errorf("Unexpected services (-want, +got):\n%s", diff)
}
})
}
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/framework/plugins/imagelocality/BUILD
Expand Up @@ -22,6 +22,7 @@ go_test(
"//pkg/scheduler/internal/cache:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/github.com/google/go-cmp/cmp:go_default_library",
],
)

Expand Down
Expand Up @@ -20,9 +20,9 @@ import (
"context"
"crypto/sha256"
"encoding/hex"
"reflect"
"testing"

"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/scheduler/framework"
Expand Down Expand Up @@ -348,8 +348,8 @@ func TestImageLocalityPriority(t *testing.T) {
gotList = append(gotList, framework.NodeScore{Name: nodeName, Score: score})
}

if !reflect.DeepEqual(test.expectedList, gotList) {
t.Errorf("expected:\n\t%+v,\ngot:\n\t%+v", test.expectedList, gotList)
if diff := cmp.Diff(test.expectedList, gotList); diff != "" {
t.Errorf("Unexpected node score list (-want, +got):\n%s", diff)
}
})
}
Expand Down