@@ -214,17 +214,57 @@ func TestSchedulerScheduleOne(t *testing.T) {
214
214
errB := errors .New ("binder" )
215
215
216
216
table := []struct {
217
- name string
218
- injectBindError error
219
- sendPod * v1.Pod
220
- algo core.ScheduleAlgorithm
221
- expectErrorPod * v1.Pod
222
- expectForgetPod * v1.Pod
223
- expectAssumedPod * v1.Pod
224
- expectError error
225
- expectBind * v1.Binding
226
- eventReason string
217
+ name string
218
+ injectBindError error
219
+ sendPod * v1.Pod
220
+ algo core.ScheduleAlgorithm
221
+ registerPluginFuncs []st.RegisterPluginFunc
222
+ expectErrorPod * v1.Pod
223
+ expectForgetPod * v1.Pod
224
+ expectAssumedPod * v1.Pod
225
+ expectError error
226
+ expectBind * v1.Binding
227
+ eventReason string
227
228
}{
229
+ {
230
+ name : "error reserve pod" ,
231
+ sendPod : podWithID ("foo" , "" ),
232
+ algo : mockScheduler {core.ScheduleResult {SuggestedHost : testNode .Name , EvaluatedNodes : 1 , FeasibleNodes : 1 }, nil },
233
+ registerPluginFuncs : []st.RegisterPluginFunc {
234
+ st .RegisterReservePlugin ("FakeReserve" , st .NewFakeReservePlugin (framework .NewStatus (framework .Error , "reserve error" ))),
235
+ },
236
+ expectErrorPod : podWithID ("foo" , testNode .Name ),
237
+ expectForgetPod : podWithID ("foo" , testNode .Name ),
238
+ expectAssumedPod : podWithID ("foo" , testNode .Name ),
239
+ expectError : errors .New (`error while running Reserve in "FakeReserve" reserve plugin for pod "foo": reserve error` ),
240
+ eventReason : "FailedScheduling" ,
241
+ },
242
+ {
243
+ name : "error permit pod" ,
244
+ sendPod : podWithID ("foo" , "" ),
245
+ algo : mockScheduler {core.ScheduleResult {SuggestedHost : testNode .Name , EvaluatedNodes : 1 , FeasibleNodes : 1 }, nil },
246
+ registerPluginFuncs : []st.RegisterPluginFunc {
247
+ st .RegisterPermitPlugin ("FakePermit" , st .NewFakePermitPlugin (framework .NewStatus (framework .Error , "permit error" ), time .Minute )),
248
+ },
249
+ expectErrorPod : podWithID ("foo" , testNode .Name ),
250
+ expectForgetPod : podWithID ("foo" , testNode .Name ),
251
+ expectAssumedPod : podWithID ("foo" , testNode .Name ),
252
+ expectError : errors .New (`error while running "FakePermit" permit plugin for pod "foo": permit error` ),
253
+ eventReason : "FailedScheduling" ,
254
+ },
255
+ {
256
+ name : "error prebind pod" ,
257
+ sendPod : podWithID ("foo" , "" ),
258
+ algo : mockScheduler {core.ScheduleResult {SuggestedHost : testNode .Name , EvaluatedNodes : 1 , FeasibleNodes : 1 }, nil },
259
+ registerPluginFuncs : []st.RegisterPluginFunc {
260
+ st .RegisterPreBindPlugin ("FakePreBind" , st .NewFakePreBindPlugin (framework .NewStatus (framework .Error , "prebind error" ))),
261
+ },
262
+ expectErrorPod : podWithID ("foo" , testNode .Name ),
263
+ expectForgetPod : podWithID ("foo" , testNode .Name ),
264
+ expectAssumedPod : podWithID ("foo" , testNode .Name ),
265
+ expectError : errors .New (`error while running "FakePreBind" prebind plugin for pod "foo": prebind error` ),
266
+ eventReason : "FailedScheduling" ,
267
+ },
228
268
{
229
269
name : "bind assumed pod scheduled" ,
230
270
sendPod : podWithID ("foo" , "" ),
@@ -252,7 +292,8 @@ func TestSchedulerScheduleOne(t *testing.T) {
252
292
expectErrorPod : podWithID ("foo" , testNode .Name ),
253
293
expectForgetPod : podWithID ("foo" , testNode .Name ),
254
294
eventReason : "FailedScheduling" ,
255
- }, {
295
+ },
296
+ {
256
297
name : "deleting pod" ,
257
298
sendPod : deletingPod ("foo" ),
258
299
algo : mockScheduler {core.ScheduleResult {}, nil },
@@ -296,10 +337,11 @@ func TestSchedulerScheduleOne(t *testing.T) {
296
337
gotBinding = action .(clienttesting.CreateAction ).GetObject ().(* v1.Binding )
297
338
return true , gotBinding , item .injectBindError
298
339
})
299
- fwk , err := st . NewFramework ([]st. RegisterPluginFunc {
340
+ registerPluginFuncs := append ( item . registerPluginFuncs ,
300
341
st .RegisterQueueSortPlugin (queuesort .Name , queuesort .New ),
301
342
st .RegisterBindPlugin (defaultbinder .Name , defaultbinder .New ),
302
- }, frameworkruntime .WithClientSet (client ))
343
+ )
344
+ fwk , err := st .NewFramework (registerPluginFuncs , frameworkruntime .WithClientSet (client ))
303
345
if err != nil {
304
346
t .Fatal (err )
305
347
}
0 commit comments