mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
scheduler test: fix test due to nil pod assumption
This commit is contained in:
parent
a2426bd48a
commit
479f507532
@ -164,8 +164,6 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
||||
extenderPredicates []fitPredicate
|
||||
extenderPrioritizers []priorityConfig
|
||||
nodes []string
|
||||
pod *v1.Pod
|
||||
pods []*v1.Pod
|
||||
expectedHost string
|
||||
expectsErr bool
|
||||
}{
|
||||
@ -284,15 +282,13 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
||||
extenders = append(extenders, &test.extenders[ii])
|
||||
}
|
||||
cache := schedulercache.New(time.Duration(0), wait.NeverStop)
|
||||
for _, pod := range test.pods {
|
||||
cache.AddPod(pod)
|
||||
}
|
||||
for _, name := range test.nodes {
|
||||
cache.AddNode(&v1.Node{ObjectMeta: v1.ObjectMeta{Name: name}})
|
||||
}
|
||||
scheduler := NewGenericScheduler(
|
||||
cache, test.predicates, algorithm.EmptyMetadataProducer, test.prioritizers, algorithm.EmptyMetadataProducer, extenders)
|
||||
machine, err := scheduler.Schedule(test.pod, algorithm.FakeNodeLister(makeNodeList(test.nodes)))
|
||||
podIgnored := &v1.Pod{}
|
||||
machine, err := scheduler.Schedule(podIgnored, algorithm.FakeNodeLister(makeNodeList(test.nodes)))
|
||||
if test.expectsErr {
|
||||
if err == nil {
|
||||
t.Errorf("Unexpected non-error for %s, machine %s", test.name, machine)
|
||||
@ -300,6 +296,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
||||
} else {
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
continue
|
||||
}
|
||||
if test.expectedHost != machine {
|
||||
t.Errorf("Failed : %s, Expected: %s, Saw: %s", test.name, test.expectedHost, machine)
|
||||
|
@ -205,6 +205,7 @@ func TestGenericScheduler(t *testing.T) {
|
||||
predicates: map[string]algorithm.FitPredicate{"true": truePredicate},
|
||||
prioritizers: []algorithm.PriorityConfig{{Map: EqualPriorityMap, Weight: 1}},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
pod: &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "ignore"}},
|
||||
expectedHosts: sets.NewString("machine1", "machine2"),
|
||||
name: "test 2",
|
||||
wErr: nil,
|
||||
@ -223,6 +224,7 @@ func TestGenericScheduler(t *testing.T) {
|
||||
predicates: map[string]algorithm.FitPredicate{"true": truePredicate},
|
||||
prioritizers: []algorithm.PriorityConfig{{Function: numericPriority, Weight: 1}},
|
||||
nodes: []string{"3", "2", "1"},
|
||||
pod: &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "ignore"}},
|
||||
expectedHosts: sets.NewString("3"),
|
||||
name: "test 4",
|
||||
wErr: nil,
|
||||
|
Loading…
Reference in New Issue
Block a user