@@ -42,6 +42,7 @@ import (
42
42
internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
43
43
internalqueue "k8s.io/kubernetes/pkg/scheduler/internal/queue"
44
44
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
45
+ st "k8s.io/kubernetes/pkg/scheduler/testing"
45
46
"k8s.io/kubernetes/pkg/scheduler/util"
46
47
)
47
48
@@ -348,16 +349,16 @@ var _ algorithm.SchedulerExtender = &FakeExtender{}
348
349
349
350
func TestGenericSchedulerWithExtenders (t * testing.T ) {
350
351
tests := []struct {
351
- name string
352
- predicates map [ string ]predicates. FitPredicate
353
- prioritizers []priorities.PriorityConfig
354
- extenders []FakeExtender
355
- nodes []string
356
- expectedResult ScheduleResult
357
- expectsErr bool
352
+ name string
353
+ registerFilterPlugin st. RegisterFilterPluginFunc
354
+ prioritizers []priorities.PriorityConfig
355
+ extenders []FakeExtender
356
+ nodes []string
357
+ expectedResult ScheduleResult
358
+ expectsErr bool
358
359
}{
359
360
{
360
- predicates : map [ string ]predicates. FitPredicate { "true" : truePredicate } ,
361
+ registerFilterPlugin : st . RegisterFilterPlugin ( "TrueFilter" , NewTrueFilterPlugin ) ,
361
362
extenders : []FakeExtender {
362
363
{
363
364
predicates : []fitPredicate {truePredicateExtender },
@@ -371,7 +372,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
371
372
name : "test 1" ,
372
373
},
373
374
{
374
- predicates : map [ string ]predicates. FitPredicate { "true" : truePredicate } ,
375
+ registerFilterPlugin : st . RegisterFilterPlugin ( "TrueFilter" , NewTrueFilterPlugin ) ,
375
376
extenders : []FakeExtender {
376
377
{
377
378
predicates : []fitPredicate {truePredicateExtender },
@@ -385,7 +386,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
385
386
name : "test 2" ,
386
387
},
387
388
{
388
- predicates : map [ string ]predicates. FitPredicate { "true" : truePredicate } ,
389
+ registerFilterPlugin : st . RegisterFilterPlugin ( "TrueFilter" , NewTrueFilterPlugin ) ,
389
390
extenders : []FakeExtender {
390
391
{
391
392
predicates : []fitPredicate {truePredicateExtender },
@@ -403,7 +404,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
403
404
name : "test 3" ,
404
405
},
405
406
{
406
- predicates : map [ string ]predicates. FitPredicate { "true" : truePredicate } ,
407
+ registerFilterPlugin : st . RegisterFilterPlugin ( "TrueFilter" , NewTrueFilterPlugin ) ,
407
408
extenders : []FakeExtender {
408
409
{
409
410
predicates : []fitPredicate {machine2PredicateExtender },
@@ -417,7 +418,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
417
418
name : "test 4" ,
418
419
},
419
420
{
420
- predicates : map [ string ]predicates. FitPredicate { "true" : truePredicate } ,
421
+ registerFilterPlugin : st . RegisterFilterPlugin ( "TrueFilter" , NewTrueFilterPlugin ) ,
421
422
extenders : []FakeExtender {
422
423
{
423
424
predicates : []fitPredicate {truePredicateExtender },
@@ -434,7 +435,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
434
435
name : "test 5" ,
435
436
},
436
437
{
437
- predicates : map [ string ]predicates. FitPredicate { "true" : truePredicate } ,
438
+ registerFilterPlugin : st . RegisterFilterPlugin ( "TrueFilter" , NewTrueFilterPlugin ) ,
438
439
extenders : []FakeExtender {
439
440
{
440
441
predicates : []fitPredicate {truePredicateExtender },
@@ -456,8 +457,8 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
456
457
name : "test 6" ,
457
458
},
458
459
{
459
- predicates : map [ string ]predicates. FitPredicate { "true" : truePredicate } ,
460
- prioritizers : []priorities.PriorityConfig {{Map : machine2Prioritizer , Weight : 20 }},
460
+ registerFilterPlugin : st . RegisterFilterPlugin ( "TrueFilter" , NewTrueFilterPlugin ) ,
461
+ prioritizers : []priorities.PriorityConfig {{Map : machine2Prioritizer , Weight : 20 }},
461
462
extenders : []FakeExtender {
462
463
{
463
464
predicates : []fitPredicate {truePredicateExtender },
@@ -481,8 +482,8 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
481
482
// If scheduler sends the pod by mistake, the test would fail
482
483
// because of the errors from errorPredicateExtender and/or
483
484
// errorPrioritizerExtender.
484
- predicates : map [ string ]predicates. FitPredicate { "true" : truePredicate } ,
485
- prioritizers : []priorities.PriorityConfig {{Map : machine2Prioritizer , Weight : 1 }},
485
+ registerFilterPlugin : st . RegisterFilterPlugin ( "TrueFilter" , NewTrueFilterPlugin ) ,
486
+ prioritizers : []priorities.PriorityConfig {{Map : machine2Prioritizer , Weight : 1 }},
486
487
extenders : []FakeExtender {
487
488
{
488
489
predicates : []fitPredicate {errorPredicateExtender },
@@ -505,7 +506,7 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
505
506
//
506
507
// If scheduler did not ignore the extender, the test would fail
507
508
// because of the errors from errorPredicateExtender.
508
- predicates : map [ string ]predicates. FitPredicate { "true" : truePredicate } ,
509
+ registerFilterPlugin : st . RegisterFilterPlugin ( "TrueFilter" , NewTrueFilterPlugin ) ,
509
510
extenders : []FakeExtender {
510
511
{
511
512
predicates : []fitPredicate {errorPredicateExtender },
@@ -540,15 +541,24 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
540
541
cache .AddNode (createNode (name ))
541
542
}
542
543
queue := internalqueue .NewSchedulingQueue (nil )
544
+
545
+ registry := framework.Registry {}
546
+ plugins := & schedulerapi.Plugins {
547
+ Filter : & schedulerapi.PluginSet {},
548
+ }
549
+ var pluginConfigs []schedulerapi.PluginConfig
550
+ test .registerFilterPlugin (& registry , plugins , pluginConfigs )
551
+ fwk , _ := framework .NewFramework (registry , plugins , pluginConfigs )
552
+
543
553
scheduler := NewGenericScheduler (
544
554
cache ,
545
555
queue ,
546
- test . predicates ,
556
+ nil ,
547
557
predicates .EmptyMetadataProducer ,
548
558
test .prioritizers ,
549
559
priorities .EmptyMetadataProducer ,
550
560
emptySnapshot ,
551
- emptyFramework ,
561
+ fwk ,
552
562
extenders ,
553
563
nil ,
554
564
informerFactory .Core ().V1 ().PersistentVolumeClaims ().Lister (),
0 commit comments