mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #98949 from gavinfish/sched-rm-reflect1
Scheduler: remove reflect.DeepEqual for defaultpreemption, helper, imagelocality package
This commit is contained in:
commit
0ce2036e81
@ -20,7 +20,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"reflect"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -302,11 +301,11 @@ func TestPostFilter(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gotResult, gotStatus := p.PostFilter(context.TODO(), state, tt.pod, tt.filteredNodesStatuses)
|
gotResult, gotStatus := p.PostFilter(context.TODO(), state, tt.pod, tt.filteredNodesStatuses)
|
||||||
if !reflect.DeepEqual(gotStatus, tt.wantStatus) {
|
if diff := cmp.Diff(tt.wantStatus, gotStatus); diff != "" {
|
||||||
t.Errorf("Status does not match: %v, want: %v", gotStatus, tt.wantStatus)
|
t.Errorf("Unexpected status (-want, +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(gotResult, tt.wantResult); diff != "" {
|
if diff := cmp.Diff(tt.wantResult, gotResult); diff != "" {
|
||||||
t.Errorf("Unexpected postFilterResult (-want, +got): %s", diff)
|
t.Errorf("Unexpected postFilterResult (-want, +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ go_test(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//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/informers:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library",
|
"//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library",
|
||||||
|
"//vendor/github.com/google/go-cmp/cmp:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ package helper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/framework"
|
"k8s.io/kubernetes/pkg/scheduler/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -76,8 +76,8 @@ func TestDefaultNormalizeScore(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefaultNormalizeScore(framework.MaxNodeScore, test.reverse, scores)
|
DefaultNormalizeScore(framework.MaxNodeScore, test.reverse, scores)
|
||||||
if !reflect.DeepEqual(scores, expectedScores) {
|
if diff := cmp.Diff(expectedScores, scores); diff != "" {
|
||||||
t.Errorf("expected %v, got %v", expectedScores, scores)
|
t.Errorf("Unexpected scores (-want, +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,10 @@ package helper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/informers"
|
"k8s.io/client-go/informers"
|
||||||
@ -97,8 +97,8 @@ func TestGetPodServices(t *testing.T) {
|
|||||||
get, err := GetPodServices(fakeInformerFactory.Core().V1().Services().Lister(), test.pod)
|
get, err := GetPodServices(fakeInformerFactory.Core().V1().Services().Lister(), test.pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error from GetPodServices: %v", err)
|
t.Errorf("Error from GetPodServices: %v", err)
|
||||||
} else if !reflect.DeepEqual(get, test.expect) {
|
} else if diff := cmp.Diff(test.expect, get); diff != "" {
|
||||||
t.Errorf("Expect services %v, but got %v", test.expect, get)
|
t.Errorf("Unexpected services (-want, +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ go_test(
|
|||||||
"//pkg/scheduler/internal/cache:go_default_library",
|
"//pkg/scheduler/internal/cache:go_default_library",
|
||||||
"//staging/src/k8s.io/api/core/v1: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",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
|
"//vendor/github.com/google/go-cmp/cmp:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/framework"
|
"k8s.io/kubernetes/pkg/scheduler/framework"
|
||||||
@ -348,8 +348,8 @@ func TestImageLocalityPriority(t *testing.T) {
|
|||||||
gotList = append(gotList, framework.NodeScore{Name: nodeName, Score: score})
|
gotList = append(gotList, framework.NodeScore{Name: nodeName, Score: score})
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(test.expectedList, gotList) {
|
if diff := cmp.Diff(test.expectedList, gotList); diff != "" {
|
||||||
t.Errorf("expected:\n\t%+v,\ngot:\n\t%+v", test.expectedList, gotList)
|
t.Errorf("Unexpected node score list (-want, +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user