Add unit tests for no score plugin scenario

This commit is contained in:
Aleksandra Malinowska 2023-11-27 10:11:05 +01:00
parent 7abba24231
commit cd3f7a31e8
2 changed files with 51 additions and 0 deletions

View File

@ -270,6 +270,30 @@ func TestSchedulerWithExtenders(t *testing.T) {
},
name: "test 9",
},
{
registerPlugins: []tf.RegisterPluginFunc{
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
},
extenders: []tf.FakeExtender{
{
ExtenderName: "FakeExtender1",
Predicates: []tf.FitPredicate{tf.TruePredicateExtender},
},
{
ExtenderName: "FakeExtender2",
Predicates: []tf.FitPredicate{tf.Node1PredicateExtender},
},
},
nodes: []string{"node1", "node2"},
expectedResult: ScheduleResult{
SuggestedHost: "node1",
EvaluatedNodes: 1,
FeasibleNodes: 1,
},
name: "test 10",
},
}
for _, test := range tests {

View File

@ -2343,6 +2343,33 @@ func TestSchedulerSchedulePod(t *testing.T) {
pod: st.MakePod().Name("ignore").UID("ignore").Obj(),
wantNodes: sets.New("node1", "node2"),
},
{
name: "test without score plugin no extra nodes are evaluated",
registerPlugins: []tf.RegisterPluginFunc{
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
tf.RegisterFilterPlugin("TrueFilter", tf.NewTrueFilterPlugin),
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
},
nodes: []string{"node1", "node2", "node3"},
pod: st.MakePod().Name("pod1").UID("pod1").Obj(),
wantNodes: sets.New("node1", "node2", "node3"),
wantEvaluatedNodes: ptr.To[int32](1),
},
{
name: "test no score plugin, prefilter plugin returning 2 nodes, only 1 node is evaluated",
registerPlugins: []tf.RegisterPluginFunc{
tf.RegisterQueueSortPlugin(queuesort.Name, queuesort.New),
tf.RegisterPreFilterPlugin(
"FakePreFilter",
tf.NewFakePreFilterPlugin("FakePreFilter", &framework.PreFilterResult{NodeNames: sets.New("node1", "node2")}, nil),
),
tf.RegisterBindPlugin(defaultbinder.Name, defaultbinder.New),
},
nodes: []string{"node1", "node2", "node3"},
pod: st.MakePod().Name("test-prefilter").UID("test-prefilter").Obj(),
wantNodes: sets.New("node1", "node2"),
wantEvaluatedNodes: ptr.To[int32](1),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {